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
a90de5234d
commit
f26c374088
20 changed files with 803 additions and 16 deletions
|
@ -1,3 +1,6 @@
|
|||
2004-01-23 Hoda Amer
|
||||
More Completion JUnit tests.
|
||||
|
||||
2004-01-22 John Camelon
|
||||
Updated CompletionFailedTest_FieldType_NoPrefix_Bug50344 and moved from failed tests.
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
#define DEBUG 1
|
||||
#define AMacro(x) x+1
|
||||
#define XMacro(x,y) x+y
|
||||
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
#include "CompletionTestStart.h"
|
||||
|
||||
void foo(int x){
|
||||
int y = a
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
#include "CompletionTestStart.h"
|
||||
|
||||
void foo(int x){
|
||||
int y =
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
#include "CompletionTestStart.h"
|
||||
|
||||
using
|
|
@ -0,0 +1,3 @@
|
|||
#include "CompletionTestStart.h"
|
||||
|
||||
using a
|
|
@ -0,0 +1,3 @@
|
|||
#include "CompletionTestStart.h"
|
||||
|
||||
#ifdef
|
|
@ -0,0 +1,3 @@
|
|||
#include "CompletionTestStart.h"
|
||||
|
||||
#ifdef D
|
|
@ -36,24 +36,30 @@ public class AutomatedSuite extends TestSuite {
|
|||
// Success Tests
|
||||
addTest(PartitionTokenScannerTest.suite());
|
||||
addTest(TextBufferTest.suite());
|
||||
addTest(CompletionTest_StatementStart_Prefix.suite());
|
||||
addTest(CompletionTest_MemberReference_Dot_Prefix.suite());
|
||||
addTest(CompletionTest_VariableType_Prefix.suite());
|
||||
// completion tests
|
||||
addTest(CompletionTest_FieldType_Prefix.suite());
|
||||
addTest(CompletionTest_FieldType_NoPrefix.suite());
|
||||
addTest(CompletionTest_FieldType_NoPrefix2.suite());
|
||||
addTest(CompletionTest_VariableType_Prefix.suite());
|
||||
addTest(CompletionTest_VariableType_NoPrefix.suite());
|
||||
addTest(CompletionTest_StatementStart_Prefix.suite());
|
||||
addTest(CompletionTest_StatementStart_NoPrefix.suite());
|
||||
addTest(CompletionTest_SingleName_Prefix.suite());
|
||||
addTest(CompletionTest_SingleName_Prefix2.suite());
|
||||
addTest(CompletionTest_SingleName_NoPrefix.suite());
|
||||
addTest(CompletionTest_MemberReference_Dot_Prefix.suite());
|
||||
addTest(CompletionTest_MemberReference_Dot_NoPrefix.suite());
|
||||
addTest(CompletionTest_MemberReference_Arrow_Prefix.suite());
|
||||
addTest(CompletionTest_MemberReference_Arrow_Prefix2.suite());
|
||||
addTest(CompletionTest_SingleName_Prefix.suite());
|
||||
addTest(CompletionTest_MemberReference_Dot_NoPrefix.suite());
|
||||
addTest(CompletionTest_MemberReference_Arrow_NoPrefix.suite());
|
||||
addTest(CompletionTest_VariableType_NoPrefix.suite());
|
||||
addTest(CompletionTest_FieldType_NoPrefix.suite());
|
||||
|
||||
// Failed Tests
|
||||
addTest(CompletionFailedTest_ScopedReference_NoPrefix_Bug50152.suite());
|
||||
addTest(CompletionFailedTest_ScopedReference_Prefix_Bug50152.suite());
|
||||
addTest(CompletionTest_FieldType_NoPrefix2.suite());
|
||||
|
||||
addTest(CompletionFailedTest_NamespaceRef_NoPrefix_Bug50471.suite());
|
||||
addTest(CompletionFailedTest_NamespaceRef_Prefix_Bug50471.suite());
|
||||
addTest(CompletionFailedTest_MacroRef_NoPrefix_Bug50487.suite());
|
||||
addTest(CompletionFailedTest_MacroRef_Prefix_Bug50487.suite());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -23,8 +23,8 @@ import org.eclipse.cdt.core.parser.ast.IASTCompletionNode.CompletionKind;
|
|||
*/
|
||||
public class CompletionTest_FieldType_NoPrefix2 extends CompletionProposalsBaseTest{
|
||||
|
||||
private final String fileName = "CompletionFailedTestStart3.h";
|
||||
private final String fileFullPath ="resources/contentassist/failedtests/" + fileName;
|
||||
private final String fileName = "CompletionTestStart13.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";
|
||||
|
|
|
@ -0,0 +1,140 @@
|
|||
/**********************************************************************
|
||||
* 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 Single name reference, with prefix
|
||||
*
|
||||
*/
|
||||
public class CompletionTest_SingleName_NoPrefix extends CompletionProposalsBaseTest{
|
||||
private final String fileName = "CompletionTestStart15.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 = "ASTFunction";
|
||||
private final String expectedContextName = "null";
|
||||
private final CompletionKind expectedKind = CompletionKind.SINGLE_NAME_REFERENCE;
|
||||
private final String expectedPrefix = "";
|
||||
private final String[] expectedResults = {
|
||||
"x : int",
|
||||
"aVariable : int",
|
||||
"xVariable : int",
|
||||
"aFunction() bool",
|
||||
"anotherFunction() void",
|
||||
"foo(int) void",
|
||||
"xFunction() bool",
|
||||
"xOtherFunction() void",
|
||||
"aClass",
|
||||
"anotherClass",
|
||||
"xOtherClass",
|
||||
"AStruct",
|
||||
"XStruct",
|
||||
"aNamespace",
|
||||
"xNamespace",
|
||||
"anEnumeration",
|
||||
"xEnumeration",
|
||||
"aFirstEnum",
|
||||
"aSecondEnum",
|
||||
"aThirdEnum",
|
||||
"xFirstEnum",
|
||||
"xSecondEnum",
|
||||
"xThirdEnum",
|
||||
"AMacro(x)",
|
||||
"DEBUG",
|
||||
"XMacro(x,y)"
|
||||
};
|
||||
|
||||
public CompletionTest_SingleName_NoPrefix(String name) {
|
||||
super(name);
|
||||
}
|
||||
|
||||
public static Test suite() {
|
||||
TestSuite suite= new TestSuite(CompletionTest_SingleName_NoPrefix.class.getName());
|
||||
suite.addTest(new CompletionTest_SingleName_NoPrefix("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,125 @@
|
|||
/**********************************************************************
|
||||
* 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 Single name reference, with prefix
|
||||
*
|
||||
*/
|
||||
public class CompletionTest_SingleName_Prefix2 extends CompletionProposalsBaseTest{
|
||||
private final String fileName = "CompletionTestStart14.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 = "ASTFunction";
|
||||
private final String expectedContextName = "null";
|
||||
private final CompletionKind expectedKind = CompletionKind.SINGLE_NAME_REFERENCE;
|
||||
private final String expectedPrefix = "a";
|
||||
private final String[] expectedResults = {
|
||||
"aVariable : int",
|
||||
"aFunction() bool",
|
||||
"anotherFunction() void",
|
||||
"aClass",
|
||||
"anotherClass",
|
||||
"aNamespace",
|
||||
"anEnumeration",
|
||||
"aFirstEnum",
|
||||
"aSecondEnum",
|
||||
"aThirdEnum",
|
||||
"AStruct",
|
||||
"AMacro(x)"
|
||||
};
|
||||
|
||||
public CompletionTest_SingleName_Prefix2(String name) {
|
||||
super(name);
|
||||
}
|
||||
|
||||
public static Test suite() {
|
||||
TestSuite suite= new TestSuite(CompletionTest_SingleName_Prefix2.class.getName());
|
||||
suite.addTest(new CompletionTest_SingleName_Prefix2("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,121 @@
|
|||
/**********************************************************************
|
||||
* 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 Macro_Reference, with no prefix
|
||||
* Bug#50487 :Wrong completion kind and prefix after "#ifdef"
|
||||
*
|
||||
*/
|
||||
public class CompletionFailedTest_MacroRef_NoPrefix_Bug50487 extends CompletionProposalsBaseTest{
|
||||
|
||||
private final String fileName = "CompletionFailedTestStart5.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 = "ASTCompilationUnit";
|
||||
private final String expectedContextName = "null";
|
||||
private final CompletionKind expectedKind = CompletionKind.VARIABLE_TYPE; // should be CompletionKind.MACRO_REFERENCE;
|
||||
private final String expectedPrefix = "";
|
||||
private final String[] expectedResults = {
|
||||
// Should be
|
||||
// "aMacro(x)",
|
||||
// "Debug",
|
||||
// "xMacro(x,y)"
|
||||
};
|
||||
|
||||
public CompletionFailedTest_MacroRef_NoPrefix_Bug50487(String name) {
|
||||
super(name);
|
||||
}
|
||||
|
||||
public static Test suite() {
|
||||
TestSuite suite= new TestSuite(CompletionFailedTest_MacroRef_NoPrefix_Bug50487.class.getName());
|
||||
suite.addTest(new CompletionFailedTest_MacroRef_NoPrefix_Bug50487("testCompletionProposals"));
|
||||
return suite;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.codeassist.tests.CompletionProposalsTest#getCompletionPosition()
|
||||
*/
|
||||
protected int getCompletionPosition() {
|
||||
return getBuffer().indexOf("#ifdef ") + 7;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.codeassist.tests.CompletionProposalsTest#getExpectedScope()
|
||||
*/
|
||||
protected String getExpectedScopeClassName() {
|
||||
return expectedScopeName;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.codeassist.tests.CompletionProposalsTest#getExpectedContext()
|
||||
*/
|
||||
protected String getExpectedContextClassName() {
|
||||
return expectedContextName;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.codeassist.tests.CompletionProposalsTest#getExpectedKind()
|
||||
*/
|
||||
protected CompletionKind getExpectedKind() {
|
||||
return expectedKind;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.codeassist.tests.CompletionProposalsTest#getExpectedPrefix()
|
||||
*/
|
||||
protected String getExpectedPrefix() {
|
||||
return expectedPrefix;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.codeassist.tests.CompletionProposalsTest#getExpectedResultsValues()
|
||||
*/
|
||||
protected String[] getExpectedResultsValues() {
|
||||
return expectedResults;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.codeassist.tests.CompletionProposalsTest#getFileName()
|
||||
*/
|
||||
protected String getFileName() {
|
||||
return fileName;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.codeassist.tests.CompletionProposalsTest#getFileFullPath()
|
||||
*/
|
||||
protected String getFileFullPath() {
|
||||
return fileFullPath;
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.codeassist.tests.CompletionProposalsTest#getHeaderFileFullPath()
|
||||
*/
|
||||
protected String getHeaderFileFullPath() {
|
||||
return headerFileFullPath;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.codeassist.tests.CompletionProposalsTest#getHeaderFileName()
|
||||
*/
|
||||
protected String getHeaderFileName() {
|
||||
return headerFileName;
|
||||
}
|
||||
|
||||
}
|
|
@ -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.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 Macro_Reference, with no prefix
|
||||
* Bug#50487 :Wrong completion kind and prefix after "#ifdef"
|
||||
*
|
||||
*/
|
||||
public class CompletionFailedTest_MacroRef_Prefix_Bug50487 extends CompletionProposalsBaseTest{
|
||||
|
||||
private final String fileName = "CompletionFailedTestStart6.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 = "ASTCompilationUnit";
|
||||
private final String expectedContextName = "null";
|
||||
private final CompletionKind expectedKind = CompletionKind.VARIABLE_TYPE; // should be CompletionKind.MACRO_REFERENCE;
|
||||
private final String expectedPrefix = ""; // should be "D";
|
||||
private final String[] expectedResults = {
|
||||
// Should be
|
||||
// "Debug"
|
||||
};
|
||||
|
||||
public CompletionFailedTest_MacroRef_Prefix_Bug50487(String name) {
|
||||
super(name);
|
||||
}
|
||||
|
||||
public static Test suite() {
|
||||
TestSuite suite= new TestSuite(CompletionFailedTest_MacroRef_Prefix_Bug50487.class.getName());
|
||||
suite.addTest(new CompletionFailedTest_MacroRef_Prefix_Bug50487("testCompletionProposals"));
|
||||
return suite;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.codeassist.tests.CompletionProposalsTest#getCompletionPosition()
|
||||
*/
|
||||
protected int getCompletionPosition() {
|
||||
return getBuffer().indexOf("ifdef D ") + 7;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.codeassist.tests.CompletionProposalsTest#getExpectedScope()
|
||||
*/
|
||||
protected String getExpectedScopeClassName() {
|
||||
return expectedScopeName;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.codeassist.tests.CompletionProposalsTest#getExpectedContext()
|
||||
*/
|
||||
protected String getExpectedContextClassName() {
|
||||
return expectedContextName;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.codeassist.tests.CompletionProposalsTest#getExpectedKind()
|
||||
*/
|
||||
protected CompletionKind getExpectedKind() {
|
||||
return expectedKind;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.codeassist.tests.CompletionProposalsTest#getExpectedPrefix()
|
||||
*/
|
||||
protected String getExpectedPrefix() {
|
||||
return expectedPrefix;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.codeassist.tests.CompletionProposalsTest#getExpectedResultsValues()
|
||||
*/
|
||||
protected String[] getExpectedResultsValues() {
|
||||
return expectedResults;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.codeassist.tests.CompletionProposalsTest#getFileName()
|
||||
*/
|
||||
protected String getFileName() {
|
||||
return fileName;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.codeassist.tests.CompletionProposalsTest#getFileFullPath()
|
||||
*/
|
||||
protected String getFileFullPath() {
|
||||
return fileFullPath;
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.codeassist.tests.CompletionProposalsTest#getHeaderFileFullPath()
|
||||
*/
|
||||
protected String getHeaderFileFullPath() {
|
||||
return headerFileFullPath;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.codeassist.tests.CompletionProposalsTest#getHeaderFileName()
|
||||
*/
|
||||
protected String getHeaderFileName() {
|
||||
return headerFileName;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,120 @@
|
|||
/**********************************************************************
|
||||
* Copyright (c) 2004 Rational Software Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Common Public License v0.5
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/cpl-v05.html
|
||||
*
|
||||
* Contributors:
|
||||
* IBM Rational Software - Initial API and implementation
|
||||
***********************************************************************/
|
||||
package org.eclipse.cdt.ui.tests.text.contentassist.failedtests;
|
||||
import junit.framework.Test;
|
||||
import junit.framework.TestSuite;
|
||||
|
||||
import org.eclipse.cdt.core.parser.ast.IASTCompletionNode.CompletionKind;
|
||||
import org.eclipse.cdt.ui.tests.text.contentassist.CompletionProposalsBaseTest;
|
||||
|
||||
/**
|
||||
* @author hamer
|
||||
*
|
||||
* Testing Namespace_Reference, with no prefix
|
||||
* Bug#50471 : Wrong completion kind after the "using" keyword
|
||||
*
|
||||
*/
|
||||
public class CompletionFailedTest_NamespaceRef_NoPrefix_Bug50471 extends CompletionProposalsBaseTest{
|
||||
|
||||
private final String fileName = "CompletionFailedTestStart3.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 = "ASTCompilationUnit";
|
||||
private final String expectedContextName = "null";
|
||||
private final CompletionKind expectedKind = CompletionKind.VARIABLE_TYPE; // should be CompletionKind.NAMESPACE_REFERENCE;
|
||||
private final String expectedPrefix = "";
|
||||
private final String[] expectedResults = {
|
||||
// Should be
|
||||
// "aNamespace",
|
||||
// "xNamespace"
|
||||
};
|
||||
|
||||
public CompletionFailedTest_NamespaceRef_NoPrefix_Bug50471(String name) {
|
||||
super(name);
|
||||
}
|
||||
|
||||
public static Test suite() {
|
||||
TestSuite suite= new TestSuite(CompletionFailedTest_NamespaceRef_NoPrefix_Bug50471.class.getName());
|
||||
suite.addTest(new CompletionFailedTest_NamespaceRef_NoPrefix_Bug50471("testCompletionProposals"));
|
||||
return suite;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.codeassist.tests.CompletionProposalsTest#getCompletionPosition()
|
||||
*/
|
||||
protected int getCompletionPosition() {
|
||||
return getBuffer().indexOf("using ") + 6;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.codeassist.tests.CompletionProposalsTest#getExpectedScope()
|
||||
*/
|
||||
protected String getExpectedScopeClassName() {
|
||||
return expectedScopeName;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.codeassist.tests.CompletionProposalsTest#getExpectedContext()
|
||||
*/
|
||||
protected String getExpectedContextClassName() {
|
||||
return expectedContextName;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.codeassist.tests.CompletionProposalsTest#getExpectedKind()
|
||||
*/
|
||||
protected CompletionKind getExpectedKind() {
|
||||
return expectedKind;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.codeassist.tests.CompletionProposalsTest#getExpectedPrefix()
|
||||
*/
|
||||
protected String getExpectedPrefix() {
|
||||
return expectedPrefix;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.codeassist.tests.CompletionProposalsTest#getExpectedResultsValues()
|
||||
*/
|
||||
protected String[] getExpectedResultsValues() {
|
||||
return expectedResults;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.codeassist.tests.CompletionProposalsTest#getFileName()
|
||||
*/
|
||||
protected String getFileName() {
|
||||
return fileName;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.codeassist.tests.CompletionProposalsTest#getFileFullPath()
|
||||
*/
|
||||
protected String getFileFullPath() {
|
||||
return fileFullPath;
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.codeassist.tests.CompletionProposalsTest#getHeaderFileFullPath()
|
||||
*/
|
||||
protected String getHeaderFileFullPath() {
|
||||
return headerFileFullPath;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.codeassist.tests.CompletionProposalsTest#getHeaderFileName()
|
||||
*/
|
||||
protected String getHeaderFileName() {
|
||||
return headerFileName;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,120 @@
|
|||
/**********************************************************************
|
||||
* Copyright (c) 2004 Rational Software Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Common Public License v0.5
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/cpl-v05.html
|
||||
*
|
||||
* Contributors:
|
||||
* IBM Rational Software - Initial API and implementation
|
||||
***********************************************************************/
|
||||
package org.eclipse.cdt.ui.tests.text.contentassist.failedtests;
|
||||
|
||||
import junit.framework.Test;
|
||||
import junit.framework.TestSuite;
|
||||
|
||||
import org.eclipse.cdt.core.parser.ast.IASTCompletionNode.CompletionKind;
|
||||
import org.eclipse.cdt.ui.tests.text.contentassist.CompletionProposalsBaseTest;
|
||||
|
||||
/**
|
||||
* @author hamer
|
||||
*
|
||||
* Testing Namespace_Reference, with prefix
|
||||
* Bug#50471 : Wrong completion kind after the "using" keyword
|
||||
*
|
||||
*/
|
||||
public class CompletionFailedTest_NamespaceRef_Prefix_Bug50471 extends CompletionProposalsBaseTest{
|
||||
|
||||
private final String fileName = "CompletionFailedTestStart4.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 = "ASTCompilationUnit";
|
||||
private final String expectedContextName = "null";
|
||||
private final CompletionKind expectedKind = CompletionKind.VARIABLE_TYPE; // should be CompletionKind.NAMESPACE_REFERENCE;
|
||||
private final String expectedPrefix = "a";
|
||||
private final String[] expectedResults = {
|
||||
// Should be
|
||||
// "aNamespace"
|
||||
};
|
||||
|
||||
public CompletionFailedTest_NamespaceRef_Prefix_Bug50471(String name) {
|
||||
super(name);
|
||||
}
|
||||
|
||||
public static Test suite() {
|
||||
TestSuite suite= new TestSuite(CompletionFailedTest_NamespaceRef_Prefix_Bug50471.class.getName());
|
||||
suite.addTest(new CompletionFailedTest_NamespaceRef_Prefix_Bug50471("testCompletionProposals"));
|
||||
return suite;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.codeassist.tests.CompletionProposalsTest#getCompletionPosition()
|
||||
*/
|
||||
protected int getCompletionPosition() {
|
||||
return getBuffer().indexOf("using a ") + 7;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.codeassist.tests.CompletionProposalsTest#getExpectedScope()
|
||||
*/
|
||||
protected String getExpectedScopeClassName() {
|
||||
return expectedScopeName;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.codeassist.tests.CompletionProposalsTest#getExpectedContext()
|
||||
*/
|
||||
protected String getExpectedContextClassName() {
|
||||
return expectedContextName;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.codeassist.tests.CompletionProposalsTest#getExpectedKind()
|
||||
*/
|
||||
protected CompletionKind getExpectedKind() {
|
||||
return expectedKind;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.codeassist.tests.CompletionProposalsTest#getExpectedPrefix()
|
||||
*/
|
||||
protected String getExpectedPrefix() {
|
||||
return expectedPrefix;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.codeassist.tests.CompletionProposalsTest#getExpectedResultsValues()
|
||||
*/
|
||||
protected String[] getExpectedResultsValues() {
|
||||
return expectedResults;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.codeassist.tests.CompletionProposalsTest#getFileName()
|
||||
*/
|
||||
protected String getFileName() {
|
||||
return fileName;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.codeassist.tests.CompletionProposalsTest#getFileFullPath()
|
||||
*/
|
||||
protected String getFileFullPath() {
|
||||
return fileFullPath;
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.codeassist.tests.CompletionProposalsTest#getHeaderFileFullPath()
|
||||
*/
|
||||
protected String getHeaderFileFullPath() {
|
||||
return headerFileFullPath;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.codeassist.tests.CompletionProposalsTest#getHeaderFileName()
|
||||
*/
|
||||
protected String getHeaderFileName() {
|
||||
return headerFileName;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,3 +1,6 @@
|
|||
2004-01-23 Hoda Amer
|
||||
Content Assist Work: Tuning of Completion Engine
|
||||
|
||||
2004-01-21 Hoda Amer
|
||||
-Fixed bug#49854 : Enumerator code complete fails when no character provided
|
||||
|
||||
|
|
|
@ -409,7 +409,8 @@ public class CCompletionProcessor implements IContentAssistProcessor {
|
|||
|
||||
if(kind == IASTCompletionNode.CompletionKind.VARIABLE_TYPE)
|
||||
addProposalsFromTemplateEngine(viewer, fGlobalContextTemplateEngine, completions);
|
||||
if(kind == IASTCompletionNode.CompletionKind.SINGLE_NAME_REFERENCE)
|
||||
if( (kind == IASTCompletionNode.CompletionKind.SINGLE_NAME_REFERENCE)
|
||||
|| (kind == IASTCompletionNode.CompletionKind.STATEMENT_START) )
|
||||
addProposalsFromTemplateEngine(viewer, fFunctionContextTemplateEngine, completions);
|
||||
if(kind == IASTCompletionNode.CompletionKind.FIELD_TYPE)
|
||||
addProposalsFromTemplateEngine(viewer, fStructureContextTemplateEngine, completions);
|
||||
|
@ -439,7 +440,8 @@ public class CCompletionProcessor implements IContentAssistProcessor {
|
|||
int length = prefix.length();
|
||||
|
||||
// calling functions should happen only within the context of a code body
|
||||
if(completionNode.getCompletionContext() != IASTCompletionNode.CompletionKind.SINGLE_NAME_REFERENCE)
|
||||
if( (completionNode.getCompletionContext() != IASTCompletionNode.CompletionKind.SINGLE_NAME_REFERENCE)
|
||||
&& (completionNode.getCompletionContext() != IASTCompletionNode.CompletionKind.STATEMENT_START))
|
||||
return;
|
||||
|
||||
IFunctionSummary[] summary;
|
||||
|
@ -515,6 +517,7 @@ public class CCompletionProcessor implements IContentAssistProcessor {
|
|||
|
||||
if (((projectScope) || (projectScopeAndDependency))
|
||||
&& ( (completionNode.getCompletionKind() == IASTCompletionNode.CompletionKind.SINGLE_NAME_REFERENCE)
|
||||
|| (completionNode.getCompletionKind() == IASTCompletionNode.CompletionKind.STATEMENT_START)
|
||||
|| (completionNode.getCompletionKind() == IASTCompletionNode.CompletionKind.VARIABLE_TYPE)
|
||||
|| (completionNode.getCompletionKind() == IASTCompletionNode.CompletionKind.FIELD_TYPE) )
|
||||
&& (prefix.length() > 0)){
|
||||
|
@ -535,7 +538,8 @@ public class CCompletionProcessor implements IContentAssistProcessor {
|
|||
orPattern.addPattern(SearchEngine.createSearchPattern(
|
||||
searchPrefix, ICSearchConstants.NAMESPACE, ICSearchConstants.DEFINITIONS, false ));
|
||||
|
||||
if( (completionNode.getCompletionKind() == IASTCompletionNode.CompletionKind.SINGLE_NAME_REFERENCE)){
|
||||
if( (completionNode.getCompletionKind() == IASTCompletionNode.CompletionKind.SINGLE_NAME_REFERENCE)
|
||||
|| (completionNode.getCompletionKind() == IASTCompletionNode.CompletionKind.STATEMENT_START)){
|
||||
orPattern.addPattern(SearchEngine.createSearchPattern(
|
||||
searchPrefix, ICSearchConstants.VAR, ICSearchConstants.DECLARATIONS, false ));
|
||||
orPattern.addPattern(SearchEngine.createSearchPattern(
|
||||
|
|
|
@ -582,7 +582,7 @@ public class CompletionEngine implements RelevanceConstants{
|
|||
IASTScope searchNode = completionNode.getCompletionScope();
|
||||
// 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
|
||||
IASTNode.LookupKind[] kinds = new IASTNode.LookupKind[7];
|
||||
IASTNode.LookupKind[] kinds = new IASTNode.LookupKind[9];
|
||||
kinds[0] = IASTNode.LookupKind.LOCAL_VARIABLES;
|
||||
kinds[1] = IASTNode.LookupKind.FIELDS;
|
||||
kinds[2] = IASTNode.LookupKind.VARIABLES;
|
||||
|
@ -590,6 +590,8 @@ public class CompletionEngine implements RelevanceConstants{
|
|||
kinds[4] = IASTNode.LookupKind.FUNCTIONS;
|
||||
kinds[5] = IASTNode.LookupKind.NAMESPACES;
|
||||
kinds[6] = IASTNode.LookupKind.ENUMERATORS;
|
||||
kinds[7] = IASTNode.LookupKind.STRUCTURES;
|
||||
kinds[8] = IASTNode.LookupKind.ENUMERATIONS;
|
||||
String prefix = completionNode.getCompletionPrefix();
|
||||
if(prefix.equals("("))
|
||||
prefix = "";
|
||||
|
@ -666,6 +668,7 @@ public class CompletionEngine implements RelevanceConstants{
|
|||
return null;
|
||||
}
|
||||
|
||||
log ("Offset = " + completionOffset);
|
||||
logNode("Scope = " , completionNode.getCompletionScope());
|
||||
logNode("Context = " , completionNode.getCompletionContext());
|
||||
logKind("Kind = ", completionNode.getCompletionKind());
|
||||
|
|
Loading…
Add table
Reference in a new issue