diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/DOMToModelPopulator.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/DOMToModelPopulator.java index 9065d064ba6..c21361574f5 100644 --- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/DOMToModelPopulator.java +++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/DOMToModelPopulator.java @@ -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; }