From 6fc37b10e7798e15bd57ac68bc3dc1787fb0b6df Mon Sep 17 00:00:00 2001 From: Nathan Ridge Date: Sat, 24 Jan 2015 05:23:26 -0500 Subject: [PATCH] Bug 458317 - Fix an NPE in MethodHighlighting.consumes() Change-Id: I6a88e26aa60d57dd8c95079672ce0c1ceff8b3d7 Signed-off-by: Nathan Ridge --- .../cdt/ui/tests/text/SemanticHighlightingTest.java | 8 ++++++++ .../cdt/internal/ui/editor/SemanticHighlightings.java | 9 ++++++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/SemanticHighlightingTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/SemanticHighlightingTest.java index 482d09ebb11..85ac7c5a5fd 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/SemanticHighlightingTest.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/SemanticHighlightingTest.java @@ -426,4 +426,12 @@ public class SemanticHighlightingTest extends TestCase { public void testCStructureName_451772() throws Exception { makeAssertions(false /* parse as C file */); } + + // template //$templateParameter + // void foo(T t) { //$functionDeclaration,templateParameter,parameterVariable + // bar(t); //$function,parameterVariable + // } + public void testNPE_458317() throws Exception { + makeAssertions(); + } } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/SemanticHighlightings.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/SemanticHighlightings.java index f99ca12ef61..24bb7e67790 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/SemanticHighlightings.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/SemanticHighlightings.java @@ -486,9 +486,12 @@ public class SemanticHighlightings { if (binding instanceof ICPPMethod) { return true; } else if (binding instanceof ICPPDeferredFunction) { - for (ICPPFunction candidate : ((ICPPDeferredFunction) binding).getCandidates()) { - if (candidate instanceof ICPPMethod) { - return true; + ICPPFunction[] candidates = ((ICPPDeferredFunction) binding).getCandidates(); + if (candidates != null) { + for (ICPPFunction candidate : candidates) { + if (candidate instanceof ICPPMethod) { + return true; + } } } }