From 7506761fce09b330864dc7a5fe7f511c0abe7713 Mon Sep 17 00:00:00 2001 From: Markus Schorn Date: Mon, 29 Jan 2007 10:18:56 +0000 Subject: [PATCH] Fix for 169860, port content assist to use index, by Bryan Wilkinson. --- .../CompletionTest_ArgumentType_NoPrefix.java | 4 ++-- .../CompletionTest_ArgumentType_NoPrefix2.java | 4 ++-- ...CompletionTest_ClassReference_NoPrefix.java | 4 ++-- .../CompletionTest_ClassReference_Prefix.java | 4 ++-- ...letionTest_ExceptionReference_NoPrefix.java | 4 ++-- .../CompletionTest_FieldType_NoPrefix.java | 4 ++-- .../CompletionTest_FieldType_NoPrefix2.java | 4 ++-- .../CompletionTest_NamespaceRef_NoPrefix.java | 4 ++-- .../CompletionTest_NamespaceRef_Prefix.java | 4 ++-- .../CompletionTest_TypeRef_NoPrefix.java | 4 ++-- .../CompletionTest_TypeRef_Prefix.java | 4 ++-- .../CompletionTest_VariableType_NoPrefix.java | 4 ++-- .../text/contentassist2/CompletionTests.java | 8 ++++---- .../contentassist/CCompletionProcessor2.java | 18 ++++++++++++------ .../DOMCompletionContributor.java | 10 ++++++++-- 15 files changed, 48 insertions(+), 36 deletions(-) diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTest_ArgumentType_NoPrefix.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTest_ArgumentType_NoPrefix.java index d8cf811ce73..c6c261110d7 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTest_ArgumentType_NoPrefix.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTest_ArgumentType_NoPrefix.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004 IBM Corporation and others. + * Copyright (c) 2004, 2007 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -7,6 +7,7 @@ * * Contributors: * IBM Rational Software - Initial API and implementation + * Bryan Wilkinson (QNX) *******************************************************************************/ package org.eclipse.cdt.ui.tests.text.contentassist2; @@ -42,7 +43,6 @@ public class CompletionTest_ArgumentType_NoPrefix extends CompletionProposalsBa public CompletionTest_ArgumentType_NoPrefix(String name) { super(name); // https://bugs.eclipse.org/bugs/show_bug.cgi?id=169860 - setExpectFailure(169860); } public static Test suite() { diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTest_ArgumentType_NoPrefix2.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTest_ArgumentType_NoPrefix2.java index 347c12456ce..8df6b0fea1b 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTest_ArgumentType_NoPrefix2.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTest_ArgumentType_NoPrefix2.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004 IBM Corporation and others. + * Copyright (c) 2004, 2007 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -7,6 +7,7 @@ * * Contributors: * IBM Rational Software - Initial API and implementation + * Bryan Wilkinson (QNX) *******************************************************************************/ package org.eclipse.cdt.ui.tests.text.contentassist2; @@ -42,7 +43,6 @@ public class CompletionTest_ArgumentType_NoPrefix2 extends CompletionProposalsB public CompletionTest_ArgumentType_NoPrefix2(String name) { super(name); // https://bugs.eclipse.org/bugs/show_bug.cgi?id=169860 - setExpectFailure(169860); } public static Test suite() { diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTest_ClassReference_NoPrefix.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTest_ClassReference_NoPrefix.java index 4b6910c2057..abc8112f8e6 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTest_ClassReference_NoPrefix.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTest_ClassReference_NoPrefix.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004 IBM Corporation and others. + * Copyright (c) 2004, 2007 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -7,6 +7,7 @@ * * Contributors: * IBM Rational Software - Initial API and implementation + * Bryan Wilkinson (QNX) *******************************************************************************/ package org.eclipse.cdt.ui.tests.text.contentassist2; @@ -37,7 +38,6 @@ public class CompletionTest_ClassReference_NoPrefix extends CompletionProposals public CompletionTest_ClassReference_NoPrefix(String name) { super(name); // https://bugs.eclipse.org/bugs/show_bug.cgi?id=169860 - setExpectFailure(169860); } public static Test suite() { diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTest_ClassReference_Prefix.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTest_ClassReference_Prefix.java index 69011004f87..b3c78b0f9c4 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTest_ClassReference_Prefix.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTest_ClassReference_Prefix.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2006 IBM Corporation and others. + * Copyright (c) 2004, 2007 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -7,6 +7,7 @@ * * Contributors: * IBM Corporation - initial API and implementation + * Bryan Wilkinson (QNX) *******************************************************************************/ package org.eclipse.cdt.ui.tests.text.contentassist2; @@ -35,7 +36,6 @@ public class CompletionTest_ClassReference_Prefix extends CompletionProposalsBa public CompletionTest_ClassReference_Prefix(String name) { super(name); // https://bugs.eclipse.org/bugs/show_bug.cgi?id=169860 - setExpectFailure(169860); } public static Test suite() { diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTest_ExceptionReference_NoPrefix.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTest_ExceptionReference_NoPrefix.java index 7abd3e5f4fa..1474fd12ae2 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTest_ExceptionReference_NoPrefix.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTest_ExceptionReference_NoPrefix.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004 IBM Corporation and others. + * Copyright (c) 2004, 2007 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -7,6 +7,7 @@ * * Contributors: * IBM Rational Software - Initial API and implementation + * Bryan Wilkinson (QNX) *******************************************************************************/ package org.eclipse.cdt.ui.tests.text.contentassist2; @@ -43,7 +44,6 @@ public class CompletionTest_ExceptionReference_NoPrefix extends CompletionPropo public CompletionTest_ExceptionReference_NoPrefix(String name) { super(name); // https://bugs.eclipse.org/bugs/show_bug.cgi?id=169860 - setExpectFailure(169860); } public static Test suite() { diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTest_FieldType_NoPrefix.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTest_FieldType_NoPrefix.java index 3ea35f01818..94ab44187ea 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTest_FieldType_NoPrefix.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTest_FieldType_NoPrefix.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004 IBM Corporation and others. + * Copyright (c) 2004, 2007 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -7,6 +7,7 @@ * * Contributors: * IBM Rational Software - Initial API and implementation + * Bryan Wilkinson (QNX) *******************************************************************************/ package org.eclipse.cdt.ui.tests.text.contentassist2; @@ -41,7 +42,6 @@ public class CompletionTest_FieldType_NoPrefix extends CompletionProposalsBaseT public CompletionTest_FieldType_NoPrefix(String name) { super(name); // https://bugs.eclipse.org/bugs/show_bug.cgi?id=169860 - setExpectFailure(169860); } public static Test suite() { diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTest_FieldType_NoPrefix2.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTest_FieldType_NoPrefix2.java index 0af1921f54e..6c9d0e40c2f 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTest_FieldType_NoPrefix2.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTest_FieldType_NoPrefix2.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004 IBM Corporation and others. + * Copyright (c) 2004, 2007 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -7,6 +7,7 @@ * * Contributors: * IBM Rational Software - Initial API and implementation + * Bryan Wilkinson (QNX) *******************************************************************************/ package org.eclipse.cdt.ui.tests.text.contentassist2; import junit.framework.Test; @@ -42,7 +43,6 @@ public class CompletionTest_FieldType_NoPrefix2 extends CompletionProposalsBase public CompletionTest_FieldType_NoPrefix2(String name) { super(name); // https://bugs.eclipse.org/bugs/show_bug.cgi?id=169860 - setExpectFailure(169860); } public static Test suite() { diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTest_NamespaceRef_NoPrefix.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTest_NamespaceRef_NoPrefix.java index 20a4d35a439..8dbc601e889 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTest_NamespaceRef_NoPrefix.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTest_NamespaceRef_NoPrefix.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2006 IBM Corporation and others. + * Copyright (c) 2004, 2007 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -7,6 +7,7 @@ * * Contributors: * IBM Rational Software - Initial API and implementation + * Bryan Wilkinson (QNX) *******************************************************************************/ package org.eclipse.cdt.ui.tests.text.contentassist2; import junit.framework.Test; @@ -34,7 +35,6 @@ public class CompletionTest_NamespaceRef_NoPrefix extends CompletionProposalsBa public CompletionTest_NamespaceRef_NoPrefix(String name) { super(name); // https://bugs.eclipse.org/bugs/show_bug.cgi?id=169860 - setExpectFailure(169860); } public static Test suite() { diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTest_NamespaceRef_Prefix.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTest_NamespaceRef_Prefix.java index d428176016f..162cbdc17ad 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTest_NamespaceRef_Prefix.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTest_NamespaceRef_Prefix.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2006 IBM Corporation and others. + * Copyright (c) 2004, 2007 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -7,6 +7,7 @@ * * Contributors: * IBM Rational Software - Initial API and implementation + * Bryan Wilkinson (QNX) *******************************************************************************/ package org.eclipse.cdt.ui.tests.text.contentassist2; @@ -34,7 +35,6 @@ public class CompletionTest_NamespaceRef_Prefix extends CompletionProposalsBase public CompletionTest_NamespaceRef_Prefix(String name) { super(name); // https://bugs.eclipse.org/bugs/show_bug.cgi?id=169860 - setExpectFailure(169860); } public static Test suite() { diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTest_TypeRef_NoPrefix.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTest_TypeRef_NoPrefix.java index c10120d99d6..e7dfea835b8 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTest_TypeRef_NoPrefix.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTest_TypeRef_NoPrefix.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2006 IBM Corporation and others. + * Copyright (c) 2004, 2007 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -7,6 +7,7 @@ * * Contributors: * IBM Rational Software - Initial API and implementation + * Bryan Wilkinson (QNX) *******************************************************************************/ package org.eclipse.cdt.ui.tests.text.contentassist2; import junit.framework.Test; @@ -34,7 +35,6 @@ public class CompletionTest_TypeRef_NoPrefix extends CompletionProposalsBaseTes public CompletionTest_TypeRef_NoPrefix(String name) { super(name); // https://bugs.eclipse.org/bugs/show_bug.cgi?id=169860 - setExpectFailure(169860); } public static Test suite() { diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTest_TypeRef_Prefix.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTest_TypeRef_Prefix.java index a34b8acfe0f..3c7309d241a 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTest_TypeRef_Prefix.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTest_TypeRef_Prefix.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2006 IBM Corporation and others. + * Copyright (c) 2004, 2007 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -7,6 +7,7 @@ * * Contributors: * IBM Rational Software - Initial API and implementation + * Bryan Wilkinson (QNX) *******************************************************************************/ package org.eclipse.cdt.ui.tests.text.contentassist2; @@ -34,7 +35,6 @@ public class CompletionTest_TypeRef_Prefix extends CompletionProposalsBaseTest{ public CompletionTest_TypeRef_Prefix(String name) { super(name); // https://bugs.eclipse.org/bugs/show_bug.cgi?id=169860 - setExpectFailure(169860); } public static Test suite() { diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTest_VariableType_NoPrefix.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTest_VariableType_NoPrefix.java index a0aaef4bc45..319027c1705 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTest_VariableType_NoPrefix.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTest_VariableType_NoPrefix.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004 IBM Corporation and others. + * Copyright (c) 2004, 2007 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -7,6 +7,7 @@ * * Contributors: * IBM Rational Software - Initial API and implementation + * Bryan Wilkinson (QNX) *******************************************************************************/ package org.eclipse.cdt.ui.tests.text.contentassist2; import junit.framework.Test; @@ -39,7 +40,6 @@ public class CompletionTest_VariableType_NoPrefix extends CompletionProposalsBa public CompletionTest_VariableType_NoPrefix(String name) { super(name); // https://bugs.eclipse.org/bugs/show_bug.cgi?id=169860 - setExpectFailure(169860); } public static Test suite() { diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTests.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTests.java index 26c6a17b6de..c937706f2f8 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTests.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006 Wind River Systems, Inc. and others. + * Copyright (c) 2006, 2007 Wind River Systems, Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -7,6 +7,7 @@ * * Contributors: * Anton Leherbauer (Wind River Systems) - initial API and implementation + * Bryan Wilkinson (QNX) *******************************************************************************/ package org.eclipse.cdt.ui.tests.text.contentassist2; @@ -40,7 +41,6 @@ public class CompletionTests extends AbstractCompletionTest { // //extern C1* gfC1(); //C2* gfC2(); -//static C3* gfC3(); // //enum E1 {e11, e12}; // @@ -239,7 +239,7 @@ public class CompletionTests extends AbstractCompletionTest { //void f() {gf/*cursor*/ public void testGlobalFunctions_GlobalScope() throws Exception { final String[] expected= { - "gfC1(void)", "gfC2(void)", "gfC3(void)" + "gfC1(void)", "gfC2(void)" }; assertCompletionResults(fCursorOffset, expected, true); } @@ -247,7 +247,7 @@ public class CompletionTests extends AbstractCompletionTest { //void C3::f() {gf/*cursor*/ public void testGlobalFunctions_MethodScope() throws Exception { final String[] expected= { - "gfC1(void)", "gfC2(void)", "gfC3(void)" + "gfC1(void)", "gfC2(void)" }; assertCompletionResults(fCursorOffset, expected, true); } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/CCompletionProcessor2.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/CCompletionProcessor2.java index 8f00672730f..16b951b9158 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/CCompletionProcessor2.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/CCompletionProcessor2.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2006 IBM Corporation and others. + * Copyright (c) 2004, 2007 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -7,6 +7,7 @@ * * Contributors: * IBM - Initial API and implementation + * Bryan Wilkinson (QNX) *******************************************************************************/ package org.eclipse.cdt.internal.ui.text.contentassist; @@ -29,9 +30,11 @@ import org.eclipse.jface.text.contentassist.IContextInformationValidator; import org.eclipse.ui.IEditorPart; import org.eclipse.cdt.core.CCorePlugin; +import org.eclipse.cdt.core.dom.IPDOMManager; import org.eclipse.cdt.core.dom.ast.ASTCompletionNode; import org.eclipse.cdt.core.index.IIndex; import org.eclipse.cdt.core.index.IIndexManager; +import org.eclipse.cdt.core.model.ITranslationUnit; import org.eclipse.cdt.core.model.IWorkingCopy; import org.eclipse.cdt.ui.CUIPlugin; import org.eclipse.cdt.ui.text.ICCompletionProposal; @@ -78,11 +81,14 @@ public class CCompletionProcessor2 implements IContentAssistProcessor { String prefix = null; if (workingCopy != null) { - // TODO, to improve performance, we want to skip all headers - // But right now we're not getting any completions -// fCurrentCompletionNode = workingCopy.getCompletionNode(index, ITranslationUnit.AST_SKIP_ALL_HEADERS, offset); - fCurrentCompletionNode = workingCopy.getCompletionNode(index, 0, offset); - + IPDOMManager manager = CCorePlugin.getPDOMManager(); + String indexerId = manager.getIndexerId(workingCopy.getCProject()); + int flags = ITranslationUnit.AST_SKIP_ALL_HEADERS; + if (IPDOMManager.ID_NO_INDEXER.equals(indexerId)) { + flags = 0; + } + fCurrentCompletionNode = workingCopy.getCompletionNode(index, flags, offset); + if (fCurrentCompletionNode != null) prefix = fCurrentCompletionNode.getPrefix(); } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/DOMCompletionContributor.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/DOMCompletionContributor.java index d7e78ca40b5..a0d51b5814d 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/DOMCompletionContributor.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/DOMCompletionContributor.java @@ -8,6 +8,7 @@ * Contributors: * IBM Corporation - initial API and implementation * Anton Leherbauer (Wind River Systems) + * Bryan Wilkinson (QNX) *******************************************************************************/ package org.eclipse.cdt.internal.ui.text.contentassist; @@ -23,6 +24,7 @@ import org.eclipse.cdt.core.dom.ast.ASTCompletionNode; import org.eclipse.cdt.core.dom.ast.ASTTypeUtil; import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.IASTFunctionStyleMacroParameter; +import org.eclipse.cdt.core.dom.ast.IASTIdExpression; import org.eclipse.cdt.core.dom.ast.IASTName; import org.eclipse.cdt.core.dom.ast.IASTPreprocessorFunctionStyleMacroDefinition; import org.eclipse.cdt.core.dom.ast.IASTPreprocessorMacroDefinition; @@ -48,6 +50,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespace; import org.eclipse.cdt.core.dom.ast.cpp.ICPPUsingDeclaration; import org.eclipse.cdt.core.model.IWorkingCopy; import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility; +import org.eclipse.cdt.core.parser.util.CharArrayUtils; import org.eclipse.cdt.ui.CUIPlugin; import org.eclipse.cdt.ui.text.contentassist.ICompletionContributor; @@ -61,7 +64,9 @@ public class DOMCompletionContributor implements ICompletionContributor { ASTCompletionNode completionNode, String prefix, List proposals) { + if (completionNode != null) { + boolean handleMacros = false; IASTName[] names = completionNode.getNames(); if (names == null || names.length == 0) // No names, not much we can do here @@ -74,6 +79,7 @@ public class DOMCompletionContributor implements ICompletionContributor { // The node isn't properly hooked up, must have backtracked out of this node continue; IBinding[] bindings = names[i].resolvePrefix(); + if (names[i].getParent() instanceof IASTIdExpression) handleMacros = true; if (bindings != null) for (int j = 0; j < bindings.length; ++j) { IBinding binding = bindings[j]; @@ -91,11 +97,11 @@ public class DOMCompletionContributor implements ICompletionContributor { } // Find all macros if there is a prefix - if (prefix.length() > 0) { + if (prefix.length() > 0 && handleMacros) { IASTPreprocessorMacroDefinition[] macros = completionNode.getTranslationUnit().getMacroDefinitions(); if (macros != null) for (int i = 0; i < macros.length; ++i) - if (macros[i].getName().toString().startsWith(prefix)) + if (CharArrayUtils.equals(macros[i].getName().toCharArray(), 0, prefix.length(), prefix.toCharArray(), false)) handleMacro(macros[i], completionNode, offset, viewer, proposals); } }