From f767541c1200fd6082d58fc331307a7f0ff02167 Mon Sep 17 00:00:00 2001 From: Anton Leherbauer Date: Fri, 11 Jan 2008 10:32:19 +0000 Subject: [PATCH] Fix for 199598: [content assist] enumeration missing from proposals in qualified name (Patch by Ed Swartz) --- .../core/dom/parser/cpp/CPPASTQualifiedName.java | 5 +++-- .../tests/text/contentassist/ContentAssistTests.java | 7 +++++-- .../tests/text/contentassist2/CompletionTests.java | 12 +++++++++++- 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTQualifiedName.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTQualifiedName.java index 00716bbd0cc..85b19f1f726 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTQualifiedName.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTQualifiedName.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2007 IBM Corporation and others. + * Copyright (c) 2004, 2008 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 @@ -23,6 +23,7 @@ import org.eclipse.cdt.core.dom.ast.IASTNode; import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration; import org.eclipse.cdt.core.dom.ast.IBinding; import org.eclipse.cdt.core.dom.ast.IEnumerator; +import org.eclipse.cdt.core.dom.ast.IEnumeration; import org.eclipse.cdt.core.dom.ast.IField; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTConversionName; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTOperatorName; @@ -301,7 +302,7 @@ public class CPPASTQualifiedName extends CPPASTNode implements } else if (bindings[i] instanceof ICPPClassType) { ICPPClassType type = (ICPPClassType) bindings[i]; if (type.isSameType(classType)) continue; - } else if (!(bindings[i] instanceof IEnumerator) || isDeclaration) { + } else if (!(bindings[i] instanceof IEnumerator || bindings[i] instanceof IEnumeration) || isDeclaration) { continue; } diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist/ContentAssistTests.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist/ContentAssistTests.java index 4b975119a8e..dc921823da3 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist/ContentAssistTests.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist/ContentAssistTests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2007 IBM Corporation and others. + * Copyright (c) 2004, 2008 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 @@ -221,10 +221,13 @@ public class ContentAssistTests extends BaseUITestCase { cu = importFile( "strategy.cpp", c2 ); //$NON-NLS-1$ results = getResults( cu, c2.indexOf( "::" ) + 2 ); //$NON-NLS-1$ - assertEquals( 3, results.length ); + assertEquals( 4, results.length ); assertEquals( "CHEAT", results[0].getDisplayString() ); //$NON-NLS-1$ assertEquals( "IDIOT", results[1].getDisplayString() ); //$NON-NLS-1$ assertEquals( "NORMAL", results[2].getDisplayString() ); //$NON-NLS-1$ + // "_Ability" is here due to fix for bug 199598 + // Difficult to differentiate between declaration and expression context + assertEquals( "_Ability", results[3].getDisplayString() ); //$NON-NLS-1$ // in a method definition context, constructors and methods should be proposed 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 a7a4d991d0f..723972c5785 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, 2007 Wind River Systems, Inc. and others. + * Copyright (c) 2006, 2008 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 @@ -885,6 +885,16 @@ public class CompletionTests extends AbstractContentAssistTest { assertCompletionResults(fCursorOffset, expected, AbstractContentAssistTest.COMPARE_REP_STRINGS); } + // void test() { + // C1::/*cursor*/ + public void testEnumInClass_bug199598() throws Exception { + // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=199598 + final String[] expected= { + "E2", "e21", "e22" + }; + assertCompletionResults(fCursorOffset, expected, AbstractContentAssistTest.COMPARE_ID_STRINGS); + } + // class Union/*cursor*/ public void testElaboratedTypeSpecifierNotClass2_bug208710() throws Exception { final String[] expected= new String[0];