Search in sources :

Example 31 with IStructuredDocumentRegionList

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

the class StyleElementAdapter method nodesReplaced.

/**
 * Implementing IStructuredDocumentListener's method
 * Event from CSS Flat Model
 */
public void nodesReplaced(StructuredDocumentRegionsReplacedEvent event) {
    if (event == null)
        return;
    if (event.getOriginalRequester() == getRequesterH2C())
        return;
    IStructuredDocumentRegionList oldStructuredDocumentRegions = event.getOldStructuredDocumentRegions();
    IStructuredDocumentRegionList newStructuredDocumentRegions = event.getNewStructuredDocumentRegions();
    if (oldStructuredDocumentRegions == null && newStructuredDocumentRegions == null)
        return;
    replaceStructuredDocumentRegions(newStructuredDocumentRegions, oldStructuredDocumentRegions);
}
Also used : IStructuredDocumentRegionList(org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegionList)

Example 32 with IStructuredDocumentRegionList

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

the class DOMModelImpl method internalSetNewDocument.

private void internalSetNewDocument(IStructuredDocument structuredDocument) {
    if (structuredDocument == null)
        return;
    IStructuredDocumentRegionList flatNodes = structuredDocument.getRegionList();
    if ((flatNodes == null) || (flatNodes.getLength() == 0)) {
        return;
    }
    if (this.document == null)
        // being constructed
        return;
    XMLModelUpdater updater = getActiveUpdater();
    if (updater != null) {
        // being updated
        try {
            updater.replaceStructuredDocumentRegions(flatNodes, null);
        } catch (Exception ex) {
            Logger.logException(ex);
            this.refresh = true;
            handleRefresh();
        } finally {
            setActive(null);
        }
        // checkForReinit();
        return;
    }
    XMLModelNotifier notifier = getModelNotifier();
    boolean isChanging = notifier.isChanging();
    // call even if changing to notify doing new model
    getModelNotifier().beginChanging(true);
    XMLModelParser parser = getModelParser();
    setActive(parser);
    this.document.removeChildNodes();
    try {
        parser.replaceStructuredDocumentRegions(flatNodes, null);
    } catch (Exception ex) {
        Logger.logException(ex);
    // meaningless to refresh, because the result might be the same
    } finally {
        setActive(null);
        if (!isChanging) {
            getModelNotifier().endChanging();
        }
        // ignore refresh
        this.refresh = false;
    }
}
Also used : IStructuredDocumentRegionList(org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegionList) DOMException(org.w3c.dom.DOMException)

Example 33 with IStructuredDocumentRegionList

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

the class Debug method dump.

public static final void dump(IStructuredDocument structuredDocument, boolean verbose) {
    ITextRegionCollection flatNode = null;
    // $NON-NLS-1$
    System.out.println("Dump of structuredDocument:");
    IStructuredDocumentRegionList flatNodes = structuredDocument.getRegionList();
    Enumeration structuredDocumentRegions = flatNodes.elements();
    while (structuredDocumentRegions.hasMoreElements()) {
        flatNode = (ITextRegionCollection) structuredDocumentRegions.nextElement();
        if (!verbose) {
            String outString = flatNode.toString();
            outString = org.eclipse.wst.sse.core.utils.StringUtils.escape(outString);
            System.out.println(outString);
        } else {
            dump(flatNode, verbose);
        }
    }
    System.out.println();
    // $NON-NLS-1$
    System.out.println("= = = = = =");
    System.out.println();
}
Also used : Enumeration(java.util.Enumeration) IStructuredDocumentRegionList(org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegionList) ITextRegionCollection(org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionCollection)

Example 34 with IStructuredDocumentRegionList

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

the class ScannerUnitTests method testELtolerance_transparency_Squote.

