Lines 12-17
Link Here
|
12 |
|
12 |
|
13 |
import java.io.*; |
13 |
import java.io.*; |
14 |
|
14 |
|
|
|
15 |
import org.eclipse.core.runtime.IStatus; |
15 |
import org.eclipse.jdt.core.compiler.CharOperation; |
16 |
import org.eclipse.jdt.core.compiler.CharOperation; |
16 |
import org.eclipse.jdt.core.search.*; |
17 |
import org.eclipse.jdt.core.search.*; |
17 |
import org.eclipse.jdt.internal.core.util.*; |
18 |
import org.eclipse.jdt.internal.core.util.*; |
Lines 218-224
Link Here
|
218 |
private void cacheDocumentNames() throws IOException { |
219 |
private void cacheDocumentNames() throws IOException { |
219 |
// will need all document names so get them now |
220 |
// will need all document names so get them now |
220 |
this.cachedChunks = new String[this.numberOfChunks][]; |
221 |
this.cachedChunks = new String[this.numberOfChunks][]; |
221 |
FileInputStream stream = new FileInputStream(this.indexFile); |
222 |
FileInputStream stream = getFileInputStream(); |
222 |
try { |
223 |
try { |
223 |
if (this.numberOfChunks > 5) BUFFER_READ_SIZE <<= 1; |
224 |
if (this.numberOfChunks > 5) BUFFER_READ_SIZE <<= 1; |
224 |
int offset = this.chunkOffsets[0]; |
225 |
int offset = this.chunkOffsets[0]; |
Lines 359-364
Link Here
|
359 |
} |
360 |
} |
360 |
} |
361 |
} |
361 |
} |
362 |
} |
|
|
363 |
private FileInputStream getFileInputStream() throws FileNotFoundException { |
364 |
FileInputStream stream = null; |
365 |
try { |
366 |
stream = new FileInputStream(this.indexFile); |
367 |
} |
368 |
catch (FileNotFoundException ex) { |
369 |
Util.log(ex, "It seems that there was an inconsistency in the IndexManager!"); //$NON-NLS-1$ |
370 |
Util.log(IStatus.ERROR, "The current DiskIndex uses an unexisting file: "+this.indexFile); //$NON-NLS-1$ |
371 |
Util.log(IStatus.ERROR, " => try to recreate it..."); //$NON-NLS-1$ |
372 |
try { |
373 |
initialize(false); |
374 |
stream = new FileInputStream(this.indexFile); |
375 |
} catch (IOException e) { |
376 |
// panic mode |
377 |
Util.log(e, "Cannot create index file "+this.indexFile); //$NON-NLS-1$ |
378 |
throw ex; |
379 |
} |
380 |
} |
381 |
return stream; |
382 |
} |
362 |
void initialize(boolean reuseExistingFile) throws IOException { |
383 |
void initialize(boolean reuseExistingFile) throws IOException { |
363 |
if (this.indexFile.exists()) { |
384 |
if (this.indexFile.exists()) { |
364 |
if (reuseExistingFile) { |
385 |
if (reuseExistingFile) { |
Lines 563-569
Link Here
|
563 |
if (this.numberOfChunks <= 0) |
584 |
if (this.numberOfChunks <= 0) |
564 |
return CharOperation.NO_STRINGS; |
585 |
return CharOperation.NO_STRINGS; |
565 |
|
586 |
|
566 |
FileInputStream stream = new FileInputStream(this.indexFile); |
587 |
FileInputStream stream = getFileInputStream(); |
567 |
try { |
588 |
try { |
568 |
int offset = this.chunkOffsets[0]; |
589 |
int offset = this.chunkOffsets[0]; |
569 |
stream.skip(offset); |
590 |
stream.skip(offset); |
Lines 602-608
Link Here
|
602 |
} |
623 |
} |
603 |
} |
624 |
} |
604 |
|
625 |
|
605 |
FileInputStream stream = new FileInputStream(this.indexFile); |
626 |
FileInputStream stream = getFileInputStream(); |
606 |
HashtableOfObject categoryTable = null; |
627 |
HashtableOfObject categoryTable = null; |
607 |
char[][] matchingWords = null; |
628 |
char[][] matchingWords = null; |
608 |
int count = 0; |
629 |
int count = 0; |
Lines 616-621
Link Here
|
616 |
try { |
637 |
try { |
617 |
if (size < 0) { // DEBUG |
638 |
if (size < 0) { // DEBUG |
618 |
System.err.println("-------------------- DEBUG --------------------"); //$NON-NLS-1$ |
639 |
System.err.println("-------------------- DEBUG --------------------"); //$NON-NLS-1$ |
|
|
640 |
System.err.println("thread = "+Thread.currentThread()); //$NON-NLS-1$ |
619 |
System.err.println("file = "+this.indexFile); //$NON-NLS-1$ |
641 |
System.err.println("file = "+this.indexFile); //$NON-NLS-1$ |
620 |
System.err.println("offset = "+offset); //$NON-NLS-1$ |
642 |
System.err.println("offset = "+offset); //$NON-NLS-1$ |
621 |
System.err.println("size = "+size); //$NON-NLS-1$ |
643 |
System.err.println("size = "+size); //$NON-NLS-1$ |
Lines 626-631
Link Here
|
626 |
// DEBUG |
648 |
// DEBUG |
627 |
oom.printStackTrace(); |
649 |
oom.printStackTrace(); |
628 |
System.err.println("-------------------- DEBUG --------------------"); //$NON-NLS-1$ |
650 |
System.err.println("-------------------- DEBUG --------------------"); //$NON-NLS-1$ |
|
|
651 |
System.err.println("thread = "+Thread.currentThread()); //$NON-NLS-1$ |
629 |
System.err.println("file = "+this.indexFile); //$NON-NLS-1$ |
652 |
System.err.println("file = "+this.indexFile); //$NON-NLS-1$ |
630 |
System.err.println("offset = "+offset); //$NON-NLS-1$ |
653 |
System.err.println("offset = "+offset); //$NON-NLS-1$ |
631 |
System.err.println("size = "+size); //$NON-NLS-1$ |
654 |
System.err.println("size = "+size); //$NON-NLS-1$ |
Lines 668-674
Link Here
|
668 |
} |
691 |
} |
669 |
|
692 |
|
670 |
if (matchingWords != null && count > 0) { |
693 |
if (matchingWords != null && count > 0) { |
671 |
stream = new FileInputStream(this.indexFile); |
694 |
stream = getFileInputStream(); |
672 |
try { |
695 |
try { |
673 |
stream.skip(firstOffset); |
696 |
stream.skip(firstOffset); |
674 |
this.bufferIndex = 0; |
697 |
this.bufferIndex = 0; |
Lines 724-730
Link Here
|
724 |
throw new IllegalArgumentException(); |
747 |
throw new IllegalArgumentException(); |
725 |
this.streamBuffer = new byte[numberOfBytes]; |
748 |
this.streamBuffer = new byte[numberOfBytes]; |
726 |
this.bufferIndex = 0; |
749 |
this.bufferIndex = 0; |
727 |
FileInputStream file = new FileInputStream(this.indexFile); |
750 |
FileInputStream file = getFileInputStream(); |
728 |
try { |
751 |
try { |
729 |
file.skip(start); |
752 |
file.skip(start); |
730 |
if (file.read(this.streamBuffer, 0, numberOfBytes) != numberOfBytes) |
753 |
if (file.read(this.streamBuffer, 0, numberOfBytes) != numberOfBytes) |
Lines 753-759
Link Here
|
753 |
if (arrayOffset instanceof int[]) |
776 |
if (arrayOffset instanceof int[]) |
754 |
return (int[]) arrayOffset; |
777 |
return (int[]) arrayOffset; |
755 |
|
778 |
|
756 |
FileInputStream stream = new FileInputStream(this.indexFile); |
779 |
FileInputStream stream = getFileInputStream(); |
757 |
try { |
780 |
try { |
758 |
int offset = ((Integer) arrayOffset).intValue(); |
781 |
int offset = ((Integer) arrayOffset).intValue(); |
759 |
stream.skip(offset); |
782 |
stream.skip(offset); |