protected IDOMNode getParentIndentNode(IDOMNode node) { IDOMNode result = null; IDOMNode parentNode = (IDOMNode) node.getParentNode(); if (parentNode.getNodeType() == Node.DOCUMENT_NODE) result = parentNode; else { ITextRegion region = parentNode.getLastStructuredDocumentRegion().getFirstRegion(); if (region.getType() == DOMRegionContext.XML_END_TAG_OPEN) result = parentNode; else result = getParentIndentNode(parentNode); } return result; }
private IDOMNode compressEmptyElementTag(IDOMNode node) { boolean compressEmptyElementTags = getCleanupPreferences().getCompressEmptyElementTags(); IDOMNode newNode = node; IStructuredDocumentRegion startTagStructuredDocumentRegion = newNode.getFirstStructuredDocumentRegion(); IStructuredDocumentRegion endTagStructuredDocumentRegion = newNode.getLastStructuredDocumentRegion(); if (compressEmptyElementTags && startTagStructuredDocumentRegion != endTagStructuredDocumentRegion && startTagStructuredDocumentRegion != null) { ITextRegionList regions = startTagStructuredDocumentRegion.getRegions(); ITextRegion lastRegion = regions.get(regions.size() - 1); // format children and end tag if not empty element tag if (lastRegion.getType() != DOMRegionContext.XML_EMPTY_TAG_CLOSE) { NodeList childNodes = newNode.getChildNodes(); if (childNodes == null || childNodes.getLength() == 0 || (childNodes.getLength() == 1 && (childNodes.item(0)).getNodeType() == Node.TEXT_NODE && ((childNodes.item(0)).getNodeValue().trim().length() == 0))) { IDOMModel structuredModel = newNode.getModel(); IStructuredDocument structuredDocument = structuredModel.getStructuredDocument(); int startTagStartOffset = newNode.getStartOffset(); int offset = endTagStructuredDocumentRegion.getStart(); int length = endTagStructuredDocumentRegion.getLength(); structuredDocument.replaceText(structuredDocument, offset, length, ""); //$NON-NLS-1$ newNode = (IDOMNode) structuredModel.getIndexedRegion(startTagStartOffset); // save offset = startTagStructuredDocumentRegion.getStart() + lastRegion.getStart(); structuredDocument.replaceText(structuredDocument, offset, 0, "/"); //$NON-NLS-1$ newNode = (IDOMNode) structuredModel.getIndexedRegion(startTagStartOffset); // save } } } return newNode; }
int length = contentAssistRequest.getReplacementLength(); if (parent instanceof IDOMNode) { if (((IDOMNode) parent).getLastStructuredDocumentRegion() != ((IDOMNode) parent).getFirstStructuredDocumentRegion()) { begin = ((IDOMNode) parent).getFirstStructuredDocumentRegion().getEndOffset(); length = ((IDOMNode) parent).getLastStructuredDocumentRegion().getStartOffset() - begin;
else if ((contentAssistRequest.getDocumentRegion() == node.getLastStructuredDocumentRegion()) && !node.getLastStructuredDocumentRegion().isEnded()) { setErrorMessage(null);
protected boolean isEndTagMissing(IDOMNode node) { boolean result = false; if ((node != null) && (node.getNodeType() != Node.DOCUMENT_NODE) && !isJSPTag(node)) { IStructuredDocumentRegion startTagStructuredDocumentRegion = node.getFirstStructuredDocumentRegion(); IStructuredDocumentRegion endTagStructuredDocumentRegion = node.getLastStructuredDocumentRegion(); ITextRegion startTagNameRegion = null; if (startTagStructuredDocumentRegion.getRegions().size() > 1) startTagNameRegion = startTagStructuredDocumentRegion.getRegions().get(1); ITextRegion endTagNameRegion = null; if (endTagStructuredDocumentRegion.getRegions().size() > 1) endTagNameRegion = endTagStructuredDocumentRegion.getRegions().get(1); ITextRegionList startTagRegions = startTagStructuredDocumentRegion.getRegions(); if (startTagNameRegion == endTagNameRegion && startTagNameRegion != null && (startTagRegions.get(0)).getType() != DOMRegionContext.XML_END_TAG_OPEN && (startTagRegions.get(startTagRegions.size() - 1).getType()) != DOMRegionContext.XML_EMPTY_TAG_CLOSE) // end tag missing result = true; } return result; }
IStructuredDocumentRegion endRegion = node.getLastStructuredDocumentRegion(); if (endRegion != null && endRegion.getNext() != null)
startTag = target.getFirstStructuredDocumentRegion(); if (startTag != null) { endTag = target.getLastStructuredDocumentRegion(); seg = new Segment(startTag, endTag);
IStructuredDocumentRegion endTagStructuredDocumentRegion = node.getLastStructuredDocumentRegion(); if (endTagStructuredDocumentRegion.getRegions().size() >= 3) { ITextRegion endTagNameRegion = endTagStructuredDocumentRegion.getRegions().get(1);