1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-29 20:05:35 +02:00

- fix bug 60928 - content assist and member definitions

- also fix bug related to the display string for constructor content assist completions
This commit is contained in:
Andrew Niefer 2004-05-11 21:37:37 +00:00
parent d4a7d540c2
commit 9446e713c1
8 changed files with 36 additions and 19 deletions

View file

@ -1,3 +1,7 @@
2004-05-11 Andrew Niefer
Renamed CompletionFailedTest_ScopedReference_ConstructorDefinition to CompletionTest_VariableType_NestedPrefix
Modified expected results for CompletionTest_ConstructorReference
2004-04-30 Hoda Amer 2004-04-30 Hoda Amer
Added CompletionFailedTest_ScopedReference_ConstructorDefinition Added CompletionFailedTest_ScopedReference_ConstructorDefinition
Added CompletionTest_ScopedReference_NonCodeScope Added CompletionTest_ScopedReference_NonCodeScope

View file

@ -1,6 +1,7 @@
class Foo{ class Foo{
public: public:
Foo(); Foo();
class DEF{};
void bar(); void bar();
static void fum(); static void fum();
static int x; static int x;

View file

@ -9,7 +9,7 @@ import junit.framework.Test;
import junit.framework.TestSuite; import junit.framework.TestSuite;
import org.eclipse.cdt.ui.tests.text.contentassist.CompletionFailedTest_MemberReference_Arrow_Prefix2; import org.eclipse.cdt.ui.tests.text.contentassist.CompletionFailedTest_MemberReference_Arrow_Prefix2;
import org.eclipse.cdt.ui.tests.text.contentassist.CompletionFailedTest_ScopedReference_ConstructorDefinition; import org.eclipse.cdt.ui.tests.text.contentassist.CompletionTest_VariableType_NestedPrefix;
import org.eclipse.cdt.ui.tests.text.contentassist.CompletionTest_ArgumentType_NoPrefix; import org.eclipse.cdt.ui.tests.text.contentassist.CompletionTest_ArgumentType_NoPrefix;
import org.eclipse.cdt.ui.tests.text.contentassist.CompletionTest_ArgumentType_NoPrefix2; import org.eclipse.cdt.ui.tests.text.contentassist.CompletionTest_ArgumentType_NoPrefix2;
import org.eclipse.cdt.ui.tests.text.contentassist.CompletionTest_ArgumentType_Prefix; import org.eclipse.cdt.ui.tests.text.contentassist.CompletionTest_ArgumentType_Prefix;
@ -44,6 +44,7 @@ import org.eclipse.cdt.ui.tests.text.contentassist.CompletionTest_SingleName_Pre
import org.eclipse.cdt.ui.tests.text.contentassist.CompletionTest_TypeDef_NoPrefix; import org.eclipse.cdt.ui.tests.text.contentassist.CompletionTest_TypeDef_NoPrefix;
import org.eclipse.cdt.ui.tests.text.contentassist.CompletionTest_TypeRef_NoPrefix; import org.eclipse.cdt.ui.tests.text.contentassist.CompletionTest_TypeRef_NoPrefix;
import org.eclipse.cdt.ui.tests.text.contentassist.CompletionTest_TypeRef_Prefix; import org.eclipse.cdt.ui.tests.text.contentassist.CompletionTest_TypeRef_Prefix;
import org.eclipse.cdt.ui.tests.text.contentassist.CompletionTest_VariableType_NestedPrefix;
import org.eclipse.cdt.ui.tests.text.contentassist.CompletionTest_VariableType_NoPrefix; import org.eclipse.cdt.ui.tests.text.contentassist.CompletionTest_VariableType_NoPrefix;
import org.eclipse.cdt.ui.tests.text.contentassist.CompletionTest_VariableType_Prefix; import org.eclipse.cdt.ui.tests.text.contentassist.CompletionTest_VariableType_Prefix;
import org.eclipse.cdt.ui.tests.textmanipulation.TextBufferTest; import org.eclipse.cdt.ui.tests.textmanipulation.TextBufferTest;
@ -109,10 +110,10 @@ public class AutomatedSuite extends TestSuite {
addTest(CompletionTest_FunctionReference_NoPrefix.suite()); addTest(CompletionTest_FunctionReference_NoPrefix.suite());
addTest(CompletionTest_ConstructorReference.suite()); addTest(CompletionTest_ConstructorReference.suite());
addTest(CompletionTest_TypeDef_NoPrefix.suite()); addTest(CompletionTest_TypeDef_NoPrefix.suite());
addTest(CompletionTest_VariableType_NestedPrefix.suite());
// Failed Tests // Failed Tests
addTest(CompletionFailedTest_MemberReference_Arrow_Prefix2.suite()); addTest(CompletionFailedTest_MemberReference_Arrow_Prefix2.suite());
addTest(CompletionFailedTest_ScopedReference_ConstructorDefinition.suite());
} }
} }

