Search in sources :

Example 1 with JsSearchScope

use of org.eclipse.wst.jsdt.web.core.javascript.search.JsSearchScope 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;
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) JsSearchScope(org.eclipse.wst.jsdt.web.core.javascript.search.JsSearchScope) IStatus(org.eclipse.core.runtime.IStatus) JsSearchSupport(org.eclipse.wst.jsdt.web.core.javascript.search.JsSearchSupport) SearchDocument(org.eclipse.wst.jsdt.core.search.SearchDocument)

Example 2 with JsSearchScope

use of org.eclipse.wst.jsdt.web.core.javascript.search.JsSearchScope in project webtools.sourceediting by eclipse.

the class JsQueryParticipant method search.

/**
 * @see org.eclipse.wst.jsdt.ui.search.IQueryParticipant#search(org.eclipse.wst.jsdt.ui.search.ISearchRequestor,
 *      org.eclipse.wst.jsdt.ui.search.QuerySpecification,
 *      org.eclipse.core.runtime.IProgressMonitor)
 */
public void search(ISearchRequestor requestor, QuerySpecification querySpecification, IProgressMonitor monitor) throws CoreException {
    // 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;
        IJavaScriptElement element = elementQuery.getElement();
        if (JsQueryParticipant.DEBUG) {
            // $NON-NLS-1$
            System.out.println("JSP Query Participant searching on ELEMENT: " + element);
        }
        SearchRequestor jspRequestor = new JsSearchRequestor(requestor);
        // pa_TODO need to adapt JavaSearchScope to a JSPSearchScope
        JsSearchSupport.getInstance().search(element, new JsSearchScope(), jspRequestor);
    } else if (querySpecification instanceof PatternQuerySpecification) {
        // pattern search (eg. from Java search page)
        PatternQuerySpecification patternQuery = (PatternQuerySpecification) querySpecification;
        String pattern = patternQuery.getPattern();
        if (JsQueryParticipant.DEBUG) {
            // $NON-NLS-1$
            System.out.println("JSP Query Participant searching on PATTERN: " + pattern);
        }
        SearchRequestor jspRequestor = new JsSearchRequestor(requestor);
        JsSearchSupport.getInstance().search(pattern, new JsSearchScope(), patternQuery.getSearchFor(), patternQuery.getLimitTo(), SearchPattern.R_PATTERN_MATCH, false, jspRequestor);
    }
}
Also used : SearchRequestor(org.eclipse.wst.jsdt.core.search.SearchRequestor) JsSearchRequestor(org.eclipse.wst.jsdt.web.ui.internal.java.search.JsSearchRequestor) ISearchRequestor(org.eclipse.wst.jsdt.ui.search.ISearchRequestor) JsSearchScope(org.eclipse.wst.jsdt.web.core.javascript.search.JsSearchScope) ElementQuerySpecification(org.eclipse.wst.jsdt.ui.search.ElementQuerySpecification) PatternQuerySpecification(org.eclipse.wst.jsdt.ui.search.PatternQuerySpecification) IJavaScriptElement(org.eclipse.wst.jsdt.core.IJavaScriptElement) JsSearchRequestor(org.eclipse.wst.jsdt.web.ui.internal.java.search.JsSearchRequestor)

Example 3 with JsSearchScope

use of org.eclipse.wst.jsdt.web.core.javascript.search.JsSearchScope in project webtools.sourceediting by eclipse.

the class JSPTypeMoveChange method createChangesFor.

public static Change[] createChangesFor(IType type, String newName) {
    JsSearchSupport support = JsSearchSupport.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 JsSearchScope(), requestor);
    return requestor.getChanges();
}
Also used : JsSearchScope(org.eclipse.wst.jsdt.web.core.javascript.search.JsSearchScope) JsSearchSupport(org.eclipse.wst.jsdt.web.core.javascript.search.JsSearchSupport)

Example 4 with JsSearchScope

use of org.eclipse.wst.jsdt.web.core.javascript.search.JsSearchScope in project webtools.sourceediting by eclipse.

the class JSPMethodRenameChange method createChangesFor.

public static Change[] createChangesFor(IFunction method, String newName) {
    JsSearchSupport support = JsSearchSupport.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 JsSearchScope(), requestor);
    return requestor.getChanges();
}
Also used : JsSearchScope(org.eclipse.wst.jsdt.web.core.javascript.search.JsSearchScope) JsSearchSupport(org.eclipse.wst.jsdt.web.core.javascript.search.JsSearchSupport)

Example 5 with JsSearchScope

use of org.eclipse.wst.jsdt.web.core.javascript.search.JsSearchScope in project webtools.sourceediting by eclipse.

the class JSPPackageRenameChange method createChangesFor.

public static Change[] createChangesFor(IPackageFragment pkg, String newName) {
    JsSearchSupport support = JsSearchSupport.getInstance();
    // should be handled by JSPIndexManager
    // https://w3.opensource.ibm.com/bugzilla/show_bug.cgi?id=3036
    // support.indexWorkspaceAndWait();
    BasicRefactorSearchRequestor requestor = new JSPPackageRenameRequestor(pkg, newName);
    support.searchRunnable(pkg, new JsSearchScope(), requestor);
    return requestor.getChanges();
}
Also used : JsSearchScope(org.eclipse.wst.jsdt.web.core.javascript.search.JsSearchScope) JsSearchSupport(org.eclipse.wst.jsdt.web.core.javascript.search.JsSearchSupport)

Aggregations

JsSearchScope (org.eclipse.wst.jsdt.web.core.javascript.search.JsSearchScope)6 JsSearchSupport (org.eclipse.wst.jsdt.web.core.javascript.search.JsSearchSupport)5 IStatus (org.eclipse.core.runtime.IStatus)1 Status (org.eclipse.core.runtime.Status)1 IJavaScriptElement (org.eclipse.wst.jsdt.core.IJavaScriptElement)1 SearchDocument (org.eclipse.wst.jsdt.core.search.SearchDocument)1 SearchRequestor (org.eclipse.wst.jsdt.core.search.SearchRequestor)1 ElementQuerySpecification (org.eclipse.wst.jsdt.ui.search.ElementQuerySpecification)1 ISearchRequestor (org.eclipse.wst.jsdt.ui.search.ISearchRequestor)1 PatternQuerySpecification (org.eclipse.wst.jsdt.ui.search.PatternQuerySpecification)1 JsSearchRequestor (org.eclipse.wst.jsdt.web.ui.internal.java.search.JsSearchRequestor)1