Example usage for org.eclipse.jdt.internal.core.index DiskIndex SIGNATURE

List of usage examples for org.eclipse.jdt.internal.core.index DiskIndex SIGNATURE

Introduction

In this page you can find the example usage for org.eclipse.jdt.internal.core.index DiskIndex SIGNATURE.

Prototype

String SIGNATURE

To view the source code for org.eclipse.jdt.internal.core.index DiskIndex SIGNATURE.

Click Source Link

Usage

From source file:com.codenvy.ide.ext.java.server.internal.core.search.indexing.IndexManager.java

License:Open Source License

private void readIndexMap() {
    try {/*from  ww  w. ja va2 s  . c  o m*/
        char[] indexMaps = org.eclipse.jdt.internal.compiler.util.Util
                .getFileCharContent(this.indexNamesMapFile, null);
        char[][] names = CharOperation.splitOn('\n', indexMaps);
        if (names.length >= 3) {
            // First line is DiskIndex signature (see writeIndexMapFile())
            String savedSignature = DiskIndex.SIGNATURE;
            if (savedSignature.equals(new String(names[0]))) {
                for (int i = 1, l = names.length - 1; i < l; i += 2) {
                    IndexLocation indexPath = IndexLocation.createIndexLocation(new URL(new String(names[i])));
                    this.indexLocations.put(new Path(new String(names[i + 1])), indexPath);
                    this.indexStates.put(indexPath, REUSE_STATE);
                }
            }
        }
    } catch (IOException ignored) {
        if (VERBOSE)
            Util.verbose("Failed to read saved index file names"); //$NON-NLS-1$
    }
    return;
}

From source file:com.codenvy.ide.ext.java.server.internal.core.search.indexing.IndexManager.java

License:Open Source License

private char[][] readIndexState(String dirOSString) {
    try {//from  w w  w .  j  av  a  2  s  .  co m
        char[] savedIndexNames = org.eclipse.jdt.internal.compiler.util.Util
                .getFileCharContent(this.savedIndexNamesFile, null);
        if (savedIndexNames.length > 0) {
            char[][] names = CharOperation.splitOn('\n', savedIndexNames);
            if (names.length > 1) {
                // First line is DiskIndex signature + saved plugin working location (see writeSavedIndexNamesFile())
                String savedSignature = DiskIndex.SIGNATURE + "+" + dirOSString; //$NON-NLS-1$
                if (savedSignature.equals(new String(names[0])))
                    return names;
            }
        }
    } catch (IOException ignored) {
        if (VERBOSE)
            Util.verbose("Failed to read saved index file names"); //$NON-NLS-1$
    }
    return null;
}

From source file:com.codenvy.ide.ext.java.server.internal.core.search.indexing.IndexManager.java

License:Open Source License

private void readParticipantsIndexNamesFile() {
    SimpleLookupTable containers = new SimpleLookupTable(3);
    try {//from   ww  w  .j  av  a 2s . c  o  m
        char[] participantIndexNames = org.eclipse.jdt.internal.compiler.util.Util
                .getFileCharContent(this.participantIndexNamesFile, null);
        if (participantIndexNames.length > 0) {
            char[][] names = CharOperation.splitOn('\n', participantIndexNames);
            if (names.length >= 3) {
                // First line is DiskIndex signature  (see writeParticipantsIndexNamesFile())
                if (DiskIndex.SIGNATURE.equals(new String(names[0]))) {
                    for (int i = 1, l = names.length - 1; i < l; i += 2) {
                        IndexLocation indexLocation = new FileIndexLocation(new File(new String(names[i])),
                                true);
                        containers.put(indexLocation, new Path(new String(names[i + 1])));
                    }
                }
            }
        }
    } catch (IOException ignored) {
        if (VERBOSE)
            Util.verbose("Failed to read participant index file names"); //$NON-NLS-1$
    }
    this.participantsContainers = containers;
    return;
}

From source file:com.codenvy.ide.ext.java.server.internal.core.search.indexing.IndexManager.java

License:Open Source License

