Search in sources :

Example 56 with IStructuredDocumentRegion

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

the class ScannerUnitTests method testBlockScanBufferBoundaries.

protected void testBlockScanBufferBoundaries(String contentTypeID) {
    IStructuredDocument document = null;
    // for (int i = 17000; i > 15000; i--) {
    for (int i = 16384 + 25; i > 16364 - 25; i--) {
        StringBuffer text = new StringBuffer();
        document = StructuredModelManager.getModelManager().createStructuredDocumentFor(contentTypeID);
        appendTagBlock(text, "script", i);
        String string = text.toString();
        try {
            document.setText(this, string);
            verifyLengths(document, string);
            assertTrue("too few document regions [run value " + i + "] ", new CoreNodeList(document.getFirstStructuredDocumentRegion()).getLength() == 3);
            verifyLengths(document, string);
            IStructuredDocumentRegion startTag = document.getFirstStructuredDocumentRegion();
            IStructuredDocumentRegion middleBlock = startTag.getNext();
            // IStructuredDocumentRegion endTag = middleBlock.getNext();
            assertTrue("not block text in middle", middleBlock.getFirstRegion().getType() == DOMRegionContext.BLOCK_TEXT);
        } catch (Exception e) {
            assertNull("exception caught" + e, e);
        }
    // System.gc();
    }
}
Also used : IStructuredDocumentRegion(org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion) IStructuredDocument(org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument) CoreNodeList(org.eclipse.wst.sse.core.internal.text.CoreNodeList) IOException(java.io.IOException)

Example 57 with IStructuredDocumentRegion

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

the class StructuredDocumentReParser method findDirtyEnd.

protected IStructuredDocumentRegion findDirtyEnd(int end) {
    // Caution: here's one place we have to cast
    IStructuredDocumentRegion result = fStructuredDocument.getRegionAtCharacterOffset(end);
    // if not well formed, get one past, if there is something there
    if ((result != null) && (!result.isEnded())) {
        if (result.getNext() != null) {
            result = result.getNext();
        }
    }
    // there's probably a better way.
    if ((result != null) && (end == result.getEnd())) {
        if (result.getNext() != null) {
            result = result.getNext();
        }
    }
    // }
    if (result != null)
        fStructuredDocument.setCachedDocumentRegion(result);
    dirtyEnd = result;
    return dirtyEnd;
}
Also used : IStructuredDocumentRegion(org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion)

Example 58 with IStructuredDocumentRegion

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

the class StructuredDocumentReParser method insertNodes.

protected void insertNodes(IStructuredDocumentRegion previousOldNode, IStructuredDocumentRegion nextOldNode, CoreNodeList newNodes) {
    // 
    IStructuredDocumentRegion firstNew = null;
    IStructuredDocumentRegion lastNew = null;
    // 
    IStructuredDocumentRegion oldPrevious = previousOldNode;
    IStructuredDocumentRegion oldNext = nextOldNode;
    // 
    if (newNodes.getLength() > 0) {
        // get pointers
        firstNew = newNodes.item(0);
        lastNew = newNodes.item(newNodes.getLength() - 1);
        // lists
        if (oldPrevious != null)
            oldPrevious.setNext(firstNew);
        if (oldNext != null) {
            oldNext.setPrevious(lastNew);
        } else {
            // SIDE EFFECT
            // if oldNext is null, that means we are replaceing the
            // lastNode in the chain,
            // so we need to update the structuredDocuments lastNode as
            // the
            // last of the new nodes.
            fStructuredDocument.setLastDocumentRegion(newNodes.item(newNodes.getLength() - 1));
        }
        if (firstNew != null)
            firstNew.setPrevious(oldPrevious);
        if (lastNew != null)
            lastNew.setNext(oldNext);
    }
// else nothing to insert
}
Also used : IStructuredDocumentRegion(org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion)

Example 59 with IStructuredDocumentRegion

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

the class StructuredDocumentReParser method findDirtyStart.

protected void findDirtyStart(int start) {
    IStructuredDocumentRegion result = fStructuredDocument.getRegionAtCharacterOffset(start);
    // bracket should become part of the previous content node)
    if (result != null) {
        IStructuredDocumentRegion previous = result.getPrevious();
        if ((previous != null) && ((!(previous.isEnded())) || (start == result.getStart()))) {
            result = previous;
        }
        // If we are now at the end of a "tag dependent" content area (or
        // JSP area)
        // then we need to back up all the way to the beginning of that.
        IStructuredDocumentRegion potential = result;
        // }
        if (potential != null) {
            result = potential;
            fStructuredDocument.setCachedDocumentRegion(result);
        }
    }
    dirtyStart = result;
}
Also used : IStructuredDocumentRegion(org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion)

Example 60 with IStructuredDocumentRegion

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

the class StructuredDocumentReParser method quickCheck.

/**
 * A method to allow any heuristic "quick checks" that might cover many
 * many cases, before expending the time on a full reparse.
 */
public StructuredDocumentEvent quickCheck() {
    StructuredDocumentEvent result = null;
    // to handle, but only if there is one flatnode involved.
    if (dirtyStart != null && dirtyStart == dirtyEnd) {
        IStructuredDocumentRegion targetNode = dirtyStart;
        result = dirtyStart.updateRegion(fRequester, targetNode, fChanges, fStart, fLengthToReplace);
        if (result != null) {
            // at this point only, we need to update the text store and
            // and downstream nodes.
            // FUTURE_TO_DO: can this dependency on structuredDocument
            // method be eliminated?
            fStructuredDocument.updateDocumentData(fStart, fLengthToReplace, fChanges);
            IStructuredDocumentRegion firstDownStreamNode = targetNode.getNext();
            // any downstream ones
            if (firstDownStreamNode != null) {
                StructuredDocumentRegionIterator.adjustStart(firstDownStreamNode, fLengthDifference);
            }
        }
    }
    if (result != null) {
        result.setDeletedText(fDeletedText);
    }
    return result;
}
Also used : StructuredDocumentEvent(org.eclipse.wst.sse.core.internal.provisional.events.StructuredDocumentEvent) IStructuredDocumentRegion(org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion)

Aggregations

IStructuredDocumentRegion (org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion)439 ITextRegion (org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion)174 IDOMNode (org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode)99 ITextRegionList (org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionList)87 IStructuredDocument (org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument)70 List (java.util.List)40 BadLocationException (org.eclipse.jface.text.BadLocationException)39 ArrayList (java.util.ArrayList)38 Iterator (java.util.Iterator)35 IndexedRegion (org.eclipse.wst.sse.core.internal.provisional.IndexedRegion)35 Node (org.w3c.dom.Node)30 ITextRegionContainer (org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionContainer)26 RegionIterator (org.eclipse.wst.css.core.internal.util.RegionIterator)19 IDOMModel (org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel)19 CustomCompletionProposal (org.eclipse.wst.sse.ui.internal.contentassist.CustomCompletionProposal)17 IStructuredModel (org.eclipse.wst.sse.core.internal.provisional.IStructuredModel)15 CMElementDeclaration (org.eclipse.wst.xml.core.internal.contentmodel.CMElementDeclaration)15 ICSSNode (org.eclipse.wst.css.core.internal.provisional.document.ICSSNode)14 CMNamedNodeMap (org.eclipse.wst.xml.core.internal.contentmodel.CMNamedNodeMap)13 NodeList (org.w3c.dom.NodeList)13