Search in sources :

Example 1 with JSDTSearchDocumentDelegate

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

the class BasicRefactorSearchRequestor method acceptSearchMatch.

/**
 * @see org.eclipse.wst.jsdt.core.search.SearchRequestor#acceptSearchMatch(org.eclipse.wst.jsdt.core.search.SearchMatch)
 */
public void acceptSearchMatch(SearchMatch javaMatch) throws CoreException {
    String matchDocumentPath = javaMatch.getResource().getFullPath().toString();
    SearchDocument searchDoc = JsSearchSupport.getInstance().getSearchDocument(matchDocumentPath);
    if (searchDoc != null && searchDoc instanceof JSDTSearchDocumentDelegate) {
        String renameText = getRenameText((JSDTSearchDocumentDelegate) searchDoc, javaMatch);
        // add it for the correct document
        addJavaEdit(searchDoc.getPath(), new ReplaceEdit(javaMatch.getOffset(), javaMatch.getLength(), renameText));
    }
}
Also used : JSDTSearchDocumentDelegate(org.eclipse.wst.jsdt.web.core.javascript.search.JSDTSearchDocumentDelegate) ReplaceEdit(org.eclipse.text.edits.ReplaceEdit) SearchDocument(org.eclipse.wst.jsdt.core.search.SearchDocument)

Example 2 with JSDTSearchDocumentDelegate

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

the class BasicJsSearchRequestor method acceptSearchMatch.

/**
 * Maps java search coordinates to corresponding JSP coordinates. Adds the
 * matches to the Search Results view.
 *
 * @see org.eclipse.wst.jsdt.core.search.SearchRequestor#acceptSearchMatch(org.eclipse.wst.jsdt.core.search.SearchMatch)
 */
public void acceptSearchMatch(SearchMatch match) throws CoreException {
    if (JsSearchSupport.getInstance().isCanceled()) {
        return;
    }
    String matchDocumentPath = match.getResource().getFullPath().toString();
    SearchDocument searchDoc = JsSearchSupport.getInstance().getSearchDocument(matchDocumentPath);
    if (searchDoc != null && searchDoc instanceof JSDTSearchDocumentDelegate) {
        JSDTSearchDocumentDelegate javaSearchDoc = (JSDTSearchDocumentDelegate) searchDoc;
        int jspStart = match.getOffset();
        int jspEnd = match.getOffset() + match.getLength();
        IJsTranslation trans = javaSearchDoc.getJspTranslation();
        String jspText = trans.getHtmlText();
        String javaText = javaSearchDoc.getJavaText();
        if (BasicJsSearchRequestor.DEBUG) {
            displayDebugInfo(match, jspStart, jspEnd, jspText, javaText);
        }
        if (jspStart > -1 && jspEnd > -1) {
            addSearchMatch(new Document(trans.getHtmlText()), javaSearchDoc.getFile(), jspStart, jspEnd, jspText);
        }
    }
}
Also used : IJsTranslation(org.eclipse.wst.jsdt.web.core.javascript.IJsTranslation) JSDTSearchDocumentDelegate(org.eclipse.wst.jsdt.web.core.javascript.search.JSDTSearchDocumentDelegate) Document(org.eclipse.jface.text.Document) IDocument(org.eclipse.jface.text.IDocument) SearchDocument(org.eclipse.wst.jsdt.core.search.SearchDocument) SearchDocument(org.eclipse.wst.jsdt.core.search.SearchDocument)

Example 3 with JSDTSearchDocumentDelegate

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

the class BasicRefactorSearchRequestor method getChanges.

/**
 * @return all JSP changes for the search matches for the given Type
 */
public Change[] getChanges() {
    JsSearchSupport support = JsSearchSupport.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 JSDTSearchDocumentDelegate) {
            JSDTSearchDocumentDelegate javaDelegate = (JSDTSearchDocumentDelegate) delegate;
            changes.add(createChange(javaDelegate, javaEdit));
        }
    }
    return (Change[]) changes.toArray(new Change[changes.size()]);
}
Also used : JSDTSearchDocumentDelegate(org.eclipse.wst.jsdt.web.core.javascript.search.JSDTSearchDocumentDelegate) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) JsSearchSupport(org.eclipse.wst.jsdt.web.core.javascript.search.JsSearchSupport) ArrayList(java.util.ArrayList) List(java.util.List) Change(org.eclipse.ltk.core.refactoring.Change) DocumentChange(org.eclipse.ltk.core.refactoring.DocumentChange) MultiTextEdit(org.eclipse.text.edits.MultiTextEdit) SearchDocument(org.eclipse.wst.jsdt.core.search.SearchDocument)

Aggregations

SearchDocument (org.eclipse.wst.jsdt.core.search.SearchDocument)3 JSDTSearchDocumentDelegate (org.eclipse.wst.jsdt.web.core.javascript.search.JSDTSearchDocumentDelegate)3 ArrayList (java.util.ArrayList)1 Iterator (java.util.Iterator)1 List (java.util.List)1 Document (org.eclipse.jface.text.Document)1 IDocument (org.eclipse.jface.text.IDocument)1 Change (org.eclipse.ltk.core.refactoring.Change)1 DocumentChange (org.eclipse.ltk.core.refactoring.DocumentChange)1 MultiTextEdit (org.eclipse.text.edits.MultiTextEdit)1 ReplaceEdit (org.eclipse.text.edits.ReplaceEdit)1 IJsTranslation (org.eclipse.wst.jsdt.web.core.javascript.IJsTranslation)1 JsSearchSupport (org.eclipse.wst.jsdt.web.core.javascript.search.JsSearchSupport)1