Search in sources :

Example 1 with IDocumentLoader

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;
}
Also used : IDocumentLoader(org.eclipse.wst.sse.core.internal.document.IDocumentLoader) IStructuredDocument(org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument) ResourceAlreadyExists(org.eclipse.wst.sse.core.internal.provisional.exceptions.ResourceAlreadyExists) IModelHandler(org.eclipse.wst.sse.core.internal.ltk.modelhandler.IModelHandler)

Example 2 with IDocumentLoader

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;
}
Also used : IDocumentLoader(org.eclipse.wst.sse.core.internal.document.IDocumentLoader) IStructuredModel(org.eclipse.wst.sse.core.internal.provisional.IStructuredModel) IEncodedDocument(org.eclipse.wst.sse.core.internal.provisional.document.IEncodedDocument)

Example 3 with IDocumentLoader

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);
}
Also used : IDocumentLoader(org.eclipse.wst.sse.core.internal.document.IDocumentLoader) IStructuredDocumentRegion(org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion) CSSDocumentLoader(org.eclipse.wst.css.core.internal.encoding.CSSDocumentLoader) IStructuredDocument(org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument) CSSSourceParser(org.eclipse.wst.css.core.internal.parser.CSSSourceParser)

Example 4 with IDocumentLoader

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);
}
Also used : IDocumentLoader(org.eclipse.wst.sse.core.internal.document.IDocumentLoader) IStructuredDocumentRegion(org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion) CSSDocumentLoader(org.eclipse.wst.css.core.internal.encoding.CSSDocumentLoader) IStructuredDocument(org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument) CSSSourceParser(org.eclipse.wst.css.core.internal.parser.CSSSourceParser)

Example 5 with IDocumentLoader

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);
}
Also used : IDocumentLoader(org.eclipse.wst.sse.core.internal.document.IDocumentLoader) IStructuredDocumentRegion(org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion) CSSDocumentLoader(org.eclipse.wst.css.core.internal.encoding.CSSDocumentLoader) IStructuredDocument(org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument) CSSSourceParser(org.eclipse.wst.css.core.internal.parser.CSSSourceParser)

Aggregations

IDocumentLoader (org.eclipse.wst.sse.core.internal.document.IDocumentLoader)8 IStructuredDocument (org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument)7 IModelHandler (org.eclipse.wst.sse.core.internal.ltk.modelhandler.IModelHandler)4 CSSDocumentLoader (org.eclipse.wst.css.core.internal.encoding.CSSDocumentLoader)3 CSSSourceParser (org.eclipse.wst.css.core.internal.parser.CSSSourceParser)3 IStructuredDocumentRegion (org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion)3 FileNotFoundException (java.io.FileNotFoundException)1 NullMemento (org.eclipse.wst.sse.core.internal.NullMemento)1 ModelHandlerRegistry (org.eclipse.wst.sse.core.internal.modelhandler.ModelHandlerRegistry)1 IStructuredModel (org.eclipse.wst.sse.core.internal.provisional.IStructuredModel)1 IEncodedDocument (org.eclipse.wst.sse.core.internal.provisional.document.IEncodedDocument)1 ResourceAlreadyExists (org.eclipse.wst.sse.core.internal.provisional.exceptions.ResourceAlreadyExists)1