public void generateIndexForJar(String pathToJar, String pathToIndexFile) throws IOException { File f = new File(pathToJar); if (!f.exists()) { throw new FileNotFoundException(pathToJar + " not found"); //$NON-NLS-1$ } IndexLocation indexLocation = new FileIndexLocation(new File(pathToIndexFile)); Index index = new Index(indexLocation, pathToJar, false /*reuse index file*/); SearchParticipant participant = SearchEngine.getDefaultSearchParticipant(); index.separator = JAR_SEPARATOR; ZipFile zip = new ZipFile(pathToJar); try { for (Enumeration e = zip.entries(); e.hasMoreElements();) { // iterate each entry to index it ZipEntry ze = (ZipEntry) e.nextElement(); String zipEntryName = ze.getName(); if (Util.isClassFileName(zipEntryName)) { final byte[] classFileBytes = org.eclipse.jdt.internal.compiler.util.Util.getZipEntryByteContent(ze, zip); JavaSearchDocument entryDocument = new JavaSearchDocument(ze, new Path(pathToJar), classFileBytes, participant); entryDocument.setIndex(index); new BinaryIndexer(entryDocument).indexDocument(); } } index.save(); } finally { zip.close(); } return; } }
void saveIndexes() { IndexManager indexManager = JavaModelManager.getJavaModelManager().getIndexManager(); IPath jspModelWorkingLocation = JSPSearchSupport.getInstance().getModelJspPluginWorkingLocation(); File folder = new File(jspModelWorkingLocation.toOSString()); String[] files = folder.list(); String locay = ""; //$NON-NLS-1$ Index index = null; try { for (int i = 0; i < files.length; i++) { if (files[i].toLowerCase().endsWith(".index")) { //$NON-NLS-1$ locay = jspModelWorkingLocation.toString() + "/" + files[i]; //$NON-NLS-1$ // reuse index file index = new Index(locay, "Index for " + locay, true); //$NON-NLS-1$ indexManager.saveIndex(index); } } } catch (Exception e) { // we should be shutting down, want to shut down quietly if (DEBUG) e.printStackTrace(); } }
public void generateIndexForJar(String pathToJar, String pathToIndexFile) throws IOException { File f = new File(pathToJar); if (!f.exists()) { throw new FileNotFoundException(pathToJar + " not found"); //$NON-NLS-1$ } IndexLocation indexLocation = new FileIndexLocation(new File(pathToIndexFile)); Index index = new Index(indexLocation, pathToJar, false /*reuse index file*/); SearchParticipant participant = SearchEngine.getDefaultSearchParticipant(); index.separator = JAR_SEPARATOR; ZipFile zip = new ZipFile(pathToJar); try { for (Enumeration e = zip.entries(); e.hasMoreElements();) { // iterate each entry to index it ZipEntry ze = (ZipEntry) e.nextElement(); String zipEntryName = ze.getName(); if (Util.isClassFileName(zipEntryName)) { final byte[] classFileBytes = org.eclipse.jdt.internal.compiler.util.Util.getZipEntryByteContent(ze, zip); JavaSearchDocument entryDocument = new JavaSearchDocument(ze, new Path(pathToJar), classFileBytes, participant); entryDocument.setIndex(index); new BinaryIndexer(entryDocument).indexDocument(); } } index.save(); } finally { zip.close(); } return; } }
public void generateIndexForJar(String pathToJar, String pathToIndexFile) throws IOException { File f = new File(pathToJar); if (!f.exists()) { throw new FileNotFoundException(pathToJar + " not found"); //$NON-NLS-1$ } IndexLocation indexLocation = new FileIndexLocation(new File(pathToIndexFile)); Index index = new Index(indexLocation, pathToJar, false /*reuse index file*/); SearchParticipant participant = SearchEngine.getDefaultSearchParticipant(); index.separator = JAR_SEPARATOR; ZipFile zip = new ZipFile(pathToJar); try { for (Enumeration e = zip.entries(); e.hasMoreElements();) { // iterate each entry to index it ZipEntry ze = (ZipEntry) e.nextElement(); String zipEntryName = ze.getName(); if (Util.isClassFileName(zipEntryName)) { final byte[] classFileBytes = org.eclipse.jdt.internal.compiler.util.Util.getZipEntryByteContent(ze, zip); JavaSearchDocument entryDocument = new JavaSearchDocument(ze, new Path(pathToJar), classFileBytes, participant); entryDocument.setIndex(index); new BinaryIndexer(entryDocument).indexDocument(); } } index.save(); } finally { zip.close(); } return; } }
public void generateIndexForJar(String pathToJar, String pathToIndexFile) throws IOException { File f = new File(pathToJar); if (!f.exists()) { throw new FileNotFoundException(pathToJar + " not found"); //$NON-NLS-1$ } IndexLocation indexLocation = new FileIndexLocation(new File(pathToIndexFile)); Index index = new Index(indexLocation, pathToJar, false /*reuse index file*/); SearchParticipant participant = SearchEngine.getDefaultSearchParticipant(); index.separator = JAR_SEPARATOR; ZipFile zip = new ZipFile(pathToJar); try { for (Enumeration e = zip.entries(); e.hasMoreElements();) { // iterate each entry to index it ZipEntry ze = (ZipEntry) e.nextElement(); String zipEntryName = ze.getName(); if (Util.isClassFileName(zipEntryName)) { final byte[] classFileBytes = org.eclipse.jdt.internal.compiler.util.Util.getZipEntryByteContent(ze, zip); JavaSearchDocument entryDocument = new JavaSearchDocument(ze, new Path(pathToJar), classFileBytes, participant); entryDocument.setIndex(index); new BinaryIndexer(entryDocument).indexDocument(); } } index.save(); } finally { zip.close(); } return; } }
public void generateIndexForJar(String pathToJar, String pathToIndexFile) throws IOException { File f = new File(pathToJar); if (!f.exists()) { throw new FileNotFoundException(pathToJar + " not found"); //$NON-NLS-1$ } IndexLocation indexLocation = new FileIndexLocation(new File(pathToIndexFile)); Index index = new Index(indexLocation, pathToJar, false /*reuse index file*/); SearchParticipant participant = SearchEngine.getDefaultSearchParticipant(); index.separator = JAR_SEPARATOR; ZipFile zip = new ZipFile(pathToJar); try { for (Enumeration e = zip.entries(); e.hasMoreElements();) { // iterate each entry to index it ZipEntry ze = (ZipEntry) e.nextElement(); String zipEntryName = ze.getName(); if (Util.isClassFileName(zipEntryName)) { final byte[] classFileBytes = org.eclipse.jdt.internal.compiler.util.Util.getZipEntryByteContent(ze, zip); JavaSearchDocument entryDocument = new JavaSearchDocument(ze, new Path(pathToJar), classFileBytes, participant); entryDocument.setIndex(index); new BinaryIndexer(entryDocument).indexDocument(); } } index.save(); } finally { zip.close(); } return; } }
/** * Recreates the index for a given path, keeping the same read-write monitor. * Returns the new empty index or null if it didn't exist before. * Warning: Does not check whether index is consistent (not being used) */ public synchronized Index recreateIndex(IPath containerPath) { // only called to over write an existing cached index... String containerPathString = containerPath.getDevice() == null ? containerPath.toString() : containerPath.toOSString(); try { // Path is already canonical IndexLocation indexLocation = computeIndexLocation(containerPath); Index index = getIndex(indexLocation); ReadWriteMonitor monitor = index == null ? null : index.monitor; if (VERBOSE) Util.verbose("-> recreating index: "+indexLocation+" for path: "+containerPathString); //$NON-NLS-1$ //$NON-NLS-2$ index = new Index(indexLocation, containerPathString, false /*do not reuse index file*/); this.indexes.put(indexLocation, index); index.monitor = monitor; return index; } catch (IOException e) { // The file could not be created. Possible reason: the project has been deleted. if (VERBOSE) { Util.verbose("-> failed to recreate index for path: "+containerPathString); //$NON-NLS-1$ e.printStackTrace(); } return null; } } /**
/** * Recreates the index for a given path, keeping the same read-write monitor. * Returns the new empty index or null if it didn't exist before. * Warning: Does not check whether index is consistent (not being used) */ public synchronized Index recreateIndex(IPath containerPath) { // only called to over write an existing cached index... String containerPathString = containerPath.getDevice() == null ? containerPath.toString() : containerPath.toOSString(); try { // Path is already canonical IndexLocation indexLocation = computeIndexLocation(containerPath); Index index = getIndex(indexLocation); ReadWriteMonitor monitor = index == null ? null : index.monitor; if (VERBOSE) Util.verbose("-> recreating index: "+indexLocation+" for path: "+containerPathString); //$NON-NLS-1$ //$NON-NLS-2$ index = new Index(indexLocation, containerPathString, false /*do not reuse index file*/); this.indexes.put(indexLocation, index); index.monitor = monitor; return index; } catch (IOException e) { // The file could not be created. Possible reason: the project has been deleted. if (VERBOSE) { Util.verbose("-> failed to recreate index for path: "+containerPathString); //$NON-NLS-1$ e.printStackTrace(); } return null; } } /**
/** * Recreates the index for a given path, keeping the same read-write monitor. * Returns the new empty index or null if it didn't exist before. * Warning: Does not check whether index is consistent (not being used) */ public synchronized Index recreateIndex(IPath containerPath) { // only called to over write an existing cached index... String containerPathString = containerPath.getDevice() == null ? containerPath.toString() : containerPath.toOSString(); try { // Path is already canonical IndexLocation indexLocation = computeIndexLocation(containerPath); Index index = getIndex(indexLocation); ReadWriteMonitor monitor = index == null ? null : index.monitor; if (VERBOSE) Util.verbose("-> recreating index: "+indexLocation+" for path: "+containerPathString); //$NON-NLS-1$ //$NON-NLS-2$ index = new Index(indexLocation, containerPathString, false /*do not reuse index file*/); this.indexes.put(indexLocation, index); index.monitor = monitor; return index; } catch (IOException e) { // The file could not be created. Possible reason: the project has been deleted. if (VERBOSE) { Util.verbose("-> failed to recreate index for path: "+containerPathString); //$NON-NLS-1$ e.printStackTrace(); } return null; } } /**
/** * Recreates the index for a given path, keeping the same read-write monitor. * Returns the new empty index or null if it didn't exist before. * Warning: Does not check whether index is consistent (not being used) */ public synchronized Index recreateIndex(IPath containerPath) { // only called to over write an existing cached index... String containerPathString = containerPath.getDevice() == null ? containerPath.toString() : containerPath.toOSString(); try { // Path is already canonical IndexLocation indexLocation = computeIndexLocation(containerPath); Index index = getIndex(indexLocation); ReadWriteMonitor monitor = index == null ? null : index.monitor; if (VERBOSE) Util.verbose("-> recreating index: "+indexLocation+" for path: "+containerPathString); //$NON-NLS-1$ //$NON-NLS-2$ index = new Index(indexLocation, containerPathString, false /*do not reuse index file*/); this.indexes.put(indexLocation, index); index.monitor = monitor; return index; } catch (IOException e) { // The file could not be created. Possible reason: the project has been deleted. if (VERBOSE) { Util.verbose("-> failed to recreate index for path: "+containerPathString); //$NON-NLS-1$ e.printStackTrace(); } return null; } } /**
/** * Recreates the index for a given path, keeping the same read-write monitor. * Returns the new empty index or null if it didn't exist before. * Warning: Does not check whether index is consistent (not being used) */ public synchronized Index recreateIndex(IPath containerPath) { // only called to over write an existing cached index... String containerPathString = containerPath.getDevice() == null ? containerPath.toString() : containerPath.toOSString(); try { // Path is already canonical IndexLocation indexLocation = computeIndexLocation(containerPath); Index index = getIndex(indexLocation); ReadWriteMonitor monitor = index == null ? null : index.monitor; if (VERBOSE) Util.verbose("-> recreating index: "+indexLocation+" for path: "+containerPathString); //$NON-NLS-1$ //$NON-NLS-2$ index = new Index(indexLocation, containerPathString, false /*do not reuse index file*/); this.indexes.put(indexLocation, index); index.monitor = monitor; return index; } catch (IOException e) { // The file could not be created. Possible reason: the project has been deleted. if (VERBOSE) { Util.verbose("-> failed to recreate index for path: "+containerPathString); //$NON-NLS-1$ e.printStackTrace(); } return null; } } /**
/** * Recreates the index for a given path, keeping the same read-write monitor. * Returns the new empty index or null if it didn't exist before. * Warning: Does not check whether index is consistent (not being used) */ public synchronized Index recreateIndex(IPath containerPath) { // only called to over write an existing cached index... String containerPathString = containerPath.getDevice() == null ? containerPath.toString() : containerPath.toOSString(); try { // Path is already canonical IPath indexLocation = computeIndexLocation(containerPath); Index index = getIndex(indexLocation); ReadWriteMonitor monitor = index == null ? null : index.monitor; if (VERBOSE) Util.verbose("-> recreating index: "+indexLocation+" for path: "+containerPathString); //$NON-NLS-1$ //$NON-NLS-2$ index = new Index(indexLocation.toOSString(), containerPathString, false /*do not reuse index file*/); this.indexes.put(indexLocation, index); index.monitor = monitor; return index; } catch (IOException e) { // The file could not be created. Possible reason: the project has been deleted. if (VERBOSE) { Util.verbose("-> failed to recreate index for path: "+containerPathString); //$NON-NLS-1$ e.printStackTrace(); } return null; } } /**
if (indexFile.exists()) { // check before creating index so as to avoid creating a new empty index if file is missing try { index = new Index(indexLocationString, containerPathString, true /*reuse index file*/); this.indexes.put(indexLocation, index); return index; if (VERBOSE) Util.verbose("-> create empty index: "+indexLocationString+" path: "+containerPathString); //$NON-NLS-1$ //$NON-NLS-2$ index = new Index(indexLocationString, containerPathString, false /*do not reuse index file*/); this.indexes.put(indexLocation, index); return index;
IPath container = getParticipantsContainer(indexLocation); if (container != null) { index = new Index(indexLocation.toOSString(), container.toOSString(), true /*reuse index file*/); this.indexes.put(indexLocation, index);
IPath container = getParticipantsContainer(indexLocation); if (container != null) { index = new Index(indexLocation, container.toOSString(), true /*reuse index file*/); this.indexes.put(indexLocation, index);
IPath container = getParticipantsContainer(indexLocation); if (container != null) { index = new Index(indexLocation, container.toOSString(), true /*reuse index file*/); this.indexes.put(indexLocation, index);
IPath container = getParticipantsContainer(indexLocation); if (container != null) { index = new Index(indexLocation, container.toOSString(), true /*reuse index file*/); this.indexes.put(indexLocation, index);
IPath container = getParticipantsContainer(indexLocation); if (container != null) { index = new Index(indexLocation, container.toOSString(), true /*reuse index file*/); this.indexes.put(indexLocation, index);
if (indexLocation.exists()) { // check before creating index so as to avoid creating a new empty index if file is missing try { index = new Index(indexLocation, containerPathString, true /*reuse index file*/); this.indexes.put(indexLocation, index); return index; if (VERBOSE) Util.verbose("-> create empty index: "+indexLocation+" path: "+containerPathString); //$NON-NLS-1$ //$NON-NLS-2$ index = new Index(indexLocation, containerPathString, false /*do not reuse index file*/); this.indexes.put(indexLocation, index); return index;
if (indexLocation.exists()) { // check before creating index so as to avoid creating a new empty index if file is missing try { index = new Index(indexLocation, containerPathString, true /*reuse index file*/); this.indexes.put(indexLocation, index); return index; if (VERBOSE) Util.verbose("-> create empty index: "+indexLocation+" path: "+containerPathString); //$NON-NLS-1$ //$NON-NLS-2$ index = new Index(indexLocation, containerPathString, false /*do not reuse index file*/); this.indexes.put(indexLocation, index); return index;