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 new file mode 100644 index 00000000000..d3b869c0a49 --- /dev/null +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTest_TypeRef_NoPrefix.java @@ -0,0 +1,138 @@ +/******************************************************************************* + * Copyright (c) 2004 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 + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Rational Software - Initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.ui.tests.text.contentassist2; +import junit.framework.Test; +import junit.framework.TestSuite; + +import org.eclipse.cdt.core.parser.ast.IASTCompletionNode.CompletionKind; + +/** + * @author hamer + * + * Testing Type_Reference, with no prefix + * Bug#50471 : Wrong completion kind after the "using" keyword + * + */ +public class CompletionTest_TypeRef_NoPrefix extends CompletionProposalsBaseTest{ + + private final String fileName = "CompletionTestStart24.cpp"; + private final String fileFullPath ="resources/contentassist/" + fileName; + private final String headerFileName = "CompletionTestStart.h"; + private final String headerFileFullPath ="resources/contentassist/" + headerFileName; + private final String expectedScopeName = "ASTCompilationUnit"; + private final String expectedContextName = "null"; + private final CompletionKind expectedKind = CompletionKind.TYPE_REFERENCE; + private final String expectedPrefix = "EOC" ; // ""; FIXME: Why does the CompletionNode have 'EOC' as expected prefix? + private final String[] expectedResults = { + "aNamespace", + "xNamespace" + /* FIXME: Additional results which should not be there. Run with trace enabled to reproduce: +Result: aClass +Result: aFirstEnum +Result: aFunction(void) bool +Result: anEnumeration +Result: anotherClass +Result: anotherFunction(void) void +Result: aSecondEnum +Result: AStruct +Result: aThirdEnum +Result: aVariable : int +Result: xEnumeration +Result: xFirstEnum +Result: xFunction(void) bool +Result: xOtherClass +Result: xOtherFunction(void) void +Result: xSecondEnum +Result: XStruct +Result: xThirdEnum +Result: xVariable : int + */ }; + + public CompletionTest_TypeRef_NoPrefix(String name) { + super(name); + } + + public static Test suite() { + TestSuite suite= new TestSuite(CompletionTest_TypeRef_NoPrefix.class.getName()); + suite.addTest(new CompletionTest_TypeRef_NoPrefix("testCompletionProposals")); + return suite; + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.core.codeassist.tests.CompletionProposalsTest#getCompletionPosition() + */ + protected int getCompletionPosition() { + return getBuffer().indexOf("using ") + 6; + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.core.codeassist.tests.CompletionProposalsTest#getExpectedScope() + */ + protected String getExpectedScopeClassName() { + return expectedScopeName; + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.core.codeassist.tests.CompletionProposalsTest#getExpectedContext() + */ + protected String getExpectedContextClassName() { + return expectedContextName; + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.core.codeassist.tests.CompletionProposalsTest#getExpectedKind() + */ + protected CompletionKind getExpectedKind() { + return expectedKind; + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.core.codeassist.tests.CompletionProposalsTest#getExpectedPrefix() + */ + protected String getExpectedPrefix() { + return expectedPrefix; + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.core.codeassist.tests.CompletionProposalsTest#getExpectedResultsValues() + */ + protected String[] getExpectedResultsValues() { + return expectedResults; + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.core.codeassist.tests.CompletionProposalsTest#getFileName() + */ + protected String getFileName() { + return fileName; + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.core.codeassist.tests.CompletionProposalsTest#getFileFullPath() + */ + protected String getFileFullPath() { + return fileFullPath; + } + /* (non-Javadoc) + * @see org.eclipse.cdt.core.codeassist.tests.CompletionProposalsTest#getHeaderFileFullPath() + */ + protected String getHeaderFileFullPath() { + return headerFileFullPath; + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.core.codeassist.tests.CompletionProposalsTest#getHeaderFileName() + */ + protected String getHeaderFileName() { + return headerFileName; + } + +} 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 new file mode 100644 index 00000000000..a372a0c1747 --- /dev/null +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTest_TypeRef_Prefix.java @@ -0,0 +1,129 @@ +/******************************************************************************* + * Copyright (c) 2004 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 + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Rational Software - Initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.ui.tests.text.contentassist2; + +import junit.framework.Test; +import junit.framework.TestSuite; + +import org.eclipse.cdt.core.parser.ast.IASTCompletionNode.CompletionKind; + +/** + * @author hamer + * + * Testing Type_Reference, with prefix + * Bug#50471 : Wrong completion kind after the "using" keyword + * + */ +public class CompletionTest_TypeRef_Prefix extends CompletionProposalsBaseTest{ + + private final String fileName = "CompletionTestStart25.cpp"; + private final String fileFullPath ="resources/contentassist/" + fileName; + private final String headerFileName = "CompletionTestStart.h"; + private final String headerFileFullPath ="resources/contentassist/" + headerFileName; + private final String expectedScopeName = "ASTCompilationUnit"; + private final String expectedContextName = "null"; + private final CompletionKind expectedKind = CompletionKind.TYPE_REFERENCE; + private final String expectedPrefix = "a"; + private final String[] expectedResults = { + "aNamespace" + /* FIXME: Additional results which should not be there. Run with trace enabled to reproduce: +Result: aClass +Result: aFirstEnum +Result: aFunction(void) bool +Result: anEnumeration +Result: anotherClass +Result: anotherFunction(void) void +Result: aSecondEnum +Result: aThirdEnum +Result: author - author name +Result: aVariable : int + */ }; + + public CompletionTest_TypeRef_Prefix(String name) { + super(name); + } + + public static Test suite() { + TestSuite suite= new TestSuite(CompletionTest_TypeRef_Prefix.class.getName()); + suite.addTest(new CompletionTest_TypeRef_Prefix("testCompletionProposals")); + return suite; + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.core.codeassist.tests.CompletionProposalsTest#getCompletionPosition() + */ + protected int getCompletionPosition() { + return getBuffer().indexOf("using a ") + 7; + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.core.codeassist.tests.CompletionProposalsTest#getExpectedScope() + */ + protected String getExpectedScopeClassName() { + return expectedScopeName; + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.core.codeassist.tests.CompletionProposalsTest#getExpectedContext() + */ + protected String getExpectedContextClassName() { + return expectedContextName; + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.core.codeassist.tests.CompletionProposalsTest#getExpectedKind() + */ + protected CompletionKind getExpectedKind() { + return expectedKind; + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.core.codeassist.tests.CompletionProposalsTest#getExpectedPrefix() + */ + protected String getExpectedPrefix() { + return expectedPrefix; + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.core.codeassist.tests.CompletionProposalsTest#getExpectedResultsValues() + */ + protected String[] getExpectedResultsValues() { + return expectedResults; + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.core.codeassist.tests.CompletionProposalsTest#getFileName() + */ + protected String getFileName() { + return fileName; + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.core.codeassist.tests.CompletionProposalsTest#getFileFullPath() + */ + protected String getFileFullPath() { + return fileFullPath; + } + /* (non-Javadoc) + * @see org.eclipse.cdt.core.codeassist.tests.CompletionProposalsTest#getHeaderFileFullPath() + */ + protected String getHeaderFileFullPath() { + return headerFileFullPath; + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.core.codeassist.tests.CompletionProposalsTest#getHeaderFileName() + */ + protected String getHeaderFileName() { + return headerFileName; + } + +}