public class XMLPositionUtility extends Object
Modifier and Type | Class and Description |
---|---|
static class |
XMLPositionUtility.EntityReferenceRange |
Modifier and Type | Method and Description |
---|---|
static boolean |
covers(org.eclipse.lsp4j.Range range,
org.eclipse.lsp4j.Position position) |
static org.eclipse.lsp4j.DocumentLink |
createDocumentLink(DOMRange target,
String location,
boolean adjust)
Create a document link
|
static org.eclipse.lsp4j.Location |
createLocation(DOMRange target)
Returns the location for the given
target node. |
static org.eclipse.lsp4j.LocationLink |
createLocationLink(DOMRange origin,
DOMRange target)
Returns the location link for the given
origin and
target nodes. |
static org.eclipse.lsp4j.LocationLink |
createLocationLink(org.eclipse.lsp4j.Range origin,
DOMRange target)
Returns the location link for the given
origin and
target nodes. |
static org.eclipse.lsp4j.LocationLink |
createLocationLink(org.eclipse.lsp4j.Range origin,
TargetRange target)
Returns the location link for the given
origin and
target nodes. |
static org.eclipse.lsp4j.Range |
createRange(DOMRange range)
Returns the range for the given
node . |
static org.eclipse.lsp4j.Range |
createRange(int startOffset,
int endOffset,
DOMDocument document) |
static boolean |
doesTagCoverPosition(org.eclipse.lsp4j.Range startTagRange,
org.eclipse.lsp4j.Range endTagRange,
org.eclipse.lsp4j.Position position) |
static org.eclipse.lsp4j.Range |
getElementDeclMissingContentOrCategory(int offset,
DOMDocument document) |
static int |
getEntityReferenceEndOffset(String text,
int offset)
Returns the end offset of the entity reference (ex : &am|p;) from the right
of the given offset and -1 if no entity reference.
|
static int |
getEntityReferenceStartOffset(String text,
int offset)
Returns the start offset of the entity reference (ex : &am|p;) from the left
of the given offset and -1 if no entity reference.
|
static org.eclipse.lsp4j.Range |
getLastDTDDeclParameter(int offset,
DOMDocument document)
Will give the range for the last DTD Decl parameter at 'offset'.
|
static org.eclipse.lsp4j.Range |
getLastValidDTDDeclParameter(int offset,
DOMDocument document) |
static org.eclipse.lsp4j.Range |
getLastValidDTDDeclParameter(int offset,
DOMDocument document,
boolean selectWholeParameter)
Will give the range for the last VALID DTD Decl parameter at 'offset'.
|
static org.eclipse.lsp4j.Range |
getLastValidDTDDeclParameterOrUnrecognized(int offset,
DOMDocument document)
Will give the range for the last VALID DTD Decl parameter at 'offset'.
|
static org.eclipse.lsp4j.Position |
getMatchingTagPosition(DOMDocument xmlDocument,
org.eclipse.lsp4j.Position position) |
static org.eclipse.lsp4j.Range |
getTagNameRange(TokenType tokenType,
int startOffset,
DOMDocument xmlDocument) |
static boolean |
isBeforeOrEqual(org.eclipse.lsp4j.Position pos1,
org.eclipse.lsp4j.Position pos2) |
static org.eclipse.lsp4j.Range |
selectAllAttributes(int offset,
DOMDocument document) |
static org.eclipse.lsp4j.Range |
selectAttributeFromGivenNameAt(String attrName,
int offset,
DOMDocument document) |
static org.eclipse.lsp4j.Range |
selectAttributeName(DOMAttr attr)
Returns the attribute name range and null otherwise.
|
static org.eclipse.lsp4j.Range |
selectAttributeNameAt(int offset,
DOMDocument document) |
static org.eclipse.lsp4j.Range |
selectAttributeNameFromGivenNameAt(String attrName,
int offset,
DOMDocument document) |
static org.eclipse.lsp4j.Range |
selectAttributePrefixFromGivenNameAt(String attrName,
int offset,
DOMDocument document)
Returns the range of the prefix of an attribute name
For example, if attrName = "xsi:example", the range for "xsi" will be
returned
|
static org.eclipse.lsp4j.Range |
selectAttributeValue(DOMAttr attr)
Returns the attribute value range and null otherwise.
|
static org.eclipse.lsp4j.Range |
selectAttributeValueAt(String attrName,
int offset,
DOMDocument document) |
static org.eclipse.lsp4j.Range |
selectAttributeValueByGivenValueAt(String attrValue,
int offset,
DOMDocument document) |
static org.eclipse.lsp4j.Range |
selectAttributeValueFromGivenValue(String attrValue,
int offset,
DOMDocument document) |
static org.eclipse.lsp4j.Range |
selectChildEndTag(String childTag,
int offset,
DOMDocument document) |
static org.eclipse.lsp4j.Range |
selectContent(int offset,
DOMDocument document) |
static int |
selectCurrentTagOffset(int offset,
DOMDocument document) |
static org.eclipse.lsp4j.Range |
selectDTDDeclTagNameAt(int offset,
DOMDocument document) |
static org.eclipse.lsp4j.Range |
selectDTDElementDeclAt(int offset,
DOMDocument document) |
static org.eclipse.lsp4j.Range |
selectEndTagLocalName(DOMElement element)
Returns the range of the end tag of the given LOCAL
element name
and null otherwise. |
static org.eclipse.lsp4j.Range |
selectEndTagName(DOMElement element)
Returns the range of the end tag of the given
element name and
null otherwise. |
static org.eclipse.lsp4j.Range |
selectEndTagName(DOMElement element,
boolean localNameOnly)
Returns the range of the end tag of the given
element and null
otherwise. |
static org.eclipse.lsp4j.Range |
selectEndTagName(int offset,
DOMDocument document) |
static XMLPositionUtility.EntityReferenceRange |
selectEntityReference(int offset,
DOMDocument document)
Returns the range of the entity reference in a text node (ex : &) and
null otherwise.
|
static XMLPositionUtility.EntityReferenceRange |
selectEntityReference(int offset,
DOMDocument document,
boolean endsWithSemicolon)
Returns the range of the entity reference in a text node (ex : &) and
null otherwise.
|
static org.eclipse.lsp4j.Range |
selectFirstChild(int offset,
DOMDocument document)
Returns the range covering the first child of the node located at offset.
|
static org.eclipse.lsp4j.Range |
selectFirstNonWhitespaceText(int offset,
DOMDocument document) |
static org.eclipse.lsp4j.Range |
selectPreviousNodesEndTag(int offset,
DOMDocument document)
Finds the offset of the first tag it comes across behind the given offset.
|
static org.eclipse.lsp4j.Range |
selectRootAttributeValue(String attrName,
DOMDocument document)
Finds the root element of the given document and returns the attribute value
Range for the attribute attrName . |
static org.eclipse.lsp4j.Range |
selectRootStartTag(DOMDocument document)
Returns the range of the root start tag (excludes the '<') of the given
document and null otherwise. |
static org.eclipse.lsp4j.Range |
selectStartTagLocalName(DOMNode element)
Returns the range of a tag's local name.
|
static org.eclipse.lsp4j.Range |
selectStartTagName(DOMNode element)
Returns the range of the start tag name (excludes the '<') of the given
element and null otherwise. |
static org.eclipse.lsp4j.Range |
selectStartTagName(int offset,
DOMDocument document) |
static org.eclipse.lsp4j.Range |
selectText(DOMText text)
Returns the text content range and null otherwise.
|
static org.eclipse.lsp4j.Range |
selectTrimmedText(int offset,
DOMDocument document)
Returns the range covering the trimmed text belonging to the node located at
offset.
|
static org.eclipse.lsp4j.Range |
selectWholeTag(int offset,
DOMDocument document) |
static org.eclipse.lsp4j.Location |
toLocation(org.eclipse.lsp4j.LocationLink locationLink) |
public static org.eclipse.lsp4j.Range selectAttributeName(DOMAttr attr)
attr
- the attribute.public static org.eclipse.lsp4j.Range selectAttributeNameAt(int offset, DOMDocument document)
public static org.eclipse.lsp4j.Range selectAttributeValue(DOMAttr attr)
attr
- the attribute.public static org.eclipse.lsp4j.Range selectAttributeValueAt(String attrName, int offset, DOMDocument document)
public static org.eclipse.lsp4j.Range selectAttributeValueFromGivenValue(String attrValue, int offset, DOMDocument document)
public static org.eclipse.lsp4j.Range selectAttributeValueByGivenValueAt(String attrValue, int offset, DOMDocument document)
public static org.eclipse.lsp4j.Range selectAttributeNameFromGivenNameAt(String attrName, int offset, DOMDocument document)
public static org.eclipse.lsp4j.Range selectAttributePrefixFromGivenNameAt(String attrName, int offset, DOMDocument document)
public static org.eclipse.lsp4j.Range selectAttributeFromGivenNameAt(String attrName, int offset, DOMDocument document)
public static org.eclipse.lsp4j.Range selectAllAttributes(int offset, DOMDocument document)
public static org.eclipse.lsp4j.Range selectChildEndTag(String childTag, int offset, DOMDocument document)
public static org.eclipse.lsp4j.Range selectRootStartTag(DOMDocument document)
document
and null otherwise.document
- the DOM document.document
and null otherwise.public static org.eclipse.lsp4j.Range selectRootAttributeValue(String attrName, DOMDocument document)
Range
for the attribute attrName
.
If attrName
is not declared then null is returned.attrName
- The name of the attribute to find the range of the value fordocument
- The document to use the root element ofdocument
where the declared value of
attribute attrName
resides (including quotations), or
null if the attriubte is not declared.public static org.eclipse.lsp4j.Range selectStartTagName(int offset, DOMDocument document)
public static org.eclipse.lsp4j.Range selectStartTagName(DOMNode element)
element
and null otherwise.element
- the DOM elementelement
and null
otherwise.public static org.eclipse.lsp4j.Range selectStartTagLocalName(DOMNode element)
element
- public static int selectCurrentTagOffset(int offset, DOMDocument document)
public static org.eclipse.lsp4j.Range selectEndTagName(int offset, DOMDocument document)
public static org.eclipse.lsp4j.Range selectEndTagName(DOMElement element)
element
name and
null otherwise.element
- the DOM elementelement
and null
otherwise.public static org.eclipse.lsp4j.Range selectEndTagLocalName(DOMElement element)
element
name
and null otherwise.element
- the DOM elementelement
and null
otherwise.public static org.eclipse.lsp4j.Range selectEndTagName(DOMElement element, boolean localNameOnly)
element
and null
otherwise.element
- the DOM elementelement
and null
otherwise.public static org.eclipse.lsp4j.Range selectPreviousNodesEndTag(int offset, DOMDocument document)
This will include the tag it starts in if the offset is within a tag's content:
<a> <b> | </b> </a>
, will give </b>
<a> <b> </b> </a| <c>
, will give </a>
<a> <b|> </b> </a>
, will give </a>
public static XMLPositionUtility.EntityReferenceRange selectEntityReference(int offset, DOMDocument document)
offset
- the offsetdocument
- the documentpublic static XMLPositionUtility.EntityReferenceRange selectEntityReference(int offset, DOMDocument document, boolean endsWithSemicolon)
offset
- the offsetdocument
- the documentendsWithSemicolon
- true if the entity reference must end with ';' and
false otherwise.public static int getEntityReferenceStartOffset(String text, int offset)
text
- the XML content.offset
- the offset.public static int getEntityReferenceEndOffset(String text, int offset)
text
- the XML content.offset
- the offset.public static org.eclipse.lsp4j.Range selectFirstNonWhitespaceText(int offset, DOMDocument document)
public static org.eclipse.lsp4j.Range selectText(DOMText text)
text
- the DOM text node..public static org.eclipse.lsp4j.Range selectContent(int offset, DOMDocument document)
public static org.eclipse.lsp4j.Range selectTrimmedText(int offset, DOMDocument document)
offset
- document
- public static org.eclipse.lsp4j.Range selectDTDElementDeclAt(int offset, DOMDocument document)
public static org.eclipse.lsp4j.Range getLastValidDTDDeclParameter(int offset, DOMDocument document, boolean selectWholeParameter)
public static org.eclipse.lsp4j.Range getLastValidDTDDeclParameter(int offset, DOMDocument document)
public static org.eclipse.lsp4j.Range getLastValidDTDDeclParameterOrUnrecognized(int offset, DOMDocument document)
public static org.eclipse.lsp4j.Range getLastDTDDeclParameter(int offset, DOMDocument document)
public static org.eclipse.lsp4j.Range selectDTDDeclTagNameAt(int offset, DOMDocument document)
public static org.eclipse.lsp4j.Range getElementDeclMissingContentOrCategory(int offset, DOMDocument document)
public static org.eclipse.lsp4j.Range createRange(DOMRange range)
node
.node
- the nodenode
.public static org.eclipse.lsp4j.Range createRange(int startOffset, int endOffset, DOMDocument document)
public static org.eclipse.lsp4j.LocationLink createLocationLink(DOMRange origin, DOMRange target)
origin
and
target
nodes.origin
- the origin node.target
- the target node.origin
and
target
nodes.public static org.eclipse.lsp4j.LocationLink createLocationLink(org.eclipse.lsp4j.Range origin, DOMRange target)
origin
and
target
nodes.origin
- the origin node.target
- the target node.origin
and
target
nodes.public static org.eclipse.lsp4j.LocationLink createLocationLink(org.eclipse.lsp4j.Range origin, TargetRange target)
origin
and
target
nodes.origin
- the origin node.target
- the target node.origin
and
target
nodes.public static org.eclipse.lsp4j.Location createLocation(DOMRange target)
target
node.target
- the target node.target
node.public static org.eclipse.lsp4j.DocumentLink createDocumentLink(DOMRange target, String location, boolean adjust) throws BadLocationException
target
- The range in the document that should be the linklocation
- URI where the link should pointadjust
- true
means the first and last character of
target
will not be a part of the link.target
that points to
location
.BadLocationException
- if target
is out of the bounds of
the documentpublic static org.eclipse.lsp4j.Range selectFirstChild(int offset, DOMDocument document)
offset
- document
- public static org.eclipse.lsp4j.Range selectWholeTag(int offset, DOMDocument document)
public static boolean doesTagCoverPosition(org.eclipse.lsp4j.Range startTagRange, org.eclipse.lsp4j.Range endTagRange, org.eclipse.lsp4j.Position position)
public static boolean covers(org.eclipse.lsp4j.Range range, org.eclipse.lsp4j.Position position)
public static boolean isBeforeOrEqual(org.eclipse.lsp4j.Position pos1, org.eclipse.lsp4j.Position pos2)
public static org.eclipse.lsp4j.Range getTagNameRange(TokenType tokenType, int startOffset, DOMDocument xmlDocument)
public static org.eclipse.lsp4j.Location toLocation(org.eclipse.lsp4j.LocationLink locationLink)
public static org.eclipse.lsp4j.Position getMatchingTagPosition(DOMDocument xmlDocument, org.eclipse.lsp4j.Position position)
Copyright © 2020. All rights reserved.