Search in sources :

Example 6 with JSPSearchScope

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

the class JSPSearchTests method testSearchMethod.

public void testSearchMethod() {
    TestJspSearchRequestor requestor = new TestJspSearchRequestor();
    requestor.addCheckMatch("searchTestJSP.jsp", 143, 158);
    requestor.addCheckMatch("searchTestJSP.jsp", 298, 315);
    JSPSearchSupport.getInstance().search("searchForMethod", new JSPSearchScope(), METHOD, ALL_OCCURRENCES, SearchPattern.R_EXACT_MATCH, true, requestor, new NullProgressMonitor());
    assertTrue("did not find all expected matches: searchForMethod", requestor.checkValid());
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) JSPSearchScope(org.eclipse.jst.jsp.core.internal.java.search.JSPSearchScope)

Example 7 with JSPSearchScope

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

the class JSPQueryParticipant method search.

/**
 * @see org.eclipse.jdt.ui.search.IQueryParticipant#search(org.eclipse.jdt.ui.search.ISearchRequestor, org.eclipse.jdt.ui.search.QuerySpecification, org.eclipse.core.runtime.IProgressMonitor)
 */
public void search(ISearchRequestor requestor, QuerySpecification querySpecification, IProgressMonitor monitor) throws CoreException {
    if (shouldSupplyJSPSearchResultsToJavaSearch()) {
        // do search based on the particular Java query
        if (querySpecification instanceof ElementQuerySpecification) {
            // element search (eg. from global find references in Java file)
            ElementQuerySpecification elementQuery = (ElementQuerySpecification) querySpecification;
            IJavaElement element = elementQuery.getElement();
            if (DEBUG)
                // $NON-NLS-1$
                System.out.println("JSP Query Participant searching on ELEMENT: " + element);
            SearchRequestor jspRequestor = new JSPSearchRequestor(requestor);
            // pa_TODO need to adapt JavaSearchScope to a JSPSearchScope
            JSPSearchSupport.getInstance().search(element, new JSPSearchScope(), jspRequestor, monitor);
        } else if (querySpecification instanceof PatternQuerySpecification) {
            // pattern search (eg. from Java search page)
            PatternQuerySpecification patternQuery = (PatternQuerySpecification) querySpecification;
            String pattern = patternQuery.getPattern();
            if (DEBUG)
                // $NON-NLS-1$
                System.out.println("JSP Query Participant searching on PATTERN: " + pattern);
            SearchRequestor jspRequestor = new JSPSearchRequestor(requestor);
            JSPSearchSupport.getInstance().search(pattern, new JSPSearchScope(), patternQuery.getSearchFor(), patternQuery.getLimitTo(), SearchPattern.R_PATTERN_MATCH, false, jspRequestor, monitor);
        }
    }
}
Also used : SearchRequestor(org.eclipse.jdt.core.search.SearchRequestor) ISearchRequestor(org.eclipse.jdt.ui.search.ISearchRequestor) JSPSearchRequestor(org.eclipse.jst.jsp.ui.internal.java.search.JSPSearchRequestor) IJavaElement(org.eclipse.jdt.core.IJavaElement) ElementQuerySpecification(org.eclipse.jdt.ui.search.ElementQuerySpecification) PatternQuerySpecification(org.eclipse.jdt.ui.search.PatternQuerySpecification) JSPSearchScope(org.eclipse.jst.jsp.core.internal.java.search.JSPSearchScope) JSPSearchRequestor(org.eclipse.jst.jsp.ui.internal.java.search.JSPSearchRequestor)

Example 8 with JSPSearchScope

use of org.eclipse.jst.jsp.core.internal.java.search.JSPSearchScope 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 9 with JSPSearchScope

use of org.eclipse.jst.jsp.core.internal.java.search.JSPSearchScope 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 10 with JSPSearchScope

use of org.eclipse.jst.jsp.core.internal.java.search.JSPSearchScope 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)

Aggregations

JSPSearchScope (org.eclipse.jst.jsp.core.internal.java.search.JSPSearchScope)13 JSPSearchSupport (org.eclipse.jst.jsp.core.internal.java.search.JSPSearchSupport)7 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)5 IJavaElement (org.eclipse.jdt.core.IJavaElement)2 Change (org.eclipse.ltk.core.refactoring.Change)2 CompositeChange (org.eclipse.ltk.core.refactoring.CompositeChange)2 TextChange (org.eclipse.ltk.core.refactoring.TextChange)2 IFile (org.eclipse.core.resources.IFile)1 IPath (org.eclipse.core.runtime.IPath)1 IStatus (org.eclipse.core.runtime.IStatus)1 Path (org.eclipse.core.runtime.Path)1 Status (org.eclipse.core.runtime.Status)1 SearchDocument (org.eclipse.jdt.core.search.SearchDocument)1 SearchRequestor (org.eclipse.jdt.core.search.SearchRequestor)1 ElementQuerySpecification (org.eclipse.jdt.ui.search.ElementQuerySpecification)1 ISearchRequestor (org.eclipse.jdt.ui.search.ISearchRequestor)1 PatternQuerySpecification (org.eclipse.jdt.ui.search.PatternQuerySpecification)1 IJSPTranslation (org.eclipse.jst.jsp.core.internal.java.IJSPTranslation)1 JSPTranslation (org.eclipse.jst.jsp.core.internal.java.JSPTranslation)1 JSPTranslationAdapter (org.eclipse.jst.jsp.core.internal.java.JSPTranslationAdapter)1