List of usage examples for org.eclipse.jdt.internal.core.index Index startQuery
public void startQuery()
From source file:com.codenvy.ide.ext.java.server.core.search.SearchPattern.java
License:Open Source License
/** * Query a given index for matching entries. Assumes the sender has opened the index and will close when finished. * * @noreference This method is not intended to be referenced by clients. * @nooverride This method is not intended to be re-implemented or extended by clients. *///from w w w . ja va2 s . c o m public void findIndexMatches(Index index, IndexQueryRequestor requestor, SearchParticipant participant, IJavaSearchScope scope, IProgressMonitor monitor) throws IOException { if (monitor != null && monitor.isCanceled()) throw new OperationCanceledException(); try { index.startQuery(); SearchPattern pattern = currentPattern(); EntryResult[] entries = pattern.queryIn(index); if (entries == null) return; SearchPattern decodedResult = pattern.getBlankPattern(); String containerPath = index.containerPath; char separator = index.separator; for (int i = 0, l = entries.length; i < l; i++) { if (monitor != null && monitor.isCanceled()) throw new OperationCanceledException(); EntryResult entry = entries[i]; decodedResult.decodeIndexKey(entry.getWord()); if (pattern.matchesDecodedKey(decodedResult)) { // TODO (kent) some clients may not need the document names String[] names = entry.getDocumentNames(index); for (int j = 0, n = names.length; j < n; j++) acceptMatch(names[j], containerPath, separator, decodedResult, requestor, participant, scope, monitor); } } } finally { index.stopQuery(); } }
From source file:com.codenvy.ide.ext.java.server.internal.core.search.matching.IntersectingPattern.java
License:Open Source License
public void findIndexMatches(Index index, IndexQueryRequestor requestor, SearchParticipant participant, IJavaSearchScope scope, IProgressMonitor progressMonitor) throws IOException { if (progressMonitor != null && progressMonitor.isCanceled()) throw new OperationCanceledException(); resetQuery();/*from w w w . j av a2s . c o m*/ SimpleSet intersectedNames = null; try { index.startQuery(); do { SearchPattern pattern = currentPattern(); EntryResult[] entries = pattern.queryIn(index); if (entries == null) return; SearchPattern decodedResult = pattern.getBlankPattern(); SimpleSet newIntersectedNames = new SimpleSet(3); for (int i = 0, l = entries.length; i < l; i++) { if (progressMonitor != null && progressMonitor.isCanceled()) throw new OperationCanceledException(); EntryResult entry = entries[i]; decodedResult.decodeIndexKey(entry.getWord()); if (pattern.matchesDecodedKey(decodedResult)) { String[] names = entry.getDocumentNames(index); if (intersectedNames != null) { for (int j = 0, n = names.length; j < n; j++) if (intersectedNames.includes(names[j])) newIntersectedNames.add(names[j]); } else { for (int j = 0, n = names.length; j < n; j++) newIntersectedNames.add(names[j]); } } } if (newIntersectedNames.elementSize == 0) return; intersectedNames = newIntersectedNames; } while (hasNextQuery()); } finally { index.stopQuery(); } String containerPath = index.containerPath; char separator = index.separator; Object[] names = intersectedNames.values; for (int i = 0, l = names.length; i < l; i++) if (names[i] != null) acceptMatch((String) names[i], containerPath, separator, null/*no pattern*/, requestor, participant, scope, progressMonitor); // AndPatterns cannot provide the decoded result }
From source file:com.codenvy.ide.ext.java.server.internal.core.search.matching.OrPattern.java
License:Open Source License
public void findIndexMatches(Index index, IndexQueryRequestor requestor, SearchParticipant participant, IJavaSearchScope scope, IProgressMonitor progressMonitor) throws IOException { // per construction, OR pattern can only be used with a PathCollector (which already gather results using a set) try {// w w w . ja v a2 s . c o m index.startQuery(); for (int i = 0, length = this.patterns.length; i < length; i++) this.patterns[i].findIndexMatches(index, requestor, participant, scope, progressMonitor); } finally { index.stopQuery(); } }
From source file:com.codenvy.ide.ext.java.server.internal.core.search.SubTypeSearchJob.java
License:Open Source License
public boolean search(Index index, IProgressMonitor progressMonitor) { if (index == null) return COMPLETE; if (this.indexes.addIfNotIncluded(index) == index) index.startQuery(); return super.search(index, progressMonitor); }