From ea5c574962a1eefbcf1e7ccab66a1fe8d1813038 Mon Sep 17 00:00:00 2001 From: Mickael Istria Date: Wed, 3 Apr 2024 16:56:13 +0200 Subject: [PATCH] Fix NPE in SourceRangeVerifier (when debugging) Some nodes may return null for structuralFeatures if those nodes are usually not available at given AST/Preview level (eg StringTemplateExpression.propertyDescriptors(apiLevel, previewEnabled). So let's handle this possible null case more gracefully. --- .../org/eclipse/jdt/internal/core/dom/SourceRangeVerifier.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/org.eclipse.jdt.core/dom/org/eclipse/jdt/internal/core/dom/SourceRangeVerifier.java b/org.eclipse.jdt.core/dom/org/eclipse/jdt/internal/core/dom/SourceRangeVerifier.java index e558aab2820..56929dbd3ec 100644 --- a/org.eclipse.jdt.core/dom/org/eclipse/jdt/internal/core/dom/SourceRangeVerifier.java +++ b/org.eclipse.jdt.core/dom/org/eclipse/jdt/internal/core/dom/SourceRangeVerifier.java @@ -57,6 +57,9 @@ public boolean preVisit2(ASTNode node) { ASTNode previous = null; List properties = node.structuralPropertiesForType(); + if (properties == null) { // happens for some nodes that aren't usually available at AST level + return false; + } for (Object p : properties) { StructuralPropertyDescriptor property = (StructuralPropertyDescriptor) p; if (property.isChildProperty()) {