use of org.eclipse.wst.jsdt.core.search.SearchDocument in project webtools.sourceediting by eclipse.
the class JsSearchQuery method doQuery.
protected IStatus doQuery() {
IStatus status = Status.OK_STATUS;
try {
JsSearchSupport support = JsSearchSupport.getInstance();
// index the file
SearchDocument delegate = support.addJspFile(getFile());
String scopePath = delegate.getPath();
JsSearchScope singleFileScope = new JsSearchScope(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()));
support.searchRunnable(getJavaElement(), singleFileScope, new JsSingleFileSearchRequestor(getInstance()));
} 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.wst.jsdt.core.search.SearchDocument in project webtools.sourceediting by eclipse.
the class JsSearchSupport method getSearchDocument.
/**
* Centralized place to access JSPSearchDocuments (used by
* JSPSearchParticipant and JSPSearchRequestor)
*
* @param searchDocPath
* @param doc
* @return the JSPSearchDocument or null if one is not found
*/
public SearchDocument getSearchDocument(String searchDocPath) {
SearchDocument delegate = null;
IFile f = fileForCUPath(searchDocPath);
if (f != null) {
delegate = createSearchDocument(f);
} else {
// handle failure case... (file deleted maybe?)
}
return delegate;
}
use of org.eclipse.wst.jsdt.core.search.SearchDocument in project webtools.sourceediting by eclipse.
the class BasicRefactorSearchRequestor method acceptSearchMatch.
/**
* @see org.eclipse.wst.jsdt.core.search.SearchRequestor#acceptSearchMatch(org.eclipse.wst.jsdt.core.search.SearchMatch)
*/
public void acceptSearchMatch(SearchMatch javaMatch) throws CoreException {
String matchDocumentPath = javaMatch.getResource().getFullPath().toString();
SearchDocument searchDoc = JsSearchSupport.getInstance().getSearchDocument(matchDocumentPath);
if (searchDoc != null && searchDoc instanceof JSDTSearchDocumentDelegate) {
String renameText = getRenameText((JSDTSearchDocumentDelegate) searchDoc, javaMatch);
// add it for the correct document
addJavaEdit(searchDoc.getPath(), new ReplaceEdit(javaMatch.getOffset(), javaMatch.getLength(), renameText));
}
}
use of org.eclipse.wst.jsdt.core.search.SearchDocument in project webtools.sourceediting by eclipse.
the class BasicJsSearchRequestor method acceptSearchMatch.
/**
* Maps java search coordinates to corresponding JSP coordinates. Adds the
* matches to the Search Results view.
*
* @see org.eclipse.wst.jsdt.core.search.SearchRequestor#acceptSearchMatch(org.eclipse.wst.jsdt.core.search.SearchMatch)
*/
public void acceptSearchMatch(SearchMatch match) throws CoreException {
if (JsSearchSupport.getInstance().isCanceled()) {
return;
}
String matchDocumentPath = match.getResource().getFullPath().toString();
SearchDocument searchDoc = JsSearchSupport.getInstance().getSearchDocument(matchDocumentPath);
if (searchDoc != null && searchDoc instanceof JSDTSearchDocumentDelegate) {
JSDTSearchDocumentDelegate javaSearchDoc = (JSDTSearchDocumentDelegate) searchDoc;
int jspStart = match.getOffset();
int jspEnd = match.getOffset() + match.getLength();
IJsTranslation trans = javaSearchDoc.getJspTranslation();
String jspText = trans.getHtmlText();
String javaText = javaSearchDoc.getJavaText();
if (BasicJsSearchRequestor.DEBUG) {
displayDebugInfo(match, jspStart, jspEnd, jspText, javaText);
}
if (jspStart > -1 && jspEnd > -1) {
addSearchMatch(new Document(trans.getHtmlText()), javaSearchDoc.getFile(), jspStart, jspEnd, jspText);
}
}
}
use of org.eclipse.wst.jsdt.core.search.SearchDocument in project webtools.sourceediting by eclipse.
the class JsSearchParticipant method locateMatches.
public void locateMatches(SearchDocument[] indexMatches, SearchPattern pattern, IJavaScriptSearchScope 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 JSDTSearchDocumentDelegate) && ((JSDTSearchDocumentDelegate) match).getFile().exists()) {
filtered.add(match);
}
}
}
indexMatches = (SearchDocument[]) filtered.toArray(new SearchDocument[filtered.size()]);
SearchEngine.getDefaultSearchParticipant().locateMatches(indexMatches, pattern, scope, requestor, monitor);
}
Aggregations