private void writeIndexMapFile() {
    BufferedWriter writer = null;
    try {/*  ww  w .  j av  a  2 s.  com*/
        writer = new BufferedWriter(new FileWriter(this.indexNamesMapFile));
        writer.write(DiskIndex.SIGNATURE);
        writer.write('\n');
        Object[] keys = this.indexStates.keyTable;
        Object[] states = this.indexStates.valueTable;
        for (int i = 0, l = states.length; i < l; i++) {
            IndexLocation location = (IndexLocation) keys[i];
            if (location != null && states[i] == REUSE_STATE) {
                IPath container = (IPath) this.indexLocations.keyForValue(location);
                if (container != null) {
                    writer.write(location.toString());
                    writer.write('\n');
                    writer.write(container.toOSString());
                    writer.write('\n');
                }
            }
        }
    } catch (IOException ignored) {
        if (VERBOSE)
            Util.verbose("Failed to write saved index file names", System.err); //$NON-NLS-1$
    } finally {
        if (writer != null) {
            try {
                writer.close();
            } catch (IOException e) {
                // ignore
            }
        }
    }
}

From source file:com.codenvy.ide.ext.java.server.internal.core.search.indexing.IndexManager.java

License:Open Source License

private void writeParticipantsIndexNamesFile() {
    BufferedWriter writer = null;
    try {//w  w  w. j ava  2  s  .co m
        writer = new BufferedWriter(new FileWriter(this.participantIndexNamesFile));
        writer.write(DiskIndex.SIGNATURE);
        writer.write('\n');
        Object[] indexFiles = this.participantsContainers.keyTable;
        Object[] containers = this.participantsContainers.valueTable;
        for (int i = 0, l = indexFiles.length; i < l; i++) {
            IndexLocation indexFile = (IndexLocation) indexFiles[i];
            if (indexFile != null) {
                writer.write(indexFile.getIndexFile().getPath());
                writer.write('\n');
                writer.write(((IPath) containers[i]).toOSString());
                writer.write('\n');
            }
        }
    } catch (IOException ignored) {
        if (VERBOSE)
            Util.verbose("Failed to write participant index file names", System.err); //$NON-NLS-1$
    } finally {
        if (writer != null) {
            try {
                writer.close();
            } catch (IOException e) {
                // ignore
            }
        }
    }
}

From source file:com.codenvy.ide.ext.java.server.internal.core.search.indexing.IndexManager.java

License:Open Source License

private void writeSavedIndexNamesFile() {
    BufferedWriter writer = null;
    try {/*from  ww w.  j a va  2 s. co m*/
        writer = new BufferedWriter(new FileWriter(this.savedIndexNamesFile));
        writer.write(DiskIndex.SIGNATURE);
        writer.write('+');
        writer.write(getJavaPluginWorkingLocation().toOSString());
        writer.write('\n');
        Object[] keys = this.indexStates.keyTable;
        Object[] states = this.indexStates.valueTable;
        for (int i = 0, l = states.length; i < l; i++) {
            IndexLocation key = (IndexLocation) keys[i];
            if (key != null && states[i] == SAVED_STATE) {
                writer.write(key.fileName());
                writer.write('\n');
            }
        }
    } catch (IOException ignored) {
        if (VERBOSE)
            Util.verbose("Failed to write saved index file names", System.err); //$NON-NLS-1$
    } finally {
        if (writer != null) {
            try {
                writer.close();
            } catch (IOException e) {
                // ignore
            }
        }
    }
}

From source file:org.eclipse.che.jdt.internal.core.search.indexing.IndexManager.java

License:Open Source License

