use of org.eclipse.jdt.core.search.SearchDocument in project che by eclipse.
the class IndexManager method addSource.
/**
* Trigger addition of a resource to an index
* Note: the actual operation is performed in background
*/
public void addSource(IFile resource, IPath containerPath, SourceElementParser parser) {
// if (JavaCore.getPlugin() == null) return;
SearchParticipant participant = SearchEngine.getDefaultSearchParticipant();
SearchDocument document = participant.getDocument(resource.getFullPath().toString());
document.setParser(parser);
IndexLocation indexLocation = computeIndexLocation(containerPath);
scheduleDocumentIndexing(document, containerPath, indexLocation, participant);
}
use of org.eclipse.jdt.core.search.SearchDocument in project webtools.sourceediting by eclipse.
the class JSPSearchParticipant method locateMatches.
public void locateMatches(SearchDocument[] indexMatches, SearchPattern pattern, IJavaSearchScope scope, SearchRequestor requestor, IProgressMonitor monitor) throws CoreException {
if (monitor != null && monitor.isCanceled())
return;
// filter out null matches
List filtered = new ArrayList();
SearchDocument match = null;
for (int i = 0; i < indexMatches.length; i++) {
if (DEBUG)
// $NON-NLS-1$
System.out.println("found possible matching JavaSearchDocumentDelegate: " + indexMatches[i]);
match = indexMatches[i];
if (match != null) {
// the file may not even exist
if (match instanceof JavaSearchDocumentDelegate && ((JavaSearchDocumentDelegate) match).getFile().exists())
filtered.add(match);
}
}
indexMatches = (SearchDocument[]) filtered.toArray(new SearchDocument[filtered.size()]);
SearchEngine.getDefaultSearchParticipant().locateMatches(indexMatches, pattern, scope, requestor, monitor);
}
use of org.eclipse.jdt.core.search.SearchDocument in project webtools.sourceediting by eclipse.
the class JSPSearchQuery method doQuery.
protected IStatus doQuery(IProgressMonitor monitor) {
IStatus status = Status.OK_STATUS;
try {
JSPSearchSupport support = JSPSearchSupport.getInstance();
// index the file
SearchDocument delegate = support.addJspFile(getFile());
String scopePath = delegate.getPath();
JSPSearchScope singleFileScope = new JSPSearchScope(new String[] { getFile().getFullPath().toString(), scopePath });
// perform a searchs
// by passing in this jsp search query, requstor can add matches
support.searchRunnable(getJavaElement(), singleFileScope, new JSPSingleFileSearchRequestor(getInstance()), monitor);
} catch (Exception e) {
// $NON-NLS-1$ //$NON-NLS-2$
status = new Status(IStatus.ERROR, "org.eclipse.wst.sse.ui", IStatus.OK, "", null);
}
return status;
}
use of org.eclipse.jdt.core.search.SearchDocument in project webtools.sourceediting by eclipse.
the class BasicRefactorSearchRequestor method getChanges.
/**
* <p>This function is not safe because it does not check for existing {@link Change}s that
* new {@link Change}s created by this method may conflict with. These conflicts can
* cause indeterminate results when applied to documents. Long story short, don't
* use this method any more.</p>
*
* @return all JSP changes for the search matches for the given Type, they may conflict
* with already existing {@link Change}s
*
* @see #getChanges(RefactoringParticipant)
*
* @deprecated
*/
public Change[] getChanges() {
JSPSearchSupport support = JSPSearchSupport.getInstance();
List changes = new ArrayList();
Iterator keys = fSearchDocPath2JavaEditMap.keySet().iterator();
String searchDocPath = null;
SearchDocument delegate = null;
while (keys.hasNext()) {
// create on the fly
searchDocPath = (String) keys.next();
MultiTextEdit javaEdit = (MultiTextEdit) fSearchDocPath2JavaEditMap.get(searchDocPath);
delegate = support.getSearchDocument(searchDocPath);
if (delegate != null && delegate instanceof JavaSearchDocumentDelegate) {
JavaSearchDocumentDelegate javaDelegate = (JavaSearchDocumentDelegate) delegate;
changes.add(createChange(javaDelegate, javaDelegate.getJspTranslation().getJspEdit(javaEdit)));
}
}
return (Change[]) changes.toArray(new Change[changes.size()]);
}
use of org.eclipse.jdt.core.search.SearchDocument in project webtools.sourceediting by eclipse.
the class BasicRefactorSearchRequestor method getChanges.
/**
* Gets new {@link Change}s created as a result of this {@link SearchRequestor}.
* Any existing {@link TextChange}s that had new edits added to them will not be
* returned.
*
* @param participant {@link RefactoringParticipant} to determine if there are already existing
* {@link TextChange}s for the documents that this {@link SearchRequestor} found.
* If existing
* {@link TextChange}s are found then they will be used for any new edits, else new {@link TextChange}s
* will be created.
*
* @return Any new {@link TextChange}s created by this {@link SearchRequestor}. If edits were
* added to existing {@link TextChange}s then those existing {@link TextChange}s will not be
* returned in this array.
*/
public Change[] getChanges(RefactoringParticipant participant) {
JSPSearchSupport support = JSPSearchSupport.getInstance();
List changes = new ArrayList();
Iterator keys = fSearchDocPath2JavaEditMap.keySet().iterator();
String searchDocPath = null;
SearchDocument delegate = null;
while (keys.hasNext()) {
// create on the fly
searchDocPath = (String) keys.next();
MultiTextEdit javaEdit = (MultiTextEdit) fSearchDocPath2JavaEditMap.get(searchDocPath);
delegate = support.getSearchDocument(searchDocPath);
if (delegate != null && delegate instanceof JavaSearchDocumentDelegate) {
JavaSearchDocumentDelegate javaDelegate = (JavaSearchDocumentDelegate) delegate;
Change change = createChange(javaDelegate, javaDelegate.getJspTranslation().getJspEdit(javaEdit), participant);
changes.add(change);
}
}
return (Change[]) changes.toArray(new Change[changes.size()]);
}
Aggregations