Search in sources :

Example 26 with IJsTranslation

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

the class JsSearchDocument method getCharContents.

/**
 * @see org.eclipse.jdt.core.search.SearchDocument#getCharContents()
 */
public char[] getCharContents() {
    if ((fCachedCharContents == null) || isDirty()) {
        IJsTranslation trans = getJSTranslation();
        fCachedCharContents = trans != null ? trans.getJsText().toCharArray() : new char[0];
        fCUPath = trans.getJavaPath();
    }
    return fCachedCharContents;
}
Also used : IJsTranslation(org.eclipse.wst.jsdt.web.core.javascript.IJsTranslation)

Example 27 with IJsTranslation

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

the class JSDTHtmlCompletionProcessor method getJSPTranslation.

private IJsTranslation getJSPTranslation(ITextViewer viewer) {
    IDOMModel xmlModel = null;
    try {
        xmlModel = (IDOMModel) StructuredModelManager.getModelManager().getExistingModelForRead(viewer.getDocument());
        IDOMDocument xmlDoc = xmlModel.getDocument();
        JsTranslationAdapter fTranslationAdapter = (JsTranslationAdapter) xmlDoc.getAdapterFor(IJsTranslation.class);
        if (fTranslationAdapter != null) {
            return fTranslationAdapter.getJsTranslation(true);
        }
    } catch (Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } finally {
        if (xmlModel != null) {
            xmlModel.releaseFromRead();
        }
    }
    return null;
}
Also used : IJsTranslation(org.eclipse.wst.jsdt.web.core.javascript.IJsTranslation) IDOMModel(org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel) IDOMDocument(org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument) JsTranslationAdapter(org.eclipse.wst.jsdt.web.core.javascript.JsTranslationAdapter)

Example 28 with IJsTranslation

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

the class AddJavaDocStubOperation method getJavaDocumentFromNode.

protected IDocument getJavaDocumentFromNode() {
    if (copy == null) {
        IJsTranslation tran = node.getTranslation();
        copy = new Document(tran.getJsText());
        textEditListener = new DocumentChangeListenerToTextEdit();
        copy.addDocumentListener(textEditListener);
    }
    return copy;
}
Also used : IJsTranslation(org.eclipse.wst.jsdt.web.core.javascript.IJsTranslation) DocumentChangeListenerToTextEdit(org.eclipse.wst.jsdt.web.core.javascript.DocumentChangeListenerToTextEdit) Document(org.eclipse.jface.text.Document) IDocument(org.eclipse.jface.text.IDocument) IStructuredDocument(org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument)

Example 29 with IJsTranslation

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

the class JSDTContentAssistant method getJSPTranslation.

private IJsTranslation getJSPTranslation(ITextViewer viewer, int offset) {
    IDOMModel xmlModel = null;
    try {
        xmlModel = (IDOMModel) StructuredModelManager.getModelManager().getExistingModelForRead(viewer.getDocument());
        IDOMDocument xmlDoc = xmlModel.getDocument();
        JsTranslationAdapter translationAdapter = (JsTranslationAdapter) xmlDoc.getAdapterFor(IJsTranslation.class);
        if (translationAdapter != null) {
            return translationAdapter.getJsTranslation(true);
        }
    } catch (Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } finally {
        if (xmlModel != null) {
            xmlModel.releaseFromRead();
        }
    }
    return null;
}
Also used : IJsTranslation(org.eclipse.wst.jsdt.web.core.javascript.IJsTranslation) IDOMModel(org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel) IDOMDocument(org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument) JsTranslationAdapter(org.eclipse.wst.jsdt.web.core.javascript.JsTranslationAdapter)

Example 30 with IJsTranslation

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

the class JSDTContetAssistInvocationContext method getJSPTranslation.

private static IJsTranslation getJSPTranslation(ITextViewer viewer) {
    IJsTranslation fTranslation = null;
    IDOMModel xmlModel = null;
    try {
        xmlModel = (IDOMModel) StructuredModelManager.getModelManager().getExistingModelForRead(viewer.getDocument());
        IDOMDocument xmlDoc = xmlModel.getDocument();
        JsTranslationAdapter fTranslationAdapter = (JsTranslationAdapter) xmlDoc.getAdapterFor(IJsTranslation.class);
        if (fTranslationAdapter != null) {
            fTranslation = fTranslationAdapter.getJsTranslation(true);
        }
    } catch (Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } finally {
        if (xmlModel != null) {
            xmlModel.releaseFromRead();
        }
    }
    return fTranslation;
}
Also used : IJsTranslation(org.eclipse.wst.jsdt.web.core.javascript.IJsTranslation) IDOMModel(org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel) IDOMDocument(org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument) JsTranslationAdapter(org.eclipse.wst.jsdt.web.core.javascript.JsTranslationAdapter)

Aggregations

IJsTranslation (org.eclipse.wst.jsdt.web.core.javascript.IJsTranslation)51 JsTranslationAdapter (org.eclipse.wst.jsdt.web.core.javascript.JsTranslationAdapter)41 IDOMModel (org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel)41 IStructuredModel (org.eclipse.wst.sse.core.internal.provisional.IStructuredModel)32 IDOMDocument (org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument)15 List (java.util.List)6 IJavaScriptElement (org.eclipse.wst.jsdt.core.IJavaScriptElement)6 IDocument (org.eclipse.jface.text.IDocument)5 IStructuredDocument (org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument)5 IModelManager (org.eclipse.wst.sse.core.internal.provisional.IModelManager)4 CoreException (org.eclipse.core.runtime.CoreException)3 BadLocationException (org.eclipse.jface.text.BadLocationException)3 Document (org.eclipse.jface.text.Document)3 JavaScriptModelException (org.eclipse.wst.jsdt.core.JavaScriptModelException)3 ArrayList (java.util.ArrayList)2 IRegion (org.eclipse.jface.text.IRegion)2 ITypedRegion (org.eclipse.jface.text.ITypedRegion)2 ISelection (org.eclipse.jface.viewers.ISelection)2 IProblem (org.eclipse.wst.jsdt.core.compiler.IProblem)2 NodeImpl (org.eclipse.wst.xml.core.internal.document.NodeImpl)2