/** * */ public static String getRegionText(IStructuredDocumentRegion flatNode, ITextRegionList regions) { StringBuffer buf = new StringBuffer(); if (regions != null) { for (Iterator i = regions.iterator(); i.hasNext();) { ITextRegion region = (ITextRegion) i.next(); if (region == null) { continue; } buf.append(flatNode.getText(region)); } } return buf.toString(); }
protected ITextRegion getNameRegion(IStructuredDocumentRegion flatNode) { if (flatNode == null) { return null; } Iterator regionList = flatNode.getRegions().iterator(); while (regionList.hasNext()) { ITextRegion region = (ITextRegion) regionList.next(); if (isNameRegion(region)) { return region; } } return null; }
static private String getTagName(IStructuredDocumentRegion tag) { ITextRegionList regions = tag.getRegions(); Iterator iter = regions.iterator(); while (iter.hasNext()) { ITextRegion rgn = (ITextRegion) iter.next(); if (rgn.getType() == DOMRegionContext.XML_TAG_NAME) return tag.getText(rgn); } return "";//$NON-NLS-1$ }
private boolean isEndTagCorrupted(ElementInfo info) { ITextRegionList regions = info.endTag.getRegions(); if (regions == null || regions.isEmpty()) return false; Iterator iter = regions.iterator(); while (iter.hasNext()) { ITextRegion rgn = (ITextRegion) iter.next(); if (!isValidRegion(rgn)) return true; // found invalid region type. } return false; // all regions are valid. }
/** * goes through comment regions, checks if any are an embedded JSP * container if it finds one, it's sends the container into the * translation routine */ protected void translateXMLCommentNode(IStructuredDocumentRegion node) { Iterator it = node.getRegions().iterator(); ITextRegion commentRegion = null; while (it != null && it.hasNext()) { commentRegion = (ITextRegion) it.next(); if (commentRegion instanceof ITextRegionContainer) { translateRegionContainer((ITextRegionContainer) commentRegion, EMBEDDED_JSP); // it's // embedded // jsp...iterate // regions... } } }
/** * */ private String makeString(ITextRegionList regions) { StringBuffer buf = new StringBuffer(); boolean bSpace = false; for (Iterator i = regions.iterator(); i.hasNext();) { ITextRegion region = (ITextRegion) i.next(); String type = region.getType(); if (!bSpace && isBlank(type)) { buf.append(" "); //$NON-NLS-1$ bSpace = true; } else { buf.append(getText(region)); bSpace = false; } } return buf.toString(); }
private String getEndTagFullText(ElementInfo info) { String hint = "";//$NON-NLS-1$ ITextRegionList regions = info.endTag.getRegions(); Iterator iter = regions.iterator(); while (iter.hasNext()) { ITextRegion rgn = (ITextRegion) iter.next(); String type = rgn.getType(); if (type == null) continue; if (type == DOMRegionContext.XML_END_TAG_OPEN || type == DOMRegionContext.XML_TAG_CLOSE) continue; hint += info.endTag.getFullText(rgn); } return hint; }
private boolean hasJSPRegion(ITextRegion container) { if (!(container instanceof ITextRegionContainer)) return false; ITextRegionList regions = ((ITextRegionContainer) container).getRegions(); if (regions == null) return false; Iterator e = regions.iterator(); while (e.hasNext()) { ITextRegion region = (ITextRegion) e.next(); if (region == null) continue; String regionType = region.getType(); if (regionType == DOMRegionContext.XML_TAG_OPEN || (isNestedTagName(regionType))) return true; } return false; }
/** * */ public static boolean hasColonSeparator(IStructuredDocumentRegion flatNode) { if (flatNode == null) { return false; } ITextRegionList regions = flatNode.getRegions(); if (regions == null || regions.size() == 0) { return false; } for (Iterator i = regions.iterator(); i.hasNext();) { ITextRegion region = (ITextRegion) i.next(); if (region == null) { continue; } if (region.getType() == CSSRegionContexts.CSS_DECLARATION_SEPARATOR) { return true; } } return false; }
/** * Check if Attr has JSP in value */ public boolean hasNestedValue() { if (this.valueRegion == null) return false; if (!(this.valueRegion instanceof ITextRegionContainer)) return false; ITextRegionList regions = ((ITextRegionContainer) this.valueRegion).getRegions(); if (regions == null) return false; Iterator e = regions.iterator(); while (e.hasNext()) { ITextRegion region = (ITextRegion) e.next(); if (region == null) continue; String regionType = region.getType(); if (regionType == DOMRegionContext.XML_TAG_OPEN || isNestedLanguageOpening(regionType)) return true; } return false; }
protected void processPageDirective(IStructuredDocumentRegion sdRegion) { if (isPageDirective(fTagname)) { this.fTranslator.translatePageDirectiveAttributes(sdRegion.getRegions().iterator(), sdRegion); } }
protected void validateRegionContainer(ITextRegionCollection container, IReporter reporter, IFile file) { ITextRegionCollection containerRegion = container; Iterator regions = containerRegion.getRegions().iterator(); ITextRegion region = null; while (regions.hasNext() && !reporter.isCancelled()) { region = (ITextRegion) regions.next(); String type = region.getType(); if (type != null && region instanceof ITextRegionCollection) { ITextRegionCollection parentRegion = ((ITextRegionCollection) region); Iterator childRegions = parentRegion.getRegions().iterator(); while (childRegions.hasNext() && !reporter.isCancelled()) { ITextRegion childRegion = (ITextRegion) childRegions.next(); if (childRegion.getType() == DOMJSPRegionContexts.JSP_EL_CONTENT) validateXMLNode(parentRegion, childRegion, reporter, file); } } } }
public String getEndTagName() { if (this.endStructuredDocumentRegion == null) return null; ITextRegionList regions = this.endStructuredDocumentRegion.getRegions(); if (regions == null) return null; Iterator e = regions.iterator(); while (e.hasNext()) { ITextRegion region = (ITextRegion) e.next(); String regionType = region.getType(); if (regionType == DOMRegionContext.XML_TAG_NAME || isNestedEndTag(regionType)) { return this.endStructuredDocumentRegion.getText(region); } } return null; }
/** * Pass the ITextRegionCollection which is the embedded region * * @param iterator */ private void translateEmbeddedJSPInBlock(ITextRegionCollection collection) { Iterator regions = collection.getRegions().iterator(); ITextRegion region = null; while (regions.hasNext()) { region = (ITextRegion) regions.next(); if (isJSP(region.getType())) break; region = null; } if (region != null) { translateEmbeddedJSPInAttribute(collection); } }
private boolean isBreakingWithNestedTag(IStructuredDocumentRegion start, IStructuredDocumentRegion end) { boolean result = false; boolean changesIncludeA_lt = fChanges != null && fChanges.indexOf('<') >= 0; boolean delsIncludeA_gt = fDeletedText != null && fDeletedText.indexOf('>') >= 0; // List regions = new ArrayList(); IStructuredDocumentRegion node = start; int endReplace = fStart + fLengthToReplace; while (end != null && node != end.getNext()) { Iterator i = node.getRegions().iterator(); while (i.hasNext()) { ITextRegion region = (ITextRegion) i.next(); if (intersects(node, region, fStart, endReplace)) { result = isBreakingWithNestedTag(changesIncludeA_lt, delsIncludeA_gt, node, region); if (result) break; } } node = node.getNext(); if (result) break; } return result; }
protected String getAttributeValue(String attrName, IStructuredDocumentRegion sdRegion) { String sdRegionText = fTextToParse.substring(sdRegion.getStartOffset(), sdRegion.getEndOffset()); String textRegionText, attrValue = ""; //$NON-NLS-1$ Iterator it = sdRegion.getRegions().iterator(); ITextRegion nameRegion, valueRegion = null; while (it.hasNext()) { nameRegion = (ITextRegion) it.next(); if (nameRegion.getType() == DOMRegionContext.XML_TAG_ATTRIBUTE_NAME) { textRegionText = sdRegionText.substring(nameRegion.getStart(), nameRegion.getTextEnd()); if (textRegionText.equalsIgnoreCase(attrName)) { while (it.hasNext()) { valueRegion = (ITextRegion) it.next(); if (valueRegion.getType() == DOMRegionContext.XML_TAG_ATTRIBUTE_VALUE) { attrValue = sdRegionText.substring(valueRegion.getStart(), valueRegion.getEnd()); break; // inner } } break; // outer } } } return StringUtils.stripQuotes(attrValue); }
ITextRegionList newRegions = new TextRegionListImpl(); int nAccepts = (accepts != null) ? accepts.length : 0; Iterator i = regions.iterator();
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 setSourceReferencePoint() { if (isJSP(getCurrentNode().getFirstRegion().getType())) { Iterator it = getCurrentNode().getRegions().iterator(); ITextRegion r = null; while (it.hasNext()) { r = (ITextRegion) it.next(); if (r.getType() == DOMJSPRegionContexts.JSP_CONTENT || r.getType() == DOMRegionContext.XML_CONTENT) break; else if (r.getType() == DOMJSPRegionContexts.JSP_DIRECTIVE_NAME) break; else if (r.getType() == DOMRegionContext.XML_TAG_ATTRIBUTE_VALUE && getCurrentNode().getFullText(r).trim().equals("import")) //$NON-NLS-1$ break; } } }
/** * insertPI method * */ private void insertPI(IStructuredDocumentRegion flatNode) { ITextRegionList regions = flatNode.getRegions(); if (regions == null) return; String target = null; Iterator e = regions.iterator(); while (e.hasNext()) { ITextRegion region = (ITextRegion) e.next(); String regionType = region.getType(); if (regionType == DOMRegionContext.XML_PI_OPEN || regionType == DOMRegionContext.XML_PI_CLOSE) continue; if (target == null) target = flatNode.getText(region); } ProcessingInstructionImpl pi = (ProcessingInstructionImpl) this.model.getDocument().createProcessingInstruction(target, null); if (pi == null) return; pi.setStructuredDocumentRegion(flatNode); insertNode(pi); }