public int getEndTagStartOffset() { if (node.getEndStructuredDocumentRegion() != null) { return node.getEndStructuredDocumentRegion().getStartOffset(); } return -1; }
public int getEndTagEndOffset() { if (node.getEndStructuredDocumentRegion() != null) { return node.getEndStructuredDocumentRegion().getEndOffset(); } return -1; }
protected void insertAfterNode(IDOMNode node, String string) { IDOMModel structuredModel = node.getModel(); IStructuredDocument structuredDocument = structuredModel.getStructuredDocument(); int offset = node.getEndOffset(); int length = 0; // 261968 - formatting tag without closing bracket: <t1><t1 if (node.getEndStructuredDocumentRegion() != null) { offset = node.getEndStructuredDocumentRegion().getTextEndOffset(); length = node.getEndOffset() - offset; } replace(structuredDocument, offset, length, string); }
void unlockBoth(IDOMNode node) { if (node == null) { return; } IStructuredDocumentRegion flatNode; // start node flatNode = node.getStartStructuredDocumentRegion(); if (flatNode != null) { unlock(flatNode); } // end node flatNode = node.getEndStructuredDocumentRegion(); if (flatNode != null) { unlock(flatNode); } }
/** * @param eObj * @return the length in characters of the XML node that * eObj was constructed from or -1 if no computable */ public static int getLength(EObject eObj) { IDOMNode node = getDomNode(eObj); if (node != null) { return node.getEndStructuredDocumentRegion().getEndOffset() - node.getStartStructuredDocumentRegion().getStartOffset(); } return -1; }
IStructuredDocumentRegion endTagStructuredDocumentRegion = parentNode.getEndStructuredDocumentRegion(); if (endTagStructuredDocumentRegion == null) { StringBuffer toAdd = new StringBuffer(parentNode.getNodeName());
/** * Return 'node' indexed end name' start position Example: <a>aaa| </a>, the * position is indicated by '|' If node is <a /> style or there is no </a> * to pair with <a>, the function return -1. * * @param node * @return */ public static int getNodeEndNameStartIndex(Node node) { if (isText(node)) { return getNodeEndIndex(node); } if (EditValidateUtil.validNode(node) && node instanceof IDOMNode) { IStructuredDocumentRegion region = ((IDOMNode) node) .getEndStructuredDocumentRegion(); if (region != null) { return region.getStartOffset(); } // else // { // if (node.hasChildNodes()) // { // return getNodeEndIndex(node); // } // } } return getNodeEndIndex(node); }
/** * This method is used from parent's setChildEditable() * * case 1:<parent><node attr="value"/> <node2></parent> * x####################x case 2:<parent><node attr="value"> <child> * </child> </node> </parent> x###################? ?#######x (? : * editable if node.isEditable() == true) */ void lockBoth(IDOMNode node) { if (node == null) { return; } IStructuredDocumentRegion flatNode; boolean canInsert = false; // end node (element) if (node.getNodeType() == Node.ELEMENT_NODE) { flatNode = node.getEndStructuredDocumentRegion(); if (flatNode != null) { canInsert = node.isChildEditable(); lock(flatNode, canInsert, false); } } // start node flatNode = node.getStartStructuredDocumentRegion(); if (flatNode != null) { lock(flatNode, false, canInsert); } }
private void getLocalRenameQuickAssistProposal(List proposals, ISourceViewer viewer, int offset) { IDOMNode node = (IDOMNode) getNodeAt(viewer, offset); IStructuredDocumentRegion startStructuredDocumentRegion = node == null ? null : node.getStartStructuredDocumentRegion(); IStructuredDocumentRegion endStructuredDocumentRegion = node == null ? null : node.getEndStructuredDocumentRegion(); ITextRegion region = null; int regionTextEndOffset = 0; if ((startStructuredDocumentRegion != null) && startStructuredDocumentRegion.containsOffset(offset)) { region = startStructuredDocumentRegion.getRegionAtCharacterOffset(offset); regionTextEndOffset = startStructuredDocumentRegion.getTextEndOffset(region); } else if ((endStructuredDocumentRegion != null) && endStructuredDocumentRegion.containsOffset(offset)) { region = endStructuredDocumentRegion.getRegionAtCharacterOffset(offset); regionTextEndOffset = endStructuredDocumentRegion.getTextEndOffset(region); } if ((region != null) && ((region.getType() == DOMRegionContext.XML_TAG_NAME) || (region.getType() == DOMRegionContext.XML_TAG_ATTRIBUTE_NAME)) && (offset <= regionTextEndOffset)) { proposals.add(new RenameInFileQuickAssistProposal()); } }
/** * @param proposals * @param viewer * @param offset */ protected void getLocalRenameQuickAssistProposal(ArrayList proposals, StructuredTextViewer viewer, int offset) { IDOMNode node = (IDOMNode) ContentAssistUtils.getNodeAt(viewer, offset); IStructuredDocumentRegion startStructuredDocumentRegion = node == null ? null : node.getStartStructuredDocumentRegion(); IStructuredDocumentRegion endStructuredDocumentRegion = node == null ? null : node.getEndStructuredDocumentRegion(); ITextRegion region = null; int regionTextEndOffset = 0; if ((startStructuredDocumentRegion != null) && startStructuredDocumentRegion.containsOffset(offset)) { region = startStructuredDocumentRegion.getRegionAtCharacterOffset(offset); regionTextEndOffset = startStructuredDocumentRegion.getTextEndOffset(region); } else if ((endStructuredDocumentRegion != null) && endStructuredDocumentRegion.containsOffset(offset)) { region = endStructuredDocumentRegion.getRegionAtCharacterOffset(offset); regionTextEndOffset = endStructuredDocumentRegion.getTextEndOffset(region); } if ((region != null) && ((region.getType() == DOMRegionContext.XML_TAG_NAME) || (region.getType() == DOMRegionContext.XML_TAG_ATTRIBUTE_NAME)) && (offset <= regionTextEndOffset)) { proposals.add(new RenameInFileQuickAssistProposal()); } }
IDOMNode aXMLNode = (IDOMNode) aNode; CMElementDeclaration ed = modelQuery.getCMElementDeclaration((Element) aNode); if ((aXMLNode.getEndStructuredDocumentRegion() == null) && ((ed == null) || (ed.getContentType() != CMElementDeclaration.EMPTY))) { String proposedText = aNode.getNodeName(); String proposedInfo = (ed != null) ? getAdditionalInfo(null, ed) : null;
result = xmlNode.getEndStructuredDocumentRegion() == null;
if ((node.getNodeType() != Node.DOCUMENT_NODE) && (node.getEndStructuredDocumentRegion() == null)) { addEndTagProposals(contentAssistRequest); if ((node.getNodeType() != Node.DOCUMENT_NODE) && (node.getEndStructuredDocumentRegion() != null)) { addTagCloseProposals(contentAssistRequest);
flatNode = node.getEndStructuredDocumentRegion(); if (flatNode != null) { unlock(flatNode);
protected IDOMNode insertMissingTags(IDOMNode node) { boolean insertMissingTags = getCleanupPreferences().getInsertMissingTags(); IDOMNode newNode = node; if (insertMissingTags) { IStructuredDocumentRegion startTagStructuredDocumentRegion = node.getStartStructuredDocumentRegion(); if (startTagStructuredDocumentRegion == null) { // implicit start tag; generate tag for it newNode = insertStartTag(node); startTagStructuredDocumentRegion = newNode.getStartStructuredDocumentRegion(); } IStructuredDocumentRegion endTagStructuredDocumentRegion = newNode.getEndStructuredDocumentRegion(); ITextRegionList regionList = startTagStructuredDocumentRegion.getRegions(); if (startTagStructuredDocumentRegion != null && regionList != null && regionList.get(regionList.size() - 1).getType() == DOMRegionContext.XML_EMPTY_TAG_CLOSE) { } else { if (startTagStructuredDocumentRegion == null) { // start tag missing if (isStartTagRequired(newNode)) newNode = insertStartTag(newNode); } else if (endTagStructuredDocumentRegion == null) { // end tag missing if (isEndTagRequired(newNode)) newNode = insertEndTag(newNode); } } } return newNode; }
private IDOMNode insertMissingTags(IDOMNode node) { boolean insertMissingTags = getCleanupPreferences().getInsertMissingTags(); IDOMNode newNode = node; if (insertMissingTags) { IStructuredDocumentRegion startTagStructuredDocumentRegion = node.getStartStructuredDocumentRegion(); if (startTagStructuredDocumentRegion == null) { // implicit start tag; generate tag for it newNode = insertStartTag(node); startTagStructuredDocumentRegion = newNode.getStartStructuredDocumentRegion(); } IStructuredDocumentRegion endTagStructuredDocumentRegion = newNode.getEndStructuredDocumentRegion(); ITextRegionList startStructuredDocumentRegionRegions = startTagStructuredDocumentRegion.getRegions(); if (startTagStructuredDocumentRegion != null && startStructuredDocumentRegionRegions != null && (startStructuredDocumentRegionRegions.get(startStructuredDocumentRegionRegions.size() - 1)).getType() == DOMRegionContext.XML_EMPTY_TAG_CLOSE) { } else { if (startTagStructuredDocumentRegion == null) { // start tag missing if (isStartTagRequired(newNode)) newNode = insertStartTag(newNode); } else if (endTagStructuredDocumentRegion == null) { // end tag missing if (isEndTagRequired(newNode)) newNode = insertEndTag(newNode); } } } return newNode; }
flatNode = node.getEndStructuredDocumentRegion(); if (flatNode != null) { canInsert = node.isChildEditable();
IStructuredDocumentRegion endTagStructuredDocumentRegion = renamedNode.getEndStructuredDocumentRegion(); if (endTagStructuredDocumentRegion != startTagStructuredDocumentRegion) insertTagClose(structuredModel, endTagStructuredDocumentRegion);
endTag = target.getEndStructuredDocumentRegion(); if (endTag != null) { seg = new Segment(endTag);
IStructuredDocumentRegion endTagStructuredDocumentRegion = renamedNode.getEndStructuredDocumentRegion(); if (endTagStructuredDocumentRegion != startTagStructuredDocumentRegion) insertTagClose(structuredModel, endTagStructuredDocumentRegion);