private void readIndexMap() {
    try {//w  w  w . j a va2 s  . co m
        char[] indexMaps = org.eclipse.jdt.internal.compiler.util.Util
                .getFileCharContent(this.indexNamesMapFile, null);
        char[][] names = CharOperation.splitOn('\n', indexMaps);
        if (names.length >= 3) {
            // First line is DiskIndex signature (see writeIndexMapFile())
            String savedSignature = DiskIndex.SIGNATURE;
            if (savedSignature.equals(new String(names[0]))) {
                for (int i = 1, l = names.length - 1; i < l; i += 2) {
                    IndexLocation indexPath = IndexLocation.createIndexLocation(new URL(new String(names[i])));
                    if (indexPath == null)
                        continue;
                    this.indexLocations.put(new Path(new String(names[i + 1])), indexPath);
                    this.indexStates.put(indexPath, REUSE_STATE);
                }
            }
        }
    } catch (IOException ignored) {
        if (VERBOSE)
            Util.verbose("Failed to read saved index file names"); //$NON-NLS-1$
    }
    return;
}

From source file:org.eclipse.jdt.internal.core.search.indexing.IndexManager.java

License:Open Source License

private void readParticipantsIndexNamesFile() {
    SimpleLookupTable containers = new SimpleLookupTable(3);
    try {/*from   w  w w  .ja v a2s.  c  o m*/
        char[] participantIndexNames = org.eclipse.jdt.internal.compiler.util.Util
                .getFileCharContent(this.participantIndexNamesFile, null);
        if (participantIndexNames.length > 0) {
            char[][] names = CharOperation.splitOn('\n', participantIndexNames);
            if (names.length >= 3) {
                // First line is DiskIndex signature  (see writeParticipantsIndexNamesFile())
                if (DiskIndex.SIGNATURE.equals(new String(names[0]))) {
                    for (int i = 1, l = names.length - 1; i < l; i += 2) {
                        containers.put(new Path(new String(names[i])), new Path(new String(names[i + 1])));
                    }
                }
            }
        }
    } catch (IOException ignored) {
        if (VERBOSE)
            Util.verbose("Failed to read participant index file names"); //$NON-NLS-1$
    }
    this.participantsContainers = containers;
    return;
}

From source file:org.eclipse.jdt.internal.core.search.indexing.IndexManager.java

License:Open Source License

private void writeParticipantsIndexNamesFile() {
    BufferedWriter writer = null;
    try {//  w  w w . j a va 2  s  . c  om
        writer = new BufferedWriter(new FileWriter(this.participantIndexNamesFile));
        writer.write(DiskIndex.SIGNATURE);
        writer.write('\n');
        Object[] indexFiles = this.participantsContainers.keyTable;
        Object[] containers = this.participantsContainers.valueTable;
        for (int i = 0, l = indexFiles.length; i < l; i++) {
            IPath indexFile = (IPath) indexFiles[i];
            if (indexFile != null) {
                writer.write(indexFile.toOSString());
                writer.write('\n');
                writer.write(((IPath) containers[i]).toOSString());
                writer.write('\n');
            }
        }
    } catch (IOException ignored) {
        if (VERBOSE)
            Util.verbose("Failed to write participant index file names", System.err); //$NON-NLS-1$
    } finally {
        if (writer != null) {
            try {
                writer.close();
            } catch (IOException e) {
                // ignore
            }
        }
    }
}

From source file:org.eclipse.jdt.internal.core.search.indexing.IndexManager.java

License:Open Source License

private void writeSavedIndexNamesFile() {
    BufferedWriter writer = null;
    try {/* ww w  .j av a 2  s .co m*/
        writer = new BufferedWriter(new FileWriter(this.savedIndexNamesFile));
        writer.write(DiskIndex.SIGNATURE);
        writer.write('+');
        writer.write(getJavaPluginWorkingLocation().toOSString());
        writer.write('\n');
        Object[] keys = this.indexStates.keyTable;
        Object[] states = this.indexStates.valueTable;
        for (int i = 0, l = states.length; i < l; i++) {
            IPath key = (IPath) keys[i];
            if (key != null && !key.isEmpty() && states[i] == SAVED_STATE) {
                writer.write(key.lastSegment());
                writer.write('\n');
            }
        }
    } catch (IOException ignored) {
        if (VERBOSE)
            Util.verbose("Failed to write saved index file names", System.err); //$NON-NLS-1$
    } finally {
        if (writer != null) {
            try {
                writer.close();
            } catch (IOException e) {
                // ignore
            }
        }
    }
}