/** */ public int getEnd() { IStructuredDocumentRegion last = getLastStructuredDocumentRegion(); if (last == null) return 0; return last.getEnd(); }
/** * getEndOffset method * * @return int */ public int getEndOffset() { if (this.endStructuredDocumentRegion != null) return this.endStructuredDocumentRegion.getEnd(); return super.getEndOffset(); }
/** * */ void expandRemovedRangeEnd(IStructuredDocumentRegion flatNode) { if (flatNode == null) { return; } int newEnd = flatNode.getEnd() + ((isOldNode(flatNode)) ? fLengthDifference : 0); if (fRemovedRangeEnd < 0 || fRemovedRangeEnd < newEnd) { fRemovedRangeEnd = newEnd; } }
/** * @return int */ public int getEndOffset() { IStructuredDocumentRegion flatNode = getLastStructuredDocumentRegion(); if (flatNode != null) return flatNode.getEnd(); return -1; }
/** * getStartEndOffset method * * @return int */ public int getStartEndOffset() { IStructuredDocumentRegion flatNode = getStructuredDocumentRegion(); if (flatNode != null) return flatNode.getEnd(); return super.getStartOffset(); }
/** * */ private void checkNextNode(IStructuredDocumentRegion flatNode, String type) { IStructuredDocumentRegion next = CSSUtil.findNextSignificantNode(flatNode); if (CSSUtil.getStructuredDocumentRegionType(next) == type) { fCreationContext.setReparseStart(flatNode.getEnd()); fCreationContext.setReparseEnd(next.getEnd()); } }
private void handleTaglib(String prefix) { // get/create TLDCMDocument TLDCMDocumentManager mgr = TaglibController.getTLDCMDocumentManager(fStructuredDocument); if (mgr != null) { // get trackers for the CMDocuments enabled at this offset List trackers = mgr.getCMDocumentTrackers(getCurrentNode().getEnd()); Iterator it = trackers.iterator(); CMDocumentTracker tracker = null; while (it.hasNext()) { tracker = (CMDocumentTracker) it.next(); addBlockMarkers(prefix + ":", tracker.getDocument()); } } }
/** * Old Nodes: --[O1]--[O2]--[O3]--- : / \ Current Nodes: * ---[C1]-----[C2]-----[C3]-----[C4]--- * * Input: O1 -> Output: O2 Input: O2 -> Output: O3 Input: O3 -> Output: C4 * Input: Cn -> Output: Cn+1 */ public IStructuredDocumentRegion getNextNode(IStructuredDocumentRegion node) { IStructuredDocumentRegion nextNode = null; if (node != null) { nextNode = node.getNext(); if (nextNode == null) { if (isOldNode(node)) { // this may be the end of old flatnodes int newStart = node.getEnd() - fLengthDifference; nextNode = fStructuredDocument.getRegionAtCharacterOffset(newStart); } } } return nextNode; }
protected void handleTaglib() { // get/create TLDCMDocument TLDCMDocumentManager mgr = TaglibController.getTLDCMDocumentManager(fStructuredDocument); if (mgr != null) { List trackers = mgr.getCMDocumentTrackers(getCurrentNode().getEnd()); Iterator it = trackers.iterator(); CMDocumentTracker tracker = null; Iterator taglibRegions = null; IStructuredDocumentRegion sdRegion = null; ITextRegion r = null; while (it.hasNext()) { tracker = (CMDocumentTracker) it.next(); sdRegion = tracker.getStructuredDocumentRegion(); // since may be call from another thread (like a background // job) // this check is to be safer if (sdRegion != null && !sdRegion.isDeleted()) { taglibRegions = sdRegion.getRegions().iterator(); while (sdRegion != null && !sdRegion.isDeleted() && taglibRegions.hasNext()) { r = (ITextRegion) taglibRegions.next(); if (r.getType().equals(DOMJSPRegionContexts.JSP_DIRECTIVE_NAME)) { if (sdRegion.getText(r).equals(JSP12TLDNames.TAGLIB)) { addBlockMarkers(tracker.getDocument()); } } } } } } }
/** * */ private void insertStructuredDocumentRegions(IStructuredDocumentRegionList regionList) { for (Enumeration e = regionList.elements(); e.hasMoreElements();) { IStructuredDocumentRegion region = (IStructuredDocumentRegion) e.nextElement(); if (region == null) { continue; } insertStructuredDocumentRegion(region); if (fCreationContext.isToReparse()) { int origStart = region.getEnd(); int origEnd = regionList.item(regionList.getLength() - 1).getEnd(); int newStart = fCreationContext.getReparseStart(); int newEnd = fCreationContext.getReparseEnd(); if (newStart < origStart || origEnd < newEnd) { IStructuredDocumentRegionList newNodeList = getStructuredDocumentRegionList(newStart, newEnd); setupCreationContext(newNodeList.item(0)); insertStructuredDocumentRegions(newNodeList); return; } else { fCreationContext.resetReparseRange(); } } } }
/** * Old Nodes: --[O1]--[O2]--[O3]--- : / \ Current Nodes: * ---[C1]-----[C2]-----[C3]-----[C4]--- * * Input: O* -> Output: C4 Input: Cn -> Output: Cn+1 */ public IStructuredDocumentRegion getNextNodeInCurrent(IStructuredDocumentRegion node) { IStructuredDocumentRegion nextNode = null; if (isOldNode(node)) { IStructuredDocumentRegion oldEndNode = fOldStructuredDocumentRegionList.item(fOldStructuredDocumentRegionList.getLength() - 1); int newStart = oldEndNode.getEnd() - fLengthDifference; nextNode = fStructuredDocument.getRegionAtCharacterOffset(newStart); } else if (node != null) { nextNode = node.getNext(); } return nextNode; }
void replaceRegions(IStructuredDocumentRegion flatNode, ITextRegionList newRegions, ITextRegionList oldRegions) { // future_TODO: optimize NodeImpl root = (NodeImpl) this.model.getDocument(); this.parentNode = root; this.nextNode = (NodeImpl) root.getFirstChild(); removeGapStructuredDocumentRegion(flatNode); insertGapStructuredDocumentRegionBefore(flatNode.getStart()); changeStructuredDocumentRegion(flatNode); insertGapStructuredDocumentRegionAfter(flatNode.getEnd()); }
void changeRegion(IStructuredDocumentRegion flatNode, ITextRegion region) { // future_TODO: optimize NodeImpl root = (NodeImpl) this.model.getDocument(); this.parentNode = root; this.nextNode = (NodeImpl) root.getFirstChild(); removeGapStructuredDocumentRegion(flatNode); insertGapStructuredDocumentRegionBefore(flatNode.getStart()); changeStructuredDocumentRegion(flatNode); insertGapStructuredDocumentRegionAfter(flatNode.getEnd()); }
/** * getNodeAt method * * @return org.w3c.dom.Node * @param offset * int */ Node getNodeAt(int offset) { IDOMNode parent = this; IDOMNode child = (IDOMNode) getFirstChild(); while (child != null) { if (child.getEndOffset() <= offset) { child = (IDOMNode) child.getNextSibling(); continue; } if (child.getStartOffset() > offset) { break; } IStructuredDocumentRegion startStructuredDocumentRegion = child.getStartStructuredDocumentRegion(); if (startStructuredDocumentRegion != null) { if (startStructuredDocumentRegion.getEnd() > offset) return child; } // dig more parent = child; child = (IDOMNode) parent.getFirstChild(); } return parent; }
if ((result != null) && (end == result.getEnd())) { if (result.getNext() != null) { result = result.getNext();
if ((result != null) && (end == result.getEnd())) { if (result.getNext() != null) { result = result.getNext();
unlock(structuredDocument, offset, length); offset = span.offset + span.length; length = flatNode.getEnd() - span.offset; unlock(structuredDocument, offset, length);
lock(structuredDocument, offset, length, false, false); offset = offset + span.offset + span.length; length = flatNode.getEnd() - offset; lock(structuredDocument, offset, length, canInsert, false); } else {