public IStructuredDocumentRegion getNext() { return getParentDocument().getFirstStructuredDocumentRegion(); }
public void modelAboutToBeChanged(IStructuredModel model) { if (model.getStructuredDocument() != null) aboutToChangeNode = model.getStructuredDocument().getFirstStructuredDocumentRegion(); }
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(); }
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(); } }
public void modelChanged(IStructuredModel model) { if (isBatchChanges) return; try { if (aboutToChangeNode != null && model.getStructuredDocument() != null && model.getStructuredDocument().getFirstStructuredDocumentRegion() != aboutToChangeNode) { String id = getModelManagerId(); IStructuredModel tempModel = null; try { tempModel = getModelManager().getExistingModelForEdit(id); xmlModelReverted = true; resource.unload(); } finally { if (tempModel != null) { tempModel.releaseFromEdit(); } } } } finally { aboutToChangeNode = null; } }
private String getNamedStyleAtOffset(int offset) { // ensure the offset is clean if (offset >= fDocument.getLength()) return getNamedStyleAtOffset(fDocument.getLength() - 1); else if (offset < 0) return getNamedStyleAtOffset(0); IStructuredDocumentRegion documentRegion = fDocument.getFirstStructuredDocumentRegion(); while (documentRegion != null && !documentRegion.containsOffset(offset)) { documentRegion = documentRegion.getNext(); } if (documentRegion != null) { // find the ITextRegion's Context at this offset ITextRegion interest = documentRegion.getRegionAtCharacterOffset(offset); if (interest == null) return null; if (offset > documentRegion.getTextEndOffset(interest)) return null; String regionContext = interest.getType(); if (regionContext == null) return null; // find the named style (internal/selectable name) for that // context String namedStyle = (String) fContextToStyleMap.get(regionContext); if (namedStyle != null) { return namedStyle; } } return null; }
public boolean parse(String filePath) { getLocalParser().removeStructuredDocumentRegionHandler(this); // from outer class List blockMarkers = this.fTranslator.getBlockMarkers(); IStructuredDocument document = StructuredDocumentFactory.getNewStructuredDocumentInstance(getLocalParser()); String contents = getContents(filePath); if (contents == null) return false; // this adds the current markers from the outer class list // to this parser so parsing works correctly for (int i = 0; i < blockMarkers.size(); i++) { addBlockMarker((BlockMarker) blockMarkers.get(i)); } reset(contents); // forceParse(); document.set(contents); IStructuredDocumentRegion cursor = document.getFirstStructuredDocumentRegion(); while (cursor != null) { nodeParsed(cursor); cursor = cursor.getNext(); } getLocalParser().addStructuredDocumentRegionHandler(this); return true; }
private void loadTagFile(CMElementDeclarationImpl ed, IFile tagFile, boolean allowIncludes) { try { IStructuredDocument document = (IStructuredDocument) new ModelHandlerForJSP().getDocumentLoader().createNewStructuredDocument(tagFile); IStructuredDocumentRegion documentRegion = document.getFirstStructuredDocumentRegion(); while (documentRegion != null) { if (documentRegion.getType().equals(DOMJSPRegionContexts.JSP_DIRECTIVE_NAME)) {
/** * Color the text in the sample area according to the current preferences */ void applyStyles() { if (fText == null || fText.isDisposed()) return; IStructuredDocumentRegion documentRegion = fDocument.getFirstStructuredDocumentRegion(); while (documentRegion != null) { ITextRegionList regions = documentRegion.getRegions(); for (int i = 0; i < regions.size(); i++) { ITextRegion currentRegion = regions.get(i); // lookup the local coloring type and apply it String namedStyle = (String) fContextToStyleMap.get(currentRegion.getType()); if (namedStyle == null) continue; TextAttribute attribute = getAttributeFor(namedStyle); if (attribute == null) continue; StyleRange style = new StyleRange(documentRegion.getStartOffset(currentRegion), currentRegion.getTextLength(), attribute.getForeground(), attribute.getBackground(), attribute.getStyle()); style.strikeout = (attribute.getStyle() & TextAttribute.STRIKETHROUGH) != 0; style.underline = (attribute.getStyle() & TextAttribute.UNDERLINE) != 0; fText.setStyleRange(style); } documentRegion = documentRegion.getNext(); } }
private void setCssValueTextCore(String value) throws DOMException { // use temporary document synchronized (CSSStyleDeclarationImpl.class) { if (sharedStructuredDocument == null) { IDocumentLoader loader = new CSSDocumentLoader(); sharedStructuredDocument = (IStructuredDocument) loader.createNewStructuredDocument(); ((CSSSourceParser) sharedStructuredDocument.getParser()).setParserMode(CSSSourceParser.MODE_DECLARATION_VALUE); } sharedStructuredDocument.set(value); IStructuredDocumentRegion node = sharedStructuredDocument.getFirstStructuredDocumentRegion(); if (node == null) { return; } if (node.getNext() != null) { throw new DOMException(DOMException.INVALID_MODIFICATION_ERR, "");//$NON-NLS-1$ } CSSDeclarationItemParser itemParser = new CSSDeclarationItemParser(getOwnerDocument()); itemParser.setStructuredDocumentTemporary(true); // make a copy of nodelist because setupValues will destroy list ITextRegionList nodeList = new TextRegionListImpl(node.getRegions()); itemParser.setupValues(this, node, nodeList); } }
DOMModelForJSP jspModel = (DOMModelForJSP) model; IStructuredDocument structuredDoc = jspModel.getStructuredDocument(); IStructuredDocumentRegion curNode = structuredDoc.getFirstStructuredDocumentRegion(); while (null != curNode && !reporter.isCancelled()) { if (curNode.getFirstRegion().getType() == DOMRegionContext.XML_TAG_OPEN )
((CSSStructuredDocumentRegionContainer)fDocument).setRangeStructuredDocumentRegion(structuredDocument.getFirstStructuredDocumentRegion(), structuredDocument.getLastStructuredDocumentRegion());
/** * /* the main control loop for translating the document, driven by the * structuredDocument nodes */ public void translate() { if (fTagToVariableMap == null) { fTagToVariableMap = new StackMap(); } setCurrentNode(new ZeroStructuredDocumentRegion(fStructuredDocument, 0)); translatePreludes(); setCurrentNode(fStructuredDocument.getFirstStructuredDocumentRegion()); while (getCurrentNode() != null && !isCanceled()) { // intercept HTML comment flat node // also handles UNDEFINED (which is what CDATA comes in as) // basically this part will handle any "embedded" JSP containers if (getCurrentNode().getType() == DOMRegionContext.XML_COMMENT_TEXT || getCurrentNode().getType() == DOMRegionContext.XML_CDATA_TEXT || getCurrentNode().getType() == DOMRegionContext.UNDEFINED) { translateXMLCommentNode(getCurrentNode()); } else { // iterate through each region in the flat node translateRegionContainer(getCurrentNode(), STANDARD_JSP); } if (getCurrentNode() != null) advanceNextNode(); } setCurrentNode(new ZeroStructuredDocumentRegion(fStructuredDocument, fStructuredDocument.getLength())); translateCodas(); buildResult(); fTagToVariableMap.clear(); }