mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Updated test cases for improved contexts provided in IASTCompletionNode.
This commit is contained in:
parent
94bfaa41cf
commit
8eaa71ea7a
21 changed files with 406 additions and 222 deletions
|
@ -0,0 +1,68 @@
|
|||
/**********************************************************************
|
||||
* Copyright (c) 2002-2004 IBM Canada 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.core.parser.failedTests;
|
||||
|
||||
import java.io.StringWriter;
|
||||
import java.util.Iterator;
|
||||
|
||||
import org.eclipse.cdt.core.parser.ast.IASTCompletionNode;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTField;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTNode;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTNode.ILookupResult;
|
||||
import org.eclipse.cdt.core.parser.tests.CompletionParseBaseTest;
|
||||
|
||||
/**
|
||||
* @author johnc
|
||||
*/
|
||||
public class CompletionParseFailedTest extends CompletionParseBaseTest {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public CompletionParseFailedTest() {
|
||||
super();
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
/**
|
||||
* @param name
|
||||
*/
|
||||
public CompletionParseFailedTest(String name) {
|
||||
super(name);
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
public void testCompletionInTypeDef() throws Exception{
|
||||
StringWriter writer = new StringWriter();
|
||||
writer.write( "struct A { int name; }; \n" );
|
||||
writer.write( "typedef struct A * PA; \n" );
|
||||
writer.write( "int main() { \n" );
|
||||
writer.write( " PA a; \n" );
|
||||
writer.write( " a->SP \n" );
|
||||
writer.write( "} \n" );
|
||||
|
||||
String code = writer.toString();
|
||||
int index = code.indexOf( "SP" );
|
||||
|
||||
IASTCompletionNode node = parse( code, index );
|
||||
ILookupResult result = node.getCompletionScope().lookup( node.getCompletionPrefix(),
|
||||
new IASTNode.LookupKind[]{ IASTNode.LookupKind.ALL },
|
||||
node.getCompletionContext() );
|
||||
|
||||
//this is where the failure happens ... when the bug is fixed this line can be removed and the rest uncommented
|
||||
assertEquals( result.getResultsSize(), 4 );
|
||||
// assertEquals( result.getResultsSize(), 1 );
|
||||
//
|
||||
// Iterator iter = result.getNodes();
|
||||
// IASTField name = (IASTField) iter.next();
|
||||
//
|
||||
// assertEquals( name.getName(), "name" );
|
||||
// assertFalse( iter.hasNext() );
|
||||
}
|
||||
}
|
|
@ -953,4 +953,5 @@ public class CompleteParseBaseTest extends TestCase
|
|||
assertTrue( qualifiedNamesEquals( fromAST, theTruth ));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,128 @@
|
|||
/**********************************************************************
|
||||
* Copyright (c) 2002-2004 IBM Canada 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.core.parser.tests;
|
||||
|
||||
import java.io.StringReader;
|
||||
import java.util.Iterator;
|
||||
import java.util.Set;
|
||||
|
||||
import org.eclipse.cdt.core.parser.IParser;
|
||||
import org.eclipse.cdt.core.parser.NullLogService;
|
||||
import org.eclipse.cdt.core.parser.ParserFactory;
|
||||
import org.eclipse.cdt.core.parser.ParserLanguage;
|
||||
import org.eclipse.cdt.core.parser.ParserMode;
|
||||
import org.eclipse.cdt.core.parser.ScannerInfo;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTCompilationUnit;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTCompletionNode;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTNode;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTOffsetableNamedElement;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTCompletionNode.CompletionKind;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTNode.ILookupResult;
|
||||
|
||||
/**
|
||||
* @author johnc
|
||||
*/
|
||||
public class CompletionParseBaseTest extends CompleteParseBaseTest {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public CompletionParseBaseTest() {
|
||||
super();
|
||||
}
|
||||
/**
|
||||
* @param name
|
||||
*/
|
||||
public CompletionParseBaseTest(String name) {
|
||||
super(name);
|
||||
}
|
||||
|
||||
protected IASTCompletionNode parse(String code, int offset) throws Exception {
|
||||
callback = new FullParseCallback();
|
||||
IParser parser = null;
|
||||
|
||||
parser =
|
||||
ParserFactory.createParser(
|
||||
ParserFactory.createScanner(
|
||||
new StringReader(code),
|
||||
"completion-test",
|
||||
new ScannerInfo(),
|
||||
ParserMode.COMPLETION_PARSE,
|
||||
ParserLanguage.CPP,
|
||||
callback,
|
||||
new NullLogService(), null),
|
||||
callback,
|
||||
ParserMode.COMPLETION_PARSE,
|
||||
ParserLanguage.CPP,
|
||||
null);
|
||||
|
||||
return parser.parse( offset );
|
||||
|
||||
}
|
||||
protected IASTCompletionNode parse(String code, int offset, ParserLanguage lang) throws Exception {
|
||||
callback = new FullParseCallback();
|
||||
IParser parser = null;
|
||||
|
||||
parser =
|
||||
ParserFactory.createParser(
|
||||
ParserFactory.createScanner(
|
||||
new StringReader(code),
|
||||
"completion-test",
|
||||
new ScannerInfo(),
|
||||
ParserMode.COMPLETION_PARSE,
|
||||
lang,
|
||||
callback,
|
||||
new NullLogService(), null),
|
||||
callback,
|
||||
ParserMode.COMPLETION_PARSE,
|
||||
lang,
|
||||
null);
|
||||
|
||||
return parser.parse( offset );
|
||||
|
||||
}
|
||||
/**
|
||||
* @param result
|
||||
*/
|
||||
protected void validateLookupResult(ILookupResult result, Set matches) {
|
||||
|
||||
assertNotNull( matches );
|
||||
assertEquals( result.getResultsSize(), matches.size() );
|
||||
|
||||
Iterator iter = result.getNodes();
|
||||
while( iter.hasNext() )
|
||||
{
|
||||
IASTOffsetableNamedElement element = (IASTOffsetableNamedElement) iter.next();
|
||||
assertTrue( matches.contains( element.getName() ));
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
protected IASTCompilationUnit getCompilationUnit() {
|
||||
IASTCompilationUnit compilationUnit = (IASTCompilationUnit) ((Scope) callback.getCompilationUnit()).getScope();
|
||||
return compilationUnit;
|
||||
}
|
||||
/**
|
||||
* @param node
|
||||
* @param hasKeywords
|
||||
*/
|
||||
protected void validateCompletionNode(IASTCompletionNode node, String prefix, CompletionKind kind, IASTNode context, boolean hasKeywords) {
|
||||
assertNotNull( node );
|
||||
assertEquals( node.getCompletionPrefix(), prefix);
|
||||
assertEquals( node.getCompletionKind(), kind );
|
||||
assertEquals( node.getCompletionContext(), context );
|
||||
if( hasKeywords )
|
||||
assertTrue( node.getKeywords().hasNext() );
|
||||
else
|
||||
assertFalse( node.getKeywords().hasNext() );
|
||||
}
|
||||
|
||||
}
|
|
@ -6,30 +6,23 @@
|
|||
*/
|
||||
package org.eclipse.cdt.core.parser.tests;
|
||||
|
||||
import java.io.StringReader;
|
||||
import java.io.StringWriter;
|
||||
import java.io.Writer;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.Set;
|
||||
|
||||
import org.eclipse.cdt.core.parser.IParser;
|
||||
import org.eclipse.cdt.core.parser.NullLogService;
|
||||
import org.eclipse.cdt.core.parser.ParserFactory;
|
||||
import org.eclipse.cdt.core.parser.ParserLanguage;
|
||||
import org.eclipse.cdt.core.parser.ParserMode;
|
||||
import org.eclipse.cdt.core.parser.ScannerInfo;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTClassSpecifier;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTCodeScope;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTCompilationUnit;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTCompletionNode;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTDeclaration;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTExpression;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTField;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTFunction;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTMethod;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTNamespaceDefinition;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTNode;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTOffsetableNamedElement;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTParameterDeclaration;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTTypedefDeclaration;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTVariable;
|
||||
|
@ -43,59 +36,13 @@ import org.eclipse.cdt.core.parser.ast.IASTNode.LookupKind;
|
|||
* To change the template for this generated type comment go to Window -
|
||||
* Preferences - Java - Code Generation - Code and Comments
|
||||
*/
|
||||
public class CompletionParseTest extends CompleteParseBaseTest {
|
||||
public class CompletionParseTest extends CompletionParseBaseTest {
|
||||
|
||||
|
||||
public CompletionParseTest(String name) {
|
||||
super(name);
|
||||
}
|
||||
|
||||
protected IASTCompletionNode parse(String code, int offset)
|
||||
throws Exception {
|
||||
callback = new FullParseCallback();
|
||||
IParser parser = null;
|
||||
|
||||
parser =
|
||||
ParserFactory.createParser(
|
||||
ParserFactory.createScanner(
|
||||
new StringReader(code),
|
||||
"completion-test",
|
||||
new ScannerInfo(),
|
||||
ParserMode.COMPLETION_PARSE,
|
||||
ParserLanguage.CPP,
|
||||
callback,
|
||||
new NullLogService(), null),
|
||||
callback,
|
||||
ParserMode.COMPLETION_PARSE,
|
||||
ParserLanguage.CPP,
|
||||
null);
|
||||
|
||||
return parser.parse( offset );
|
||||
|
||||
}
|
||||
|
||||
protected IASTCompletionNode parse(String code, int offset, ParserLanguage lang ) throws Exception {
|
||||
callback = new FullParseCallback();
|
||||
IParser parser = null;
|
||||
|
||||
parser =
|
||||
ParserFactory.createParser(
|
||||
ParserFactory.createScanner(
|
||||
new StringReader(code),
|
||||
"completion-test",
|
||||
new ScannerInfo(),
|
||||
ParserMode.COMPLETION_PARSE,
|
||||
lang,
|
||||
callback,
|
||||
new NullLogService(), null),
|
||||
callback,
|
||||
ParserMode.COMPLETION_PARSE,
|
||||
lang,
|
||||
null);
|
||||
|
||||
return parser.parse( offset );
|
||||
|
||||
}
|
||||
public void testBaseCase_SimpleDeclaration() throws Exception
|
||||
{
|
||||
StringWriter writer = new StringWriter();
|
||||
|
@ -219,7 +166,7 @@ public class CompletionParseTest extends CompleteParseBaseTest {
|
|||
assertTrue( node.getCompletionScope() instanceof IASTFunction );
|
||||
assertEquals( node.getCompletionKind(), IASTCompletionNode.CompletionKind.MEMBER_REFERENCE );
|
||||
assertNotNull( node.getCompletionContext() );
|
||||
assertTrue( node.getCompletionContext() instanceof IASTClassSpecifier );
|
||||
assertTrue( node.getCompletionContext() instanceof IASTVariable );
|
||||
|
||||
IASTNode.LookupKind[] kinds = new IASTNode.LookupKind[1];
|
||||
kinds[0] = IASTNode.LookupKind.ALL;
|
||||
|
@ -261,8 +208,8 @@ public class CompletionParseTest extends CompleteParseBaseTest {
|
|||
assertEquals(node.getCompletionKind(), IASTCompletionNode.CompletionKind.MEMBER_REFERENCE);
|
||||
assertTrue(node.getCompletionScope() instanceof IASTFunction );
|
||||
assertEquals( ((IASTFunction)node.getCompletionScope()).getName(), "foo" );
|
||||
assertTrue(node.getCompletionContext() instanceof IASTClassSpecifier );
|
||||
assertEquals( ((IASTClassSpecifier)node.getCompletionContext()).getName(), "B" );
|
||||
assertTrue(node.getCompletionContext() instanceof IASTVariable );
|
||||
assertEquals( ((IASTVariable)node.getCompletionContext()).getName(), "b" );
|
||||
}
|
||||
|
||||
public void testMemberCompletion_Dot() throws Exception
|
||||
|
@ -289,8 +236,8 @@ public class CompletionParseTest extends CompleteParseBaseTest {
|
|||
assertEquals(node.getCompletionKind(), IASTCompletionNode.CompletionKind.MEMBER_REFERENCE);
|
||||
assertTrue(node.getCompletionScope() instanceof IASTFunction );
|
||||
assertEquals( ((IASTFunction)node.getCompletionScope()).getName(), "foo" );
|
||||
assertTrue(node.getCompletionContext() instanceof IASTClassSpecifier );
|
||||
assertEquals( ((IASTClassSpecifier)node.getCompletionContext()).getName(), "B" );
|
||||
assertTrue(node.getCompletionContext() instanceof IASTVariable );
|
||||
assertEquals( ((IASTVariable)node.getCompletionContext()).getName(), "b" );
|
||||
}
|
||||
|
||||
|
||||
|
@ -325,7 +272,7 @@ public class CompletionParseTest extends CompleteParseBaseTest {
|
|||
assertTrue( node.getCompletionScope() instanceof IASTFunction );
|
||||
assertEquals( node.getCompletionKind(), IASTCompletionNode.CompletionKind.MEMBER_REFERENCE );
|
||||
assertNotNull( node.getCompletionContext() );
|
||||
assertTrue( node.getCompletionContext() instanceof IASTClassSpecifier );
|
||||
assertTrue( node.getCompletionContext() instanceof IASTVariable );
|
||||
|
||||
IASTNode.LookupKind[] kinds = new IASTNode.LookupKind[1];
|
||||
kinds[0] = IASTNode.LookupKind.METHODS;
|
||||
|
@ -371,7 +318,7 @@ public class CompletionParseTest extends CompleteParseBaseTest {
|
|||
assertTrue( node.getCompletionScope() instanceof IASTFunction );
|
||||
assertEquals( node.getCompletionKind(), IASTCompletionNode.CompletionKind.MEMBER_REFERENCE );
|
||||
assertNotNull( node.getCompletionContext() );
|
||||
assertTrue( node.getCompletionContext() instanceof IASTClassSpecifier );
|
||||
assertTrue( node.getCompletionContext() instanceof IASTVariable );
|
||||
|
||||
ILookupResult result = node.getCompletionScope().lookup( prefix, new IASTNode.LookupKind [] { IASTNode.LookupKind.METHODS }, node.getCompletionContext() );
|
||||
assertEquals( result.getPrefix(), prefix );
|
||||
|
@ -413,7 +360,7 @@ public class CompletionParseTest extends CompleteParseBaseTest {
|
|||
assertTrue( node.getCompletionScope() instanceof IASTFunction );
|
||||
assertEquals( node.getCompletionKind(), IASTCompletionNode.CompletionKind.MEMBER_REFERENCE );
|
||||
assertNotNull( node.getCompletionContext() );
|
||||
assertTrue( node.getCompletionContext() instanceof IASTClassSpecifier );
|
||||
assertTrue( node.getCompletionContext() instanceof IASTVariable );
|
||||
|
||||
ILookupResult result = node.getCompletionScope().lookup( prefix, new IASTNode.LookupKind [] { IASTNode.LookupKind.METHODS }, node.getCompletionContext() );
|
||||
assertEquals( result.getPrefix(), prefix );
|
||||
|
@ -690,31 +637,6 @@ public class CompletionParseTest extends CompleteParseBaseTest {
|
|||
assertFalse( iter.hasNext() );
|
||||
}
|
||||
|
||||
public void testCompletionInTypeDef() throws Exception{
|
||||
StringWriter writer = new StringWriter();
|
||||
writer.write( "struct A { int name; }; \n" );
|
||||
writer.write( "typedef struct A * PA; \n" );
|
||||
writer.write( "int main() { \n" );
|
||||
writer.write( " PA a; \n" );
|
||||
writer.write( " a->SP \n" );
|
||||
writer.write( "} \n" );
|
||||
|
||||
String code = writer.toString();
|
||||
int index = code.indexOf( "SP" );
|
||||
|
||||
IASTCompletionNode node = parse( code, index );
|
||||
ILookupResult result = node.getCompletionScope().lookup( node.getCompletionPrefix(),
|
||||
new IASTNode.LookupKind[]{ IASTNode.LookupKind.ALL },
|
||||
node.getCompletionContext() );
|
||||
|
||||
assertEquals( result.getResultsSize(), 1 );
|
||||
|
||||
Iterator iter = result.getNodes();
|
||||
IASTField name = (IASTField) iter.next();
|
||||
|
||||
assertEquals( name.getName(), "name" );
|
||||
assertFalse( iter.hasNext() );
|
||||
}
|
||||
|
||||
public void testCompletionInFunctionBodyFullyQualified() throws Exception
|
||||
{
|
||||
|
@ -743,46 +665,6 @@ public class CompletionParseTest extends CompleteParseBaseTest {
|
|||
results.add( "NMS");
|
||||
validateLookupResult(result, results );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param result
|
||||
*/
|
||||
private void validateLookupResult(ILookupResult result, Set matches) {
|
||||
|
||||
assertNotNull( matches );
|
||||
assertEquals( result.getResultsSize(), matches.size() );
|
||||
|
||||
Iterator iter = result.getNodes();
|
||||
while( iter.hasNext() )
|
||||
{
|
||||
IASTOffsetableNamedElement element = (IASTOffsetableNamedElement) iter.next();
|
||||
assertTrue( matches.contains( element.getName() ));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
protected IASTCompilationUnit getCompilationUnit() {
|
||||
IASTCompilationUnit compilationUnit = (IASTCompilationUnit) ((Scope) callback.getCompilationUnit()).getScope();
|
||||
return compilationUnit;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param node
|
||||
* @param hasKeywords TODO
|
||||
*/
|
||||
protected void validateCompletionNode(IASTCompletionNode node, String prefix, CompletionKind kind, IASTNode context, boolean hasKeywords ) {
|
||||
assertNotNull( node );
|
||||
assertEquals( node.getCompletionPrefix(), prefix);
|
||||
assertEquals( node.getCompletionKind(), kind );
|
||||
assertEquals( node.getCompletionContext(), context );
|
||||
if( hasKeywords )
|
||||
assertTrue( node.getKeywords().hasNext() );
|
||||
else
|
||||
assertFalse( node.getKeywords().hasNext() );
|
||||
}
|
||||
|
||||
public void testCompletionInFunctionBodyQualifiedName() throws Exception
|
||||
|
@ -911,4 +793,23 @@ public class CompletionParseTest extends CompleteParseBaseTest {
|
|||
assertTrue( i.next() instanceof IASTField );
|
||||
assertTrue( i.next() instanceof IASTField );
|
||||
}
|
||||
|
||||
public void testCompletionOnExpression() throws Exception
|
||||
{
|
||||
Writer writer = new StringWriter();
|
||||
writer.write( "class ABC { public: void voidMethod(); };\n");
|
||||
writer.write( "ABC * someFunction(void) { return new ABC(); }\n");
|
||||
writer.write( "void testFunction( void ) { someFunction()->V }\n" );
|
||||
String code = writer.toString();
|
||||
for( int i = 0; i < 2; ++i )
|
||||
{
|
||||
int index = code.indexOf( "V");
|
||||
if( i == 1 ) ++index;
|
||||
IASTCompletionNode node = parse( code, index );
|
||||
assertEquals( node.getCompletionPrefix(), (i == 0 )? "": "V");
|
||||
assertEquals( node.getCompletionKind(), CompletionKind.MEMBER_REFERENCE );
|
||||
assertTrue( node.getCompletionContext() instanceof IASTExpression );
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@ import org.eclipse.cdt.core.model.tests.BinaryTests;
|
|||
import org.eclipse.cdt.core.model.tests.ElementDeltaTests;
|
||||
import org.eclipse.cdt.core.model.tests.WorkingCopyTests;
|
||||
import org.eclipse.cdt.core.parser.failedTests.ASTFailedTests;
|
||||
import org.eclipse.cdt.core.parser.failedTests.CompletionParseFailedTest;
|
||||
import org.eclipse.cdt.core.parser.failedTests.FailedCompleteParseASTTest;
|
||||
import org.eclipse.cdt.core.parser.failedTests.STLFailedTests;
|
||||
import org.eclipse.cdt.core.parser.tests.ParserTestSuite;
|
||||
|
@ -67,6 +68,7 @@ public class AutomatedIntegrationSuite extends TestSuite {
|
|||
suite.addTestSuite(ASTFailedTests.class);
|
||||
suite.addTestSuite(STLFailedTests.class);
|
||||
suite.addTestSuite(FailedCompleteParseASTTest.class);
|
||||
suite.addTestSuite(CompletionParseFailedTest.class);
|
||||
|
||||
return suite;
|
||||
}
|
||||
|
|
|
@ -31,4 +31,14 @@ public class ASTPointerOperator extends Enum
|
|||
{
|
||||
super(enumValue);
|
||||
}
|
||||
|
||||
public boolean isStarOperator()
|
||||
{
|
||||
return ( ( this == VOLATILE_POINTER ) || ( this == CONST_POINTER ) || ( this == RESTRICT_POINTER ) || ( this == POINTER ));
|
||||
}
|
||||
|
||||
public boolean isReferenceOperator()
|
||||
{
|
||||
return ( this == REFERENCE );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ import org.eclipse.cdt.core.parser.ISourceElementCallbackDelegate;
|
|||
* @author jcamelon
|
||||
*
|
||||
*/
|
||||
public interface IASTExpression extends ISourceElementCallbackDelegate
|
||||
public interface IASTExpression extends ISourceElementCallbackDelegate, IASTNode
|
||||
{
|
||||
public class Kind extends Enum
|
||||
{
|
||||
|
|
|
@ -19,7 +19,6 @@ import org.eclipse.cdt.core.parser.IToken;
|
|||
import org.eclipse.cdt.core.parser.ITokenDuple;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTClassSpecifier.ClassNameType;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTExpression.IASTNewExpressionDescriptor;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTExpression.Kind;
|
||||
/**
|
||||
* @author jcamelon
|
||||
*
|
||||
|
@ -240,12 +239,6 @@ public interface IASTFactory
|
|||
*/
|
||||
public void signalEndOfClassSpecifier(IASTClassSpecifier astClassSpecifier);
|
||||
|
||||
/**
|
||||
* @param kind
|
||||
* @param firstExpression
|
||||
*/
|
||||
public IASTNode getCompletionContext(Kind kind, IASTExpression expression);
|
||||
|
||||
public IASTNode lookupSymbolInContext( IASTScope scope, ITokenDuple duple ) throws ASTNotImplementedException;
|
||||
|
||||
/**
|
||||
|
@ -265,6 +258,18 @@ public interface IASTFactory
|
|||
* @param expression
|
||||
* @return
|
||||
*/
|
||||
public IASTNode expressionToASTNode(IASTScope scope, IASTExpression expression);
|
||||
public IASTNode expressionToMostPreciseASTNode(IASTScope scope, IASTExpression expression);
|
||||
|
||||
/**
|
||||
* @param node
|
||||
* @return
|
||||
*/
|
||||
public boolean validateIndirectMemberOperation(IASTNode node);
|
||||
|
||||
/**
|
||||
* @param node
|
||||
* @return
|
||||
*/
|
||||
public boolean validateDirectMemberOperation(IASTNode node);
|
||||
|
||||
}
|
|
@ -10,6 +10,7 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.parser;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.Set;
|
||||
|
||||
import org.eclipse.cdt.core.parser.BacktrackException;
|
||||
|
@ -21,11 +22,15 @@ import org.eclipse.cdt.core.parser.IToken;
|
|||
import org.eclipse.cdt.core.parser.ITokenDuple;
|
||||
import org.eclipse.cdt.core.parser.ParserLanguage;
|
||||
import org.eclipse.cdt.core.parser.ast.ASTNotImplementedException;
|
||||
import org.eclipse.cdt.core.parser.ast.ASTPointerOperator;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTCompletionNode;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTExpression;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTNode;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTParameterDeclaration;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTScope;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTVariable;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTCompletionNode.CompletionKind;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTExpression.Kind;
|
||||
import org.eclipse.cdt.core.parser.extension.IParserExtension;
|
||||
import org.eclipse.cdt.internal.core.parser.token.KeywordSets;
|
||||
import org.eclipse.cdt.internal.core.parser.token.TokenDuple;
|
||||
|
@ -126,13 +131,6 @@ public class ContextualParser extends CompleteParser {
|
|||
finalToken = token;
|
||||
}
|
||||
|
||||
protected IASTNode getCompletionContextForExpression(IASTExpression firstExpression, boolean isTemplate) {
|
||||
return astFactory.getCompletionContext( (isTemplate
|
||||
? IASTExpression.Kind.POSTFIX_DOT_TEMPL_IDEXPRESS
|
||||
: IASTExpression.Kind.POSTFIX_DOT_IDEXPRESSION),
|
||||
firstExpression ) ;
|
||||
}
|
||||
|
||||
protected void setCompletionValues(IASTScope scope, CompletionKind kind, Key key, IASTNode node, String prefix) throws EndOfFileException {
|
||||
setCompletionToken( TokenFactory.createToken( IToken.tIDENTIFIER, prefix ) );
|
||||
setCompletionValues(scope, kind, key, node );
|
||||
|
@ -171,8 +169,27 @@ public class ContextualParser extends CompleteParser {
|
|||
|
||||
|
||||
|
||||
protected void setCompletionValues(IASTScope scope, CompletionKind kind, Key key, IASTExpression firstExpression, boolean isTemplate) throws EndOfFileException {
|
||||
setCompletionValues(scope,kind,key, getCompletionContextForExpression(firstExpression,isTemplate) );
|
||||
protected void setCompletionValues(IASTScope scope, CompletionKind kind, Key key, IASTExpression firstExpression, Kind expressionKind) throws EndOfFileException {
|
||||
IASTNode node = astFactory.expressionToMostPreciseASTNode( scope, firstExpression );
|
||||
if( kind == CompletionKind.MEMBER_REFERENCE )
|
||||
{
|
||||
if( ! validMemberOperation( node, expressionKind ))
|
||||
node =null;
|
||||
}
|
||||
setCompletionValues(scope,kind,key, node );
|
||||
}
|
||||
|
||||
/**
|
||||
* @param node
|
||||
* @param expressionKind
|
||||
* @return
|
||||
*/
|
||||
private boolean validMemberOperation(IASTNode node, Kind expressionKind) {
|
||||
if( expressionKind == Kind.POSTFIX_ARROW_IDEXPRESSION || expressionKind == Kind.POSTFIX_ARROW_TEMPL_IDEXP )
|
||||
return astFactory.validateIndirectMemberOperation( node );
|
||||
else if( expressionKind == Kind.POSTFIX_DOT_IDEXPRESSION || expressionKind == Kind.POSTFIX_DOT_TEMPL_IDEXPRESS )
|
||||
return astFactory.validateDirectMemberOperation( node );
|
||||
return false;
|
||||
}
|
||||
|
||||
protected void setCompletionScope(IASTScope scope) {
|
||||
|
|
|
@ -2285,7 +2285,7 @@ public class ExpressionParser implements IExpressionParser, IParserData {
|
|||
firstExpression.getRHSExpression().getIdExpression() != null )
|
||||
{
|
||||
setCurrentFunctionName( firstExpression.getRHSExpression().getIdExpression() );
|
||||
context = astFactory.expressionToASTNode( scope, firstExpression.getLHSExpression() );
|
||||
context = astFactory.expressionToMostPreciseASTNode( scope, firstExpression.getLHSExpression() );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2376,18 +2376,19 @@ public class ExpressionParser implements IExpressionParser, IParserData {
|
|||
isTemplate = true;
|
||||
}
|
||||
|
||||
setCompletionValues(scope, CompletionKind.MEMBER_REFERENCE, KeywordSets.Key.EMPTY, firstExpression, isTemplate );
|
||||
Kind memberCompletionKind = (isTemplate
|
||||
? IASTExpression.Kind.POSTFIX_DOT_TEMPL_IDEXPRESS
|
||||
: IASTExpression.Kind.POSTFIX_DOT_IDEXPRESSION);
|
||||
|
||||
setCompletionValues(scope, CompletionKind.MEMBER_REFERENCE, KeywordSets.Key.EMPTY, firstExpression, memberCompletionKind );
|
||||
secondExpression = primaryExpression(scope, CompletionKind.MEMBER_REFERENCE, key);
|
||||
|
||||
try
|
||||
{
|
||||
firstExpression =
|
||||
firstExpression =
|
||||
astFactory.createExpression(
|
||||
scope,
|
||||
(isTemplate
|
||||
? IASTExpression.Kind.POSTFIX_DOT_TEMPL_IDEXPRESS
|
||||
: IASTExpression.Kind.POSTFIX_DOT_IDEXPRESSION),
|
||||
memberCompletionKind,
|
||||
firstExpression,
|
||||
secondExpression,
|
||||
null,
|
||||
|
@ -2415,17 +2416,19 @@ public class ExpressionParser implements IExpressionParser, IParserData {
|
|||
isTemplate = true;
|
||||
}
|
||||
|
||||
setCompletionValues(scope, CompletionKind.MEMBER_REFERENCE, KeywordSets.Key.EMPTY, firstExpression, isTemplate );
|
||||
Kind arrowCompletionKind = (isTemplate
|
||||
? IASTExpression.Kind.POSTFIX_ARROW_TEMPL_IDEXP
|
||||
: IASTExpression.Kind.POSTFIX_ARROW_IDEXPRESSION);
|
||||
|
||||
setCompletionValues(scope, CompletionKind.MEMBER_REFERENCE, KeywordSets.Key.EMPTY, firstExpression, arrowCompletionKind );
|
||||
secondExpression = primaryExpression(scope, CompletionKind.MEMBER_REFERENCE, key);
|
||||
|
||||
try
|
||||
{
|
||||
firstExpression =
|
||||
firstExpression =
|
||||
astFactory.createExpression(
|
||||
scope,
|
||||
(isTemplate
|
||||
? IASTExpression.Kind.POSTFIX_ARROW_TEMPL_IDEXP
|
||||
: IASTExpression.Kind.POSTFIX_ARROW_IDEXPRESSION),
|
||||
arrowCompletionKind,
|
||||
firstExpression,
|
||||
secondExpression,
|
||||
null,
|
||||
|
@ -2826,7 +2829,7 @@ public class ExpressionParser implements IExpressionParser, IParserData {
|
|||
protected void setCompletionValues(IASTScope scope, IASTCompletionNode.CompletionKind kind, KeywordSets.Key key, IASTNode node, String prefix) throws EndOfFileException {
|
||||
}
|
||||
|
||||
protected void setCompletionValues(IASTScope scope, CompletionKind kind, Key key, IASTExpression firstExpression, boolean isTemplate) throws EndOfFileException {
|
||||
protected void setCompletionValues(IASTScope scope, CompletionKind kind, Key key, IASTExpression firstExpression, Kind expressionKind) throws EndOfFileException {
|
||||
}
|
||||
|
||||
protected void setCompletionValues( IASTScope scope, CompletionKind kind, IToken first, IToken last, Key key ) throws EndOfFileException {
|
||||
|
|
|
@ -25,7 +25,7 @@ import org.eclipse.cdt.core.parser.ast.IASTTypeId;
|
|||
* @author jcamelon
|
||||
*
|
||||
*/
|
||||
public class ASTExpression implements IASTExpression
|
||||
public class ASTExpression extends ASTNode implements IASTExpression
|
||||
{
|
||||
private final Kind kind;
|
||||
private final IASTExpression lhs;
|
||||
|
|
|
@ -97,6 +97,7 @@ import org.eclipse.cdt.internal.core.parser.pst.StandardSymbolExtension;
|
|||
import org.eclipse.cdt.internal.core.parser.pst.TemplateSymbolExtension;
|
||||
import org.eclipse.cdt.internal.core.parser.pst.TypeInfo;
|
||||
import org.eclipse.cdt.internal.core.parser.pst.ISymbolASTExtension.ExtensionException;
|
||||
import org.eclipse.cdt.internal.core.parser.pst.TypeInfo.PtrOp;
|
||||
import org.eclipse.cdt.internal.core.parser.util.TraceUtil;
|
||||
|
||||
|
||||
|
@ -3282,26 +3283,6 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
|||
return new ASTInitializerClause( kind, assignmentExpression, initializerClauses, designators );
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ast.IASTFactory#getCompletionContext(org.eclipse.cdt.core.parser.ast.IASTExpression.Kind, org.eclipse.cdt.core.parser.ast.IASTExpression)
|
||||
*/
|
||||
public IASTNode getCompletionContext(Kind kind, IASTExpression expression) {
|
||||
IContainerSymbol context = null;
|
||||
try {
|
||||
context = getSearchScope( kind, expression, null );
|
||||
} catch (ASTSemanticException e) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if( context != null ){
|
||||
ISymbolASTExtension symbolExtension = context.getASTExtension();
|
||||
return ( symbolExtension != null ) ? symbolExtension.getPrimaryDeclaration() : null;
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ast.IASTFactory#lookupSymbolInContext(org.eclipse.cdt.core.parser.ast.IASTScope, org.eclipse.cdt.core.parser.ITokenDuple)
|
||||
*/
|
||||
|
@ -3318,9 +3299,10 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ast.IASTFactory#getNodeForThisExpression(org.eclipse.cdt.core.parser.ast.IASTExpression)
|
||||
*/
|
||||
public IASTNode expressionToASTNode(IASTScope scope, IASTExpression expression) {
|
||||
public IASTNode expressionToMostPreciseASTNode(IASTScope scope, IASTExpression expression) {
|
||||
if( expression == null ) return null;
|
||||
if( expression.getExpressionKind() == IASTExpression.Kind.ID_EXPRESSION )
|
||||
{
|
||||
if( expression instanceof ASTExpression)
|
||||
{
|
||||
try {
|
||||
|
@ -3329,7 +3311,53 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
|||
// assert false : e;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
return expression;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ast.IASTFactory#validateIndirectMemberOperation(org.eclipse.cdt.core.parser.ast.IASTNode)
|
||||
*/
|
||||
public boolean validateIndirectMemberOperation(IASTNode node) {
|
||||
List pointerOps = null;
|
||||
if( ( node instanceof ISymbolOwner ) )
|
||||
pointerOps = ((ISymbolOwner) node).getSymbol().getTypeInfo().getFinalType().getPtrOperators();
|
||||
else if( node instanceof ASTExpression )
|
||||
{
|
||||
ISymbol typeSymbol = ((ASTExpression)node).getResultType().getResult().getTypeSymbol();
|
||||
if( typeSymbol != null )
|
||||
pointerOps = typeSymbol.getTypeInfo().getFinalType().getPtrOperators();
|
||||
}
|
||||
else
|
||||
return false;
|
||||
|
||||
|
||||
if( pointerOps == null || pointerOps.isEmpty() ) return false;
|
||||
TypeInfo.PtrOp lastOperator = (PtrOp) pointerOps.get( pointerOps.size() - 1 );
|
||||
if( lastOperator.getType() == TypeInfo.PtrOp.t_array || lastOperator.getType() == TypeInfo.PtrOp.t_pointer ) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ast.IASTFactory#validateDirectMemberOperation(org.eclipse.cdt.core.parser.ast.IASTNode)
|
||||
*/
|
||||
public boolean validateDirectMemberOperation(IASTNode node) {
|
||||
List pointerOps = null;
|
||||
if( ( node instanceof ISymbolOwner ) )
|
||||
pointerOps = ((ISymbolOwner) node).getSymbol().getPtrOperators();
|
||||
else if( node instanceof ASTExpression )
|
||||
{
|
||||
ISymbol typeSymbol = ((ASTExpression)node).getResultType().getResult().getTypeSymbol();
|
||||
if( typeSymbol != null )
|
||||
pointerOps = typeSymbol.getPtrOperators();
|
||||
}
|
||||
else
|
||||
return false;
|
||||
|
||||
if( pointerOps == null || pointerOps.isEmpty() ) return true;
|
||||
TypeInfo.PtrOp lastOperator = (PtrOp) pointerOps.get( pointerOps.size() - 1 );
|
||||
if( lastOperator.getType() == TypeInfo.PtrOp.t_reference ) return true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@ import org.eclipse.cdt.core.parser.ISourceElementRequestor;
|
|||
import org.eclipse.cdt.core.parser.ast.ASTExpressionEvaluationException;
|
||||
import org.eclipse.cdt.core.parser.ast.ASTNotImplementedException;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTExpression;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTNode;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTTypeId;
|
||||
|
||||
|
||||
|
@ -216,5 +217,13 @@ public class ASTExpression implements IASTExpression {
|
|||
throw new ASTNotImplementedException();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ast.IASTNode#lookup(java.lang.String, org.eclipse.cdt.core.parser.ast.IASTNode.LookupKind[], org.eclipse.cdt.core.parser.ast.IASTNode)
|
||||
*/
|
||||
public ILookupResult lookup(String prefix, LookupKind[] k, IASTNode context) throws LookupError, ASTNotImplementedException {
|
||||
// Not provided in this mode
|
||||
throw new ASTNotImplementedException();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -872,18 +872,6 @@ public class ExpressionParseASTFactory extends BaseASTFactory implements IASTFac
|
|||
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.cdt.core.parser.ast.IASTFactory#getCompletionContext(org.eclipse.cdt.core.parser.ast.IASTExpression.Kind,
|
||||
* org.eclipse.cdt.core.parser.ast.IASTExpression)
|
||||
*/
|
||||
public IASTNode getCompletionContext(
|
||||
Kind kind,
|
||||
IASTExpression expression) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
|
@ -898,7 +886,7 @@ public class ExpressionParseASTFactory extends BaseASTFactory implements IASTFac
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ast.IASTFactory#getNodeForThisExpression(org.eclipse.cdt.core.parser.ast.IASTExpression)
|
||||
*/
|
||||
public IASTNode expressionToASTNode(IASTScope scope, IASTExpression expression) {
|
||||
public IASTNode expressionToMostPreciseASTNode(IASTScope scope, IASTExpression expression) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
@ -910,5 +898,21 @@ public class ExpressionParseASTFactory extends BaseASTFactory implements IASTFac
|
|||
return scope;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ast.IASTFactory#validateIndirectMemberOperation(org.eclipse.cdt.core.parser.ast.IASTNode)
|
||||
*/
|
||||
public boolean validateIndirectMemberOperation(IASTNode node) {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ast.IASTFactory#validateDirectMemberOperation(org.eclipse.cdt.core.parser.ast.IASTNode)
|
||||
*/
|
||||
public boolean validateDirectMemberOperation(IASTNode node) {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -71,7 +71,6 @@ public class QuickParseASTFactory extends BaseASTFactory implements IASTFactory
|
|||
|
||||
private static final boolean CREATE_EXCESS_CONSTRUCTS = true;
|
||||
|
||||
|
||||
public QuickParseASTFactory( IASTFactoryExtension extension )
|
||||
{
|
||||
super(extension);
|
||||
|
@ -346,14 +345,6 @@ public class QuickParseASTFactory extends BaseASTFactory implements IASTFactory
|
|||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ast.IASTFactory#getCompletionContext(org.eclipse.cdt.core.parser.ast.IASTExpression.Kind, org.eclipse.cdt.core.parser.ast.IASTExpression)
|
||||
*/
|
||||
public IASTNode getCompletionContext(Kind kind, IASTExpression expression) {
|
||||
//we have no cross-reference information about the type of the expression
|
||||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ast.IASTFactory#lookupSymbolInContext(org.eclipse.cdt.core.parser.ast.IASTScope, org.eclipse.cdt.core.parser.ITokenDuple)
|
||||
*/
|
||||
|
@ -371,7 +362,23 @@ public class QuickParseASTFactory extends BaseASTFactory implements IASTFactory
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ast.IASTFactory#getNodeForThisExpression(org.eclipse.cdt.core.parser.ast.IASTExpression)
|
||||
*/
|
||||
public IASTNode expressionToASTNode(IASTScope scope, IASTExpression expression) {
|
||||
public IASTNode expressionToMostPreciseASTNode(IASTScope scope, IASTExpression expression) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ast.IASTFactory#validateIndirectMemberOperation(org.eclipse.cdt.core.parser.ast.IASTNode)
|
||||
*/
|
||||
public boolean validateIndirectMemberOperation(IASTNode node) {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ast.IASTFactory#validateDirectMemberOperation(org.eclipse.cdt.core.parser.ast.IASTNode)
|
||||
*/
|
||||
public boolean validateDirectMemberOperation(IASTNode node) {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ import org.eclipse.cdt.ui.tests.text.contentassist.CompletionTest_MacroRef_NoPre
|
|||
import org.eclipse.cdt.ui.tests.text.contentassist.CompletionTest_MacroRef_Prefix;
|
||||
import org.eclipse.cdt.ui.tests.text.contentassist.CompletionTest_MemberReference_Arrow_NoPrefix;
|
||||
import org.eclipse.cdt.ui.tests.text.contentassist.CompletionTest_MemberReference_Arrow_Prefix;
|
||||
import org.eclipse.cdt.ui.tests.text.contentassist.CompletionTest_MemberReference_Arrow_Prefix2;
|
||||
import org.eclipse.cdt.ui.tests.text.contentassist.CompletionFailedTest_MemberReference_Arrow_Prefix2;
|
||||
import org.eclipse.cdt.ui.tests.text.contentassist.CompletionTest_MemberReference_Dot_NoPrefix;
|
||||
import org.eclipse.cdt.ui.tests.text.contentassist.CompletionTest_MemberReference_Dot_Prefix;
|
||||
import org.eclipse.cdt.ui.tests.text.contentassist.CompletionTest_NamespaceRef_NoPrefix;
|
||||
|
@ -87,7 +87,7 @@ public class AutomatedSuite extends TestSuite {
|
|||
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(CompletionFailedTest_MemberReference_Arrow_Prefix2.suite());
|
||||
addTest(CompletionTest_MemberReference_Arrow_NoPrefix.suite());
|
||||
addTest(CompletionTest_NamespaceRef_Prefix.suite());
|
||||
addTest(CompletionTest_NamespaceRef_NoPrefix.suite());
|
||||
|
|
|
@ -21,27 +21,28 @@ import org.eclipse.cdt.core.parser.ast.IASTCompletionNode.CompletionKind;
|
|||
* Complex Context: Function return value: foo()->a(CTRL+SPACE)
|
||||
*
|
||||
*/
|
||||
public class CompletionTest_MemberReference_Arrow_Prefix2 extends CompletionProposalsBaseTest{
|
||||
public class CompletionFailedTest_MemberReference_Arrow_Prefix2 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 String expectedContextName = "ASTExpression";
|
||||
private final CompletionKind expectedKind = CompletionKind.MEMBER_REFERENCE;
|
||||
private final String expectedPrefix = "a";
|
||||
//TODO Andrew uncomment these when you get the bug fixed
|
||||
private final String[] expectedResults = {
|
||||
"aField : int",
|
||||
"aMethod() int"
|
||||
// "aField : int",
|
||||
// "aMethod() int"
|
||||
};
|
||||
|
||||
public CompletionTest_MemberReference_Arrow_Prefix2(String name) {
|
||||
public CompletionFailedTest_MemberReference_Arrow_Prefix2(String name) {
|
||||
super(name);
|
||||
}
|
||||
|
||||
public static Test suite() {
|
||||
TestSuite suite= new TestSuite(CompletionTest_MemberReference_Arrow_Prefix2.class.getName());
|
||||
suite.addTest(new CompletionTest_MemberReference_Arrow_Prefix2("testCompletionProposals"));
|
||||
TestSuite suite= new TestSuite(CompletionFailedTest_MemberReference_Arrow_Prefix2.class.getName());
|
||||
suite.addTest(new CompletionFailedTest_MemberReference_Arrow_Prefix2("testCompletionProposals"));
|
||||
return suite;
|
||||
}
|
||||
/* (non-Javadoc)
|
|
@ -28,7 +28,7 @@ public class CompletionTest_MemberReference_Arrow_NoPrefix extends CompletionPr
|
|||
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 String expectedContextName = "ASTVariable";
|
||||
private final CompletionKind expectedKind = CompletionKind.MEMBER_REFERENCE;
|
||||
private final String expectedPrefix = "";
|
||||
private final String[] expectedResults = {
|
||||
|
|
|
@ -27,7 +27,7 @@ public class CompletionTest_MemberReference_Arrow_Prefix extends CompletionProp
|
|||
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 String expectedContextName = "ASTVariable";
|
||||
private final CompletionKind expectedKind = CompletionKind.MEMBER_REFERENCE;
|
||||
private final String expectedPrefix = "a";
|
||||
private final String[] expectedResults = {
|
||||
|
|
|
@ -27,7 +27,7 @@ public class CompletionTest_MemberReference_Dot_NoPrefix extends CompletionProp
|
|||
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 String expectedContextName = "ASTVariable";
|
||||
private final CompletionKind expectedKind = CompletionKind.MEMBER_REFERENCE;
|
||||
private final String expectedPrefix = "";
|
||||
private final String[] expectedResults = {
|
||||
|
|
|
@ -27,7 +27,7 @@ public class CompletionTest_MemberReference_Dot_Prefix extends CompletionPropos
|
|||
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 String expectedContextName = "ASTVariable";
|
||||
private final CompletionKind expectedKind = CompletionKind.MEMBER_REFERENCE;
|
||||
private final String expectedPrefix = "a";
|
||||
private final String[] expectedResults = {
|
||||
|
|
Loading…
Add table
Reference in a new issue