public void testELtolerance_transparency_Squote() {
    IStructuredDocumentRegionList nodes = setUpJSP("<a type='${out.foo}'/>");
    boolean sizeCheck = checkSimpleRegionCounts(nodes, new int[] { 6 });
    sizeCheck &= checkSimpleRegionCount(((ITextRegionContainer) nodes.item(0).getRegions().get(4)), 5);
    assertTrue("IStructuredDocumentRegion and ITextRegion count", sizeCheck);
    boolean typeCheck = checkSimpleRegionTypes(nodes.item(0).getRegions(), new String[] { DOMRegionContext.XML_TAG_OPEN, DOMRegionContext.XML_TAG_NAME, DOMRegionContext.XML_TAG_ATTRIBUTE_NAME, DOMRegionContext.XML_TAG_ATTRIBUTE_EQUALS, DOMRegionContext.XML_TAG_ATTRIBUTE_VALUE, DOMRegionContext.XML_EMPTY_TAG_CLOSE });
    typeCheck &= checkSimpleRegionTypes(((ITextRegionContainer) nodes.item(0).getRegions().get(4)).getRegions(), new String[] { DOMJSPRegionContexts.XML_TAG_ATTRIBUTE_VALUE_SQUOTE, DOMJSPRegionContexts.JSP_EL_OPEN, DOMJSPRegionContexts.JSP_EL_CONTENT, DOMJSPRegionContexts.JSP_EL_CLOSE, DOMJSPRegionContexts.XML_TAG_ATTRIBUTE_VALUE_SQUOTE });
    assertTrue("region context type check", typeCheck);
    verifyModelLength();
}
Also used : IStructuredDocumentRegionList(org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegionList) ITextRegionContainer(org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionContainer)

Example 35 with IStructuredDocumentRegionList

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

the class ScannerUnitTests method testEmbeddedJSPScriptletInCDATA.

public void testEmbeddedJSPScriptletInCDATA() {
    IStructuredDocumentRegionList nodes = setUpJSP("<![CDATA[<%%>]]>");
    boolean sizeCheck = checkSimpleRegionCounts(nodes, new int[] { 3 });
    assertTrue("IStructuredDocumentRegion and ITextRegion count", sizeCheck);
    boolean typeCheck = checkComplexRegionTypes(nodes.item(0).getRegions(), new String[] { DOMRegionContext.XML_CDATA_OPEN, DOMRegionContext.XML_CDATA_TEXT, DOMRegionContext.XML_CDATA_CLOSE }, new String[][] { { DOMJSPRegionContexts.JSP_SCRIPTLET_OPEN, DOMJSPRegionContexts.JSP_CLOSE } });
    assertTrue("region context type check", typeCheck);
    verifyModelLength();
}
Also used : IStructuredDocumentRegionList(org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegionList)

Aggregations

IStructuredDocumentRegionList (org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegionList)68 ITextRegionContainer (org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionContainer)11 IStructuredDocumentRegion (org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion)10 IStructuredDocument (org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument)6 ICSSModel (org.eclipse.wst.css.core.internal.provisional.document.ICSSModel)3 ITextRegionCollection (org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionCollection)3 Enumeration (java.util.Enumeration)2 Iterator (java.util.Iterator)2 ITextRegion (org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion)2 IDOMNode (org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode)2 DOMException (org.w3c.dom.DOMException)2 Element (org.w3c.dom.Element)2 NodesEvent (org.eclipse.wst.dtd.core.internal.event.NodesEvent)1 IStructuredModel (org.eclipse.wst.sse.core.internal.provisional.IStructuredModel)1 NewDocumentEvent (org.eclipse.wst.sse.core.internal.provisional.events.NewDocumentEvent)1 NoChangeEvent (org.eclipse.wst.sse.core.internal.provisional.events.NoChangeEvent)1 RegionChangedEvent (org.eclipse.wst.sse.core.internal.provisional.events.RegionChangedEvent)1 RegionsReplacedEvent (org.eclipse.wst.sse.core.internal.provisional.events.RegionsReplacedEvent)1 StructuredDocumentRegionsReplacedEvent (org.eclipse.wst.sse.core.internal.provisional.events.StructuredDocumentRegionsReplacedEvent)1 CoreNodeList (org.eclipse.wst.sse.core.internal.text.CoreNodeList)1