1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Patch for Hoda Amer

Core: 
        - Last part of solution to bug#42453: Expression result types not computed 
        Added the handling of POSTFIX_TYPENAME_IDENTIFIER 
        Completed bug#43221: POSTFIX_TYPENAME_IDENTIFIER not implemented 
        - Solution to bug#43644 : 6 triangle icons appearing in outline viewer when typing ... 
Tests: 
        Enabled CompleteParseASTExpressionTest.testPostfixTypenameIdentifier() 
UI: 
        Solution to bug#43646: Code Assist won't work if missing end bracket
This commit is contained in:
John Camelon 2003-09-25 19:40:39 +00:00
parent f13c66b5ca
commit ba0a125734
7 changed files with 362 additions and 358 deletions

View file

@ -1,3 +1,6 @@
2003-09-25 Hoda Amer
Enabled CompleteParseASTExpressionTest.testPostfixTypenameIdentifier()
2003-09-24 Hoda Amer
Added testNewTypeId(), testCastExpression(), testPostfixDynamicCast(),
testPostfixReinterpretCast(), testPostfixStaticCast(), and testPostfixConstCast()

View file

@ -197,15 +197,15 @@ public class CompleteParseASTExpressionTest extends CompleteParseBaseTest{
assertAllReferences( 1, createTaskList( new Task( foo )));
}
// // Kind POSTFIX_TYPENAME_IDENTIFIER
// public void testPostfixTypenameIdentifier() throws Exception{
// Iterator i = parse( "class A {}; \n int foo(); int foo( A a ); \n int x = foo( typename A() );").getDeclarations();
// IASTClassSpecifier cl = (IASTClassSpecifier)((IASTAbstractTypeSpecifierDeclaration)i.next()).getTypeSpecifier();
// IASTFunction f1 = (IASTFunction) i.next();
// IASTFunction f2 = (IASTFunction) i.next();
// IASTVariable x = (IASTVariable) i.next();
// assertAllReferences( 3, createTaskList( new Task( cl, 2 ), new Task( f2) ) );
// }
// Kind POSTFIX_TYPENAME_IDENTIFIER
public void testPostfixTypenameIdentifier() throws Exception{
Iterator i = parse( "class A {}; \n int foo(); int foo( A a ); \n int x = foo( typename A() );").getDeclarations();
IASTClassSpecifier cl = (IASTClassSpecifier)((IASTAbstractTypeSpecifierDeclaration)i.next()).getTypeSpecifier();
IASTFunction f1 = (IASTFunction) i.next();
IASTFunction f2 = (IASTFunction) i.next();
IASTVariable x = (IASTVariable) i.next();
assertAllReferences( 3, createTaskList( new Task( cl, 2 ), new Task( f2) ) );
}
// Kind POSTFIX_TYPENAME_TEMPLATEID
@ -235,6 +235,7 @@ public class CompleteParseASTExpressionTest extends CompleteParseBaseTest{
}
// Kind POSTFIX_DOT_TEMPL_IDEXPRESS
// Kind POSTFIX_ARROW_TEMPL_IDEXP
// Kind POSTFIX_DOT_DESTRUCTOR
// Kind POSTFIX_ARROW_DESTRUCTOR

View file

