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
d228fe824a
commit
c44ab7ec78
18 changed files with 682 additions and 24 deletions
|
@ -1,3 +1,6 @@
|
||||||
|
2004-01-21 Hoda Amer
|
||||||
|
Added more JUnit tests for Content Assist
|
||||||
|
|
||||||
2004-01-19 Hoda Amer
|
2004-01-19 Hoda Amer
|
||||||
Added a JUnit test case for completion on Macros with function style.
|
Added a JUnit test case for completion on Macros with function style.
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,11 @@
|
||||||
#define AMacro(x) x+1
|
#define AMacro(x) x+1
|
||||||
|
#define XMacro(x,y) x+y
|
||||||
|
|
||||||
|
int aVariable;
|
||||||
|
int xVariable;
|
||||||
|
|
||||||
int aVariable = 0;
|
|
||||||
bool aFunction();
|
bool aFunction();
|
||||||
|
bool xFunction();
|
||||||
|
|
||||||
enum anEnumeration {
|
enum anEnumeration {
|
||||||
aFirstEnum,
|
aFirstEnum,
|
||||||
|
@ -9,27 +13,54 @@ enum anEnumeration {
|
||||||
aThirdEnum
|
aThirdEnum
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum xEnumeration {
|
||||||
|
xFirstEnum,
|
||||||
|
xSecondEnum,
|
||||||
|
xThirdEnum
|
||||||
|
};
|
||||||
|
|
||||||
struct AStruct{
|
struct AStruct{
|
||||||
int aStructField;
|
int aStructField;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct XStruct{
|
||||||
|
int xStructField;
|
||||||
|
};
|
||||||
|
|
||||||
void anotherFunction(){
|
void anotherFunction(){
|
||||||
int aLocalDeclaration = 1;
|
int aLocalDeclaration = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void xOtherFunction(){
|
||||||
|
int xLocalDeclaration = 1;
|
||||||
|
}
|
||||||
|
|
||||||
class aClass {
|
class aClass {
|
||||||
public:
|
public:
|
||||||
int aField;
|
int aField;
|
||||||
|
float xAClassField;
|
||||||
int aMethod();
|
int aMethod();
|
||||||
}
|
void xAClassMethod(int x);
|
||||||
|
};
|
||||||
|
|
||||||
class anotherClass {
|
class anotherClass {
|
||||||
public:
|
public:
|
||||||
int anotherField;
|
int anotherField;
|
||||||
void anotherMethod();
|
void anotherMethod();
|
||||||
}
|
};
|
||||||
|
|
||||||
|
class xOtherClass {
|
||||||
|
public:
|
||||||
|
int xOtherField;
|
||||||
|
void xOtherMethod();
|
||||||
|
};
|
||||||
|
|
||||||
namespace aNamespace {
|
namespace aNamespace {
|
||||||
void aNamespaceFunction(){
|
void aNamespaceFunction(){
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
namespace xNamespace {
|
||||||
|
void xNamespaceFunction(){
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
#include "CompletionTestStart.h"
|
||||||
|
|
||||||
|
void anotherClass::anotherMethod()
|
||||||
|
{
|
||||||
|
aClass* c = new aClass();
|
||||||
|
c->
|
||||||
|
}
|
|
@ -0,0 +1,3 @@
|
||||||
|
#include "CompletionTestStart.h"
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
#include "CompletionTestStart.h"
|
||||||
|
|
||||||
|
class aThirdClass {
|
||||||
|
int x;
|
||||||
|
|
||||||
|
};
|
|
@ -2,4 +2,4 @@
|
||||||
|
|
||||||
class aThirdClass {
|
class aThirdClass {
|
||||||
a
|
a
|
||||||
}
|
};
|
|
@ -0,0 +1,7 @@
|
||||||
|
#include "CompletionTestStart.h"
|
||||||
|
|
||||||
|
void anotherClass::anotherMethod()
|
||||||
|
{
|
||||||
|
aClass c;
|
||||||
|
c.
|
||||||
|
}
|
|
@ -0,0 +1,5 @@
|
||||||
|
#include "CompletionTestStart.h"
|
||||||
|
|
||||||
|
class aThirdClass {
|
||||||
|
|
||||||
|
};
|
|
@ -44,10 +44,15 @@ public class AutomatedSuite extends TestSuite {
|
||||||
addTest(CompletionProposalsTest6.suite());
|
addTest(CompletionProposalsTest6.suite());
|
||||||
addTest(CompletionProposalsTest7.suite());
|
addTest(CompletionProposalsTest7.suite());
|
||||||
addTest(CompletionProposalsTest8.suite());
|
addTest(CompletionProposalsTest8.suite());
|
||||||
|
addTest(CompletionProposalsTest9.suite());
|
||||||
|
addTest(CompletionProposalsTest10.suite());
|
||||||
|
addTest(CompletionProposalsTest11.suite());
|
||||||
|
addTest(CompletionProposalsTest12.suite());
|
||||||
|
|
||||||
// Failed Tests
|
// Failed Tests
|
||||||
addTest(CompletionProposalsFailedTest1.suite());
|
addTest(CompletionProposalsFailedTest1.suite());
|
||||||
addTest(CompletionProposalsFailedTest2.suite());
|
addTest(CompletionProposalsFailedTest2.suite());
|
||||||
|
addTest(CompletionProposalsFailedTest3.suite());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,119 @@
|
||||||
|
/**********************************************************************
|
||||||
|
* 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;
|
||||||
|
import junit.framework.Test;
|
||||||
|
import junit.framework.TestSuite;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTCompletionNode.CompletionKind;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author hamer
|
||||||
|
*
|
||||||
|
* Testing Function/Method scope, a class context, with NO prefix
|
||||||
|
* After an ->
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class CompletionProposalsTest10 extends CompletionProposalsBaseTest{
|
||||||
|
private final String fileName = "CompletionTestStart10.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 = "ASTMethod";
|
||||||
|
private final String expectedContextName = "ASTClassSpecifier";
|
||||||
|
private final CompletionKind expectedKind = CompletionKind.MEMBER_REFERENCE;
|
||||||
|
private final String expectedPrefix = "";
|
||||||
|
private final String[] expectedResults = {
|
||||||
|
"aField : int",
|
||||||
|
"xAClassField : float",
|
||||||
|
"aMethod() int",
|
||||||
|
"xAClassMethod(int) void"
|
||||||
|
};
|
||||||
|
|
||||||
|
public CompletionProposalsTest10(String name) {
|
||||||
|
super(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Test suite() {
|
||||||
|
TestSuite suite= new TestSuite(CompletionProposalsTest10.class.getName());
|
||||||
|
suite.addTest(new CompletionProposalsTest10("testCompletionProposals"));
|
||||||
|
return suite;
|
||||||
|
}
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.codeassist.tests.CompletionProposalsTest#getCompletionPosition()
|
||||||
|
*/
|
||||||
|
protected int getCompletionPosition() {
|
||||||
|
return getBuffer().indexOf(" c-> ") + 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (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,113 @@
|
||||||
|
/**********************************************************************
|
||||||
|
* 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;
|
||||||
|
import junit.framework.Test;
|
||||||
|
import junit.framework.TestSuite;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTCompletionNode.CompletionKind;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author hamer
|
||||||
|
*
|
||||||
|
* Testing Global scope, declaration start, with NO prefix
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class CompletionProposalsTest11 extends CompletionProposalsBaseTest{
|
||||||
|
private final String fileName = "CompletionTestStart11.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.VARIABLE_TYPE;
|
||||||
|
private final String expectedPrefix = "";
|
||||||
|
private final String[] expectedResults = {
|
||||||
|
};
|
||||||
|
|
||||||
|
public CompletionProposalsTest11(String name) {
|
||||||
|
super(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Test suite() {
|
||||||
|
TestSuite suite= new TestSuite(CompletionProposalsTest11.class.getName());
|
||||||
|
suite.addTest(new CompletionProposalsTest11("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,114 @@
|
||||||
|
/**********************************************************************
|
||||||
|
* 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;
|
||||||
|
|
||||||
|
import junit.framework.Test;
|
||||||
|
import junit.framework.TestSuite;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTCompletionNode.CompletionKind;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author hamer
|
||||||
|
*
|
||||||
|
* Testing Class scope, declaration start, with NO prefix
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class CompletionProposalsTest12 extends CompletionProposalsBaseTest{
|
||||||
|
private final String fileName = "CompletionTestStart12.h";
|
||||||
|
private final String fileFullPath ="resources/contentassist/" + fileName;
|
||||||
|
private final String headerFileName = "CompletionTestStart.h";
|
||||||
|
private final String headerFileFullPath ="resources/contentassist/" + headerFileName;
|
||||||
|
private final String expectedScopeName = "ASTClassSpecifier";
|
||||||
|
private final String expectedContextName = "null";
|
||||||
|
private final CompletionKind expectedKind = CompletionKind.FIELD_TYPE;
|
||||||
|
private final String expectedPrefix = "";
|
||||||
|
private final String[] expectedResults = {
|
||||||
|
};
|
||||||
|
|
||||||
|
public CompletionProposalsTest12(String name) {
|
||||||
|
super(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Test suite() {
|
||||||
|
TestSuite suite= new TestSuite(CompletionProposalsTest12.class.getName());
|
||||||
|
suite.addTest(new CompletionProposalsTest12("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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -32,9 +32,9 @@ public class CompletionProposalsTest3 extends CompletionProposalsBaseTest{
|
||||||
private final String[] expectedResults = {
|
private final String[] expectedResults = {
|
||||||
"aClass",
|
"aClass",
|
||||||
"anotherClass",
|
"anotherClass",
|
||||||
|
"aNamespace",
|
||||||
"anEnumeration",
|
"anEnumeration",
|
||||||
"AStruct",
|
"AStruct"
|
||||||
"AMacro(x)"
|
|
||||||
};
|
};
|
||||||
|
|
||||||
public CompletionProposalsTest3(String name) {
|
public CompletionProposalsTest3(String name) {
|
||||||
|
@ -42,15 +42,15 @@ public class CompletionProposalsTest3 extends CompletionProposalsBaseTest{
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Test suite() {
|
public static Test suite() {
|
||||||
TestSuite suite= new TestSuite(CompletionProposalsTest2.class.getName());
|
TestSuite suite= new TestSuite(CompletionProposalsTest3.class.getName());
|
||||||
suite.addTest(new CompletionProposalsTest2("testCompletionProposals"));
|
suite.addTest(new CompletionProposalsTest3("testCompletionProposals"));
|
||||||
return suite;
|
return suite;
|
||||||
}
|
}
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.codeassist.tests.CompletionProposalsTest#getCompletionPosition()
|
* @see org.eclipse.cdt.core.codeassist.tests.CompletionProposalsTest#getCompletionPosition()
|
||||||
*/
|
*/
|
||||||
protected int getCompletionPosition() {
|
protected int getCompletionPosition() {
|
||||||
return getBuffer().indexOf(" c.a ") + 4;
|
return getBuffer().indexOf(" a ") + 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
|
|
|
@ -21,7 +21,7 @@ import org.eclipse.cdt.core.parser.ast.IASTCompletionNode.CompletionKind;
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class CompletionProposalsTest4 extends CompletionProposalsBaseTest{
|
public class CompletionProposalsTest4 extends CompletionProposalsBaseTest{
|
||||||
private final String fileName = "CompletionTestStart4.cpp";
|
private final String fileName = "CompletionTestStart4.h";
|
||||||
private final String fileFullPath ="resources/contentassist/" + fileName;
|
private final String fileFullPath ="resources/contentassist/" + fileName;
|
||||||
private final String headerFileName = "CompletionTestStart.h";
|
private final String headerFileName = "CompletionTestStart.h";
|
||||||
private final String headerFileFullPath ="resources/contentassist/" + headerFileName;
|
private final String headerFileFullPath ="resources/contentassist/" + headerFileName;
|
||||||
|
|
|
@ -0,0 +1,118 @@
|
||||||
|
/**********************************************************************
|
||||||
|
* 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;
|
||||||
|
import junit.framework.Test;
|
||||||
|
import junit.framework.TestSuite;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTCompletionNode.CompletionKind;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author hamer
|
||||||
|
*
|
||||||
|
* Testing Function/Method scope, a class context, with NO prefix
|
||||||
|
* After a .
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class CompletionProposalsTest9 extends CompletionProposalsBaseTest{
|
||||||
|
private final String fileName = "CompletionTestStart9.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 = "ASTMethod";
|
||||||
|
private final String expectedContextName = "ASTClassSpecifier";
|
||||||
|
private final CompletionKind expectedKind = CompletionKind.MEMBER_REFERENCE;
|
||||||
|
private final String expectedPrefix = "";
|
||||||
|
private final String[] expectedResults = {
|
||||||
|
"aField : int",
|
||||||
|
"xAClassField : float",
|
||||||
|
"aMethod() int",
|
||||||
|
"xAClassMethod(int) void"
|
||||||
|
};
|
||||||
|
|
||||||
|
public CompletionProposalsTest9(String name) {
|
||||||
|
super(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Test suite() {
|
||||||
|
TestSuite suite= new TestSuite(CompletionProposalsTest9.class.getName());
|
||||||
|
suite.addTest(new CompletionProposalsTest9("testCompletionProposals"));
|
||||||
|
return suite;
|
||||||
|
}
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.codeassist.tests.CompletionProposalsTest#getCompletionPosition()
|
||||||
|
*/
|
||||||
|
protected int getCompletionPosition() {
|
||||||
|
return getBuffer().indexOf(" c. ") + 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (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,117 @@
|
||||||
|
/**********************************************************************
|
||||||
|
* 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 scope, declaration start, with NO prefix
|
||||||
|
* Bug#50344 :Wrong completion in Class scope if before the first declaration
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class CompletionProposalsFailedTest3 extends CompletionProposalsBaseTest{
|
||||||
|
|
||||||
|
private final String fileName = "CompletionFailedTestStart3.h";
|
||||||
|
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 = "ASTCompilationUnit"; // should be "ASTClassSpecifier";
|
||||||
|
private final String expectedContextName = "null";
|
||||||
|
private final CompletionKind expectedKind =CompletionKind.USER_SPECIFIED_NAME; // should be CompletionKind.FIELD_TYPE;
|
||||||
|
private final String expectedPrefix = "";
|
||||||
|
private final String[] expectedResults = {
|
||||||
|
};
|
||||||
|
|
||||||
|
public CompletionProposalsFailedTest3(String name) {
|
||||||
|
super(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Test suite() {
|
||||||
|
TestSuite suite= new TestSuite(CompletionProposalsFailedTest3.class.getName());
|
||||||
|
suite.addTest(new CompletionProposalsFailedTest3("testCompletionProposals"));
|
||||||
|
return suite;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.codeassist.tests.CompletionProposalsTest#getCompletionPosition()
|
||||||
|
*/
|
||||||
|
protected int getCompletionPosition() {
|
||||||
|
return getBuffer().indexOf(" ") + 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (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-21 Hoda Amer
|
||||||
|
-Fixed bug#49854 : Enumerator code complete fails when no character provided
|
||||||
|
|
||||||
2004-01-20 Alain Magloire
|
2004-01-20 Alain Magloire
|
||||||
|
|
||||||
Remove the hardcode "objdump" in the EditorUtility.
|
Remove the hardcode "objdump" in the EditorUtility.
|
||||||
|
|
|
@ -495,7 +495,11 @@ public class CompletionEngine implements RelevanceConstants{
|
||||||
// instead of only fields and methods
|
// instead of only fields and methods
|
||||||
IASTNode.LookupKind[] kinds = new IASTNode.LookupKind[1];
|
IASTNode.LookupKind[] kinds = new IASTNode.LookupKind[1];
|
||||||
kinds[0] = IASTNode.LookupKind.THIS;
|
kinds[0] = IASTNode.LookupKind.THIS;
|
||||||
|
result = lookup(searchNode, completionNode.getCompletionPrefix(), kinds, completionNode.getCompletionContext());
|
||||||
|
addToCompletions(result);
|
||||||
|
|
||||||
|
kinds = new IASTNode.LookupKind[1];
|
||||||
|
kinds[0] = IASTNode.LookupKind.LOCAL_VARIABLES;
|
||||||
result = lookup(searchNode, completionNode.getCompletionPrefix(), kinds, completionNode.getCompletionContext());
|
result = lookup(searchNode, completionNode.getCompletionPrefix(), kinds, completionNode.getCompletionContext());
|
||||||
addToCompletions(result);
|
addToCompletions(result);
|
||||||
}
|
}
|
||||||
|
@ -540,13 +544,13 @@ public class CompletionEngine implements RelevanceConstants{
|
||||||
// 1. basic completion on all types
|
// 1. basic completion on all types
|
||||||
completionOnTypeReference(completionNode);
|
completionOnTypeReference(completionNode);
|
||||||
// 2. Get the search scope node
|
// 2. Get the search scope node
|
||||||
|
if(completionNode.getCompletionPrefix().length() > 0) {
|
||||||
IASTScope searchNode = completionNode.getCompletionScope();
|
IASTScope searchNode = completionNode.getCompletionScope();
|
||||||
|
|
||||||
IASTNode.LookupKind[] kinds = new IASTNode.LookupKind[1];
|
IASTNode.LookupKind[] kinds = new IASTNode.LookupKind[1];
|
||||||
kinds[0] = IASTNode.LookupKind.NAMESPACES;
|
kinds[0] = IASTNode.LookupKind.NAMESPACES;
|
||||||
ILookupResult result = lookup(searchNode, completionNode.getCompletionPrefix(), kinds, completionNode.getCompletionContext());
|
ILookupResult result = lookup(searchNode, completionNode.getCompletionPrefix(), kinds, completionNode.getCompletionContext());
|
||||||
addToCompletions(result);
|
addToCompletions(result);
|
||||||
|
}
|
||||||
// TODO
|
// TODO
|
||||||
// 3. provide a template for constructor/ destructor
|
// 3. provide a template for constructor/ destructor
|
||||||
// 4. lookup methods
|
// 4. lookup methods
|
||||||
|
@ -562,13 +566,16 @@ public class CompletionEngine implements RelevanceConstants{
|
||||||
private void completionOnVariableType(IASTCompletionNode completionNode){
|
private void completionOnVariableType(IASTCompletionNode completionNode){
|
||||||
// 1. basic completion on all types
|
// 1. basic completion on all types
|
||||||
completionOnTypeReference(completionNode);
|
completionOnTypeReference(completionNode);
|
||||||
|
// look for namespaces only if you have a prefix
|
||||||
|
if(completionNode.getCompletionPrefix().length() > 0){
|
||||||
IASTScope searchNode = completionNode.getCompletionScope();
|
IASTScope searchNode = completionNode.getCompletionScope();
|
||||||
IASTNode.LookupKind[] kinds = new IASTNode.LookupKind[1];
|
IASTNode.LookupKind[] kinds = new IASTNode.LookupKind[1];
|
||||||
kinds[0] = IASTNode.LookupKind.NAMESPACES;
|
kinds[0] = IASTNode.LookupKind.NAMESPACES;
|
||||||
ILookupResult result = lookup(searchNode, completionNode.getCompletionPrefix(), kinds, completionNode.getCompletionContext());
|
ILookupResult result = lookup(searchNode, completionNode.getCompletionPrefix(), kinds, completionNode.getCompletionContext());
|
||||||
addToCompletions(result);
|
addToCompletions(result);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void completionOnSingleNameReference(IASTCompletionNode completionNode){
|
private void completionOnSingleNameReference(IASTCompletionNode completionNode){
|
||||||
// 1. Get the search scope node
|
// 1. Get the search scope node
|
||||||
// the search node is the code scope inwhich completion is requested
|
// the search node is the code scope inwhich completion is requested
|
||||||
|
|
Loading…
Add table
Reference in a new issue