Skip to content

Commit

Permalink
NPE when typing <?
Browse files Browse the repository at this point in the history
Fixes #614

Signed-off-by: azerr <[email protected]>
  • Loading branch information
angelozerr authored and fbricon committed Mar 9, 2020
1 parent b8bd96d commit 60d7b64
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -247,8 +247,22 @@ static DOMNode findUnclosedChildNode(String childTag, List<DOMNode> children) {
return null;
}

/**
* Returns the range of the root start tag (excludes the '<') of the given
* <code>document</code> and null otherwise.
*
* @param document the DOM document.
* @return the range of the root start tag (excludes the '<') of the given
* <code>document</code> and null otherwise.
*/
public static Range selectRootStartTag(DOMDocument document) {
DOMNode root = document.getDocumentElement();
if (root == null) {
root = document.getChild(0);
}
if (root == null) {
return null;
}
return selectStartTagName(root);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,14 @@ public void testMarkupEntityMismatch2() throws Exception {
testCodeActionsFor(xml, d, ca(d, te(0, 5, 0, 5, "</ABC>")));
}

@Test
public void testMarkupEntityMismatch3() throws Exception {
String xml = "<?";

Diagnostic d = d(0, 1, 0, 1, XMLSyntaxErrorCode.MarkupEntityMismatch);
testDiagnosticsFor(xml, d);
}

@Test
public void testMarkupNotRecognizedInContent() throws Exception {
String xml = "<GrpHdr>\r\n" + "<- almost a comment-->\r\n" + "<MsgId>2.012.001</MsgId>";
Expand Down

0 comments on commit 60d7b64

Please sign in to comment.