View file

@ -35,9 +35,8 @@ public class CompletionTest_ConstructorReference extends CompletionProposalsBas
private final CompletionKind expectedKind = CompletionKind.CONSTRUCTOR_REFERENCE; private final CompletionKind expectedKind = CompletionKind.CONSTRUCTOR_REFERENCE;
private final String expectedPrefix = ""; private final String expectedPrefix = "";
private final String[] expectedResults = { private final String[] expectedResults = {
// should be "xOtherClass(char*)",
// "xOtherClass(char*)", "xOtherClass(int)"
// "xOtherClass(int)"
}; };
public CompletionTest_ConstructorReference(String name) { public CompletionTest_ConstructorReference(String name) {

View file

@ -21,7 +21,7 @@ import org.eclipse.cdt.core.parser.ast.IASTCompletionNode.CompletionKind;
* Bug#50152: Wrong context sent after a "::" * Bug#50152: Wrong context sent after a "::"
* *
*/ */
public class CompletionFailedTest_ScopedReference_ConstructorDefinition extends CompletionProposalsBaseTest{ public class CompletionTest_VariableType_NestedPrefix extends CompletionProposalsBaseTest{
private final String fileName = "CompletionTestStart38.cpp"; private final String fileName = "CompletionTestStart38.cpp";
private final String fileFullPath ="resources/contentassist/" + fileName; private final String fileFullPath ="resources/contentassist/" + fileName;
@ -29,19 +29,20 @@ public class CompletionFailedTest_ScopedReference_ConstructorDefinition extends
private final String headerFileFullPath ="resources/contentassist/" + headerFileName; private final String headerFileFullPath ="resources/contentassist/" + headerFileName;
private final String expectedScopeName = "ASTCompilationUnit"; private final String expectedScopeName = "ASTCompilationUnit";
private final String expectedContextName = "ASTClassSpecifier"; private final String expectedContextName = "ASTClassSpecifier";
private final CompletionKind expectedKind = CompletionKind.VARIABLE_TYPE; // should be CompletionKind.CONSTRUCTOR_REFERENCE private final CompletionKind expectedKind = CompletionKind.VARIABLE_TYPE;
private final String expectedPrefix = ""; private final String expectedPrefix = "";
private final String[] expectedResults = { private final String[] expectedResults = {
// "Foo()" "Foo()",
"DEF"
}; };
public CompletionFailedTest_ScopedReference_ConstructorDefinition(String name) { public CompletionTest_VariableType_NestedPrefix(String name) {
super(name); super(name);
} }
public static Test suite() { public static Test suite() {
TestSuite suite= new TestSuite(CompletionFailedTest_ScopedReference_ConstructorDefinition.class.getName()); TestSuite suite= new TestSuite(CompletionTest_VariableType_NestedPrefix.class.getName());
suite.addTest(new CompletionFailedTest_ScopedReference_ConstructorDefinition("testCompletionProposals")); suite.addTest(new CompletionTest_VariableType_NestedPrefix("testCompletionProposals"));
return suite; return suite;
} }

View file

@ -1,3 +1,8 @@
2004-05-11 Andrew Niefer
- content assist bug 60298:
* src/org/eclipse/cdt/internal/ui/text/contentassist/CompletionEngine.java
* src/org/eclipse/cdt/ui/FunctionPrototypeSummary.java
2004-05-11 Alain Magloire 2004-05-11 Alain Magloire
Preliminary work to get Parser IProblem in the CEditor. Preliminary work to get Parser IProblem in the CEditor.

View file

@ -565,8 +565,14 @@ public class CompletionEngine implements RelevanceConstants {
} }
} }
private void completionOnVariableType(IASTCompletionNode completionNode){ private void completionOnVariableType(IASTCompletionNode completionNode){
// 1. basic completion on all types IASTNode.LookupKind[] kinds = new IASTNode.LookupKind[5];
completionOnTypeReference(completionNode); kinds[0] = IASTNode.LookupKind.STRUCTURES;
kinds[1] = IASTNode.LookupKind.ENUMERATIONS;
kinds[2] = IASTNode.LookupKind.NAMESPACES;
kinds[3] = IASTNode.LookupKind.TYPEDEFS;
kinds[4] = IASTNode.LookupKind.CONSTRUCTORS;
ILookupResult result = lookup(completionNode.getCompletionScope(), completionNode.getCompletionPrefix(), kinds, completionNode.getCompletionContext(), null);
addToCompletions(result);
} }
private void completionOnSingleNameReference(IASTCompletionNode completionNode){ private void completionOnSingleNameReference(IASTCompletionNode completionNode){
@ -781,11 +787,11 @@ public class CompletionEngine implements RelevanceConstants {
} }
} }
else if(kind == CompletionKind.VARIABLE_TYPE) { else if(kind == CompletionKind.VARIABLE_TYPE) {
if (completionNode.getCompletionContext() == null){ if (completionNode.getCompletionContext() != null){
// CompletionOnVariableType // CompletionOnVariableType
completionOnVariableType(completionNode); completionOnVariableType(completionNode);
}else { }else {
completionOnScopedReference(completionNode); completionOnTypeReference( completionNode );
} }
} }
else if(kind == CompletionKind.ARGUMENT_TYPE){ else if(kind == CompletionKind.ARGUMENT_TYPE){

View file

@ -14,7 +14,7 @@ public class FunctionPrototypeSummary implements IFunctionSummary.IFunctionProto
* @param The string describing the prototype which is properly * @param The string describing the prototype which is properly
* formed with following format -- returntype function(arguments) * formed with following format -- returntype function(arguments)
* The following formats will be converted as follows: * The following formats will be converted as follows:
* function(arguments) --> void function(arguments) * function(arguments) --> function(arguments) //constructors!
* returntype function --> returntype function() * returntype function --> returntype function()
* function --> void function() * function --> void function()
*/ */
@ -55,8 +55,8 @@ public class FunctionPrototypeSummary implements IFunctionSummary.IFunctionProto
fname = proto.substring(namestart, nameend + 1).trim(); fname = proto.substring(namestart, nameend + 1).trim();
if(namestart == 0) { if(namestart == 0) {
//@@@ Should this be int instead? //Constructors are like this, don't stick a type on them.
freturn = "void"; //$NON-NLS-1$ freturn = ""; //$NON-NLS-1$
} else { } else {
freturn = proto.substring(0, namestart).trim(); freturn = proto.substring(0, namestart).trim();
} }
@ -90,7 +90,7 @@ public class FunctionPrototypeSummary implements IFunctionSummary.IFunctionProto
buffer.append(getArguments()); buffer.append(getArguments());
} }
buffer.append(")"); //$NON-NLS-1$ buffer.append(")"); //$NON-NLS-1$
if((namefirst) && (appendReturnType) ) { if((namefirst) && (appendReturnType) && getReturnType().length() > 0 ) {
buffer.append(" "); //$NON-NLS-1$ buffer.append(" "); //$NON-NLS-1$
buffer.append(getReturnType()); buffer.append(getReturnType());
} }