/** * */ public static IStructuredDocumentRegion findPreviousSignificantNode(IStructuredDocumentRegion startNode) { if (startNode == null) { return null; } IStructuredDocumentRegion node = startNode.getPrevious(); while (node != null) { String type = getStructuredDocumentRegionType(node); if (type != CSSRegionContexts.CSS_S && type != CSSRegionContexts.CSS_COMMENT && type != CSSRegionContexts.CSS_CDO && type != CSSRegionContexts.CSS_CDC) { return node; } node = node.getPrevious(); } return null; }
/** * Returns the previous php structured document. Special cases : 1) previous * is null - returns null 2) previous is not PHP region - returns the last * region of the last php block * * @param currentStructuredDocumentRegion */ public static IStructuredDocumentRegion getLastTwigStructuredDocumentRegion( IStructuredDocumentRegion currentStructuredDocumentRegion) { assert currentStructuredDocumentRegion != null; // get last region currentStructuredDocumentRegion = currentStructuredDocumentRegion.getPrevious(); // search for last php block (then returns the last region) while (currentStructuredDocumentRegion != null && currentStructuredDocumentRegion.getType() != TwigRegionContext.TWIG_CONTENT) { currentStructuredDocumentRegion = currentStructuredDocumentRegion.getPrevious(); } return currentStructuredDocumentRegion; }
private IStructuredDocumentRegion findRuleStart(IStructuredDocumentRegion startRegion) { IStructuredDocumentRegion region = startRegion; // find '{' while (region != null && region.getType() != CSSRegionContexts.CSS_LBRACE) { region = region.getPrevious(); } // if (region == startRegion) { // return null; // } // else if (region != null) { // '{' is found region = region.getPrevious(); if (isLeadingDeclarationType(region.getType())) { return region; } } return null; }
/** * The rule is, that is we are content, preceded by lone <, then we need * to advance one more for dirty end. */ protected boolean isLoneOpenFollowedByContent(IStructuredDocumentRegion flatNode) { boolean result = false; String type = flatNode.getType(); if (type == DOMRegionContext.XML_CONTENT) { IStructuredDocumentRegion previous = flatNode.getPrevious(); String previousType = null; if (previous != null) { previousType = previous.getType(); } if (previousType != null) { result = (previousType == DOMRegionContext.XML_TAG_OPEN); } } return result; }
/** * */ public static IStructuredDocumentRegion findNodeBackward(IStructuredDocumentRegion startNode, IStructuredDocumentRegion endNode, String type) { IStructuredDocumentRegion node; for (node = startNode; node != null; node = node.getPrevious()) { if (node.getStartOffset() < endNode.getStartOffset()) { node = null; break; } else if (getStructuredDocumentRegionType(node) == type) { break; } } return node; }
@Override protected void findDirtyStart(int start) { IStructuredDocumentRegion result = fStructuredDocument.getRegionAtCharacterOffset(start); // heuristic: if the postion is exactly equal to the start, then // go back one more, if it exists. This prevents problems with // insertions // of text that should be merged with the previous node instead of // simply hung // off of it as a separate node (ex.: XML content inserted right // before an open // 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; while (isPartOfBlockRegion(potential)) { potential = potential.getPrevious(); } if (potential != null) { result = potential; fStructuredDocument.setCachedDocumentRegion(result); } } dirtyStart = result; }
protected void findDirtyStart(int start) { IStructuredDocumentRegion result = fStructuredDocument.getRegionAtCharacterOffset(start); // heuristic: if the postion is exactly equal to the start, then // go back one more, if it exists. This prevents problems with // insertions // of text that should be merged with the previous node instead of // simply hung // off of it as a separate node (ex.: XML content inserted right // before an open // 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; while (isPartOfBlockRegion(potential)) { potential = potential.getPrevious(); } if (potential != null) { result = potential; fStructuredDocument.setCachedDocumentRegion(result); } } dirtyStart = result; }
/** * Old Nodes: --[O1]--[O2]--[O3]--- : / \ Current Nodes: * ---[C1]-----[C2]-----[C3]-----[C4]--- * * Input: O1 -> Output: C1 Input: O2 -> Output: O1 Input: O3 -> Output: O2 * Input: Cn -> Output: Cn-1 */ public IStructuredDocumentRegion getPrevNode(IStructuredDocumentRegion node) { IStructuredDocumentRegion prevNode = null; if (node != null) { prevNode = node.getPrevious(); if (prevNode == null) { if (isOldNode(node)) { // this may be the start of old flatnodes int newEnd = node.getStart() - 1; prevNode = fStructuredDocument.getRegionAtCharacterOffset(newEnd); } } } return prevNode; }
/** * Old Nodes: --[O1]--[O2]--[O3]--- : / \ Current Nodes: * ---[C1]-----[C2]-----[C3]-----[C4]--- * * Input: O* -> Output: C1 Input: Cn -> Output: Cn-1 */ public IStructuredDocumentRegion getPrevNodeInCurrent(IStructuredDocumentRegion node) { IStructuredDocumentRegion prevNode = null; if (isOldNode(node)) { IStructuredDocumentRegion oldStartNode = fOldStructuredDocumentRegionList.item(0); int newEnd = oldStartNode.getStart() - 1; prevNode = fStructuredDocument.getRegionAtCharacterOffset(newEnd); } else if (node != null) { prevNode = node.getPrevious(); } return prevNode; }
private String getParentName(IStructuredDocumentRegion sdRegion) { String result = "UNKNOWN"; //$NON-NLS-1$ while (sdRegion != null && isValidJspActionRegionType(sdRegion.getType())) sdRegion = sdRegion.getPrevious(); if (sdRegion != null) { ITextRegionList regions = sdRegion.getRegions(); // only find parent names from a start tag if (regions.size() > 1) { ITextRegion r = regions.get(1); if (regions.get(0).getType().equals(DOMRegionContext.XML_TAG_OPEN) && r.getType().equals(DOMRegionContext.XML_TAG_NAME)) { result = sdRegion.getText(r); } } } return result; }
private ReparseRange getUpdateRangeForDelimiter(int start, int end) { if (dirtyStart != null && dirtyStart.getStart() < start) { start = dirtyStart.getStart(); } IStructuredDocumentRegion docRegion = fStructuredDocument.getRegionAtCharacterOffset(start); if (docRegion == null) { return null; } if (docRegion.getType() == CSSRegionContexts.CSS_DELIMITER) { IStructuredDocumentRegion prevRegion = docRegion.getPrevious(); if (prevRegion != null) { return new ReparseRange(prevRegion.getStart(), end); } } return null; }
private void checkForSpaceBeforeName(IStructuredDocumentRegion structuredDocumentRegion, IReporter reporter) { if (structuredDocumentRegion.isDeleted()) { return; } String sdRegionText = structuredDocumentRegion.getFullText(); if (sdRegionText.startsWith(" ")) { //$NON-NLS-1$ IStructuredDocumentRegion prev = structuredDocumentRegion.getPrevious(); if (prev != null) { // this is possibly the case of "< tag" if ((prev.getRegions().size() == 1) && isStartTag(prev)) { // add the error for preceding space in tag name String messageText = XMLUIMessages.ReconcileStepForMarkup_2; int start = structuredDocumentRegion.getStartOffset(); // find length of whitespace int length = sdRegionText.trim().equals("") ? sdRegionText.length() : sdRegionText.indexOf(sdRegionText.trim()); //$NON-NLS-1$ LocalizedMessage message = new LocalizedMessage(IMessage.HIGH_SEVERITY, messageText); message.setOffset(start); message.setLength(length); message.setLineNo(getLineNumber(start)); MarkupQuickAssistProcessor processor = new MarkupQuickAssistProcessor(); processor.setProblemId(ProblemIDsXML.SpacesBeforeTagName); message.setAttribute(QUICKASSISTPROCESSOR, processor); AnnotationInfo info = new AnnotationInfo(message); ((IncrementalReporter) reporter).addAnnotationInfo(this, info); } } } }
IStructuredDocumentRegion sdPrev = sdRegion.getPrevious(); if (sdPrev != null) { if (DEBUG) {
/** * */ public ITextRegion prev() { if (documentRegion == null) return null; if (current < 0 || documentRegion.getRegions() == null || documentRegion.getRegions().size() <= current) return null; ITextRegion region = documentRegion.getRegions().get(current); curDocumentRegion = documentRegion; if (current == 0) { documentRegion = documentRegion.getPrevious(); if (documentRegion != null) current = documentRegion.getRegions().size(); else current = 0; } current--; return region; }
sdRegion = sdRegion.getPrevious(); String fileLocation = getAttributeValue("file", sdRegion); //$NON-NLS-1$ this.fTranslator.handleIncludeFile(fileLocation);
if ((sdRegion.getStartOffset(region) == sdRegion.getStartOffset()) && (sdRegion.getPrevious() != null) && (!sdRegion.getPrevious().isEnded())) { region = sdRegion.getPrevious().getRegionAtCharacterOffset(offset - 1);
ITextRegion attrNameRegion = null; while (node != null && isValidScriptingRegionType(node.getType())) { node = node.getPrevious();
IStructuredDocumentRegion prev = structuredDocumentRegion.getPrevious(); if ((prev != null) && !prev.isDeleted()) { String prevText = prev.getFullText();
while ((sdRegion = sdRegion.getPrevious()) != null) { if (sdRegion.getFirstRegion().getType().equals(TwigRegionContext.TWIG_OPEN) || sdRegion.getFirstRegion().getType().equals(TwigRegionContext.TWIG_STMT_OPEN)) {
boolean result = false; IStructuredDocumentRegion previous = parent.getPrevious();