1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00
org.eclipse.cdt.core.tests: Added CompletionTest::testBug52253().
This commit is contained in:
John Camelon 2004-04-15 03:21:05 +00:00
parent f6c0374580
commit 92d011ea1d
7 changed files with 45 additions and 29 deletions

View file

@ -1,3 +1,6 @@
2004-04-14 John Camelon
Added CompletionTest::testBug52253().
2004-04-14 John Camelon
Added CompleteParseASTTest::testBug44249().

View file

@ -18,7 +18,6 @@ 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.ParserUtil;
import org.eclipse.cdt.core.parser.ScannerInfo;
import org.eclipse.cdt.core.parser.ast.IASTClassSpecifier;
import org.eclipse.cdt.core.parser.ast.IASTCodeScope;
@ -841,5 +840,26 @@ public class CompletionParseTest extends CompleteParseBaseTest {
IASTCompletionNode node = parse( code, code.indexOf( where ) + where.length() );
assertEquals( node.getCompletionPrefix(), "GL_T");
}
public void testBug52253() throws Exception
{
Writer writer = new StringWriter();
writer.write( "class CMyClass {public:\n void doorBell(){ return; }};");
writer.write( "int main(int argc, char **argv) {CMyClass mc; mc.do }");
String code = writer.toString();
final String where = "mc.do";
IASTCompletionNode node = parse( code, code.indexOf( where) + where.length() );
assertEquals( node.getCompletionPrefix(), "do");
assertEquals( node.getCompletionKind(), CompletionKind.MEMBER_REFERENCE );
ILookupResult result = node.getCompletionScope().lookup( node.getCompletionPrefix(),
new IASTNode.LookupKind[]{ IASTNode.LookupKind.ALL },
node.getCompletionContext() );
assertEquals( result.getResultsSize(), 1 );
Iterator i = result.getNodes();
IASTMethod doorBell = (IASTMethod) i.next();
assertFalse( i.hasNext() );
assertEquals( doorBell.getName(), "doorBell");
}
}

View file

@ -1,3 +1,6 @@
2004-04-14 John Camelon
Fixed https://bugs.eclipse.org/bugs/show_bug.cgi?id=52253
2004-04-14 John Camelon
Fixed https://bugs.eclipse.org/bugs/show_bug.cgi?id=44249
Fixed https://bugs.eclipse.org/bugs/show_bug.cgi?id=52004

View file

@ -37,7 +37,7 @@ public interface IToken {
public boolean looksLikeExpression();
public boolean isPointer();
public boolean isOperator();
public boolean isKeywordOrOperator();
public boolean canBeAPrefix();
// Token types
@ -143,8 +143,6 @@ public interface IToken {
static public final int tDIV = 52;
// static public final int tCLASSNAME = 53;
static public final int t_and = 54;
static public final int t_and_eq = 55;

View file

@ -93,7 +93,7 @@ public class CompletionParser extends ContextualParser implements IParser {
if( exception.getCompletionNode() == null )
{
setCompletionToken( exception.getFinalToken() );
if( (finalToken!= null )&& (finalToken.isKeywordOrOperator() ))
if( (finalToken!= null )&& (!finalToken.canBeAPrefix() ))
setCompletionToken(null);
}
else

View file

@ -2230,9 +2230,6 @@ public class ExpressionParser implements IExpressionParser {
setCompletionValues(scope, CompletionKind.MEMBER_REFERENCE, KeywordSets.Key.EMPTY, firstExpression, isTemplate );
secondExpression = primaryExpression(scope, CompletionKind.MEMBER_REFERENCE);
checkEndOfFile();
setCompletionValues(scope, CompletionKind.NO_SUCH_KIND, KeywordSets.Key.EMPTY );
try
{
@ -2269,12 +2266,9 @@ public class ExpressionParser implements IExpressionParser {
isTemplate = true;
}
setCompletionValues(scope, CompletionKind.MEMBER_REFERENCE, KeywordSets.Key.EMPTY, firstExpression, isTemplate );
secondExpression = primaryExpression(scope, CompletionKind.MEMBER_REFERENCE);
checkEndOfFile();
setCompletionValues(scope, CompletionKind.MEMBER_REFERENCE, KeywordSets.Key.EMPTY, firstExpression, isTemplate );
secondExpression = primaryExpression(scope, CompletionKind.MEMBER_REFERENCE);
setCompletionValues(scope, CompletionKind.NO_SUCH_KIND, KeywordSets.Key.EMPTY );
try
{
firstExpression =
@ -2560,7 +2554,6 @@ public class ExpressionParser implements IExpressionParser {
duple = d.getNameDuple();
}
checkEndOfFile();
try
{
return astFactory.createExpression(
@ -2581,6 +2574,14 @@ public class ExpressionParser implements IExpressionParser {
throw backtrack;
}
default :
if( !queryLookaheadCapability(2) )
{
if( LA(1).canBeAPrefix() )
{
consume();
checkEndOfFile();
}
}
IASTExpression empty = null;
try {
empty = astFactory.createExpression(

View file

@ -16,7 +16,7 @@ import org.eclipse.cdt.core.parser.IToken;
/**
* @author johnc
*/
public abstract class AbstractToken {
public abstract class AbstractToken implements IToken {
public AbstractToken( int type, int lineNumber )
{
@ -70,20 +70,11 @@ public abstract class AbstractToken {
/* (non-Javadoc)
* @see org.eclipse.cdt.core.parser.IToken#isKeyword()
*/
public boolean isKeywordOrOperator() {
switch( getType() )
{
case IToken.tCHAR:
case IToken.tFLOATINGPT:
case IToken.tIDENTIFIER:
case IToken.tINTEGER:
case IToken.tSTRING:
case IToken.tLSTRING:
case IToken.tLCHAR:
return false;
default:
return true;
}
public boolean canBeAPrefix() {
if( getType() == tIDENTIFIER ) return true;
if( getType() >= t_and && getType() <= t_xor_eq ) return true;
if( getType() >= t__Bool && getType() <= t_restrict ) return true;
return false;
}
public boolean looksLikeExpression()