mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Content Assist Work: More JUnit tests
This commit is contained in:
parent
52351e60d8
commit
069a0e8535
10 changed files with 292 additions and 1 deletions
|
@ -1,3 +1,7 @@
|
||||||
|
2004-01-17 Hoda Amer
|
||||||
|
Added IASTCompletionNode.CompletionKind.New_Type_Reference
|
||||||
|
for a completion kind after a new expression.
|
||||||
|
|
||||||
2004-01-27 Andrew Niefer
|
2004-01-27 Andrew Niefer
|
||||||
Updates to handle _Bool
|
Updates to handle _Bool
|
||||||
- modified CompleteParseASTFactory.getParameterTypeInfo
|
- modified CompleteParseASTFactory.getParameterTypeInfo
|
||||||
|
|
|
@ -70,6 +70,9 @@ public interface IASTCompletionNode {
|
||||||
// the beginning of a statement
|
// the beginning of a statement
|
||||||
public static final CompletionKind STATEMENT_START = new CompletionKind( 16 );
|
public static final CompletionKind STATEMENT_START = new CompletionKind( 16 );
|
||||||
|
|
||||||
|
// after a new expression
|
||||||
|
public static final CompletionKind NEW_TYPE_REFERENCE = new CompletionKind( 17 );
|
||||||
|
|
||||||
// error condition -- a place in the grammar where there is nothing to lookup
|
// error condition -- a place in the grammar where there is nothing to lookup
|
||||||
public static final CompletionKind NO_SUCH_KIND = new CompletionKind( 200 );
|
public static final CompletionKind NO_SUCH_KIND = new CompletionKind( 200 );
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1,3 +1,6 @@
|
||||||
|
2004-01-27 Hoda Amer
|
||||||
|
More Completion JUnit tests.
|
||||||
|
|
||||||
2004-01-26 Hoda Amer
|
2004-01-26 Hoda Amer
|
||||||
More Completion JUnit tests.
|
More Completion JUnit tests.
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
#include "CompletionTestStart.h"
|
||||||
|
|
||||||
|
void anotherClass::anotherMethod()
|
||||||
|
{
|
||||||
|
aClass myClass = new a
|
||||||
|
}
|
|
@ -0,0 +1,7 @@
|
||||||
|
#include "CompletionTestStart.h"
|
||||||
|
|
||||||
|
void anotherClass::anotherMethod()
|
||||||
|
{
|
||||||
|
aClass myClass = new
|
||||||
|
}
|
||||||
|
|
|
@ -68,6 +68,8 @@ public class AutomatedSuite extends TestSuite {
|
||||||
addTest(CompletionFailedTest_ClassReference_Prefix_Bug50621.suite());
|
addTest(CompletionFailedTest_ClassReference_Prefix_Bug50621.suite());
|
||||||
addTest(CompletionFailedTest_ExceptionReference_NoPrefix_Bug50640.suite());
|
addTest(CompletionFailedTest_ExceptionReference_NoPrefix_Bug50640.suite());
|
||||||
addTest(CompletionFailedTest_ExceptionReference_Prefix_Bug50640.suite());
|
addTest(CompletionFailedTest_ExceptionReference_Prefix_Bug50640.suite());
|
||||||
|
addTest(CompletionFailedTest_NewTypeReference_NoPrefix_Bug50711.suite());
|
||||||
|
addTest(CompletionFailedTest_NewTypeReference_Prefix_Bug50711.suite());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,120 @@
|
||||||
|
/**********************************************************************
|
||||||
|
* Copyright (c) 2004 Rational Software Corporation and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Common Public License v0.5
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/cpl-v05.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* IBM Rational Software - Initial API and implementation
|
||||||
|
***********************************************************************/
|
||||||
|
package org.eclipse.cdt.ui.tests.text.contentassist.failedtests;
|
||||||
|
|
||||||
|
import junit.framework.Test;
|
||||||
|
import junit.framework.TestSuite;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTCompletionNode.CompletionKind;
|
||||||
|
import org.eclipse.cdt.ui.tests.text.contentassist.CompletionProposalsBaseTest;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author hamer
|
||||||
|
*
|
||||||
|
* Testing Class_Reference, with prefix
|
||||||
|
* Bug#50711 : Wrong completion kind in a new expression
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class CompletionFailedTest_NewTypeReference_NoPrefix_Bug50711 extends CompletionProposalsBaseTest{
|
||||||
|
|
||||||
|
private final String fileName = "CompletionFailedTestStart12.cpp";
|
||||||
|
private final String fileFullPath ="resources/contentassist/failedtests/" + fileName;
|
||||||
|
private final String headerFileName = "CompletionTestStart.h";
|
||||||
|
private final String headerFileFullPath ="resources/contentassist/" + headerFileName;
|
||||||
|
private final String expectedScopeName = "ASTMethod";
|
||||||
|
private final String expectedContextName = "null"; // should be "ASTClassSpecifier"
|
||||||
|
private final CompletionKind expectedKind = CompletionKind.SINGLE_NAME_REFERENCE; // sould be CompletionKind.NEW_TYPE_REFERENCE;
|
||||||
|
private final String expectedPrefix = "";
|
||||||
|
private final String[] expectedResults = {
|
||||||
|
// should be
|
||||||
|
// "aClass"
|
||||||
|
};
|
||||||
|
|
||||||
|
public CompletionFailedTest_NewTypeReference_NoPrefix_Bug50711(String name) {
|
||||||
|
super(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Test suite() {
|
||||||
|
TestSuite suite= new TestSuite(CompletionFailedTest_NewTypeReference_NoPrefix_Bug50711.class.getName());
|
||||||
|
suite.addTest(new CompletionFailedTest_NewTypeReference_NoPrefix_Bug50711("testCompletionProposals"));
|
||||||
|
return suite;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.codeassist.tests.CompletionProposalsTest#getCompletionPosition()
|
||||||
|
*/
|
||||||
|
protected int getCompletionPosition() {
|
||||||
|
return getBuffer().indexOf(" ") + 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,124 @@
|
||||||
|
/**********************************************************************
|
||||||
|
* Copyright (c) 2004 Rational Software Corporation and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Common Public License v0.5
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/cpl-v05.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* IBM Rational Software - Initial API and implementation
|
||||||
|
***********************************************************************/
|
||||||
|
package org.eclipse.cdt.ui.tests.text.contentassist.failedtests;
|
||||||
|
|
||||||
|
import junit.framework.Test;
|
||||||
|
import junit.framework.TestSuite;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTCompletionNode.CompletionKind;
|
||||||
|
import org.eclipse.cdt.ui.tests.text.contentassist.CompletionProposalsBaseTest;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author hamer
|
||||||
|
*
|
||||||
|
* Testing Class_Reference, with prefix
|
||||||
|
* Bug#50711 : Wrong completion kind in a new expression
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class CompletionFailedTest_NewTypeReference_Prefix_Bug50711 extends CompletionProposalsBaseTest{
|
||||||
|
|
||||||
|
private final String fileName = "CompletionFailedTestStart11.cpp";
|
||||||
|
private final String fileFullPath ="resources/contentassist/failedtests/" + fileName;
|
||||||
|
private final String headerFileName = "CompletionTestStart.h";
|
||||||
|
private final String headerFileFullPath ="resources/contentassist/" + headerFileName;
|
||||||
|
private final String expectedScopeName = "ASTMethod";
|
||||||
|
private final String expectedContextName = "null"; // should be "ASTClassSpecifier"
|
||||||
|
private final CompletionKind expectedKind = CompletionKind.SINGLE_NAME_REFERENCE; // sould be CompletionKind.NEW_TYPE_REFERENCE;
|
||||||
|
private final String expectedPrefix = "a";
|
||||||
|
private final String[] expectedResults = {
|
||||||
|
// Should be
|
||||||
|
// "aClass",
|
||||||
|
// "anotherClass",
|
||||||
|
// "aNamespace",
|
||||||
|
// "anEnumeration",
|
||||||
|
// "AStruct"
|
||||||
|
};
|
||||||
|
|
||||||
|
public CompletionFailedTest_NewTypeReference_Prefix_Bug50711(String name) {
|
||||||
|
super(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Test suite() {
|
||||||
|
TestSuite suite= new TestSuite(CompletionFailedTest_NewTypeReference_Prefix_Bug50711.class.getName());
|
||||||
|
suite.addTest(new CompletionFailedTest_NewTypeReference_Prefix_Bug50711("testCompletionProposals"));
|
||||||
|
return suite;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.codeassist.tests.CompletionProposalsTest#getCompletionPosition()
|
||||||
|
*/
|
||||||
|
protected int getCompletionPosition() {
|
||||||
|
return getBuffer().indexOf(" a ") + 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -1,3 +1,6 @@
|
||||||
|
2004-01-27 Hoda Amer
|
||||||
|
Added handling for New_Type_Reference completion type
|
||||||
|
|
||||||
2004-01-26 John Camelon
|
2004-01-26 John Camelon
|
||||||
Updated clients to use new Scanner logging service.
|
Updated clients to use new Scanner logging service.
|
||||||
|
|
||||||
|
|
|
@ -621,6 +621,21 @@ public class CompletionEngine implements RelevanceConstants {
|
||||||
// only look for macros
|
// only look for macros
|
||||||
List result = lookupMacros(completionNode.getCompletionPrefix());
|
List result = lookupMacros(completionNode.getCompletionPrefix());
|
||||||
addMacrosToCompletions(result.iterator());
|
addMacrosToCompletions(result.iterator());
|
||||||
|
}
|
||||||
|
private void completionOnNewTypeReference(IASTCompletionNode completionNode){
|
||||||
|
// 1. Get the search scope node
|
||||||
|
IASTScope searchNode = completionNode.getCompletionScope();
|
||||||
|
// look for the specific type being newed and the scope
|
||||||
|
IASTNode context = completionNode.getCompletionContext();
|
||||||
|
if ((context != null) && (context instanceof IASTClassSpecifier)){
|
||||||
|
IASTClassSpecifier classContext = (IASTClassSpecifier) context;
|
||||||
|
IASTNode.LookupKind[] kinds = new IASTNode.LookupKind[1];
|
||||||
|
kinds[0] = IASTNode.LookupKind.STRUCTURES;
|
||||||
|
ILookupResult result = lookup(searchNode, completionNode.getCompletionPrefix(), kinds, null);
|
||||||
|
addToCompletions(result);
|
||||||
|
}
|
||||||
|
// basic completion on all types
|
||||||
|
completionOnTypeReference(completionNode);
|
||||||
}
|
}
|
||||||
// TODO: complete the lookups
|
// TODO: complete the lookups
|
||||||
private void completionOnConstructorReference(IASTCompletionNode completionNode){
|
private void completionOnConstructorReference(IASTCompletionNode completionNode){
|
||||||
|
@ -699,7 +714,7 @@ public class CompletionEngine implements RelevanceConstants {
|
||||||
completionOnSingleNameReference(completionNode);
|
completionOnSingleNameReference(completionNode);
|
||||||
}
|
}
|
||||||
else if(kind == CompletionKind.TYPE_REFERENCE){
|
else if(kind == CompletionKind.TYPE_REFERENCE){
|
||||||
// CompletionOnStructureReference
|
// CompletionOnTypeReference
|
||||||
completionOnTypeReference(completionNode);
|
completionOnTypeReference(completionNode);
|
||||||
}
|
}
|
||||||
else if(kind == CompletionKind.CLASS_REFERENCE){
|
else if(kind == CompletionKind.CLASS_REFERENCE){
|
||||||
|
@ -718,6 +733,10 @@ public class CompletionEngine implements RelevanceConstants {
|
||||||
// CompletionOnMacroReference
|
// CompletionOnMacroReference
|
||||||
completionOnMacroReference(completionNode);
|
completionOnMacroReference(completionNode);
|
||||||
}
|
}
|
||||||
|
else if(kind == CompletionKind.NEW_TYPE_REFERENCE){
|
||||||
|
// completionOnNewTypeReference
|
||||||
|
completionOnNewTypeReference(completionNode);
|
||||||
|
}
|
||||||
else if(kind == CompletionKind.CONSTRUCTOR_REFERENCE){
|
else if(kind == CompletionKind.CONSTRUCTOR_REFERENCE){
|
||||||
// completionOnConstructorReference
|
// completionOnConstructorReference
|
||||||
completionOnConstructorReference(completionNode);
|
completionOnConstructorReference(completionNode);
|
||||||
|
|
Loading…
Add table
Reference in a new issue