use of org.eclipse.wst.sse.core.internal.document.IDocumentLoader in project webtools.sourceediting by eclipse.
the class ModelManagerImpl method createNewStructuredDocumentFor.
/**
* Factory method, since a proper IStructuredDocument must have a proper
* parser assigned. Note: its assume that IFile does not actually exist as
* a resource yet. If it does, ResourceAlreadyExists exception is thrown.
* If the resource does already exist, then createStructuredDocumentFor is
* the right API to use.
*
* @throws ResourceInUse
*/
public IStructuredDocument createNewStructuredDocumentFor(IFile iFile) throws ResourceAlreadyExists, IOException, CoreException {
if (iFile.exists()) {
throw new ResourceAlreadyExists(iFile.getFullPath().toOSString());
}
// Will reconsider in future version
// String id = calculateId(iFile);
// if (isResourceInUse(id)) {
// throw new ResourceInUse(iFile.getFullPath().toOSString());
// }
IDocumentLoader loader = null;
IModelHandler handler = calculateType(iFile);
loader = handler.getDocumentLoader();
// for this API, "createNew" we assume the IFile does not exist yet
// as checked above, so just create empty document.
IStructuredDocument result = (IStructuredDocument) loader.createNewStructuredDocument();
return result;
}
use of org.eclipse.wst.sse.core.internal.document.IDocumentLoader in project webtools.sourceediting by eclipse.
the class ModelManagerImpl method createUnManagedStructuredModelFor.
/**
* Conveience method. It depends on the loaders newModel method to return
* an appropriate StrucuturedModel appropriately initialized.
*/
public IStructuredModel createUnManagedStructuredModelFor(IFile iFile) throws IOException, CoreException {
IStructuredModel result = null;
result = createUnManagedEmptyModelFor(iFile);
IDocumentLoader loader = result.getModelHandler().getDocumentLoader();
IEncodedDocument document = loader.createNewStructuredDocument(iFile);
result.getStructuredDocument().setText(this, document.get());
return result;
}
use of org.eclipse.wst.sse.core.internal.document.IDocumentLoader in project webtools.sourceediting by eclipse.
the class TestCSSDecl method testCSSStyleDeclItemSTYLE_SHEET.
public void testCSSStyleDeclItemSTYLE_SHEET() {
String value = "color: blue;";
IDocumentLoader loader = new CSSDocumentLoader();
IStructuredDocument sharedStructuredDocument = (IStructuredDocument) loader.createNewStructuredDocument();
((CSSSourceParser) sharedStructuredDocument.getParser()).setParserMode(CSSSourceParser.MODE_STYLESHEET);
sharedStructuredDocument.set(value);
IStructuredDocumentRegion region = sharedStructuredDocument.getFirstStructuredDocumentRegion();
assertNotNull(region);
}
use of org.eclipse.wst.sse.core.internal.document.IDocumentLoader in project webtools.sourceediting by eclipse.
the class TestCSSDecl method testCSSStyleDeclItemMODE_DECLARATION.
public void testCSSStyleDeclItemMODE_DECLARATION() {
String value = "color: blue;";
IDocumentLoader loader = new CSSDocumentLoader();
IStructuredDocument sharedStructuredDocument = (IStructuredDocument) loader.createNewStructuredDocument();
((CSSSourceParser) sharedStructuredDocument.getParser()).setParserMode(CSSSourceParser.MODE_DECLARATION);
sharedStructuredDocument.set(value);
IStructuredDocumentRegion region = sharedStructuredDocument.getFirstStructuredDocumentRegion();
assertNotNull(region);
}
use of org.eclipse.wst.sse.core.internal.document.IDocumentLoader in project webtools.sourceediting by eclipse.
the class TestCSSDecl method testCSSStyleDeclItem.
public void testCSSStyleDeclItem() {
String value = "color: blue;";
IDocumentLoader loader = new CSSDocumentLoader();
IStructuredDocument sharedStructuredDocument = (IStructuredDocument) loader.createNewStructuredDocument();
((CSSSourceParser) sharedStructuredDocument.getParser()).setParserMode(CSSSourceParser.MODE_DECLARATION_VALUE);
sharedStructuredDocument.set(value);
IStructuredDocumentRegion region = sharedStructuredDocument.getFirstStructuredDocumentRegion();
assertNotNull(region);
}
Aggregations