use of org.eclipse.wst.common.core.search.pattern.ComponentSearchPattern in project webtools.sourceediting by eclipse.
the class XMLSearchParticipant method locateMatches.
public void locateMatches(SearchDocumentSet documentSet, SearchPattern pattern, SearchScope scope, SearchRequestor requestor, Map searchOptions, IProgressMonitor monitor) throws CoreException {
long time = System.currentTimeMillis();
// TODO: use the file reference entries in the documents to reduce the scope to the referenced files only
// SearchDocument[] documents = documentSet.getSearchDocuments(id);
// check to see if the search pattern is qualified by a file location
// if this is the case then we can use file scoping rules to prune the matches
IFile targetFile = null;
if (pattern instanceof ComponentSearchPattern) {
ComponentSearchPattern componentSearchPattern = (ComponentSearchPattern) pattern;
targetFile = componentSearchPattern.getFile();
}
// here we should have in scope only referenced files
IFile[] files = scope.enclosingFiles();
for (int i = 0; i < files.length; i++) {
IFile file = files[i];
String path = file.getLocation().toString();
SearchDocument document = documentSet.getSearchDocument(path, id);
if (document != null) {
Entry[] entries = document.getEntries(getSearchEntryCategory(pattern), null, 0);
if ((entries != null && entries.length > 0) || (searchOptions != null && searchOptions.get("searchDirtyContent") != null)) {
// for (int j = 0; j < entries.length; j++)
// {
// Entry entry = entries[j];
// System.out.println("entry " + entry.getCategory() + " " + entry.getKey() + " " + entry.getClass().getName());
// }
boolean isInScope = true;
if (targetFile != null) {
try {
// $NON-NLS-1$ //$NON-NLS-2$
isInScope = isLinked(documentSet, "file:///" + path, "file:///" + targetFile.getLocation().toString());
// if (path.endsWith("CancelSelection.wsdl") && path.indexOf("clone1") != -1)
// {
// fileReferenceTable.debug(qualifiedPath, 0, 5);
// }
} catch (Exception e) {
e.printStackTrace();
}
}
if (isInScope) {
this.locateMatches(pattern, document, requestor, searchOptions, monitor);
}
}
}
}
if (debugPerf) {
System.out.println(// $NON-NLS-1$
"" + getDescription() + ": " + (System.currentTimeMillis() - time) + // $NON-NLS-1$ //$NON-NLS-2$
"ms for locateMatches");
}
}
Aggregations