1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00
John Camelon 2004-05-21 17:54:41 +00:00
parent 129dd89591
commit a355b2cf1d
3 changed files with 31 additions and 2 deletions

View file

@ -1102,4 +1102,19 @@ public class CompletionParseTest extends CompletionParseBaseTest {
assertTrue( ((IASTFunction)node.getCompletionScope()).getName().equals( "f" ) ); //$NON-NLS-1$ assertTrue( ((IASTFunction)node.getCompletionScope()).getName().equals( "f" ) ); //$NON-NLS-1$
assertEquals( node.getCompletionKind(), IASTCompletionNode.CompletionKind.SINGLE_NAME_REFERENCE ); assertEquals( node.getCompletionKind(), IASTCompletionNode.CompletionKind.SINGLE_NAME_REFERENCE );
} }
public void testBug62728() throws Exception
{
Writer writer = new StringWriter();
writer.write( "struct Temp { char * t; };" ); //$NON-NLS-1$
writer.write( "int f(Temp * t) {\n" ); //$NON-NLS-1$
writer.write( "t->t[5] = t-> "); //$NON-NLS-1$
String code = writer.toString();
IASTCompletionNode node = parse( code, code.indexOf( "= t->") + 5 ); //$NON-NLS-1$
assertNotNull( node );
assertEquals( node.getCompletionKind(), IASTCompletionNode.CompletionKind.MEMBER_REFERENCE );
assertTrue( node.getCompletionScope() instanceof IASTFunction );
assertTrue( ((IASTFunction)node.getCompletionScope()).getName().equals( "f" ) ); //$NON-NLS-1$
assertNotNull( node.getCompletionContext() );
}
} }

View file

@ -239,6 +239,19 @@ public interface IASTExpression extends ISourceElementCallbackDelegate, IASTNode
return false; return false;
} }
/**
* @return
*/
public boolean isLiteral() {
if( this == PRIMARY_INTEGER_LITERAL ||
this == PRIMARY_CHAR_LITERAL ||
this == PRIMARY_FLOAT_LITERAL ||
this == PRIMARY_STRING_LITERAL ||
this == PRIMARY_BOOLEAN_LITERAL )
return true;
return false;
}
} }

View file

@ -1415,7 +1415,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
} }
ExpressionResult result = null; ExpressionResult result = null;
if( literal != null && !literal.equals(EMPTY_STRING) ){ if( literal != null && !literal.equals(EMPTY_STRING) && kind.isLiteral() ){
info.setDefault( literal ); info.setDefault( literal );
} }
// types that resolve to void // types that resolve to void
@ -1573,7 +1573,8 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
if(left == null) if(left == null)
handleProblem( scope, IProblem.SEMANTIC_MALFORMED_EXPRESSION, null ); handleProblem( scope, IProblem.SEMANTIC_MALFORMED_EXPRESSION, null );
info = left.getResultType().getResult(); info = left.getResultType().getResult();
if ((info != null) && (info.getTypeSymbol() != null)){ if ((info != null))
{
info.addOperatorExpression( TypeInfo.OperatorExpression.subscript ); info.addOperatorExpression( TypeInfo.OperatorExpression.subscript );
}else { }else {
handleProblem( scope, IProblem.SEMANTIC_MALFORMED_EXPRESSION, null ); handleProblem( scope, IProblem.SEMANTIC_MALFORMED_EXPRESSION, null );