Search in sources :

Example 1 with BasicStructuredDocumentRegion

use of org.eclipse.wst.sse.core.internal.text.BasicStructuredDocumentRegion in project webtools.sourceediting by eclipse.

the class TestObjects method testDeletedFlag.

public void testDeletedFlag() {
    BasicStructuredDocumentRegion region = new BasicStructuredDocumentRegion();
    region.setParentDocument(new BasicStructuredDocument());
    boolean deleted = region.isDeleted();
    boolean ended = region.isEnded();
    region.setDeleted(!deleted);
    assertEquals(!deleted, region.isDeleted());
    assertEquals(ended, region.isEnded());
}
Also used : BasicStructuredDocumentRegion(org.eclipse.wst.sse.core.internal.text.BasicStructuredDocumentRegion) BasicStructuredDocument(org.eclipse.wst.sse.core.internal.text.BasicStructuredDocument)

Example 2 with BasicStructuredDocumentRegion

use of org.eclipse.wst.sse.core.internal.text.BasicStructuredDocumentRegion in project webtools.sourceediting by eclipse.

the class JSPedCSSModelParser method insertStructuredDocumentRegion.

/**
 */
protected CSSNodeImpl insertStructuredDocumentRegion(IStructuredDocumentRegion region) {
    CSSModelCreationContext creationContext = getCreationContext();
    if (creationContext == null || region == null) {
        return null;
    }
    String type = ((BasicStructuredDocumentRegion) region).getType();
    CSSNodeImpl modified = null;
    if (type == JSPedCSSRegionContexts.CSS_JSP_DIRECTIVE) {
        boolean isInclude = region.getText().indexOf("include") != -1;
        if (isInclude) {
            modified = insertUnknownImport(region);
        } else {
            modified = insertUnknownRule(region);
        }
    }
    // post process
    if (modified != null) {
        if (modified instanceof CSSStructuredDocumentRegionContainer) {
            ((CSSStructuredDocumentRegionContainer) modified).propagateRangeStructuredDocumentRegion();
        }
    }
    return modified != null ? modified : super.insertStructuredDocumentRegion(region);
}
Also used : BasicStructuredDocumentRegion(org.eclipse.wst.sse.core.internal.text.BasicStructuredDocumentRegion) CSSStructuredDocumentRegionContainer(org.eclipse.wst.css.core.internal.document.CSSStructuredDocumentRegionContainer) CSSNodeImpl(org.eclipse.wst.css.core.internal.document.CSSNodeImpl) CSSModelCreationContext(org.eclipse.wst.css.core.internal.document.CSSModelCreationContext)

Example 3 with BasicStructuredDocumentRegion

use of org.eclipse.wst.sse.core.internal.text.BasicStructuredDocumentRegion in project webtools.sourceediting by eclipse.

the class TestObjects method testEndedFlag.

public void testEndedFlag() {
    BasicStructuredDocumentRegion region = new BasicStructuredDocumentRegion();
    region.setParentDocument(new BasicStructuredDocument());
    boolean deleted = region.isDeleted();
    boolean ended = region.isEnded();
    region.setEnded(!ended);
    assertEquals(!ended, region.isEnded());
    assertEquals(deleted, region.isDeleted());
}
Also used : BasicStructuredDocumentRegion(org.eclipse.wst.sse.core.internal.text.BasicStructuredDocumentRegion) BasicStructuredDocument(org.eclipse.wst.sse.core.internal.text.BasicStructuredDocument)

Example 4 with BasicStructuredDocumentRegion

use of org.eclipse.wst.sse.core.internal.text.BasicStructuredDocumentRegion in project webtools.sourceediting by eclipse.

the class CSSModelParser method insertStructuredDocumentRegion.

/**
 * currently public but may be made default access protected in future.
 */
protected CSSNodeImpl insertStructuredDocumentRegion(IStructuredDocumentRegion region) {
    if (fCreationContext == null || region == null) {
        return null;
    }
    String type = ((BasicStructuredDocumentRegion) region).getType();
    CSSNodeImpl modified = null;
    ICSSNode target = fCreationContext.getTargetNode();
    if ((fParseFloating && target == null) || target instanceof ICSSRuleContainer) {
        if (type == CSSRegionContexts.CSS_DELIMITER) {
            modified = insertSemiColonForRule(region);
        } else if (type == CSSRegionContexts.CSS_LBRACE) {
            modified = insertBraceOpen(region);
        } else if (type == CSSRegionContexts.CSS_RBRACE) {
            modified = insertBraceClose(region);
        } else if (type == CSSRegionContexts.CSS_MEDIA || type == CSSRegionContexts.CSS_PAGE || type == CSSRegionContexts.CSS_FONT_FACE || CSSUtil.isSelectorText(region)) {
            checkNextNode(region, CSSRegionContexts.CSS_LBRACE);
        } else if (type == CSSRegionContexts.CSS_IMPORT || type == CSSRegionContexts.CSS_CHARSET) {
            checkNextNode(region, CSSRegionContexts.CSS_DELIMITER);
        }
    } else if ((target instanceof CSSRuleDeclContainer || target instanceof CSSStyleDeclaration) && type == CSSRegionContexts.CSS_DECLARATION_PROPERTY) {
        modified = insertStyleDeclarationItem(region);
    } else if (target instanceof ICSSStyleDeclItem && type == CSSRegionContexts.CSS_DECLARATION_DELIMITER) {
        modified = insertSemiColonForStyleDeclarationItem(region);
    } else if (type == CSSRegionContexts.CSS_RBRACE) {
        modified = insertBraceClose(region);
    }
    // post process
    if (modified != null) {
        if (modified instanceof CSSStructuredDocumentRegionContainer) {
            ((CSSStructuredDocumentRegionContainer) modified).propagateRangeStructuredDocumentRegion();
        }
    }
    return modified;
}
Also used : ICSSRuleContainer(org.eclipse.wst.css.core.internal.provisional.document.ICSSRuleContainer) BasicStructuredDocumentRegion(org.eclipse.wst.sse.core.internal.text.BasicStructuredDocumentRegion) ICSSStyleDeclItem(org.eclipse.wst.css.core.internal.provisional.document.ICSSStyleDeclItem) ICSSNode(org.eclipse.wst.css.core.internal.provisional.document.ICSSNode) CSSStyleDeclaration(org.w3c.dom.css.CSSStyleDeclaration)

Aggregations

BasicStructuredDocumentRegion (org.eclipse.wst.sse.core.internal.text.BasicStructuredDocumentRegion)4 BasicStructuredDocument (org.eclipse.wst.sse.core.internal.text.BasicStructuredDocument)2 CSSModelCreationContext (org.eclipse.wst.css.core.internal.document.CSSModelCreationContext)1 CSSNodeImpl (org.eclipse.wst.css.core.internal.document.CSSNodeImpl)1 CSSStructuredDocumentRegionContainer (org.eclipse.wst.css.core.internal.document.CSSStructuredDocumentRegionContainer)1 ICSSNode (org.eclipse.wst.css.core.internal.provisional.document.ICSSNode)1 ICSSRuleContainer (org.eclipse.wst.css.core.internal.provisional.document.ICSSRuleContainer)1 ICSSStyleDeclItem (org.eclipse.wst.css.core.internal.provisional.document.ICSSStyleDeclItem)1 CSSStyleDeclaration (org.w3c.dom.css.CSSStyleDeclaration)1