Search in sources :

Example 86 with IStructuredModel

use of org.eclipse.wst.sse.core.internal.provisional.IStructuredModel in project webtools.sourceediting by eclipse.

the class AbstractModelLoader method createModel.

public IStructuredModel createModel(IStructuredDocument structuredDocument, String baseLocation, IModelHandler handler) {
    documentLoaderInstance = null;
    IStructuredModel model = newModel();
    model.setBaseLocation(baseLocation);
    // handler must be set early, incase a re-init is
    // required during creation.
    model.setModelHandler(handler);
    addFactories(model, getAdapterFactories());
    // For types with propagating adapters, it's important
    // that the propagating adapter be in place before the contents
    // are set.
    preLoadAdapt(model);
    initEmbeddedTypePre(model, structuredDocument);
    model.setStructuredDocument(structuredDocument);
    // 
    initEmbeddedTypePost(model);
    return model;
}
Also used : IStructuredModel(org.eclipse.wst.sse.core.internal.provisional.IStructuredModel)

Example 87 with IStructuredModel

use of org.eclipse.wst.sse.core.internal.provisional.IStructuredModel in project webtools.sourceediting by eclipse.

the class JSPModelLoader method createModel.

public IStructuredModel createModel(IStructuredModel oldModel) {
    IStructuredModel model = super.createModel(oldModel);
    // For JSPs, the ModelQueryAdapter must be "attached" to the document
    // before content is set in the model, so taglib initialization can
    // take place.
    // In this "clone model" case, we create a ModelQuery adapter
    // create a new instance from the old data. Note: I think this
    // "forced fit" only works here since the implementation of
    // ModelQueryAdapter does not
    // have to be released.
    ModelQueryAdapter modelQueryAdapter = getModelQueryAdapter(model);
    if (modelQueryAdapter == null) {
        modelQueryAdapter = getModelQueryAdapter(oldModel);
        IDOMDocument document = ((IDOMModel) model).getDocument();
        document.addAdapter(new JSPModelQueryAdapterImpl(modelQueryAdapter.getCMDocumentCache(), modelQueryAdapter.getModelQuery(), modelQueryAdapter.getIdResolver()));
    }
    return model;
}
Also used : ModelQueryAdapter(org.eclipse.wst.xml.core.internal.ssemodelquery.ModelQueryAdapter) IDOMModel(org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel) JSPModelQueryAdapterImpl(org.eclipse.jst.jsp.core.internal.modelquery.JSPModelQueryAdapterImpl) IDOMDocument(org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument) IStructuredModel(org.eclipse.wst.sse.core.internal.provisional.IStructuredModel)

Example 88 with IStructuredModel

use of org.eclipse.wst.sse.core.internal.provisional.IStructuredModel in project webtools.sourceediting by eclipse.

the class JSPContentValidator method validateFile.

protected void validateFile(IFile f, IReporter reporter) {
    IStructuredModel model = null;
    try {
        if (fragmentCheck(f) && !reporter.isCancelled()) {
            model = StructuredModelManager.getModelManager().getModelForRead(f);
            if (!reporter.isCancelled() && model instanceof IDOMModel) {
                reporter.removeAllMessages(this, f);
                validate(reporter, f, (IDOMModel) model);
            }
        }
    } catch (IOException e) {
        Logger.logException(e);
    } catch (CoreException e) {
        Logger.logException(e);
    } finally {
        if (model != null)
            model.releaseFromRead();
    }
}
Also used : CoreException(org.eclipse.core.runtime.CoreException) IDOMModel(org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel) IStructuredModel(org.eclipse.wst.sse.core.internal.provisional.IStructuredModel) IOException(java.io.IOException)

Example 89 with IStructuredModel

use of org.eclipse.wst.sse.core.internal.provisional.IStructuredModel in project webtools.sourceediting by eclipse.

the class TLDValidator method detectProblems.

private Map[] detectProblems(IJavaProject javaProject, IFile tld, IScopeContext[] preferenceScopes) throws CoreException {
    List problems = new ArrayList();
    IStructuredModel m = null;
    try {
        m = StructuredModelManager.getModelManager().getModelForRead(tld);
        if (m != null && m instanceof IDOMModel) {
            IDOMDocument document = ((IDOMModel) m).getDocument();
            for (int i = 0; i < classElementNames.length; i++) {
                NodeList classes = document.getElementsByTagName(classElementNames[i]);
                for (int j = 0; j < classes.getLength(); j++) {
                    Map problem = checkClass(javaProject, classes.item(j), preferenceScopes, missingClassSeverityPreferenceKeys[i], missingClassMessages[i]);
                    if (problem != null)
                        problems.add(problem);
                }
            }
        }
    } catch (IOException e) {
        Logger.logException(e);
    } finally {
        if (m != null)
            m.releaseFromRead();
    }
    return (Map[]) problems.toArray(new Map[problems.size()]);
}
Also used : IDOMModel(org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel) NodeList(org.w3c.dom.NodeList) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) NodeList(org.w3c.dom.NodeList) List(java.util.List) IDOMDocument(org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument) IStructuredModel(org.eclipse.wst.sse.core.internal.provisional.IStructuredModel) IOException(java.io.IOException) HashMap(java.util.HashMap) Map(java.util.Map)

Example 90 with IStructuredModel

use of org.eclipse.wst.sse.core.internal.provisional.IStructuredModel in project webtools.sourceediting by eclipse.

the class TagModelQuery method getEmbeddedMimeType.

private String getEmbeddedMimeType(Node node) {
    String type = DEFAULT_MIMETYPE;
    if (node instanceof IDOMNode) {
        IStructuredModel model = ((IDOMNode) node).getModel();
        String baseLocation = model.getBaseLocation();
        if (!baseLocation.equals(IModelManager.UNMANAGED_MODEL)) {
            IPath path = new Path(baseLocation);
            if (path.segmentCount() > 1) {
                IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(path.segment(0));
                if (project.isAccessible()) {
                    String key = createPreferenceKey(path);
                    IEclipsePreferences preferences = new ProjectScope(project).getNode(JSPCorePlugin.getDefault().getBundle().getSymbolicName());
                    type = preferences.get(key, DEFAULT_MIMETYPE);
                }
            }
        }
    }
    return type;
}
Also used : IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.core.runtime.Path) ProjectScope(org.eclipse.core.resources.ProjectScope) IPath(org.eclipse.core.runtime.IPath) IDOMNode(org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode) IEclipsePreferences(org.eclipse.core.runtime.preferences.IEclipsePreferences) IStructuredModel(org.eclipse.wst.sse.core.internal.provisional.IStructuredModel) IProject(org.eclipse.core.resources.IProject)

Aggregations

IStructuredModel (org.eclipse.wst.sse.core.internal.provisional.IStructuredModel)482 IDOMModel (org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel)110 IModelManager (org.eclipse.wst.sse.core.internal.provisional.IModelManager)102 IStructuredDocument (org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument)81 IFile (org.eclipse.core.resources.IFile)75 IOException (java.io.IOException)69 CoreException (org.eclipse.core.runtime.CoreException)49 IDocument (org.eclipse.jface.text.IDocument)46 IDOMDocument (org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument)42 InputStream (java.io.InputStream)40 IDOMNode (org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode)36 Path (org.eclipse.core.runtime.Path)35 BadLocationException (org.eclipse.jface.text.BadLocationException)34 IJsTranslation (org.eclipse.wst.jsdt.web.core.javascript.IJsTranslation)32 JsTranslationAdapter (org.eclipse.wst.jsdt.web.core.javascript.JsTranslationAdapter)32 IProject (org.eclipse.core.resources.IProject)31 IndexedRegion (org.eclipse.wst.sse.core.internal.provisional.IndexedRegion)31 IPath (org.eclipse.core.runtime.IPath)27 ByteArrayInputStream (java.io.ByteArrayInputStream)22 Document (org.w3c.dom.Document)19