use of org.eclipse.wst.sse.core.internal.provisional.IModelManager in project webtools.sourceediting by eclipse.
the class ValidatorGroupListener method validationStarting.
public void validationStarting(IResource resource, IProgressMonitor monitor, ValidationState state) {
if (_debug)
System.out.println("Starting: " + resource.getFullPath());
try {
if (monitor != null && !monitor.isCanceled()) {
if (resource.getType() != IResource.FILE)
return;
synchronized (LOCK) {
final IPath path = resource.getFullPath();
final ValidationModelReference ref = (ValidationModelReference) fDiagnosticMap.get(path);
if (ref != null) {
// The model is already being tracked
++ref.count;
} else {
// The model has not been obtained as part of the validation group yet
IModelManager modelManager = StructuredModelManager.getModelManager();
// possible when shutting down
if (modelManager != null) {
IStructuredModel model = modelManager.getModelForRead((IFile) resource);
if (model != null) {
fDiagnosticMap.put(resource.getFullPath(), new ValidationModelReference(model));
}
}
}
}
}
} catch (Exception e) {
Logger.logException(e);
}
}
use of org.eclipse.wst.sse.core.internal.provisional.IModelManager in project webtools.sourceediting by eclipse.
the class Validator method getModel.
protected IStructuredModel getModel(String uriString) {
URI uri;
try {
uri = new URI(uriString);
} catch (URISyntaxException e) {
logWarning(e);
return null;
}
IFile[] files = ResourcesPlugin.getWorkspace().getRoot().findFilesForLocationURI(uri);
if (files == null || files.length <= 0 || !files[0].exists()) {
return null;
}
IFile file = files[0];
IModelManager manager = StructuredModelManager.getModelManager();
if (manager == null)
return null;
IStructuredModel model = null;
try {
file.refreshLocal(IResource.DEPTH_ZERO, new NullProgressMonitor());
} catch (CoreException e) {
logWarning(e);
}
try {
try {
model = manager.getModelForRead(file);
} catch (UnsupportedEncodingException ex) {
// retry ignoring META charset for invalid META charset
// specification
// recreate input stream, because it is already partially read
model = manager.getModelForRead(file, new String(), null);
}
} catch (UnsupportedEncodingException ex) {
} catch (IOException ex) {
} catch (CoreException e) {
logWarning(e);
}
return model;
}
use of org.eclipse.wst.sse.core.internal.provisional.IModelManager in project webtools.sourceediting by eclipse.
the class HTMLConverter method readModel.
/**
*/
private IDOMModel readModel(InputStream input) throws IOException, UnsupportedEncodingException {
if (input == null)
return null;
// create temporary model
// $NON-NLS-1$
String id = input.toString() + ".html";
IModelManager manager = StructuredModelManager.getModelManager();
IStructuredModel model = manager.getModelForEdit(id, input, null);
if (!(model instanceof IDOMModel)) {
if (model != null)
model.releaseFromEdit();
return null;
}
return (IDOMModel) model;
}
use of org.eclipse.wst.sse.core.internal.provisional.IModelManager in project webtools.sourceediting by eclipse.
the class HTMLConverter method readModel.
/**
*/
private IDOMModel readModel(IFile file) throws IOException, CoreException {
if (file == null)
return null;
IModelManager manager = StructuredModelManager.getModelManager();
IStructuredModel model = manager.getModelForEdit(file);
if (!(model instanceof IDOMModel)) {
if (model != null)
model.releaseFromEdit();
return null;
}
return (IDOMModel) model;
}
use of org.eclipse.wst.sse.core.internal.provisional.IModelManager in project webtools.sourceediting by eclipse.
the class FormattingTests method getModelForEdit.
/**
* must release model (from edit) after
*
* @param filename
* relative to this class (TestFormatProcessorCSS)
*/
private IStructuredModel getModelForEdit(final String path) {
IFile file = getFile(path);
IStructuredModel model = null;
try {
IModelManager modelManager = StructuredModelManager.getModelManager();
model = modelManager.getModelForEdit(file);
} catch (CoreException ce) {
ce.printStackTrace();
} catch (IOException io) {
io.printStackTrace();
}
return model;
}
Aggregations