Search in sources :

Example 6 with JSPSearchSupport

use of org.eclipse.jst.jsp.core.internal.java.search.JSPSearchSupport 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()]);
}
Also used : JSPSearchSupport(org.eclipse.jst.jsp.core.internal.java.search.JSPSearchSupport) JavaSearchDocumentDelegate(org.eclipse.jst.jsp.core.internal.java.search.JavaSearchDocumentDelegate) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) ArrayList(java.util.ArrayList) List(java.util.List) TextChange(org.eclipse.ltk.core.refactoring.TextChange) Change(org.eclipse.ltk.core.refactoring.Change) MultiTextEdit(org.eclipse.text.edits.MultiTextEdit) SearchDocument(org.eclipse.jdt.core.search.SearchDocument)

Example 7 with JSPSearchSupport

use of org.eclipse.jst.jsp.core.internal.java.search.JSPSearchSupport in project webtools.sourceediting by eclipse.

the class JSPMethodRenameChange method createChangesFor.

/**
 * @deprecated
 */
public static Change[] createChangesFor(IMethod method, String newName) {
    JSPSearchSupport support = JSPSearchSupport.getInstance();
    // should be handled by JSPIndexManager
    // https://w3.opensource.ibm.com/bugzilla/show_bug.cgi?id=3036
    // support.indexWorkspaceAndWait();
    BasicRefactorSearchRequestor requestor = new JSPMethodRenameRequestor(method, newName);
    support.searchRunnable(method, new JSPSearchScope(), requestor);
    return requestor.getChanges();
}
Also used : JSPSearchSupport(org.eclipse.jst.jsp.core.internal.java.search.JSPSearchSupport) JSPSearchScope(org.eclipse.jst.jsp.core.internal.java.search.JSPSearchScope)

Example 8 with JSPSearchSupport

use of org.eclipse.jst.jsp.core.internal.java.search.JSPSearchSupport in project webtools.sourceediting by eclipse.

the class JSPMoveParticipant method createChangesFor.

/**
 * Using a {@link SearchRequestor} create new changes.
 *
 * @param element the {@link IJavaElement} to create new changes for
 * @param newName the new name of the given {@link IJavaElement}
 *
 * @return any newly created {@link Change}s.  It is important to note
 * that while no NEW {@link Change}s maybe returned it is possible that
 * new {@link TextEdit}s will still added to existing {@link Change}s.
 */
protected Change[] createChangesFor(IJavaElement element, String newName, IProgressMonitor monitor) {
    Change[] changes;
    BasicRefactorSearchRequestor requestor = getSearchRequestor(element, newName);
    if (requestor != null) {
        JSPSearchSupport support = JSPSearchSupport.getInstance();
        support.searchRunnable(element, new JSPSearchScope(), requestor, monitor);
        changes = requestor.getChanges(this);
    } else {
        changes = new Change[0];
    }
    return changes;
}
Also used : JSPSearchSupport(org.eclipse.jst.jsp.core.internal.java.search.JSPSearchSupport) JSPSearchScope(org.eclipse.jst.jsp.core.internal.java.search.JSPSearchScope) CompositeChange(org.eclipse.ltk.core.refactoring.CompositeChange) TextChange(org.eclipse.ltk.core.refactoring.TextChange) Change(org.eclipse.ltk.core.refactoring.Change)

Example 9 with JSPSearchSupport

use of org.eclipse.jst.jsp.core.internal.java.search.JSPSearchSupport in project webtools.sourceediting by eclipse.

the class JSPTypeMoveChange method createChangesFor.

/**
 * @deprecated
 */
public static Change[] createChangesFor(IType type, String newName) {
    JSPSearchSupport support = JSPSearchSupport.getInstance();
    // should be handled by JSPIndexManager
    // https://w3.opensource.ibm.com/bugzilla/show_bug.cgi?id=3036
    // support.indexWorkspaceAndWait();
    JSPTypeMoveRequestor requestor = new JSPTypeMoveRequestor(type, newName);
    support.searchRunnable(type, new JSPSearchScope(), requestor);
    return requestor.getChanges();
}
Also used : JSPSearchSupport(org.eclipse.jst.jsp.core.internal.java.search.JSPSearchSupport) JSPSearchScope(org.eclipse.jst.jsp.core.internal.java.search.JSPSearchScope)

Example 10 with JSPSearchSupport

use of org.eclipse.jst.jsp.core.internal.java.search.JSPSearchSupport in project webtools.sourceediting by eclipse.

the class JSPSearchTests method testIndexWorkspace.

public void testIndexWorkspace() {
    JSPSearchSupport support = JSPSearchSupport.getInstance();
    SearchDocument doc = JSPSearchSupport.getInstance().getSearchDocument("/judo/searchTestJSP.java");
    assertNotNull("couldn't retrieve:'/judo/searchTestJSP.java'", doc);
    doc = support.getSearchDocument("/judo/searchTestJSP2.java");
    assertNotNull("couldn't retrieve:'/judo/searchTestJSP2.java'", doc);
    doc = support.getSearchDocument("/judo/searchTestJSP3.java");
    assertNotNull("couldn't retrieve:'/judo/searchTestJSP3.java'", doc);
}
Also used : JSPSearchSupport(org.eclipse.jst.jsp.core.internal.java.search.JSPSearchSupport) SearchDocument(org.eclipse.jdt.core.search.SearchDocument)

Aggregations

JSPSearchSupport (org.eclipse.jst.jsp.core.internal.java.search.JSPSearchSupport)10 JSPSearchScope (org.eclipse.jst.jsp.core.internal.java.search.JSPSearchScope)7 SearchDocument (org.eclipse.jdt.core.search.SearchDocument)4 Change (org.eclipse.ltk.core.refactoring.Change)4 TextChange (org.eclipse.ltk.core.refactoring.TextChange)4 ArrayList (java.util.ArrayList)2 Iterator (java.util.Iterator)2 List (java.util.List)2 JavaSearchDocumentDelegate (org.eclipse.jst.jsp.core.internal.java.search.JavaSearchDocumentDelegate)2 CompositeChange (org.eclipse.ltk.core.refactoring.CompositeChange)2 MultiTextEdit (org.eclipse.text.edits.MultiTextEdit)2 IStatus (org.eclipse.core.runtime.IStatus)1 Status (org.eclipse.core.runtime.Status)1