diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CVisitor.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CVisitor.java index 8233483fd52..1299665fcb3 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CVisitor.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CVisitor.java @@ -6,10 +6,10 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * IBM Rational Software - Initial API and implementation - * Markus Schorn (Wind River Systems) - * Bryan Wilkinson (QNX) - * Andrew Ferguson (Symbian) + * IBM Rational Software - Initial API and implementation + * Markus Schorn (Wind River Systems) + * Bryan Wilkinson (QNX) + * Andrew Ferguson (Symbian) *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser.c; @@ -1220,12 +1220,13 @@ public class CVisitor { } } else if ( parent instanceof IASTTranslationUnit ){ IASTTranslationUnit translation = (IASTTranslationUnit) parent; - if (!prefix || translation.getIndex() == null) { + if (!prefix) { nodes = translation.getDeclarations(); scope = (ICScope) translation.getScope(); } else { - //The index will be search later - nodes = null; + // The index will be search later, still we need to look at the declarations found in + // the AST, bug 180883 + nodes = translation.getDeclarations(); scope = null; } } else if( parent instanceof IASTStandardFunctionDeclarator ){ diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTests_PlainC.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTests_PlainC.java index f54731468cb..5b86e5a72ac 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTests_PlainC.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTests_PlainC.java @@ -7,6 +7,7 @@ * * Contributors: * Anton Leherbauer (Wind River Systems) - initial API and implementation + * Markus Schorn (Wind River Systems) *******************************************************************************/ package org.eclipse.cdt.ui.tests.text.contentassist2; @@ -126,7 +127,7 @@ public class CompletionTests_PlainC extends AbstractContentAssistTest { //// to_be_replaced_ //void gfunc(){aNew/*cursor*/ - public void _testGlobalVariableBeforeSave_Bug180883() throws Exception { + public void testGlobalVariableBeforeSave_Bug180883() throws Exception { String replace= "// to_be_replaced_"; String globalVar= "int aNewGlobalVar;"; IDocument doc= getDocument(); @@ -143,4 +144,13 @@ public class CompletionTests_PlainC extends AbstractContentAssistTest { assertCompletionResults(expected); } + // static int staticVar197990; + // void gFunc() { + // stat/*cursor*/ + public void testStaticVariables_Bug197990() throws Exception { + final String[] expected= { + "staticVar197990" + }; + assertCompletionResults(expected); + } }