[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[cdt-patch] Solution to bug#42453, #43221, #43644 and bug#43646
|
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
Hoda Amer
Staff Software Engineer
Rational Software - IBM Software Group
Index: model/org/eclipse/cdt/internal/core/model/CModelBuilder.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CModelBuilder.java,v
retrieving revision 1.19
diff -u -r1.19 CModelBuilder.java
--- model/org/eclipse/cdt/internal/core/model/CModelBuilder.java 23 Sep 2003 20:46:17 -0000 1.19
+++ model/org/eclipse/cdt/internal/core/model/CModelBuilder.java 25 Sep 2003 17:34:42 -0000
@@ -428,14 +428,15 @@
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 @@
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;
}
Index: parser/ChangeLog
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/parser/ChangeLog,v
retrieving revision 1.138
diff -u -r1.138 ChangeLog
--- parser/ChangeLog 25 Sep 2003 14:26:28 -0000 1.138
+++ parser/ChangeLog 25 Sep 2003 17:34:42 -0000
@@ -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,
Index: parser/org/eclipse/cdt/internal/core/parser/ast/complete/CompleteParseASTFactory.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/complete/CompleteParseASTFactory.java,v
retrieving revision 1.47
diff -u -r1.47 CompleteParseASTFactory.java
--- parser/org/eclipse/cdt/internal/core/parser/ast/complete/CompleteParseASTFactory.java 25 Sep 2003 14:26:28 -0000 1.47
+++ parser/org/eclipse/cdt/internal/core/parser/ast/complete/CompleteParseASTFactory.java 25 Sep 2003 17:34:43 -0000
@@ -808,8 +808,11 @@
ASTExpression expression = new ASTExpression( kind, lhs, rhs, thirdExpression,
typeId, idExpression, literal, newDescriptor, references);
-
- expression.setResultType (getExpressionResultType(expression, symbol));
+ try{
+ expression.setResultType (getExpressionResultType(expression, symbol));
+ }catch (ASTSemanticException e){
+ throw e;
+ }
return expression;
}
@@ -917,351 +920,348 @@
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();
-
- // types that resolve to void
- if ((expression.getExpressionKind() == IASTExpression.Kind.PRIMARY_EMPTY)
- || (expression.getExpressionKind() == IASTExpression.Kind.THROWEXPRESSION)
- || (expression.getExpressionKind() == IASTExpression.Kind.POSTFIX_DOT_DESTRUCTOR)
- || (expression.getExpressionKind() == IASTExpression.Kind.POSTFIX_ARROW_DESTRUCTOR)
- || (expression.getExpressionKind() == IASTExpression.Kind.DELETE_CASTEXPRESSION)
- || (expression.getExpressionKind() == IASTExpression.Kind.DELETE_VECTORCASTEXPRESSION)
- ){
- info.setType(TypeInfo.t_void);
- result.add(info);
- return result;
- }
- // types that resolve to int
- if ((expression.getExpressionKind() == IASTExpression.Kind.PRIMARY_INTEGER_LITERAL)
- || (expression.getExpressionKind() == IASTExpression.Kind.POSTFIX_SIMPLETYPE_INT)
- ){
- info.setType(TypeInfo.t_int);
- result.add(info);
- return result;
- }
- // size of is always unsigned int
- if ((expression.getExpressionKind() == IASTExpression.Kind.UNARY_SIZEOF_TYPEID)
- || (expression.getExpressionKind() == IASTExpression.Kind.UNARY_SIZEOF_UNARYEXPRESSION)
- ){
- info.setType(TypeInfo.t_int);
- info.setBit(true, TypeInfo.isUnsigned);
- result.add(info);
- return result;
- }
- // types that resolve to char
- if( (expression.getExpressionKind() == IASTExpression.Kind.PRIMARY_CHAR_LITERAL)
- || (expression.getExpressionKind() == IASTExpression.Kind.POSTFIX_SIMPLETYPE_CHAR)){
- info.setType(TypeInfo.t_char);
- result.add(info);
- return result;
- }
- // types that resolve to float
- if( (expression.getExpressionKind() == IASTExpression.Kind.PRIMARY_FLOAT_LITERAL)
- || (expression.getExpressionKind() == IASTExpression.Kind.POSTFIX_SIMPLETYPE_FLOAT)){
- info.setType(TypeInfo.t_float);
- result.add(info);
- return result;
- }
- // types that resolve to string
- if (expression.getExpressionKind() == IASTExpression.Kind.PRIMARY_STRING_LITERAL){
- info.setType(TypeInfo.t_char);
- info.addPtrOperator(new TypeInfo.PtrOp(TypeInfo.PtrOp.t_pointer));
- result.add(info);
- return result;
- }
- // types that resolve to double
- if( expression.getExpressionKind() == IASTExpression.Kind.POSTFIX_SIMPLETYPE_DOUBLE){
- info.setType(TypeInfo.t_double);
- result.add(info);
- return result;
- }
- // types that resolve to wchar
- if(expression.getExpressionKind() == IASTExpression.Kind.POSTFIX_SIMPLETYPE_WCHART){
- info.setType(TypeInfo.t_wchar_t);
- result.add(info);
- return result;
- }
- // types that resolve to bool
- if( (expression.getExpressionKind() == IASTExpression.Kind.PRIMARY_BOOLEAN_LITERAL)
- || (expression.getExpressionKind() == IASTExpression.Kind.POSTFIX_SIMPLETYPE_BOOL)
- || (expression.getExpressionKind() == IASTExpression.Kind.RELATIONAL_GREATERTHAN)
- || (expression.getExpressionKind() == IASTExpression.Kind.RELATIONAL_GREATERTHANEQUALTO)
- || (expression.getExpressionKind() == IASTExpression.Kind.RELATIONAL_LESSTHAN)
- || (expression.getExpressionKind() == IASTExpression.Kind.RELATIONAL_LESSTHANEQUALTO)
- || (expression.getExpressionKind() == IASTExpression.Kind.EQUALITY_EQUALS)
- || (expression.getExpressionKind() == IASTExpression.Kind.EQUALITY_NOTEQUALS)
- || (expression.getExpressionKind() == IASTExpression.Kind.LOGICALANDEXPRESSION)
- || (expression.getExpressionKind() == IASTExpression.Kind.LOGICALOREXPRESSION)
- )
- {
- info.setType(TypeInfo.t_bool);
- result.add(info);
- return result;
- }
- // short added to a type
- if (expression.getExpressionKind() == IASTExpression.Kind.POSTFIX_SIMPLETYPE_SHORT ){
- info = (TypeInfo)((ASTExpression)expression.getLHSExpression()).getResultType().iterator().next();
- info.setBit(true, TypeInfo.isShort);
- result.add(info);
- return result;
- }
- // long added to a type
- if (expression.getExpressionKind() == IASTExpression.Kind.POSTFIX_SIMPLETYPE_LONG ){
- info = (TypeInfo)((ASTExpression)expression.getLHSExpression()).getResultType().iterator().next();
- info.setBit(true, TypeInfo.isLong);
- result.add(info);
- return result;
- }
- // signed added to a type
- if (expression.getExpressionKind() == IASTExpression.Kind.POSTFIX_SIMPLETYPE_SIGNED ){
- info = (TypeInfo)((ASTExpression)expression.getLHSExpression()).getResultType().iterator().next();
- info.setBit(false, TypeInfo.isUnsigned);
- result.add(info);
- return result;
- }
- // unsigned added to a type
- if (expression.getExpressionKind() == IASTExpression.Kind.POSTFIX_SIMPLETYPE_UNSIGNED ){
- info = (TypeInfo)((ASTExpression)expression.getLHSExpression()).getResultType().iterator().next();
- info.setBit(true, TypeInfo.isUnsigned);
- result.add(info);
- return result;
- }
- // Id expressions resolve to t_type, symbol already looked up
- if( expression.getExpressionKind() == IASTExpression.Kind.ID_EXPRESSION )
- {
- info.setType(TypeInfo.t_type);
- info.setTypeSymbol(symbol);
- result.add(info);
- return result;
- }
- // an ampersand implies a pointer operation of type reference
- if (expression.getExpressionKind() == IASTExpression.Kind.UNARY_AMPSND_CASTEXPRESSION){
- List lhsResult = ((ASTExpression)expression.getLHSExpression()).getResultType();
- if( lhsResult.iterator().hasNext())
- info = (TypeInfo)lhsResult.iterator().next();
- if ((info != null) && (info.getTypeSymbol() != null)){
- info.addOperatorExpression( TypeInfo.OperatorExpression.addressof );
+ try {
+ // types that resolve to void
+ if ((expression.getExpressionKind() == IASTExpression.Kind.PRIMARY_EMPTY)
+ || (expression.getExpressionKind() == IASTExpression.Kind.THROWEXPRESSION)
+ || (expression.getExpressionKind() == IASTExpression.Kind.POSTFIX_DOT_DESTRUCTOR)
+ || (expression.getExpressionKind() == IASTExpression.Kind.POSTFIX_ARROW_DESTRUCTOR)
+ || (expression.getExpressionKind() == IASTExpression.Kind.DELETE_CASTEXPRESSION)
+ || (expression.getExpressionKind() == IASTExpression.Kind.DELETE_VECTORCASTEXPRESSION)
+ ){
+ info.setType(TypeInfo.t_void);
+ result.add(info);
+ return result;
}
- result.add(info);
- return result;
- }
-
- // a star implies a pointer operation of type pointer
- if (expression.getExpressionKind() == IASTExpression.Kind.UNARY_STAR_CASTEXPRESSION){
- List lhsResult = ((ASTExpression)expression.getLHSExpression()).getResultType();
- if( lhsResult.iterator().hasNext())
- info = (TypeInfo)lhsResult.iterator().next();
- if ((info != null)&& (info.getTypeSymbol() != null)){
- info.addOperatorExpression( TypeInfo.OperatorExpression.indirection );
- }
- result.add(info);
- return result;
- }
- // subscript
- if (expression.getExpressionKind() == IASTExpression.Kind.POSTFIX_SUBSCRIPT){
- List lhsResult = ((ASTExpression)expression.getLHSExpression()).getResultType();
- if( lhsResult.iterator().hasNext())
- info = (TypeInfo)lhsResult.iterator().next();
- if ((info != null) && (info.getTypeSymbol() != null)){
- info.addOperatorExpression( TypeInfo.OperatorExpression.subscript );
- }
- result.add(info);
- return result;
- }
- // the dot and the arrow resolves to the type of the member
- if ((expression.getExpressionKind() == IASTExpression.Kind.POSTFIX_DOT_IDEXPRESSION)
- || (expression.getExpressionKind() == IASTExpression.Kind.POSTFIX_ARROW_IDEXPRESSION)
- || (expression.getExpressionKind() == IASTExpression.Kind.POSTFIX_DOT_TEMPL_IDEXPRESS)
- || (expression.getExpressionKind() == IASTExpression.Kind.POSTFIX_ARROW_TEMPL_IDEXP)
- ){
- if(symbol != null){
- info = new TypeInfo(symbol.getTypeInfo());
+ // types that resolve to int
+ if ((expression.getExpressionKind() == IASTExpression.Kind.PRIMARY_INTEGER_LITERAL)
+ || (expression.getExpressionKind() == IASTExpression.Kind.POSTFIX_SIMPLETYPE_INT)
+ ){
+ info.setType(TypeInfo.t_int);
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)
- ){
- List rhsResult = ((ASTExpression)expression.getRHSExpression()).getResultType();
- if( rhsResult.iterator().hasNext())
- info = (TypeInfo)rhsResult.iterator().next();
- if (info != null){
- info.addOperatorExpression( TypeInfo.OperatorExpression.indirection );
- }
- if(symbol != null){
- info.setTypeSymbol(symbol);
- }
- result.add(info);
- return result;
- }
- // this
- if (expression.getExpressionKind() == IASTExpression.Kind.PRIMARY_THIS){
- if(symbol != null)
+ // size of is always unsigned int
+ if ((expression.getExpressionKind() == IASTExpression.Kind.UNARY_SIZEOF_TYPEID)
+ || (expression.getExpressionKind() == IASTExpression.Kind.UNARY_SIZEOF_UNARYEXPRESSION)
+ ){
+ info.setType(TypeInfo.t_int);
+ info.setBit(true, TypeInfo.isUnsigned);
+ result.add(info);
+ return result;
+ }
+ // types that resolve to char
+ if( (expression.getExpressionKind() == IASTExpression.Kind.PRIMARY_CHAR_LITERAL)
+ || (expression.getExpressionKind() == IASTExpression.Kind.POSTFIX_SIMPLETYPE_CHAR)){
+ info.setType(TypeInfo.t_char);
+ result.add(info);
+ return result;
+ }
+ // types that resolve to float
+ if( (expression.getExpressionKind() == IASTExpression.Kind.PRIMARY_FLOAT_LITERAL)
+ || (expression.getExpressionKind() == IASTExpression.Kind.POSTFIX_SIMPLETYPE_FLOAT)){
+ info.setType(TypeInfo.t_float);
+ result.add(info);
+ return result;
+ }
+ // types that resolve to string
+ if (expression.getExpressionKind() == IASTExpression.Kind.PRIMARY_STRING_LITERAL){
+ info.setType(TypeInfo.t_char);
+ info.addPtrOperator(new TypeInfo.PtrOp(TypeInfo.PtrOp.t_pointer));
+ result.add(info);
+ return result;
+ }
+ // types that resolve to double
+ if( expression.getExpressionKind() == IASTExpression.Kind.POSTFIX_SIMPLETYPE_DOUBLE){
+ info.setType(TypeInfo.t_double);
+ result.add(info);
+ return result;
+ }
+ // types that resolve to wchar
+ if(expression.getExpressionKind() == IASTExpression.Kind.POSTFIX_SIMPLETYPE_WCHART){
+ info.setType(TypeInfo.t_wchar_t);
+ result.add(info);
+ return result;
+ }
+ // types that resolve to bool
+ if( (expression.getExpressionKind() == IASTExpression.Kind.PRIMARY_BOOLEAN_LITERAL)
+ || (expression.getExpressionKind() == IASTExpression.Kind.POSTFIX_SIMPLETYPE_BOOL)
+ || (expression.getExpressionKind() == IASTExpression.Kind.RELATIONAL_GREATERTHAN)
+ || (expression.getExpressionKind() == IASTExpression.Kind.RELATIONAL_GREATERTHANEQUALTO)
+ || (expression.getExpressionKind() == IASTExpression.Kind.RELATIONAL_LESSTHAN)
+ || (expression.getExpressionKind() == IASTExpression.Kind.RELATIONAL_LESSTHANEQUALTO)
+ || (expression.getExpressionKind() == IASTExpression.Kind.EQUALITY_EQUALS)
+ || (expression.getExpressionKind() == IASTExpression.Kind.EQUALITY_NOTEQUALS)
+ || (expression.getExpressionKind() == IASTExpression.Kind.LOGICALANDEXPRESSION)
+ || (expression.getExpressionKind() == IASTExpression.Kind.LOGICALOREXPRESSION)
+ )
+ {
+ info.setType(TypeInfo.t_bool);
+ result.add(info);
+ return result;
+ }
+ // short added to a type
+ if (expression.getExpressionKind() == IASTExpression.Kind.POSTFIX_SIMPLETYPE_SHORT ){
+ info = (TypeInfo)((ASTExpression)expression.getLHSExpression()).getResultType().iterator().next();
+ info.setBit(true, TypeInfo.isShort);
+ result.add(info);
+ return result;
+ }
+ // long added to a type
+ if (expression.getExpressionKind() == IASTExpression.Kind.POSTFIX_SIMPLETYPE_LONG ){
+ info = (TypeInfo)((ASTExpression)expression.getLHSExpression()).getResultType().iterator().next();
+ info.setBit(true, TypeInfo.isLong);
+ result.add(info);
+ return result;
+ }
+ // signed added to a type
+ if (expression.getExpressionKind() == IASTExpression.Kind.POSTFIX_SIMPLETYPE_SIGNED ){
+ info = (TypeInfo)((ASTExpression)expression.getLHSExpression()).getResultType().iterator().next();
+ info.setBit(false, TypeInfo.isUnsigned);
+ result.add(info);
+ return result;
+ }
+ // unsigned added to a type
+ if (expression.getExpressionKind() == IASTExpression.Kind.POSTFIX_SIMPLETYPE_UNSIGNED ){
+ info = (TypeInfo)((ASTExpression)expression.getLHSExpression()).getResultType().iterator().next();
+ info.setBit(true, TypeInfo.isUnsigned);
+ result.add(info);
+ return result;
+ }
+ // Id expressions resolve to t_type, symbol already looked up
+ if( expression.getExpressionKind() == IASTExpression.Kind.ID_EXPRESSION )
{
info.setType(TypeInfo.t_type);
- info.setTypeSymbol(symbol);
- info.addOperatorExpression( TypeInfo.OperatorExpression.addressof );
+ info.setTypeSymbol(symbol);
result.add(info);
return result;
}
- }
- // conditional
- if (expression.getExpressionKind() == IASTExpression.Kind.CONDITIONALEXPRESSION){
- ASTExpression right = (ASTExpression)expression.getRHSExpression();
- ASTExpression third = (ASTExpression)expression.getThirdExpression();
- if((right != null ) && (third != null)){
- TypeInfo rightType =(TypeInfo)right.getResultType().iterator().next();
- TypeInfo thirdType =(TypeInfo)third.getResultType().iterator().next();
- info = conditionalExpressionConversions(rightType, thirdType);
+ // an ampersand implies a pointer operation of type reference
+ if (expression.getExpressionKind() == IASTExpression.Kind.UNARY_AMPSND_CASTEXPRESSION){
+ List lhsResult = ((ASTExpression)expression.getLHSExpression()).getResultType();
+ if( lhsResult.iterator().hasNext())
+ info = (TypeInfo)lhsResult.iterator().next();
+ if ((info != null) && (info.getTypeSymbol() != null)){
+ info.addOperatorExpression( TypeInfo.OperatorExpression.addressof );
+ }
result.add(info);
return result;
}
- }
- // new
- if( ( expression.getExpressionKind() == IASTExpression.Kind.NEW_TYPEID )
- || ( expression.getExpressionKind() == IASTExpression.Kind.NEW_NEWTYPEID ) )
- {
- try
- {
- info = expression.getTypeId().getTypeSymbol().getTypeInfo();
- info.addPtrOperator( new TypeInfo.PtrOp(TypeInfo.PtrOp.t_pointer));
- }
- catch (ASTNotImplementedException e)
- {
- // will never happen
- }
- result.add(info);
- return result;
- }
- // types that use the usual arithmetic conversions
- if((expression.getExpressionKind() == IASTExpression.Kind.MULTIPLICATIVE_MULTIPLY)
- || (expression.getExpressionKind() == IASTExpression.Kind.MULTIPLICATIVE_DIVIDE)
- || (expression.getExpressionKind() == IASTExpression.Kind.MULTIPLICATIVE_MODULUS)
- || (expression.getExpressionKind() == IASTExpression.Kind.ADDITIVE_PLUS)
- || (expression.getExpressionKind() == IASTExpression.Kind.ADDITIVE_MINUS)
- || (expression.getExpressionKind() == IASTExpression.Kind.ANDEXPRESSION)
- || (expression.getExpressionKind() == IASTExpression.Kind.EXCLUSIVEOREXPRESSION)
- || (expression.getExpressionKind() == IASTExpression.Kind.INCLUSIVEOREXPRESSION)
- ){
- ASTExpression left = (ASTExpression)expression.getLHSExpression();
- ASTExpression right = (ASTExpression)expression.getRHSExpression();
- if((left != null ) && (right != null)){
- TypeInfo leftType =(TypeInfo)left.getResultType().iterator().next();
- TypeInfo rightType =(TypeInfo)right.getResultType().iterator().next();
- info = usualArithmeticConversions(leftType, rightType);
+
+ // a star implies a pointer operation of type pointer
+ if (expression.getExpressionKind() == IASTExpression.Kind.UNARY_STAR_CASTEXPRESSION){
+ List lhsResult = ((ASTExpression)expression.getLHSExpression()).getResultType();
+ if( lhsResult.iterator().hasNext())
+ info = (TypeInfo)lhsResult.iterator().next();
+ if ((info != null)&& (info.getTypeSymbol() != null)){
+ info.addOperatorExpression( TypeInfo.OperatorExpression.indirection );
+ }
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)
- || (expression.getExpressionKind() == IASTExpression.Kind.POSTFIX_DECREMENT)
- || (expression.getExpressionKind() == IASTExpression.Kind.POSTFIX_TYPEID_EXPRESSION)
- || (expression.getExpressionKind() == IASTExpression.Kind.UNARY_INCREMENT)
- || (expression.getExpressionKind() == IASTExpression.Kind.UNARY_DECREMENT)
- || (expression.getExpressionKind() == IASTExpression.Kind.UNARY_PLUS_CASTEXPRESSION)
- || (expression.getExpressionKind() == IASTExpression.Kind.UNARY_MINUS_CASTEXPRESSION)
- || (expression.getExpressionKind() == IASTExpression.Kind.UNARY_NOT_CASTEXPRESSION)
- || (expression.getExpressionKind() == IASTExpression.Kind.UNARY_TILDE_CASTEXPRESSION)
- || (expression.getExpressionKind() == IASTExpression.Kind.SHIFT_LEFT)
- || (expression.getExpressionKind() == IASTExpression.Kind.SHIFT_RIGHT)
- || (expression.getExpressionKind() == IASTExpression.Kind.ASSIGNMENTEXPRESSION_NORMAL)
- || (expression.getExpressionKind() == IASTExpression.Kind.ASSIGNMENTEXPRESSION_PLUS)
- || (expression.getExpressionKind() == IASTExpression.Kind.ASSIGNMENTEXPRESSION_MINUS)
- || (expression.getExpressionKind() == IASTExpression.Kind.ASSIGNMENTEXPRESSION_MULT)
- || (expression.getExpressionKind() == IASTExpression.Kind.ASSIGNMENTEXPRESSION_DIV)
- || (expression.getExpressionKind() == IASTExpression.Kind.ASSIGNMENTEXPRESSION_MOD)
- || (expression.getExpressionKind() == IASTExpression.Kind.ASSIGNMENTEXPRESSION_LSHIFT)
- || (expression.getExpressionKind() == IASTExpression.Kind.ASSIGNMENTEXPRESSION_RSHIFT)
- || (expression.getExpressionKind() == IASTExpression.Kind.ASSIGNMENTEXPRESSION_AND)
- || (expression.getExpressionKind() == IASTExpression.Kind.ASSIGNMENTEXPRESSION_OR)
- || (expression.getExpressionKind() == IASTExpression.Kind.ASSIGNMENTEXPRESSION_XOR)
- ){
- ASTExpression left = (ASTExpression)expression.getLHSExpression();
- if(left != null){
- TypeInfo leftType =(TypeInfo)left.getResultType().iterator().next();
- result.add(leftType);
+ // subscript
+ if (expression.getExpressionKind() == IASTExpression.Kind.POSTFIX_SUBSCRIPT){
+ List lhsResult = ((ASTExpression)expression.getLHSExpression()).getResultType();
+ if( lhsResult.iterator().hasNext())
+ info = (TypeInfo)lhsResult.iterator().next();
+ if ((info != null) && (info.getTypeSymbol() != null)){
+ info.addOperatorExpression( TypeInfo.OperatorExpression.subscript );
+ }
+ result.add(info);
return result;
}
- }
- // the cast changes the types to the type looked up in typeId = symbol
- if(( expression.getExpressionKind() == IASTExpression.Kind.CASTEXPRESSION )
- || ( expression.getExpressionKind() == IASTExpression.Kind.POSTFIX_DYNAMIC_CAST )
- || ( expression.getExpressionKind() == IASTExpression.Kind.POSTFIX_STATIC_CAST )
- || ( expression.getExpressionKind() == IASTExpression.Kind.POSTFIX_REINTERPRET_CAST )
- || ( expression.getExpressionKind() == IASTExpression.Kind.POSTFIX_CONST_CAST )
- ){
- try{
- info = new TypeInfo(expression.getTypeId().getTypeSymbol().getTypeInfo());
- }catch (Exception e){
- }
- result.add(info);
- return result;
- }
- // a list collects all types of left and right hand sides
- if(expression.getExpressionKind() == IASTExpression.Kind.EXPRESSIONLIST){
- if(expression.getLHSExpression() != null){
- Iterator i = ((ASTExpression)expression.getLHSExpression()).getResultType().iterator();
- while (i.hasNext()){
- result.add(i.next());
- }
- }
- if(expression.getRHSExpression() != null){
- Iterator i = ((ASTExpression)expression.getRHSExpression()).getResultType().iterator();
- while (i.hasNext()){
- result.add(i.next());
- }
- }
- return result;
- }
- // a function call type is the return type of the function
- if(expression.getExpressionKind() == IASTExpression.Kind.POSTFIX_FUNCTIONCALL){
- if(symbol != null){
- IParameterizedSymbol psymbol = (IParameterizedSymbol) symbol;
- ISymbol returnTypeSymbol = psymbol.getReturnType();
- info.setType(returnTypeSymbol.getType());
+ // the dot and the arrow resolves to the type of the member
+ if ((expression.getExpressionKind() == IASTExpression.Kind.POSTFIX_DOT_IDEXPRESSION)
+ || (expression.getExpressionKind() == IASTExpression.Kind.POSTFIX_ARROW_IDEXPRESSION)
+ || (expression.getExpressionKind() == IASTExpression.Kind.POSTFIX_DOT_TEMPL_IDEXPRESS)
+ || (expression.getExpressionKind() == IASTExpression.Kind.POSTFIX_ARROW_TEMPL_IDEXP)
+ ){
+ 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)
+ ){
+ List rhsResult = ((ASTExpression)expression.getRHSExpression()).getResultType();
+ if( rhsResult.iterator().hasNext())
+ info = (TypeInfo)rhsResult.iterator().next();
+ if (info != null){
+ info.addOperatorExpression( TypeInfo.OperatorExpression.indirection );
+ }
+ if(symbol != null){
+ info.setTypeSymbol(symbol);
+ }
+ result.add(info);
+ return result;
+ }
+ // this
+ if (expression.getExpressionKind() == IASTExpression.Kind.PRIMARY_THIS){
+ if(symbol != null)
+ {
+ 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();
+ ASTExpression third = (ASTExpression)expression.getThirdExpression();
+ if((right != null ) && (third != null)){
+ 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 ) )
+ {
+ try
+ {
+ info = expression.getTypeId().getTypeSymbol().getTypeInfo();
+ info.addPtrOperator( new TypeInfo.PtrOp(TypeInfo.PtrOp.t_pointer));
+ }
+ catch (ASTNotImplementedException e)
+ {
+ // will never happen
+ }
+ result.add(info);
+ return result;
+ }
+ // types that use the usual arithmetic conversions
+ if((expression.getExpressionKind() == IASTExpression.Kind.MULTIPLICATIVE_MULTIPLY)
+ || (expression.getExpressionKind() == IASTExpression.Kind.MULTIPLICATIVE_DIVIDE)
+ || (expression.getExpressionKind() == IASTExpression.Kind.MULTIPLICATIVE_MODULUS)
+ || (expression.getExpressionKind() == IASTExpression.Kind.ADDITIVE_PLUS)
+ || (expression.getExpressionKind() == IASTExpression.Kind.ADDITIVE_MINUS)
+ || (expression.getExpressionKind() == IASTExpression.Kind.ANDEXPRESSION)
+ || (expression.getExpressionKind() == IASTExpression.Kind.EXCLUSIVEOREXPRESSION)
+ || (expression.getExpressionKind() == IASTExpression.Kind.INCLUSIVEOREXPRESSION)
+ ){
+ ASTExpression left = (ASTExpression)expression.getLHSExpression();
+ ASTExpression right = (ASTExpression)expression.getRHSExpression();
+ if((left != null ) && (right != null)){
+ 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)
+ || (expression.getExpressionKind() == IASTExpression.Kind.POSTFIX_DECREMENT)
+ || (expression.getExpressionKind() == IASTExpression.Kind.POSTFIX_TYPEID_EXPRESSION)
+ || (expression.getExpressionKind() == IASTExpression.Kind.UNARY_INCREMENT)
+ || (expression.getExpressionKind() == IASTExpression.Kind.UNARY_DECREMENT)
+ || (expression.getExpressionKind() == IASTExpression.Kind.UNARY_PLUS_CASTEXPRESSION)
+ || (expression.getExpressionKind() == IASTExpression.Kind.UNARY_MINUS_CASTEXPRESSION)
+ || (expression.getExpressionKind() == IASTExpression.Kind.UNARY_NOT_CASTEXPRESSION)
+ || (expression.getExpressionKind() == IASTExpression.Kind.UNARY_TILDE_CASTEXPRESSION)
+ || (expression.getExpressionKind() == IASTExpression.Kind.SHIFT_LEFT)
+ || (expression.getExpressionKind() == IASTExpression.Kind.SHIFT_RIGHT)
+ || (expression.getExpressionKind() == IASTExpression.Kind.ASSIGNMENTEXPRESSION_NORMAL)
+ || (expression.getExpressionKind() == IASTExpression.Kind.ASSIGNMENTEXPRESSION_PLUS)
+ || (expression.getExpressionKind() == IASTExpression.Kind.ASSIGNMENTEXPRESSION_MINUS)
+ || (expression.getExpressionKind() == IASTExpression.Kind.ASSIGNMENTEXPRESSION_MULT)
+ || (expression.getExpressionKind() == IASTExpression.Kind.ASSIGNMENTEXPRESSION_DIV)
+ || (expression.getExpressionKind() == IASTExpression.Kind.ASSIGNMENTEXPRESSION_MOD)
+ || (expression.getExpressionKind() == IASTExpression.Kind.ASSIGNMENTEXPRESSION_LSHIFT)
+ || (expression.getExpressionKind() == IASTExpression.Kind.ASSIGNMENTEXPRESSION_RSHIFT)
+ || (expression.getExpressionKind() == IASTExpression.Kind.ASSIGNMENTEXPRESSION_AND)
+ || (expression.getExpressionKind() == IASTExpression.Kind.ASSIGNMENTEXPRESSION_OR)
+ || (expression.getExpressionKind() == IASTExpression.Kind.ASSIGNMENTEXPRESSION_XOR)
+ ){
+ ASTExpression left = (ASTExpression)expression.getLHSExpression();
+ if(left != null){
+ 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 )
+ || ( expression.getExpressionKind() == IASTExpression.Kind.POSTFIX_DYNAMIC_CAST )
+ || ( expression.getExpressionKind() == IASTExpression.Kind.POSTFIX_STATIC_CAST )
+ || ( expression.getExpressionKind() == IASTExpression.Kind.POSTFIX_REINTERPRET_CAST )
+ || ( expression.getExpressionKind() == IASTExpression.Kind.POSTFIX_CONST_CAST )
+ ){
+ try{
+ info = new TypeInfo(expression.getTypeId().getTypeSymbol().getTypeInfo());
+ }catch (Exception e){
+ }
+ result.add(info);
+ return result;
+ }
+ // a list collects all types of left and right hand sides
+ if(expression.getExpressionKind() == IASTExpression.Kind.EXPRESSIONLIST){
+ if(expression.getLHSExpression() != null){
+ Iterator i = ((ASTExpression)expression.getLHSExpression()).getResultType().iterator();
+ while (i.hasNext()){
+ result.add(i.next());
+ }
+ }
+ if(expression.getRHSExpression() != null){
+ Iterator i = ((ASTExpression)expression.getRHSExpression()).getResultType().iterator();
+ while (i.hasNext()){
+ result.add(i.next());
+ }
+ }
+ return result;
+ }
+ // a function call type is the return type of the function
+ if(expression.getExpressionKind() == IASTExpression.Kind.POSTFIX_FUNCTIONCALL){
+ if(symbol != null){
+ IParameterizedSymbol psymbol = (IParameterizedSymbol) symbol;
+ ISymbol returnTypeSymbol = psymbol.getReturnType();
+ info.setType(returnTypeSymbol.getType());
+ }
+ result.add(info);
+ return result;
}
- result.add(info);
- return result;
- }
-
- if( expression.getExpressionKind() == IASTExpression.Kind.POSTFIX_TYPEID_TYPEID )
- {
- 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 ) )
-// {
-// IASTTypeId typeId = expression.getTypeId();
-// try
-// {
-// info = typeId.getTypeSymbol().getTypeInfo();
-// }
-// catch (ASTNotImplementedException e)
-// {
-// // will not ever happen from within CompleteParseASTFactory
-// }
-// result.add(info);
-// return result;
-// }
- return result;
+ if( expression.getExpressionKind() == IASTExpression.Kind.POSTFIX_TYPEID_TYPEID )
+ {
+ 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;
}
protected void getExpressionReferences(IASTExpression expression, List references)
Index: ChangeLog
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core.tests/ChangeLog,v
retrieving revision 1.113
diff -u -r1.113 ChangeLog
--- ChangeLog 25 Sep 2003 14:26:33 -0000 1.113
+++ ChangeLog 25 Sep 2003 17:35:00 -0000
@@ -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()
Index: parser/org/eclipse/cdt/core/parser/tests/CompleteParseASTExpressionTest.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/CompleteParseASTExpressionTest.java,v
retrieving revision 1.10
diff -u -r1.10 CompleteParseASTExpressionTest.java
--- parser/org/eclipse/cdt/core/parser/tests/CompleteParseASTExpressionTest.java 25 Sep 2003 14:26:33 -0000 1.10
+++ parser/org/eclipse/cdt/core/parser/tests/CompleteParseASTExpressionTest.java 25 Sep 2003 17:35:00 -0000
@@ -197,15 +197,15 @@
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 @@
}
// Kind POSTFIX_DOT_TEMPL_IDEXPRESS
// Kind POSTFIX_ARROW_TEMPL_IDEXP
+
// Kind POSTFIX_DOT_DESTRUCTOR
// Kind POSTFIX_ARROW_DESTRUCTOR
Index: ChangeLog
===================================================================
RCS file: /home/tools/org.eclipse.cdt.ui/ChangeLog,v
retrieving revision 1.189
diff -u -r1.189 ChangeLog
--- ChangeLog 25 Sep 2003 14:10:30 -0000 1.189
+++ ChangeLog 25 Sep 2003 17:35:29 -0000
@@ -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.
Index: src/org/eclipse/cdt/internal/ui/text/CCompletionProcessor.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CCompletionProcessor.java,v
retrieving revision 1.13
diff -u -r1.13 CCompletionProcessor.java
--- src/org/eclipse/cdt/internal/ui/text/CCompletionProcessor.java 23 Sep 2003 15:17:20 -0000 1.13
+++ src/org/eclipse/cdt/internal/ui/text/CCompletionProcessor.java 25 Sep 2003 17:35:29 -0000
@@ -14,8 +14,6 @@
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 @@
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--;