use of org.eclipse.jst.jsp.core.internal.java.search.JavaSearchDocumentDelegate 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.jst.jsp.core.internal.java.search.JavaSearchDocumentDelegate 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()]);
}
use of org.eclipse.jst.jsp.core.internal.java.search.JavaSearchDocumentDelegate in project webtools.sourceediting by eclipse.
the class BasicJSPSearchRequestor method acceptSearchMatch.
/**
* Maps java search coordinates to corresponding JSP coordinates.
* Adds the matches to the Search Results view.
* @see org.eclipse.jdt.core.search.SearchRequestor#acceptSearchMatch(org.eclipse.jdt.core.search.SearchMatch)
*/
public void acceptSearchMatch(SearchMatch match) throws CoreException {
if (JSPSearchSupport.getInstance().isCanceled())
return;
String matchDocumentPath = match.getResource().getFullPath().toString();
SearchDocument searchDoc = JSPSearchSupport.getInstance().getSearchDocument(matchDocumentPath);
if (searchDoc != null && searchDoc instanceof JavaSearchDocumentDelegate) {
JavaSearchDocumentDelegate javaSearchDoc = (JavaSearchDocumentDelegate) searchDoc;
int jspStart = javaSearchDoc.getJspOffset(match.getOffset());
int jspEnd = javaSearchDoc.getJspOffset(match.getOffset() + match.getLength());
JSPTranslation trans = javaSearchDoc.getJspTranslation();
String jspText = trans.getJspText();
String javaText = javaSearchDoc.getJavaText();
if (DEBUG)
displayDebugInfo(match, jspStart, jspEnd, jspText, javaText);
if (jspStart > -1 && jspEnd > -1)
addSearchMatch(new Document(trans.getJspText()), javaSearchDoc.getFile(), jspStart, jspEnd, jspText);
}
}
use of org.eclipse.jst.jsp.core.internal.java.search.JavaSearchDocumentDelegate in project webtools.sourceediting by eclipse.
the class BasicRefactorSearchRequestor method acceptSearchMatch.
/**
* @see org.eclipse.jdt.core.search.SearchRequestor#acceptSearchMatch(org.eclipse.jdt.core.search.SearchMatch)
*/
public void acceptSearchMatch(SearchMatch javaMatch) throws CoreException {
String matchDocumentPath = javaMatch.getResource().getFullPath().toString();
SearchDocument searchDoc = JSPSearchSupport.getInstance().getSearchDocument(matchDocumentPath);
if (searchDoc != null && searchDoc instanceof JavaSearchDocumentDelegate) {
String renameText = getRenameText((JavaSearchDocumentDelegate) searchDoc, javaMatch);
// if rename text is null then don't create an edit for it
if (renameText != null) {
// add it for the correct document
addJavaEdit(searchDoc.getPath(), new ReplaceEdit(javaMatch.getOffset(), javaMatch.getLength(), renameText));
}
}
}
Aggregations