mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-07 17:56:01 +02:00
This commit is contained in:
parent
d595dc0508
commit
129dd89591
3 changed files with 30 additions and 14 deletions
|
@ -1086,4 +1086,20 @@ public class CompletionParseTest extends CompletionParseBaseTest {
|
|||
assertTrue( blah instanceof IASTVariable );
|
||||
assertEquals( ((IASTVariable)blah).getName(), "blah" ); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
public void testBug62725() throws Exception
|
||||
{
|
||||
Writer writer = new StringWriter();
|
||||
writer.write( "int f() {\n" ); //$NON-NLS-1$
|
||||
writer.write( " int biSizeImage = 5;\n" ); //$NON-NLS-1$
|
||||
writer.write( "for (int i = 0; i < bi " ); //$NON-NLS-1$
|
||||
String code = writer.toString();
|
||||
IASTCompletionNode node = parse( code, code.indexOf( "< bi") + 4 ); //$NON-NLS-1$
|
||||
assertNotNull( node );
|
||||
assertEquals( node.getCompletionPrefix(), "bi"); //$NON-NLS-1$\
|
||||
assertNull( node.getCompletionContext() );
|
||||
assertTrue( node.getCompletionScope() instanceof IASTFunction );
|
||||
assertTrue( ((IASTFunction)node.getCompletionScope()).getName().equals( "f" ) ); //$NON-NLS-1$
|
||||
assertEquals( node.getCompletionKind(), IASTCompletionNode.CompletionKind.SINGLE_NAME_REFERENCE );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -275,7 +275,7 @@ public class ExpressionParser implements IExpressionParser, IParserData {
|
|||
return last;
|
||||
}
|
||||
|
||||
protected List templateArgumentList( IASTScope scope ) throws EndOfFileException, BacktrackException
|
||||
protected List templateArgumentList( IASTScope scope, IASTCompletionNode.CompletionKind kind ) throws EndOfFileException, BacktrackException
|
||||
{
|
||||
IASTExpression expression = null;
|
||||
List list = new LinkedList();
|
||||
|
@ -294,7 +294,7 @@ public class ExpressionParser implements IExpressionParser, IParserData {
|
|||
IToken mark = mark();
|
||||
|
||||
try{
|
||||
IASTTypeId typeId = typeId( scope, false, CompletionKind.TYPE_REFERENCE );
|
||||
IASTTypeId typeId = typeId( scope, false, kind );
|
||||
|
||||
expression = astFactory.createExpression( scope, IASTExpression.Kind.POSTFIX_TYPEID_TYPEID,
|
||||
null, null, null, typeId, null, EMPTY_STRING, null);
|
||||
|
@ -423,7 +423,7 @@ public class ExpressionParser implements IExpressionParser, IParserData {
|
|||
else
|
||||
setCompletionValuesNoContext(scope, kind, key );
|
||||
|
||||
last = consumeTemplateArguments(scope, last, argumentList);
|
||||
last = consumeTemplateArguments(scope, last, argumentList, kind);
|
||||
if( last.getType() == IToken.tGT )
|
||||
hasTemplateId = true;
|
||||
break;
|
||||
|
@ -454,7 +454,7 @@ public class ExpressionParser implements IExpressionParser, IParserData {
|
|||
prev = last;
|
||||
last = consume();
|
||||
setCompletionValues( scope, kind, first, prev, Key.EMPTY );
|
||||
last = consumeTemplateArguments(scope, last, argumentList);
|
||||
last = consumeTemplateArguments(scope, last, argumentList, kind);
|
||||
if( last.getType() == IToken.tGT )
|
||||
hasTemplateId = true;
|
||||
}
|
||||
|
@ -524,14 +524,14 @@ public class ExpressionParser implements IExpressionParser, IParserData {
|
|||
* @throws EndOfFileException
|
||||
* @throws BacktrackException
|
||||
*/
|
||||
protected IToken consumeTemplateArguments(IASTScope scope, IToken last, TemplateParameterManager argumentList) throws EndOfFileException, BacktrackException {
|
||||
protected IToken consumeTemplateArguments(IASTScope scope, IToken last, TemplateParameterManager argumentList, IASTCompletionNode.CompletionKind completionKind) throws EndOfFileException, BacktrackException {
|
||||
if( language != ParserLanguage.CPP ) return last;
|
||||
if( LT(1) == IToken.tLT ){
|
||||
IToken secondMark = mark();
|
||||
consume( IToken.tLT );
|
||||
try
|
||||
{
|
||||
List list = templateArgumentList( scope );
|
||||
List list = templateArgumentList( scope, completionKind );
|
||||
argumentList.addSegment( list );
|
||||
last = consume( IToken.tGT );
|
||||
} catch( BacktrackException bt )
|
||||
|
@ -619,7 +619,7 @@ public class ExpressionParser implements IExpressionParser, IParserData {
|
|||
}
|
||||
}
|
||||
|
||||
protected void operatorId(Declarator d, IToken originalToken, TemplateParameterManager templateArgs) throws BacktrackException, EndOfFileException {
|
||||
protected void operatorId(Declarator d, IToken originalToken, TemplateParameterManager templateArgs, IASTCompletionNode.CompletionKind completionKind ) throws BacktrackException, EndOfFileException {
|
||||
// we know this is an operator
|
||||
IToken operatorToken = consume(IToken.t_operator);
|
||||
IToken toSend = null;
|
||||
|
@ -669,7 +669,7 @@ public class ExpressionParser implements IExpressionParser, IParserData {
|
|||
|
||||
try
|
||||
{
|
||||
toSend = consumeTemplateArguments( d.getDeclarationWrapper().getScope(), toSend, templateArgs );
|
||||
toSend = consumeTemplateArguments( d.getDeclarationWrapper().getScope(), toSend, templateArgs, completionKind );
|
||||
if( toSend.getType() == IToken.tGT ){
|
||||
hasTemplateId = true;
|
||||
}
|
||||
|
@ -2737,7 +2737,7 @@ public class ExpressionParser implements IExpressionParser, IParserData {
|
|||
end = consumeTemplateParameters(end);
|
||||
}
|
||||
if (LT(1) == IToken.t_operator)
|
||||
operatorId(d, start, null);
|
||||
operatorId(d, start, null, kind);
|
||||
else
|
||||
{
|
||||
backup(mark);
|
||||
|
@ -2745,7 +2745,7 @@ public class ExpressionParser implements IExpressionParser, IParserData {
|
|||
}
|
||||
}
|
||||
else if( LT(1) == IToken.t_operator )
|
||||
operatorId( d, null, null);
|
||||
operatorId( d, null, null, kind);
|
||||
|
||||
duple = d.getNameDuple();
|
||||
}
|
||||
|
|
|
@ -2362,7 +2362,7 @@ public abstract class Parser extends ExpressionParser implements IParser
|
|||
try
|
||||
{
|
||||
if (LT(1) == IToken.t_operator)
|
||||
operatorId(d, null, null);
|
||||
operatorId(d, null, null, kind);
|
||||
else
|
||||
{
|
||||
try
|
||||
|
@ -2387,7 +2387,7 @@ public abstract class Parser extends ExpressionParser implements IParser
|
|||
IToken end = null;
|
||||
|
||||
if (start.getType() == IToken.tIDENTIFIER){
|
||||
end = consumeTemplateArguments(d.getDeclarationWrapper().getScope(), end, argumentList);
|
||||
end = consumeTemplateArguments(d.getDeclarationWrapper().getScope(), end, argumentList, kind);
|
||||
if( end != null && end.getType() == IToken.tGT )
|
||||
hasTemplateId = true;
|
||||
}
|
||||
|
@ -2397,13 +2397,13 @@ public abstract class Parser extends ExpressionParser implements IParser
|
|||
{
|
||||
end = consume();
|
||||
if (end.getType() == IToken.tIDENTIFIER){
|
||||
end = consumeTemplateArguments(d.getDeclarationWrapper().getScope(), end, argumentList);
|
||||
end = consumeTemplateArguments(d.getDeclarationWrapper().getScope(), end, argumentList, kind);
|
||||
if( end.getType() == IToken.tGT )
|
||||
hasTemplateId = true;
|
||||
}
|
||||
}
|
||||
if (LT(1) == IToken.t_operator)
|
||||
operatorId(d11, start, ( hasTemplateId ? argumentList : null ) );
|
||||
operatorId(d11, start, ( hasTemplateId ? argumentList : null ), kind );
|
||||
else
|
||||
{
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue