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;
}
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;
}
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();
}
}
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()]);
}
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;
}
Aggregations