Skip to content

Commit

Permalink
Avoid NPE in DOMToModelConverter.toLocalVariable
Browse files Browse the repository at this point in the history
Fixes #1018
  • Loading branch information
mickaelistria committed Dec 6, 2024
1 parent 6d6f311 commit 798288e
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1183,10 +1183,12 @@ private static void setSourceRange(SourceRefElementInfo info, ASTNode node) {
private static int getStartConsideringLeadingComments(ASTNode node) {
int start = node.getStartPosition();
var unit = domUnit(node);
int index = unit.firstLeadingCommentIndex(node);
if (index >= 0 && index <= unit.getCommentList().size()) {
Comment comment = (Comment)unit.getCommentList().get(index);
start = comment.getStartPosition();
if (unit != null) {
int index = unit.firstLeadingCommentIndex(node);
if (index >= 0 && index <= unit.getCommentList().size()) {
Comment comment = (Comment)unit.getCommentList().get(index);
start = comment.getStartPosition();
}
}
return start;
}
Expand Down

0 comments on commit 798288e

Please sign in to comment.