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
9960da3ec4
commit
bcdd0ab7c3
28 changed files with 928 additions and 88 deletions
|
@ -1,3 +1,7 @@
|
||||||
|
2004-01-16 Hoda Amer
|
||||||
|
Modified CModelElementsTest to test for enumerator constant expression
|
||||||
|
Bug#47552
|
||||||
|
|
||||||
2004-01-15 Andrew Niefer
|
2004-01-15 Andrew Niefer
|
||||||
Moved testBug48307_FriendFunction_1 & testBug48307_FriendFunction_2 to ContextualParseTest
|
Moved testBug48307_FriendFunction_1 & testBug48307_FriendFunction_2 to ContextualParseTest
|
||||||
Updated ContextualParseTest now that the order of prefix lookup results is predictable.
|
Updated ContextualParseTest now that the order of prefix lookup results is predictable.
|
||||||
|
|
|
@ -273,10 +273,11 @@ public class CModelElementsTests extends TestCase {
|
||||||
checkElementOffset((CElement)enum);
|
checkElementOffset((CElement)enum);
|
||||||
checkLineNumbers((CElement)enum, 57, 61);
|
checkLineNumbers((CElement)enum, 57, 61);
|
||||||
|
|
||||||
// enum ---> enumerator: first
|
// enum ---> enumerator: first = 1
|
||||||
ArrayList enumEnumerators = enum.getChildrenOfType(ICElement.C_ENUMERATOR);
|
ArrayList enumEnumerators = enum.getChildrenOfType(ICElement.C_ENUMERATOR);
|
||||||
IEnumerator first = (IEnumerator) enumEnumerators.get(0);
|
IEnumerator first = (IEnumerator) enumEnumerators.get(0);
|
||||||
assertEquals(first.getElementName(), new String("first"));
|
assertEquals(first.getElementName(), new String("first"));
|
||||||
|
assertEquals("1", first.getConstantExpression());
|
||||||
checkElementOffset((CElement)first);
|
checkElementOffset((CElement)first);
|
||||||
// enum ---> enumerator: second
|
// enum ---> enumerator: second
|
||||||
IEnumerator second = (IEnumerator) enumEnumerators.get(1);
|
IEnumerator second = (IEnumerator) enumEnumerators.get(1);
|
||||||
|
|
|
@ -55,7 +55,7 @@ namespace MyPackage
|
||||||
// check enums
|
// check enums
|
||||||
// enum without name
|
// enum without name
|
||||||
enum {
|
enum {
|
||||||
first,
|
first = 1,
|
||||||
second,
|
second,
|
||||||
third
|
third
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,6 @@
|
||||||
|
2004-01-16 Hoda Amer
|
||||||
|
Solution to bug#47552: IEnumerator#getConstantExpression is always empty
|
||||||
|
|
||||||
2004-01-15 Hoda Amer
|
2004-01-15 Hoda Amer
|
||||||
Moved Content Assist log to the UI plugin
|
Moved Content Assist log to the UI plugin
|
||||||
|
|
||||||
|
|
|
@ -43,6 +43,7 @@ import org.eclipse.cdt.core.parser.ast.IASTDeclaration;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTElaboratedTypeSpecifier;
|
import org.eclipse.cdt.core.parser.ast.IASTElaboratedTypeSpecifier;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTEnumerationSpecifier;
|
import org.eclipse.cdt.core.parser.ast.IASTEnumerationSpecifier;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTEnumerator;
|
import org.eclipse.cdt.core.parser.ast.IASTEnumerator;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTExpression;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTField;
|
import org.eclipse.cdt.core.parser.ast.IASTField;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTFunction;
|
import org.eclipse.cdt.core.parser.ast.IASTFunction;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTInclusion;
|
import org.eclipse.cdt.core.parser.ast.IASTInclusion;
|
||||||
|
@ -380,6 +381,13 @@ public class CModelBuilder {
|
||||||
|
|
||||||
private Enumerator createEnumerator(Parent enum, IASTEnumerator enumDef){
|
private Enumerator createEnumerator(Parent enum, IASTEnumerator enumDef){
|
||||||
Enumerator element = new Enumerator (enum, enumDef.getName().toString());
|
Enumerator element = new Enumerator (enum, enumDef.getName().toString());
|
||||||
|
IASTExpression initialValue = enumDef.getInitialValue();
|
||||||
|
if(initialValue != null){
|
||||||
|
if(initialValue.getLiteralString().length() > 0)
|
||||||
|
element.setConstantExpression(initialValue.getLiteralString());
|
||||||
|
else
|
||||||
|
element.setConstantExpression(initialValue.getIdExpression());
|
||||||
|
}
|
||||||
// add to parent
|
// add to parent
|
||||||
enum.addChild(element);
|
enum.addChild(element);
|
||||||
// set enumerator position
|
// set enumerator position
|
||||||
|
|
|
@ -35,10 +35,9 @@ public interface IASTNode {
|
||||||
public static final LookupKind FIELDS = new LookupKind( 10 );
|
public static final LookupKind FIELDS = new LookupKind( 10 );
|
||||||
public static final LookupKind CONSTRUCTORS = new LookupKind (11);
|
public static final LookupKind CONSTRUCTORS = new LookupKind (11);
|
||||||
public static final LookupKind NAMESPACES = new LookupKind( 12 );
|
public static final LookupKind NAMESPACES = new LookupKind( 12 );
|
||||||
public static final LookupKind MACROS = new LookupKind( 13 );
|
public static final LookupKind ENUMERATIONS = new LookupKind( 13 );
|
||||||
public static final LookupKind ENUMERATIONS = new LookupKind( 14 );
|
public static final LookupKind ENUMERATORS = new LookupKind( 14 );
|
||||||
public static final LookupKind ENUMERATORS = new LookupKind( 15 );
|
public static final LookupKind THIS = new LookupKind(15);
|
||||||
public static final LookupKind THIS = new LookupKind(16);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param enumValue
|
* @param enumValue
|
||||||
|
|
|
@ -103,13 +103,16 @@ public class ASTUtil {
|
||||||
if(clause != null){
|
if(clause != null){
|
||||||
IASTExpression expression = clause.getAssigmentExpression();
|
IASTExpression expression = clause.getAssigmentExpression();
|
||||||
if(expression != null){
|
if(expression != null){
|
||||||
String literal = expression.getLiteralString();
|
String literal = (expression.getLiteralString().length() > 0
|
||||||
if(literal.length() > 0)
|
? expression.getLiteralString()
|
||||||
|
: expression.getIdExpression() );
|
||||||
|
if(literal.length() > 0){
|
||||||
initializer.append("=");
|
initializer.append("=");
|
||||||
initializer.append(literal);
|
initializer.append(literal);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return initializer.toString();
|
return initializer.toString();
|
||||||
}
|
}
|
||||||
public static String getPointerToFunctionType(IASTAbstractDeclaration declaration){
|
public static String getPointerToFunctionType(IASTAbstractDeclaration declaration){
|
||||||
|
|
|
@ -1,3 +1,7 @@
|
||||||
|
2004-01-16 Hoda Amer
|
||||||
|
Added More success JUnit tests.
|
||||||
|
Added two failed JUnit tests.
|
||||||
|
|
||||||
2004-01-15 Hoda Amer
|
2004-01-15 Hoda Amer
|
||||||
Moved Content Assist testing to the UI.tests plugin
|
Moved Content Assist testing to the UI.tests plugin
|
||||||
Started a new framework of JUnit tests for content assist.
|
Started a new framework of JUnit tests for content assist.
|
||||||
|
|
|
@ -21,10 +21,15 @@ class aClass {
|
||||||
public:
|
public:
|
||||||
int aField;
|
int aField;
|
||||||
int aMethod();
|
int aMethod();
|
||||||
};
|
}
|
||||||
|
|
||||||
class anotherClass {
|
class anotherClass {
|
||||||
public:
|
public:
|
||||||
int anotherField;
|
int anotherField;
|
||||||
void anotherMethod();
|
void anotherMethod();
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace aNamespace {
|
||||||
|
void aNamespaceFunction(){
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
#include "CompletionTestStart.h"
|
||||||
|
|
||||||
|
class aThirdClass {
|
||||||
|
a
|
||||||
|
}
|
|
@ -0,0 +1,6 @@
|
||||||
|
#include "CompletionTestStart.h"
|
||||||
|
|
||||||
|
void anotherClass::anotherMethod()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,7 @@
|
||||||
|
#include "CompletionTestStart.h"
|
||||||
|
|
||||||
|
void anotherClass::anotherMethod()
|
||||||
|
{
|
||||||
|
aClass* c = new aClass();
|
||||||
|
c->a
|
||||||
|
}
|
|
@ -0,0 +1,10 @@
|
||||||
|
#include "CompletionTestStart.h"
|
||||||
|
|
||||||
|
aClass* foo(){
|
||||||
|
return new aClass();
|
||||||
|
}
|
||||||
|
|
||||||
|
void anotherClass::anotherMethod()
|
||||||
|
{
|
||||||
|
foo()->a
|
||||||
|
}
|
|
@ -0,0 +1,6 @@
|
||||||
|
#include "CompletionTestStart.h"
|
||||||
|
|
||||||
|
void anotherClass::anotherMethod()
|
||||||
|
{
|
||||||
|
aNamespace::
|
||||||
|
}
|
|
@ -0,0 +1,6 @@
|
||||||
|
#include "CompletionTestStart.h"
|
||||||
|
|
||||||
|
void anotherClass::anotherMethod()
|
||||||
|
{
|
||||||
|
aNamespace::a
|
||||||
|
}
|
|
@ -9,9 +9,8 @@ import junit.framework.Test;
|
||||||
import junit.framework.TestSuite;
|
import junit.framework.TestSuite;
|
||||||
|
|
||||||
import org.eclipse.cdt.ui.tests.text.PartitionTokenScannerTest;
|
import org.eclipse.cdt.ui.tests.text.PartitionTokenScannerTest;
|
||||||
import org.eclipse.cdt.ui.tests.text.contentassist.CompletionProposalsTest1;
|
import org.eclipse.cdt.ui.tests.text.contentassist.*;
|
||||||
import org.eclipse.cdt.ui.tests.text.contentassist.CompletionProposalsTest2;
|
import org.eclipse.cdt.ui.tests.text.contentassist.failedtests.*;
|
||||||
import org.eclipse.cdt.ui.tests.text.contentassist.CompletionProposalsTest3;
|
|
||||||
import org.eclipse.cdt.ui.tests.textmanipulation.TextBufferTest;
|
import org.eclipse.cdt.ui.tests.textmanipulation.TextBufferTest;
|
||||||
|
|
||||||
|
|
||||||
|
@ -33,11 +32,22 @@ public class AutomatedSuite extends TestSuite {
|
||||||
* Construct the test suite.
|
* Construct the test suite.
|
||||||
*/
|
*/
|
||||||
public AutomatedSuite() {
|
public AutomatedSuite() {
|
||||||
|
|
||||||
|
// Success Tests
|
||||||
addTest(PartitionTokenScannerTest.suite());
|
addTest(PartitionTokenScannerTest.suite());
|
||||||
addTest(TextBufferTest.suite());
|
addTest(TextBufferTest.suite());
|
||||||
addTest(CompletionProposalsTest1.suite());
|
addTest(CompletionProposalsTest1.suite());
|
||||||
addTest(CompletionProposalsTest2.suite());
|
addTest(CompletionProposalsTest2.suite());
|
||||||
addTest(CompletionProposalsTest3.suite());
|
addTest(CompletionProposalsTest3.suite());
|
||||||
|
addTest(CompletionProposalsTest4.suite());
|
||||||
|
addTest(CompletionProposalsTest5.suite());
|
||||||
|
addTest(CompletionProposalsTest6.suite());
|
||||||
|
addTest(CompletionProposalsTest7.suite());
|
||||||
|
|
||||||
|
// Failed Tests
|
||||||
|
addTest(CompletionProposalsFailedTest1.suite());
|
||||||
|
addTest(CompletionProposalsFailedTest2.suite());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,7 +43,7 @@ import org.eclipse.core.runtime.Path;
|
||||||
import org.eclipse.jface.text.Document;
|
import org.eclipse.jface.text.Document;
|
||||||
import org.eclipse.jface.text.contentassist.ICompletionProposal;
|
import org.eclipse.jface.text.contentassist.ICompletionProposal;
|
||||||
|
|
||||||
public abstract class CompletionProposalsTest extends TestCase{
|
public abstract class CompletionProposalsBaseTest extends TestCase{
|
||||||
private final String pluginName = "org.eclipse.cdt.ui.tests";
|
private final String pluginName = "org.eclipse.cdt.ui.tests";
|
||||||
private final String projectName = "TestProject1";
|
private final String projectName = "TestProject1";
|
||||||
private final String projectType = "bin";
|
private final String projectType = "bin";
|
||||||
|
@ -56,7 +56,7 @@ public abstract class CompletionProposalsTest extends TestCase{
|
||||||
private Document document = null;
|
private Document document = null;
|
||||||
|
|
||||||
|
|
||||||
public CompletionProposalsTest(String name) {
|
public CompletionProposalsBaseTest(String name) {
|
||||||
super(name);
|
super(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -84,9 +84,9 @@ public abstract class CompletionProposalsTest extends TestCase{
|
||||||
fCFile = fCProject.getProject().getFile(fileName);
|
fCFile = fCProject.getProject().getFile(fileName);
|
||||||
if ( (!fCFile.exists()) &&( !fHeaderFile.exists() )) {
|
if ( (!fCFile.exists()) &&( !fHeaderFile.exists() )) {
|
||||||
try{
|
try{
|
||||||
String fileFullPath = pluginRoot+ getFileFullPath();
|
|
||||||
FileInputStream headerFileIn = new FileInputStream(pluginRoot+ getHeaderFileFullPath());
|
FileInputStream headerFileIn = new FileInputStream(pluginRoot+ getHeaderFileFullPath());
|
||||||
fHeaderFile.create(headerFileIn,false, monitor);
|
fHeaderFile.create(headerFileIn,false, monitor);
|
||||||
|
String fileFullPath = pluginRoot+ getFileFullPath();
|
||||||
FileInputStream bodyFileIn = new FileInputStream(fileFullPath);
|
FileInputStream bodyFileIn = new FileInputStream(fileFullPath);
|
||||||
fCFile.create(bodyFileIn,false, monitor);
|
fCFile.create(bodyFileIn,false, monitor);
|
||||||
} catch (CoreException e) {
|
} catch (CoreException e) {
|
||||||
|
@ -164,9 +164,9 @@ public abstract class CompletionProposalsTest extends TestCase{
|
||||||
assertEquals(prefix, getExpectedPrefix());
|
assertEquals(prefix, getExpectedPrefix());
|
||||||
|
|
||||||
String[] expected = getExpectedResultsValues();
|
String[] expected = getExpectedResultsValues();
|
||||||
assertEquals(results.length, expected.length);
|
assertTrue(results.length >= expected.length);
|
||||||
|
|
||||||
for (int i = 0; i<results.length; i++){
|
for (int i = 0; i<expected.length; i++){
|
||||||
ICompletionProposal proposal = results[i];
|
ICompletionProposal proposal = results[i];
|
||||||
String displayString = proposal.getDisplayString();
|
String displayString = proposal.getDisplayString();
|
||||||
assertEquals(displayString, expected[i]);
|
assertEquals(displayString, expected[i]);
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2001 Rational Software Corp. and others.
|
* Copyright (c) 2004 Rational Software Corp. and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Common Public License v0.5
|
* are made available under the terms of the Common Public License v0.5
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -17,8 +17,10 @@ import org.eclipse.cdt.core.parser.ast.IASTCompletionNode.CompletionKind;
|
||||||
/**
|
/**
|
||||||
* @author hamer
|
* @author hamer
|
||||||
*
|
*
|
||||||
|
* Testing Function/Method scope, statement start, with a prefix
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
public class CompletionProposalsTest1 extends CompletionProposalsTest{
|
public class CompletionProposalsTest1 extends CompletionProposalsBaseTest{
|
||||||
|
|
||||||
private final String fileName = "CompletionTestStart1.cpp";
|
private final String fileName = "CompletionTestStart1.cpp";
|
||||||
private final String fileFullPath ="resources/contentassist/" + fileName;
|
private final String fileFullPath ="resources/contentassist/" + fileName;
|
||||||
|
@ -36,11 +38,10 @@ public class CompletionProposalsTest1 extends CompletionProposalsTest{
|
||||||
"anotherFunction() void",
|
"anotherFunction() void",
|
||||||
"aClass",
|
"aClass",
|
||||||
"anotherClass",
|
"anotherClass",
|
||||||
|
"aNamespace",
|
||||||
"anEnumeration",
|
"anEnumeration",
|
||||||
"AStruct",
|
"AStruct",
|
||||||
// "AMacro",
|
"AMacro"
|
||||||
"asm",
|
|
||||||
"auto"
|
|
||||||
};
|
};
|
||||||
|
|
||||||
public CompletionProposalsTest1(String name) {
|
public CompletionProposalsTest1(String name) {
|
||||||
|
|
|
@ -17,8 +17,11 @@ import org.eclipse.cdt.core.parser.ast.IASTCompletionNode.CompletionKind;
|
||||||
/**
|
/**
|
||||||
* @author hamer
|
* @author hamer
|
||||||
*
|
*
|
||||||
|
* Testing Function/Method scope, a class context, with a prefix
|
||||||
|
* After a .
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
public class CompletionProposalsTest2 extends CompletionProposalsTest{
|
public class CompletionProposalsTest2 extends CompletionProposalsBaseTest{
|
||||||
private final String fileName = "CompletionTestStart2.cpp";
|
private final String fileName = "CompletionTestStart2.cpp";
|
||||||
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";
|
||||||
|
|
|
@ -17,8 +17,10 @@ import org.eclipse.cdt.core.parser.ast.IASTCompletionNode.CompletionKind;
|
||||||
/**
|
/**
|
||||||
* @author hamer
|
* @author hamer
|
||||||
*
|
*
|
||||||
|
* Testing Global scope, declaration start, with a prefix
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
public class CompletionProposalsTest3 extends CompletionProposalsTest{
|
public class CompletionProposalsTest3 extends CompletionProposalsBaseTest{
|
||||||
private final String fileName = "CompletionTestStart3.cpp";
|
private final String fileName = "CompletionTestStart3.cpp";
|
||||||
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";
|
||||||
|
@ -32,9 +34,7 @@ public class CompletionProposalsTest3 extends CompletionProposalsTest{
|
||||||
"anotherClass",
|
"anotherClass",
|
||||||
"anEnumeration",
|
"anEnumeration",
|
||||||
"AStruct",
|
"AStruct",
|
||||||
// "AMacro",
|
"AMacro"
|
||||||
"asm",
|
|
||||||
"auto"
|
|
||||||
};
|
};
|
||||||
|
|
||||||
public CompletionProposalsTest3(String name) {
|
public CompletionProposalsTest3(String name) {
|
||||||
|
|
|
@ -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 Class scope, declaration start, with a prefix
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class CompletionProposalsTest4 extends CompletionProposalsBaseTest{
|
||||||
|
private final String fileName = "CompletionTestStart4.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 = "ASTClassSpecifier";
|
||||||
|
private final String expectedContextName = "null";
|
||||||
|
private final CompletionKind expectedKind = CompletionKind.FIELD_TYPE;
|
||||||
|
private final String expectedPrefix = "a";
|
||||||
|
private final String[] expectedResults = {
|
||||||
|
"aClass",
|
||||||
|
"anotherClass",
|
||||||
|
"aThirdClass",
|
||||||
|
"aNamespace",
|
||||||
|
"anEnumeration",
|
||||||
|
"AStruct"
|
||||||
|
};
|
||||||
|
|
||||||
|
public CompletionProposalsTest4(String name) {
|
||||||
|
super(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Test suite() {
|
||||||
|
TestSuite suite= new TestSuite(CompletionProposalsTest4.class.getName());
|
||||||
|
suite.addTest(new CompletionProposalsTest4("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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,116 @@
|
||||||
|
/**********************************************************************
|
||||||
|
* 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, statement start, with no prefix
|
||||||
|
* Lookup.THIS
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class CompletionProposalsTest5 extends CompletionProposalsBaseTest{
|
||||||
|
private final String fileName = "CompletionTestStart5.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 = "null";
|
||||||
|
private final CompletionKind expectedKind = CompletionKind.STATEMENT_START;
|
||||||
|
private final String expectedPrefix = "";
|
||||||
|
private final String[] expectedResults = {
|
||||||
|
"anotherField : int",
|
||||||
|
"anotherMethod() void"
|
||||||
|
};
|
||||||
|
|
||||||
|
public CompletionProposalsTest5(String name) {
|
||||||
|
super(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Test suite() {
|
||||||
|
TestSuite suite= new TestSuite(CompletionProposalsTest5.class.getName());
|
||||||
|
suite.addTest(new CompletionProposalsTest5("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,116 @@
|
||||||
|
/**********************************************************************
|
||||||
|
* 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 a prefix
|
||||||
|
* After an ->
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class CompletionProposalsTest6 extends CompletionProposalsBaseTest{
|
||||||
|
private final String fileName = "CompletionTestStart6.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 = "a";
|
||||||
|
private final String[] expectedResults = {
|
||||||
|
"aField : int",
|
||||||
|
"aMethod() int"
|
||||||
|
};
|
||||||
|
|
||||||
|
public CompletionProposalsTest6(String name) {
|
||||||
|
super(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Test suite() {
|
||||||
|
TestSuite suite= new TestSuite(CompletionProposalsTest6.class.getName());
|
||||||
|
suite.addTest(new CompletionProposalsTest6("testCompletionProposals"));
|
||||||
|
return suite;
|
||||||
|
}
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.codeassist.tests.CompletionProposalsTest#getCompletionPosition()
|
||||||
|
*/
|
||||||
|
protected int getCompletionPosition() {
|
||||||
|
return getBuffer().indexOf(" c->a ") + 5;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (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,116 @@
|
||||||
|
/**********************************************************************
|
||||||
|
* 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 a prefix
|
||||||
|
* Complex Context: Function return value: foo()->a(CTRL+SPACE)
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class CompletionProposalsTest7 extends CompletionProposalsBaseTest{
|
||||||
|
private final String fileName = "CompletionTestStart7.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 = "a";
|
||||||
|
private final String[] expectedResults = {
|
||||||
|
"aField : int",
|
||||||
|
"aMethod() int"
|
||||||
|
};
|
||||||
|
|
||||||
|
public CompletionProposalsTest7(String name) {
|
||||||
|
super(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Test suite() {
|
||||||
|
TestSuite suite= new TestSuite(CompletionProposalsTest7.class.getName());
|
||||||
|
suite.addTest(new CompletionProposalsTest7("testCompletionProposals"));
|
||||||
|
return suite;
|
||||||
|
}
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.codeassist.tests.CompletionProposalsTest#getCompletionPosition()
|
||||||
|
*/
|
||||||
|
protected int getCompletionPosition() {
|
||||||
|
return getBuffer().indexOf("->a ") + 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,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.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 Function/Method scope, Namespace context, with no prefix
|
||||||
|
* Bug#50152: Wrong context sent after a "::"
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class CompletionProposalsFailedTest1 extends CompletionProposalsBaseTest{
|
||||||
|
|
||||||
|
private final String fileName = "CompletionFailedTestStart1.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 "ASTNamespaceDefinition";
|
||||||
|
private final CompletionKind expectedKind = CompletionKind.SINGLE_NAME_REFERENCE; // should be CompletionKind.SCOPED_REFERENCE;
|
||||||
|
private final String expectedPrefix = "::"; // should be "";
|
||||||
|
private final String[] expectedResults = {
|
||||||
|
// shoud be "aNamespaceFunction() void"
|
||||||
|
};
|
||||||
|
|
||||||
|
public CompletionProposalsFailedTest1(String name) {
|
||||||
|
super(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Test suite() {
|
||||||
|
TestSuite suite= new TestSuite(CompletionProposalsFailedTest1.class.getName());
|
||||||
|
suite.addTest(new CompletionProposalsFailedTest1("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,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.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 Function/Method scope, Namespace context, with a prefix
|
||||||
|
* Bug#50152: Wrong context sent after a "::"
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class CompletionProposalsFailedTest2 extends CompletionProposalsBaseTest{
|
||||||
|
|
||||||
|
private final String fileName = "CompletionFailedTestStart2.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 "ASTNamespaceDefinition";
|
||||||
|
private final CompletionKind expectedKind = CompletionKind.SINGLE_NAME_REFERENCE; // should be CompletionKind.SCOPED_REFERENCE;
|
||||||
|
private final String expectedPrefix = "a";
|
||||||
|
private final String[] expectedResults = {
|
||||||
|
// shoud be "aNamespaceFunction() void"
|
||||||
|
};
|
||||||
|
|
||||||
|
public CompletionProposalsFailedTest2(String name) {
|
||||||
|
super(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Test suite() {
|
||||||
|
TestSuite suite= new TestSuite(CompletionProposalsFailedTest2.class.getName());
|
||||||
|
suite.addTest(new CompletionProposalsFailedTest2("testCompletionProposals"));
|
||||||
|
return suite;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.codeassist.tests.CompletionProposalsTest#getCompletionPosition()
|
||||||
|
*/
|
||||||
|
protected int getCompletionPosition() {
|
||||||
|
return getBuffer().indexOf("::a ") + 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-16 Hoda Amer
|
||||||
|
Added lookupMacros to the CompletionEngine
|
||||||
|
|
||||||
2004-01-16 John Camelon
|
2004-01-16 John Camelon
|
||||||
IASTNode.LookupException references changed to IASTNode.LookupError.
|
IASTNode.LookupException references changed to IASTNode.LookupError.
|
||||||
|
|
||||||
|
|
|
@ -13,8 +13,12 @@ package org.eclipse.cdt.internal.ui.text.contentassist;
|
||||||
import java.io.CharArrayReader;
|
import java.io.CharArrayReader;
|
||||||
import java.io.Reader;
|
import java.io.Reader;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.TreeSet;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.CCorePlugin;
|
import org.eclipse.cdt.core.CCorePlugin;
|
||||||
import org.eclipse.cdt.core.model.CoreModel;
|
import org.eclipse.cdt.core.model.CoreModel;
|
||||||
|
@ -41,7 +45,6 @@ import org.eclipse.cdt.core.parser.ast.IASTEnumerationSpecifier;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTEnumerator;
|
import org.eclipse.cdt.core.parser.ast.IASTEnumerator;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTField;
|
import org.eclipse.cdt.core.parser.ast.IASTField;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTFunction;
|
import org.eclipse.cdt.core.parser.ast.IASTFunction;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTMacro;
|
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTMethod;
|
import org.eclipse.cdt.core.parser.ast.IASTMethod;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTNamespaceDefinition;
|
import org.eclipse.cdt.core.parser.ast.IASTNamespaceDefinition;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTNode;
|
import org.eclipse.cdt.core.parser.ast.IASTNode;
|
||||||
|
@ -49,8 +52,8 @@ import org.eclipse.cdt.core.parser.ast.IASTParameterDeclaration;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTScope;
|
import org.eclipse.cdt.core.parser.ast.IASTScope;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTVariable;
|
import org.eclipse.cdt.core.parser.ast.IASTVariable;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTCompletionNode.CompletionKind;
|
import org.eclipse.cdt.core.parser.ast.IASTCompletionNode.CompletionKind;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTNode.LookupKind;
|
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTNode.ILookupResult;
|
import org.eclipse.cdt.core.parser.ast.IASTNode.ILookupResult;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTNode.LookupKind;
|
||||||
import org.eclipse.cdt.internal.core.CharOperation;
|
import org.eclipse.cdt.internal.core.CharOperation;
|
||||||
import org.eclipse.cdt.internal.core.parser.util.ASTUtil;
|
import org.eclipse.cdt.internal.core.parser.util.ASTUtil;
|
||||||
import org.eclipse.cdt.internal.ui.util.IDebugLogConstants;
|
import org.eclipse.cdt.internal.ui.util.IDebugLogConstants;
|
||||||
|
@ -92,6 +95,7 @@ public class CompletionEngine implements RelevanceConstants{
|
||||||
"template",
|
"template",
|
||||||
};
|
};
|
||||||
private static final String exceptionKeyword = "...";
|
private static final String exceptionKeyword = "...";
|
||||||
|
private Map macroMap = new HashMap();
|
||||||
// scope relevance element counters
|
// scope relevance element counters
|
||||||
private int numFields = 0;
|
private int numFields = 0;
|
||||||
private int numVariables = 0;
|
private int numVariables = 0;
|
||||||
|
@ -104,7 +108,6 @@ public class CompletionEngine implements RelevanceConstants{
|
||||||
private int numEnumerations = 0;
|
private int numEnumerations = 0;
|
||||||
private int numEnumerators = 0;
|
private int numEnumerators = 0;
|
||||||
private int numNamespaces = 0;
|
private int numNamespaces = 0;
|
||||||
private int numMacros = 0;
|
|
||||||
|
|
||||||
public CompletionEngine(ICompletionRequestor completionRequestor){
|
public CompletionEngine(ICompletionRequestor completionRequestor){
|
||||||
requestor = completionRequestor;
|
requestor = completionRequestor;
|
||||||
|
@ -183,9 +186,11 @@ public class CompletionEngine implements RelevanceConstants{
|
||||||
ParserLanguage language = CoreModel.getDefault().hasCCNature(project) ? ParserLanguage.CPP : ParserLanguage.C;
|
ParserLanguage language = CoreModel.getDefault().hasCCNature(project) ? ParserLanguage.CPP : ParserLanguage.C;
|
||||||
|
|
||||||
IParser parser = null;
|
IParser parser = null;
|
||||||
|
IScanner scanner = null;
|
||||||
|
macroMap.clear();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
IScanner scanner = ParserFactory.createScanner( reader, realPath.toOSString(), scanInfo, ParserMode.COMPLETION_PARSE, language, requestor, ParserUtil.getParserLogService() );
|
scanner = ParserFactory.createScanner( reader, realPath.toOSString(), scanInfo, ParserMode.COMPLETION_PARSE, language, requestor, ParserUtil.getParserLogService() );
|
||||||
parser = ParserFactory.createParser( scanner, requestor, ParserMode.COMPLETION_PARSE, language, ParserUtil.getParserLogService() );
|
parser = ParserFactory.createParser( scanner, requestor, ParserMode.COMPLETION_PARSE, language, ParserUtil.getParserLogService() );
|
||||||
}
|
}
|
||||||
catch( ParserFactoryError pfe )
|
catch( ParserFactoryError pfe )
|
||||||
|
@ -196,6 +201,7 @@ public class CompletionEngine implements RelevanceConstants{
|
||||||
IASTCompletionNode result = null;
|
IASTCompletionNode result = null;
|
||||||
try {
|
try {
|
||||||
result = parser.parse(completionOffset);
|
result = parser.parse(completionOffset);
|
||||||
|
macroMap = scanner.getDefinitions();
|
||||||
} catch (ParseError e ) {
|
} catch (ParseError e ) {
|
||||||
//TODO - this can be more than just a Not Implemented exception
|
//TODO - this can be more than just a Not Implemented exception
|
||||||
}
|
}
|
||||||
|
@ -300,14 +306,6 @@ public class CompletionEngine implements RelevanceConstants{
|
||||||
completionStart, completionLength, relevance);
|
completionStart, completionLength, relevance);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(node instanceof IASTMacro){
|
|
||||||
numMacros++;
|
|
||||||
IASTMacro macro = (IASTMacro)node;
|
|
||||||
int relevance = computeRelevance(ICElement.C_MACRO, prefix, macro.getName());
|
|
||||||
relevance += totalNumberOfResults - numMacros;
|
|
||||||
|
|
||||||
requestor.acceptMacro(macro.getName(), completionStart, completionLength, relevance);
|
|
||||||
}
|
|
||||||
else if(node instanceof IASTNamespaceDefinition){
|
else if(node instanceof IASTNamespaceDefinition){
|
||||||
numNamespaces++;
|
numNamespaces++;
|
||||||
IASTNamespaceDefinition namespace = (IASTNamespaceDefinition)node;
|
IASTNamespaceDefinition namespace = (IASTNamespaceDefinition)node;
|
||||||
|
@ -349,6 +347,22 @@ public class CompletionEngine implements RelevanceConstants{
|
||||||
log("No of Keywords = " + numOfKeywords);
|
log("No of Keywords = " + numOfKeywords);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void addMacroToCompletions (String macroName){
|
||||||
|
int relevance = MACRO_TYPE_RELEVANCE;
|
||||||
|
requestor.acceptMacro(macroName, completionStart, completionLength, relevance);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addMacrosToCompletions(Iterator macros){
|
||||||
|
int numOfMacros = 0;
|
||||||
|
while (macros.hasNext()){
|
||||||
|
String macro = (String) macros.next();
|
||||||
|
addMacroToCompletions(macro);
|
||||||
|
numOfMacros++;
|
||||||
|
}
|
||||||
|
log("No of Macros = " + numOfMacros);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private void resetElementNumbers(){
|
private void resetElementNumbers(){
|
||||||
numFields = 0;
|
numFields = 0;
|
||||||
numVariables = 0;
|
numVariables = 0;
|
||||||
|
@ -361,11 +375,12 @@ public class CompletionEngine implements RelevanceConstants{
|
||||||
numEnumerations = 0;
|
numEnumerations = 0;
|
||||||
numEnumerators = 0;
|
numEnumerators = 0;
|
||||||
numNamespaces = 0;
|
numNamespaces = 0;
|
||||||
numMacros = 0;
|
|
||||||
}
|
}
|
||||||
private void addToCompletions (ILookupResult result){
|
private void addToCompletions (ILookupResult result){
|
||||||
if(result == null)
|
if(result == null){
|
||||||
|
log("Lookup Results = null ................. !!! No Lookup Results found !!! ");
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
Iterator nodes = result.getNodes();
|
Iterator nodes = result.getNodes();
|
||||||
int numberOfElements = result.getResultsSize();
|
int numberOfElements = result.getResultsSize();
|
||||||
|
|
||||||
|
@ -379,7 +394,7 @@ public class CompletionEngine implements RelevanceConstants{
|
||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
|
|
||||||
private List lookupKeyword(String prefix, int lookupType){
|
private List lookupKeywords(String prefix, int lookupType){
|
||||||
List result = new ArrayList();
|
List result = new ArrayList();
|
||||||
switch (lookupType){
|
switch (lookupType){
|
||||||
case BASIC_TYPES_KEYWORDS:
|
case BASIC_TYPES_KEYWORDS:
|
||||||
|
@ -408,6 +423,30 @@ public class CompletionEngine implements RelevanceConstants{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private List lookupMacros(String prefix){
|
||||||
|
Set keySet = new TreeSet(macroMap.keySet());
|
||||||
|
Iterator i = keySet.iterator();
|
||||||
|
|
||||||
|
List resultSet = new ArrayList();
|
||||||
|
while( i.hasNext() )
|
||||||
|
{
|
||||||
|
String key = (String) i.next();
|
||||||
|
String value = "";
|
||||||
|
if(key.length() > prefix.length()) {
|
||||||
|
value = key.substring(0, prefix.length());
|
||||||
|
}else {
|
||||||
|
value = key;
|
||||||
|
}
|
||||||
|
if( value.equalsIgnoreCase( prefix ) ) {
|
||||||
|
resultSet.add( key );
|
||||||
|
}
|
||||||
|
else if( value.compareToIgnoreCase( prefix ) > 0 )
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return resultSet;
|
||||||
|
}
|
||||||
|
|
||||||
private void completionOnMemberReference(IASTCompletionNode completionNode){
|
private void completionOnMemberReference(IASTCompletionNode completionNode){
|
||||||
// Completing after a dot
|
// Completing after a dot
|
||||||
// 1. Get the search scope node
|
// 1. Get the search scope node
|
||||||
|
@ -428,6 +467,7 @@ public class CompletionEngine implements RelevanceConstants{
|
||||||
IASTScope searchNode = completionNode.getCompletionScope();
|
IASTScope searchNode = completionNode.getCompletionScope();
|
||||||
|
|
||||||
ILookupResult result = null;
|
ILookupResult result = null;
|
||||||
|
if (completionNode.getCompletionPrefix().length() > 0){
|
||||||
// lookup fields and methods with the right visibility
|
// lookup fields and methods with the right visibility
|
||||||
IASTNode.LookupKind[] kinds = new IASTNode.LookupKind[8];
|
IASTNode.LookupKind[] kinds = new IASTNode.LookupKind[8];
|
||||||
kinds[0] = IASTNode.LookupKind.FIELDS;
|
kinds[0] = IASTNode.LookupKind.FIELDS;
|
||||||
|
@ -441,13 +481,27 @@ public class CompletionEngine implements RelevanceConstants{
|
||||||
|
|
||||||
result = lookup (searchNode, completionNode.getCompletionPrefix(), kinds, completionNode.getCompletionContext());
|
result = lookup (searchNode, completionNode.getCompletionPrefix(), kinds, completionNode.getCompletionContext());
|
||||||
addToCompletions (result);
|
addToCompletions (result);
|
||||||
|
|
||||||
|
List macros = lookupMacros(completionNode.getCompletionPrefix());
|
||||||
|
addMacrosToCompletions(macros.iterator());
|
||||||
|
}
|
||||||
|
else // prefix is empty
|
||||||
|
{
|
||||||
|
// instead of only fields and methods
|
||||||
|
IASTNode.LookupKind[] kinds = new IASTNode.LookupKind[1];
|
||||||
|
kinds[0] = IASTNode.LookupKind.THIS;
|
||||||
|
|
||||||
|
result = lookup(searchNode, completionNode.getCompletionPrefix(), kinds, completionNode.getCompletionContext());
|
||||||
|
addToCompletions(result);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
private void completionOnScopedReference(IASTCompletionNode completionNode){
|
private void completionOnScopedReference(IASTCompletionNode completionNode){
|
||||||
// 1. Get the search scope node
|
// 1. Get the search scope node
|
||||||
// the search node is the name before the qualification
|
// the search node is the name before the qualification
|
||||||
IASTScope searchNode = completionNode.getCompletionScope();
|
IASTScope searchNode = completionNode.getCompletionScope();
|
||||||
// here we have to look for anything that could be referenced within this scope
|
// here we have to look for anything that could be referenced within this scope
|
||||||
// 1. lookup local variables, global variables, functions, methods, structures, enums, macros, and namespaces
|
// 1. lookup local variables, global variables, functions, methods, structures, enums, and namespaces
|
||||||
IASTNode.LookupKind[] kinds = new IASTNode.LookupKind[4];
|
IASTNode.LookupKind[] kinds = new IASTNode.LookupKind[4];
|
||||||
kinds[0] = IASTNode.LookupKind.VARIABLES;
|
kinds[0] = IASTNode.LookupKind.VARIABLES;
|
||||||
kinds[1] = IASTNode.LookupKind.STRUCTURES;
|
kinds[1] = IASTNode.LookupKind.STRUCTURES;
|
||||||
|
@ -482,6 +536,12 @@ public class CompletionEngine implements RelevanceConstants{
|
||||||
completionOnTypeReference(completionNode);
|
completionOnTypeReference(completionNode);
|
||||||
// 2. Get the search scope node
|
// 2. Get the search scope node
|
||||||
IASTScope searchNode = completionNode.getCompletionScope();
|
IASTScope searchNode = completionNode.getCompletionScope();
|
||||||
|
|
||||||
|
IASTNode.LookupKind[] kinds = new IASTNode.LookupKind[1];
|
||||||
|
kinds[0] = IASTNode.LookupKind.NAMESPACES;
|
||||||
|
ILookupResult result = lookup(searchNode, completionNode.getCompletionPrefix(), kinds, completionNode.getCompletionContext());
|
||||||
|
addToCompletions(result);
|
||||||
|
|
||||||
// TODO
|
// TODO
|
||||||
// 3. provide a template for constructor/ destructor
|
// 3. provide a template for constructor/ destructor
|
||||||
// 4. lookup methods
|
// 4. lookup methods
|
||||||
|
@ -497,13 +557,17 @@ 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);
|
||||||
|
|
||||||
|
IASTScope searchNode = completionNode.getCompletionScope();
|
||||||
|
IASTNode.LookupKind[] kinds = new IASTNode.LookupKind[1];
|
||||||
|
kinds[0] = IASTNode.LookupKind.NAMESPACES;
|
||||||
|
ILookupResult result = lookup(searchNode, completionNode.getCompletionPrefix(), kinds, completionNode.getCompletionContext());
|
||||||
|
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
|
||||||
IASTScope searchNode = completionNode.getCompletionScope();
|
IASTScope searchNode = completionNode.getCompletionScope();
|
||||||
// if prefix is not empty
|
|
||||||
if (completionNode.getCompletionPrefix().length() > 0){
|
|
||||||
// here we have to look for any names that could be referenced within this scope
|
// here we have to look for any names that could be referenced within this scope
|
||||||
// 1. lookup local variables, global variables, functions, methods, structures, enums, macros, and namespaces
|
// 1. lookup local variables, global variables, functions, methods, structures, enums, macros, and namespaces
|
||||||
IASTNode.LookupKind[] kinds = new IASTNode.LookupKind[7];
|
IASTNode.LookupKind[] kinds = new IASTNode.LookupKind[7];
|
||||||
|
@ -516,17 +580,10 @@ public class CompletionEngine implements RelevanceConstants{
|
||||||
kinds[6] = IASTNode.LookupKind.ENUMERATORS;
|
kinds[6] = IASTNode.LookupKind.ENUMERATORS;
|
||||||
ILookupResult result = lookup(searchNode, completionNode.getCompletionPrefix(), kinds, completionNode.getCompletionContext());
|
ILookupResult result = lookup(searchNode, completionNode.getCompletionPrefix(), kinds, completionNode.getCompletionContext());
|
||||||
addToCompletions(result);
|
addToCompletions(result);
|
||||||
} else // prefix is empty
|
|
||||||
{
|
List macros = lookupMacros(completionNode.getCompletionPrefix());
|
||||||
// instead of only fields and methods
|
addMacrosToCompletions(macros.iterator());
|
||||||
// kinds[0] = IASTNode.LookupKind.THIS
|
|
||||||
IASTNode.LookupKind[] kinds = new IASTNode.LookupKind[3];
|
|
||||||
kinds[0] = IASTNode.LookupKind.LOCAL_VARIABLES;
|
|
||||||
kinds[1] = IASTNode.LookupKind.FIELDS;
|
|
||||||
kinds[2] = IASTNode.LookupKind.METHODS;
|
|
||||||
ILookupResult result = lookup(searchNode, completionNode.getCompletionPrefix(), kinds, completionNode.getCompletionContext());
|
|
||||||
addToCompletions(result);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void completionOnClassReference(IASTCompletionNode completionNode){
|
private void completionOnClassReference(IASTCompletionNode completionNode){
|
||||||
|
@ -559,10 +616,8 @@ public class CompletionEngine implements RelevanceConstants{
|
||||||
// 1. Get the search scope node
|
// 1. Get the search scope node
|
||||||
IASTScope searchNode = completionNode.getCompletionScope();
|
IASTScope searchNode = completionNode.getCompletionScope();
|
||||||
// only look for macros
|
// only look for macros
|
||||||
IASTNode.LookupKind[] kinds = new IASTNode.LookupKind[1];
|
List result = lookupMacros(completionNode.getCompletionPrefix());
|
||||||
kinds[0] = IASTNode.LookupKind.MACROS;
|
addMacrosToCompletions(result.iterator());
|
||||||
ILookupResult result = lookup(searchNode, completionNode.getCompletionPrefix(), kinds, completionNode.getCompletionContext());
|
|
||||||
addToCompletions(result);
|
|
||||||
}
|
}
|
||||||
private void completionOnFunctionReference(IASTCompletionNode completionNode){
|
private void completionOnFunctionReference(IASTCompletionNode completionNode){
|
||||||
// TODO: complete the lookups
|
// TODO: complete the lookups
|
||||||
|
@ -579,7 +634,7 @@ public class CompletionEngine implements RelevanceConstants{
|
||||||
private void completionOnKeyword(IASTCompletionNode completionNode){
|
private void completionOnKeyword(IASTCompletionNode completionNode){
|
||||||
// lookup every type of keywords
|
// lookup every type of keywords
|
||||||
// 1. basic types keword list
|
// 1. basic types keword list
|
||||||
List result = lookupKeyword(completionNode.getCompletionPrefix(), BASIC_TYPES_KEYWORDS);
|
List result = lookupKeywords(completionNode.getCompletionPrefix(), BASIC_TYPES_KEYWORDS);
|
||||||
addKeywordsToCompletions(result.iterator());
|
addKeywordsToCompletions(result.iterator());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -800,8 +855,6 @@ public class CompletionEngine implements RelevanceConstants{
|
||||||
kindName.append("CONSTRUCTORS");
|
kindName.append("CONSTRUCTORS");
|
||||||
else if(kind == IASTNode.LookupKind.NAMESPACES)
|
else if(kind == IASTNode.LookupKind.NAMESPACES)
|
||||||
kindName.append("NAMESPACES");
|
kindName.append("NAMESPACES");
|
||||||
else if(kind == IASTNode.LookupKind.MACROS)
|
|
||||||
kindName.append("MACROS");
|
|
||||||
else if(kind == IASTNode.LookupKind.ENUMERATIONS)
|
else if(kind == IASTNode.LookupKind.ENUMERATIONS)
|
||||||
kindName.append("ENUMERATIONS");
|
kindName.append("ENUMERATIONS");
|
||||||
else if(kind == IASTNode.LookupKind.ENUMERATORS)
|
else if(kind == IASTNode.LookupKind.ENUMERATORS)
|
||||||
|
|
Loading…
Add table
Reference in a new issue