Search in sources :

Example 51 with IJsTranslation

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

the class JFaceNodeAdapterForJs method getTranslation.

private IJsTranslation getTranslation(Node node) {
    IStructuredModel model = null;
    IModelManager modelManager = StructuredModelManager.getModelManager();
    IDOMDocument xmlDoc = null;
    try {
        if (modelManager != null) {
            IStructuredDocument doc = ((NodeImpl) node).getStructuredDocument();
            model = modelManager.getExistingModelForRead(doc);
        // model = modelManager.getModelForRead(doc);
        }
        IDOMModel domModel = (IDOMModel) model;
        if (domModel == null)
            return null;
        xmlDoc = domModel.getDocument();
    } catch (Exception e) {
        Logger.logException(e);
    } finally {
        if (model != null) {
            // model.changedModel();
            model.releaseFromRead();
        }
    }
    if (xmlDoc == null) {
        return null;
    }
    JsTranslationAdapter translationAdapter = (JsTranslationAdapter) xmlDoc.getAdapterFor(IJsTranslation.class);
    return translationAdapter.getJsTranslation(true);
}
Also used : IJsTranslation(org.eclipse.wst.jsdt.web.core.javascript.IJsTranslation) NodeImpl(org.eclipse.wst.xml.core.internal.document.NodeImpl) IDOMModel(org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel) IModelManager(org.eclipse.wst.sse.core.internal.provisional.IModelManager) IDOMDocument(org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument) IStructuredDocument(org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument) IStructuredModel(org.eclipse.wst.sse.core.internal.provisional.IStructuredModel) JsTranslationAdapter(org.eclipse.wst.jsdt.web.core.javascript.JsTranslationAdapter) JavaScriptModelException(org.eclipse.wst.jsdt.core.JavaScriptModelException)

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