protected boolean isPartOfBlockRegion(IStructuredDocumentRegion flatNode) { boolean result = false; String type = flatNode.getType(); result = (type == DOMRegionContext.BLOCK_TEXT); return result; }
/** * Returns true if potentially could be a jsp embedded region. Things like * JSP Declaration can't be embedded. */ private boolean isJSPEmbeddedStartOrEnd(IStructuredDocumentRegion flatNode) { boolean result = false; String type = flatNode.getType(); result = ((type == DOMJSPRegionContexts.JSP_SCRIPTLET_OPEN) || (type == DOMJSPRegionContexts.JSP_EXPRESSION_OPEN) || (type == DOMJSPRegionContexts.JSP_DECLARATION_OPEN)); return result; }
/** * 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; }
/** * extends super class behavior */ protected boolean isPartOfBlockRegion(IStructuredDocumentRegion flatNode) { boolean result = false; String type = flatNode.getType(); result = ((type == DOMJSPRegionContexts.JSP_CLOSE) || (type == DOMJSPRegionContexts.JSP_CONTENT) || super.isPartOfBlockRegion(flatNode)); return result; }
/** * Tells you if the flatnode is <%, <%=, or <%! ISSUE: this is a bit of * hidden JSP knowledge that was implemented this way for expedency. * Should be evolved in future to depend on "nestedContext". */ public static boolean isJSPOpenDelimiter(IStructuredDocumentRegion fn) { if (fn == null) { return false; } return isJSPOpenDelimiter(fn.getType()); }
/** * Tells you if the flatnode is the %> delimiter * * ISSUE: this is a bit of hidden JSP knowledge that was implemented this * way for expedency. Should be evolved in future to depend on * "nestedContext". */ public static boolean isJSPCloseDelimiter(IStructuredDocumentRegion fn) { if (fn == null) { return false; } return isJSPCloseDelimiter(fn.getType()); }
/** * Tells you if the flatnode is the JSP region <%%>, <%=%>, <%!%> * * ISSUE: this is a bit of hidden JSP knowledge that was implemented this * way for expedency. Should be evolved in future to depend on * "nestedContext". */ public static boolean isJSPDelimiter(IStructuredDocumentRegion fn) { boolean isDelimiter = false; String type = fn.getType(); if (type != null) { isDelimiter = isJSPDelimiter(type); } return isDelimiter; }
protected void performValidation(IFile file, IReporter reporter, IStructuredDocument structuredDoc) { IStructuredDocumentRegion curNode = structuredDoc.getFirstStructuredDocumentRegion(); while (null != curNode && !reporter.isCancelled()) { if (curNode.getType() != DOMRegionContext.XML_COMMENT_TEXT && curNode.getType() != DOMRegionContext.XML_CDATA_TEXT && curNode.getType() != DOMRegionContext.UNDEFINED) { validateRegionContainer(curNode, reporter, file); } curNode = curNode.getNext(); } }
private boolean isParentStyleTag(Node node) { if (node == null) return false; if (node.getNodeType() != Node.TEXT_NODE) return false; if (!(node instanceof IDOMNode)) return false; IStructuredDocumentRegion flatNode = ((IDOMNode) node).getFirstStructuredDocumentRegion(); if (flatNode == null) return false; if (flatNode.getType() != DOMRegionContext.BLOCK_TEXT) return false; // check if the parent is STYLE element Node parent = node.getParentNode(); if (parent == null) return false; if (parent.getNodeType() != Node.ELEMENT_NODE) return false; String name = parent.getNodeName(); if (name == null) return false; if (!name.equalsIgnoreCase("STYLE"))//$NON-NLS-1$ return false; return true; }
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; }
/** * 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; }
protected void performValidation(IFile f, IReporter reporter, IStructuredDocument sDoc) { /* * when validating an entire file need to clear dupes or else you're * comparing between files */ fPrefixValueRegionToDocumentRegionMap.clear(); fTaglibPrefixesInUse.clear(); // iterate all document regions IStructuredDocumentRegion region = sDoc.getFirstStructuredDocumentRegion(); while (region != null && !reporter.isCancelled()) { // only checking directives if (region.getType() == DOMJSPRegionContexts.JSP_DIRECTIVE_NAME) { processDirective(reporter, f, sDoc, region); } region = region.getNext(); } if (!reporter.isCancelled()) { reportTaglibDuplicatePrefixes(f, reporter, sDoc); } fPrefixValueRegionToDocumentRegionMap.clear(); fTaglibPrefixesInUse.clear(); }
/** * @param sdRegion * @param offset * @return */ private boolean isAction(IStructuredDocumentRegion sdRegion, int offset) { if (!sdRegion.getType().equals(DOMRegionContext.XML_TAG_NAME)) return false; /* * shouldn't get a tag name region type unless a tag name region * exists at [1] */ ITextRegion tagNameRegion = sdRegion.getRegions().get(1); String tagName = sdRegion.getText(tagNameRegion); RegionParser parser = fStructuredDocument.getParser(); if (parser instanceof JSPSourceParser) { if (tagName.equals(fLastCheckedPrefix)) return true; List fCustomActionPrefixes = ((JSPSourceParser) parser).getNestablePrefixes(); for (int i = 0; i < fCustomActionPrefixes.size(); i++) if (tagName.startsWith(((TagMarker) fCustomActionPrefixes.get(i)).getTagName())) { fLastCheckedPrefix = tagName; return true; } } return false; }
protected boolean isDocumentRegionBasedPartition(IStructuredDocumentRegion sdRegion, ITextRegion containedChildRegion, int offset) { String documentRegionContext = sdRegion.getType(); if (containedChildRegion != null) { if (documentRegionContext.equals(DOMJSPRegionContexts.JSP_DIRECTIVE_NAME) || documentRegionContext.equals(DOMJSPRegionContexts.JSP_ROOT_TAG_NAME)) { setInternalPartition(offset, containedChildRegion.getLength(), IJSPPartitions.JSP_DIRECTIVE); return true; } // https://bugs.eclipse.org/bugs/show_bug.cgi?id=113346 if (fEnableJSPActionPartitions && isAction(sdRegion, offset) && !(containedChildRegion instanceof ITextRegionContainer)) { // if (fEnableJSPActionPartitions && isAction(sdRegion, // offset)) { setInternalPartition(offset, containedChildRegion.getLength(), IJSPPartitions.JSP_DIRECTIVE); return true; } } return super.isDocumentRegionBasedPartition(sdRegion, containedChildRegion, offset); }
protected void performValidation(IFile f, IReporter reporter, IStructuredModel model, IRegion validateRegion) { IStructuredDocument sDoc = model.getStructuredDocument(); // iterate all document regions IStructuredDocumentRegion region = sDoc.getRegionAtCharacterOffset(validateRegion.getOffset()); while (region != null && !reporter.isCancelled() && (region.getStartOffset() <= (validateRegion.getOffset() + validateRegion.getLength()))) { if (region.getType() == DOMJSPRegionContexts.JSP_DIRECTIVE_NAME) { // only checking directives processDirective(reporter, f, model, region); fTaglibPrefixes.clear(); } else if (region.getType() == DOMRegionContext.XML_TAG_NAME) { // and jsp tags String tagName = getStartTagName(region); int colonPosition = tagName.indexOf(':'); if (colonPosition > -1) { // get tag's prefix and check if it's really a jsp action // tag String prefix = tagName.substring(0, colonPosition); if (getTaglibPrefixes(sDoc).contains(prefix)) processDirective(reporter, f, model, region); } } region = region.getNext(); } }
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 boolean canFormatText(IDOMText text) { if (text == null) return false; IStructuredDocumentRegion flatNode = text.getFirstStructuredDocumentRegion(); if (flatNode != null) { String type = flatNode.getType(); if (isUnparsedRegion(type)) return false; } Node parent = text.getParentNode(); if (parent != null && parent.getNodeType() == Node.ELEMENT_NODE) { IDOMElement element = (IDOMElement) parent; if (!element.isGlobalTag() && !text.isElementContentWhitespace()) return false; } return canFormatChild(parent); }
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; }
public static AngularELRegion getAngularELRegion( IStructuredDocumentRegion documentRegion, int documentPosition, IProject project) { String startSymbol = AngularProject.DEFAULT_START_SYMBOL; String endSymbol = AngularProject.DEFAULT_END_SYMBOL; try { AngularProject angularProject = AngularProject .getAngularProject(project); startSymbol = angularProject.getStartSymbol(); endSymbol = angularProject.getEndSymbol(); } catch (CoreException e) { } String regionType = documentRegion.getType(); String regionText = documentRegion.getText(); int regionStartOffset = documentRegion.getStartOffset(); return getAngularELRegion(regionType, regionText, regionStartOffset, documentPosition, startSymbol, endSymbol); }
if ((prev != null) && !prev.isDeleted()) { String prevText = prev.getFullText(); if ((prev.getType() == DOMRegionContext.XML_CONTENT) && prevText.endsWith(" ")) { //$NON-NLS-1$ String messageText = XMLUIMessages.ReconcileStepForMarkup_5; int start = prev.getStartOffset();