@ -428,14 +428,15 @@ public class CModelBuilder {
private VariableDeclaration createVariableSpecification(Parent parent, IASTVariable varDeclaration, boolean isTemplate)throws ASTNotImplementedException
{
IASTAbstractDeclaration abstractDeclaration = varDeclaration.getAbstractDeclaration();
CElement abstractElement = createAbstractElement (parent, abstractDeclaration , isTemplate);
String variableName = varDeclaration.getName();
if(variableName == null){
if((variableName == null) || (variableName.length() <= 0)){
// something is wrong, skip this element
return null;
}
IASTAbstractDeclaration abstractDeclaration = varDeclaration.getAbstractDeclaration();
CElement abstractElement = createAbstractElement (parent, abstractDeclaration , isTemplate);
VariableDeclaration element = null;
if(varDeclaration instanceof IASTField){
IASTField fieldDeclaration = (IASTField) varDeclaration;
@ -484,7 +485,7 @@ public class CModelBuilder {
private FunctionDeclaration createFunctionSpecification(Parent parent, IASTFunction functionDeclaration, boolean isTemplate)
{
String name = functionDeclaration.getName();
if (name == null) {
if ((name == null) || (name.length() <= 0)) {
// Something is wrong, skip this element
return null;
}

View file

@ -1,3 +1,9 @@
2003-09-25 Hoda Amer
- Last part of solution to bug#42453: Expression result types not computed
Added the handling of POSTFIX_TYPENAME_IDENTIFIER
Completed bug#43221: POSTFIX_TYPENAME_IDENTIFIER not implemented
- Solution to bug#43644 : 6 triangle icons appearing in outline viewer when typing ...
2003-09-24 Hoda Amer
Partial solution to bug#42453: Expression result types not computed
Added the handling of the NEW_TYPEID, CASTEXPRESSION, POSTFIX_DYNAMIC_CAST,

View file

@ -808,8 +808,11 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
ASTExpression expression = new ASTExpression( kind, lhs, rhs, thirdExpression,
typeId, idExpression, literal, newDescriptor, references);
try{
expression.setResultType (getExpressionResultType(expression, symbol));
}catch (ASTSemanticException e){
throw e;
}
return expression;
}
@ -917,10 +920,10 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
return info;
}
}
protected List getExpressionResultType(IASTExpression expression, ISymbol symbol){
protected List getExpressionResultType(IASTExpression expression, ISymbol symbol)throws ASTSemanticException{
List result = new ArrayList();
TypeInfo info = new TypeInfo();
try {
// types that resolve to void
if ((expression.getExpressionKind() == IASTExpression.Kind.PRIMARY_EMPTY)
|| (expression.getExpressionKind() == IASTExpression.Kind.THROWEXPRESSION)
@ -1078,10 +1081,10 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
){
if(symbol != null){
info = new TypeInfo(symbol.getTypeInfo());
}
result.add(info);
return result;
}
}
// the dot* and the arrow* are the same as dot/arrow + unary star
if ((expression.getExpressionKind() == IASTExpression.Kind.PM_DOTSTAR)
|| (expression.getExpressionKind() == IASTExpression.Kind.PM_ARROWSTAR)
@ -1105,10 +1108,10 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
info.setType(TypeInfo.t_type);
info.setTypeSymbol(symbol);
info.addOperatorExpression( TypeInfo.OperatorExpression.addressof );
}
result.add(info);
return result;
}
}
// conditional
if (expression.getExpressionKind() == IASTExpression.Kind.CONDITIONALEXPRESSION){
ASTExpression right = (ASTExpression)expression.getRHSExpression();
@ -1117,10 +1120,10 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
TypeInfo rightType =(TypeInfo)right.getResultType().iterator().next();
TypeInfo thirdType =(TypeInfo)third.getResultType().iterator().next();
info = conditionalExpressionConversions(rightType, thirdType);
}
result.add(info);
return result;
}
}
// new
if( ( expression.getExpressionKind() == IASTExpression.Kind.NEW_TYPEID )
|| ( expression.getExpressionKind() == IASTExpression.Kind.NEW_NEWTYPEID ) )
@ -1153,10 +1156,10 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
TypeInfo leftType =(TypeInfo)left.getResultType().iterator().next();
TypeInfo rightType =(TypeInfo)right.getResultType().iterator().next();
info = usualArithmeticConversions(leftType, rightType);
}
result.add(info);
return result;
}
}
// types that resolve to LHS types
if ((expression.getExpressionKind() == IASTExpression.Kind.PRIMARY_BRACKETED_EXPRESSION)
|| (expression.getExpressionKind() == IASTExpression.Kind.POSTFIX_INCREMENT)
@ -1184,10 +1187,10 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
){
ASTExpression left = (ASTExpression)expression.getLHSExpression();
if(left != null){
TypeInfo leftType =(TypeInfo)left.getResultType().iterator().next();
result.add(leftType);
return result;
info =(TypeInfo)left.getResultType().iterator().next();
}
result.add(info);
return result;
}
// the cast changes the types to the type looked up in typeId = symbol
if(( expression.getExpressionKind() == IASTExpression.Kind.CASTEXPRESSION )
@ -1245,22 +1248,19 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
return result;
}
// if ( ( expression.getExpressionKind() == IASTExpression.Kind.POSTFIX_TYPENAME_IDENTIFIER )
// || ( expression.getExpressionKind() == IASTExpression.Kind.POSTFIX_TYPENAME_TEMPLATEID ) )
// {
// IASTTypeId typeId = expression.getTypeId();
// try
// {
// info = typeId.getTypeSymbol().getTypeInfo();
// }
// catch (ASTNotImplementedException e)
// {
// // will not ever happen from within CompleteParseASTFactory
// }
// result.add(info);
// return result;
// }
if ( ( expression.getExpressionKind() == IASTExpression.Kind.POSTFIX_TYPENAME_IDENTIFIER )
|| ( expression.getExpressionKind() == IASTExpression.Kind.POSTFIX_TYPENAME_TEMPLATEID ) )
{
if(symbol != null){
info.setType(TypeInfo.t_type);
info.setTypeSymbol(symbol);
}
result.add(info);
return result;
}
} catch (Exception e){
throw new ASTSemanticException();
}
return result;
}

View file

@ -1,3 +1,6 @@
2003-09-25 Hoda Amer
Solution to bug#43646: Code Assist won't work if missing end bracket
2003-09-25 Alain Magloire
Add HelpContext IDs in the preference page.

View file

@ -14,8 +14,6 @@ import java.util.Map;
import org.eclipse.cdt.core.model.CoreModel;
import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.core.model.IFunction;
import org.eclipse.cdt.core.model.IFunctionDeclaration;
import org.eclipse.cdt.core.model.IMember;
import org.eclipse.cdt.core.model.IMethod;
import org.eclipse.cdt.core.model.IMethodDeclaration;
@ -317,15 +315,7 @@ public class CCompletionProcessor implements IContentAssistProcessor {
IRegion region;
String frag = "";
int pos = startPos;
// TODO: Do all possible scopes
// possible scopes include IStructure, INamespace, and ITranslationUnit
if( ( !(currentScope instanceof IMethod))
&& ( !(currentScope instanceof IMethodDeclaration))
&& ( !(currentScope instanceof IFunction))
&& ( !(currentScope instanceof IFunctionDeclaration))
){
return null;
}
// Move back the pos by one the position is 0-based
if (pos > 0) {
pos--;