Search in sources :

Example 6 with SearchDocument

use of org.eclipse.jdt.core.search.SearchDocument in project che by eclipse.

the class IndexManager method addBinary.

/**
     * Trigger addition of a resource to an index
     * Note: the actual operation is performed in background
     */
public void addBinary(IFile resource, IPath containerPath) {
    //        if (JavaCore.getPlugin() == null) return;
    SearchParticipant participant = SearchEngine.getDefaultSearchParticipant();
    SearchDocument document = participant.getDocument(resource.getFullPath().toString());
    IndexLocation indexLocation = computeIndexLocation(containerPath);
    scheduleDocumentIndexing(document, containerPath, indexLocation, participant);
}
Also used : FileIndexLocation(org.eclipse.jdt.internal.core.index.FileIndexLocation) IndexLocation(org.eclipse.jdt.internal.core.index.IndexLocation) SearchParticipant(org.eclipse.jdt.core.search.SearchParticipant) SearchDocument(org.eclipse.jdt.core.search.SearchDocument)

Example 7 with SearchDocument

use of org.eclipse.jdt.core.search.SearchDocument 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);
    }
}
Also used : JSPTranslation(org.eclipse.jst.jsp.core.internal.java.JSPTranslation) JavaSearchDocumentDelegate(org.eclipse.jst.jsp.core.internal.java.search.JavaSearchDocumentDelegate) Document(org.eclipse.jface.text.Document) IDocument(org.eclipse.jface.text.IDocument) SearchDocument(org.eclipse.jdt.core.search.SearchDocument) SearchDocument(org.eclipse.jdt.core.search.SearchDocument)

Example 8 with SearchDocument

use of org.eclipse.jdt.core.search.SearchDocument 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));
        }
    }
}
Also used : JavaSearchDocumentDelegate(org.eclipse.jst.jsp.core.internal.java.search.JavaSearchDocumentDelegate) ReplaceEdit(org.eclipse.text.edits.ReplaceEdit) SearchDocument(org.eclipse.jdt.core.search.SearchDocument)

Example 9 with SearchDocument

use of org.eclipse.jdt.core.search.SearchDocument 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)

Example 10 with SearchDocument

use of org.eclipse.jdt.core.search.SearchDocument in project webtools.sourceediting by eclipse.

the class JSPSearchSupport 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;
}
Also used : IFile(org.eclipse.core.resources.IFile) SearchDocument(org.eclipse.jdt.core.search.SearchDocument)

Aggregations

SearchDocument (org.eclipse.jdt.core.search.SearchDocument)10 JSPSearchSupport (org.eclipse.jst.jsp.core.internal.java.search.JSPSearchSupport)4 JavaSearchDocumentDelegate (org.eclipse.jst.jsp.core.internal.java.search.JavaSearchDocumentDelegate)4 ArrayList (java.util.ArrayList)3 List (java.util.List)3 Iterator (java.util.Iterator)2 SearchParticipant (org.eclipse.jdt.core.search.SearchParticipant)2 FileIndexLocation (org.eclipse.jdt.internal.core.index.FileIndexLocation)2 IndexLocation (org.eclipse.jdt.internal.core.index.IndexLocation)2 Change (org.eclipse.ltk.core.refactoring.Change)2 TextChange (org.eclipse.ltk.core.refactoring.TextChange)2 MultiTextEdit (org.eclipse.text.edits.MultiTextEdit)2 IFile (org.eclipse.core.resources.IFile)1 IStatus (org.eclipse.core.runtime.IStatus)1 Status (org.eclipse.core.runtime.Status)1 Document (org.eclipse.jface.text.Document)1 IDocument (org.eclipse.jface.text.IDocument)1 JSPTranslation (org.eclipse.jst.jsp.core.internal.java.JSPTranslation)1 JSPSearchScope (org.eclipse.jst.jsp.core.internal.java.search.JSPSearchScope)1 ReplaceEdit (org.eclipse.text.edits.ReplaceEdit)1