From 64bae1cd1176b32df6b39fe990bb8a44475c4e24 Mon Sep 17 00:00:00 2001 From: Markus Schorn Date: Mon, 2 Nov 2009 13:36:18 +0000 Subject: [PATCH] F3 on built-in macro throws NPE, bug 293864. --- .../text/selection/CSelectionTestsAnyIndexer.java | 12 ++++++++++++ .../ui/search/actions/OpenDeclarationsJob.java | 3 +++ 2 files changed, 15 insertions(+) diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selection/CSelectionTestsAnyIndexer.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selection/CSelectionTestsAnyIndexer.java index 5686c3f380e..85ae30b3334 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selection/CSelectionTestsAnyIndexer.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selection/CSelectionTestsAnyIndexer.java @@ -547,4 +547,16 @@ public abstract class CSelectionTestsAnyIndexer extends BaseSelectionTestsIndexe assertTrue(name.isDefinition()); assertEquals("myFunc", name.toString()); } + + // int x= __LINE__; + public void testBuiltinMacro_Bug293864() throws Exception { + final StringBuffer[] contents = getContentsForTest(1); + String code= contents[0].toString(); + IFile file = importFile("source.c", code); + int offset= code.indexOf("__LINE__"); + + TestSourceReader.waitUntilFileIsIndexed(index, file, MAX_WAIT_TIME); + // just make sure that no NPE is thrown. + testF3(file, offset); + } } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/OpenDeclarationsJob.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/OpenDeclarationsJob.java index 65c20514b30..7cb71886aa3 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/OpenDeclarationsJob.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/OpenDeclarationsJob.java @@ -394,6 +394,9 @@ class OpenDeclarationsJob extends Job implements ASTRunnable { } private boolean isSameName(IName n1, IName n2) { + if (n1 == n2) + return true; + IASTFileLocation loc1 = n1.getFileLocation(); IASTFileLocation loc2 = n2.getFileLocation(); if (loc1 == null || loc2 == null)