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 2003-09-24 Hoda Amer
Added testNewTypeId(), testCastExpression(), testPostfixDynamicCast(), Added testNewTypeId(), testCastExpression(), testPostfixDynamicCast(),
testPostfixReinterpretCast(), testPostfixStaticCast(), and testPostfixConstCast() testPostfixReinterpretCast(), testPostfixStaticCast(), and testPostfixConstCast()

View file

@ -197,15 +197,15 @@ public class CompleteParseASTExpressionTest extends CompleteParseBaseTest{
assertAllReferences( 1, createTaskList( new Task( foo ))); assertAllReferences( 1, createTaskList( new Task( foo )));
} }
// // Kind POSTFIX_TYPENAME_IDENTIFIER // Kind POSTFIX_TYPENAME_IDENTIFIER
// public void testPostfixTypenameIdentifier() throws Exception{ public void testPostfixTypenameIdentifier() throws Exception{
// Iterator i = parse( "class A {}; \n int foo(); int foo( A a ); \n int x = foo( typename A() );").getDeclarations(); 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(); IASTClassSpecifier cl = (IASTClassSpecifier)((IASTAbstractTypeSpecifierDeclaration)i.next()).getTypeSpecifier();
// IASTFunction f1 = (IASTFunction) i.next(); IASTFunction f1 = (IASTFunction) i.next();
// IASTFunction f2 = (IASTFunction) i.next(); IASTFunction f2 = (IASTFunction) i.next();
// IASTVariable x = (IASTVariable) i.next(); IASTVariable x = (IASTVariable) i.next();
// assertAllReferences( 3, createTaskList( new Task( cl, 2 ), new Task( f2) ) ); assertAllReferences( 3, createTaskList( new Task( cl, 2 ), new Task( f2) ) );
// } }
// Kind POSTFIX_TYPENAME_TEMPLATEID // Kind POSTFIX_TYPENAME_TEMPLATEID
@ -235,6 +235,7 @@ public class CompleteParseASTExpressionTest extends CompleteParseBaseTest{
} }
// Kind POSTFIX_DOT_TEMPL_IDEXPRESS // Kind POSTFIX_DOT_TEMPL_IDEXPRESS
// Kind POSTFIX_ARROW_TEMPL_IDEXP // Kind POSTFIX_ARROW_TEMPL_IDEXP
// Kind POSTFIX_DOT_DESTRUCTOR // Kind POSTFIX_DOT_DESTRUCTOR
// Kind POSTFIX_ARROW_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 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(); String variableName = varDeclaration.getName();
if(variableName == null){ if((variableName == null) || (variableName.length() <= 0)){
// something is wrong, skip this element // something is wrong, skip this element
return null; return null;
} }
IASTAbstractDeclaration abstractDeclaration = varDeclaration.getAbstractDeclaration();
CElement abstractElement = createAbstractElement (parent, abstractDeclaration , isTemplate);
VariableDeclaration element = null; VariableDeclaration element = null;
if(varDeclaration instanceof IASTField){ if(varDeclaration instanceof IASTField){
IASTField fieldDeclaration = (IASTField) varDeclaration; IASTField fieldDeclaration = (IASTField) varDeclaration;
@ -484,7 +485,7 @@ public class CModelBuilder {
private FunctionDeclaration createFunctionSpecification(Parent parent, IASTFunction functionDeclaration, boolean isTemplate) private FunctionDeclaration createFunctionSpecification(Parent parent, IASTFunction functionDeclaration, boolean isTemplate)
{ {
String name = functionDeclaration.getName(); String name = functionDeclaration.getName();
if (name == null) { if ((name == null) || (name.length() <= 0)) {
// Something is wrong, skip this element // Something is wrong, skip this element
return null; 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 2003-09-24 Hoda Amer
Partial solution to bug#42453: Expression result types not computed Partial solution to bug#42453: Expression result types not computed
Added the handling of the NEW_TYPEID, CASTEXPRESSION, POSTFIX_DYNAMIC_CAST, 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, ASTExpression expression = new ASTExpression( kind, lhs, rhs, thirdExpression,
typeId, idExpression, literal, newDescriptor, references); typeId, idExpression, literal, newDescriptor, references);
try{
expression.setResultType (getExpressionResultType(expression, symbol)); expression.setResultType (getExpressionResultType(expression, symbol));
}catch (ASTSemanticException e){
throw e;
}
return expression; return expression;
} }
@ -917,10 +920,10 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
return info; return info;
} }
} }
protected List getExpressionResultType(IASTExpression expression, ISymbol symbol){ protected List getExpressionResultType(IASTExpression expression, ISymbol symbol)throws ASTSemanticException{
List result = new ArrayList(); List result = new ArrayList();
TypeInfo info = new TypeInfo(); TypeInfo info = new TypeInfo();
try {
// types that resolve to void // types that resolve to void
if ((expression.getExpressionKind() == IASTExpression.Kind.PRIMARY_EMPTY) if ((expression.getExpressionKind() == IASTExpression.Kind.PRIMARY_EMPTY)
|| (expression.getExpressionKind() == IASTExpression.Kind.THROWEXPRESSION) || (expression.getExpressionKind() == IASTExpression.Kind.THROWEXPRESSION)
@ -1078,10 +1081,10 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
){ ){
if(symbol != null){ if(symbol != null){
info = new TypeInfo(symbol.getTypeInfo()); info = new TypeInfo(symbol.getTypeInfo());
}
result.add(info); result.add(info);
return result; return result;
} }
}
// the dot* and the arrow* are the same as dot/arrow + unary star // the dot* and the arrow* are the same as dot/arrow + unary star
if ((expression.getExpressionKind() == IASTExpression.Kind.PM_DOTSTAR) if ((expression.getExpressionKind() == IASTExpression.Kind.PM_DOTSTAR)
|| (expression.getExpressionKind() == IASTExpression.Kind.PM_ARROWSTAR) || (expression.getExpressionKind() == IASTExpression.Kind.PM_ARROWSTAR)
@ -1105,10 +1108,10 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
info.setType(TypeInfo.t_type); info.setType(TypeInfo.t_type);
info.setTypeSymbol(symbol); info.setTypeSymbol(symbol);
info.addOperatorExpression( TypeInfo.OperatorExpression.addressof ); info.addOperatorExpression( TypeInfo.OperatorExpression.addressof );
}
result.add(info); result.add(info);
return result; return result;
} }
}
// conditional // conditional
if (expression.getExpressionKind() == IASTExpression.Kind.CONDITIONALEXPRESSION){ if (expression.getExpressionKind() == IASTExpression.Kind.CONDITIONALEXPRESSION){
ASTExpression right = (ASTExpression)expression.getRHSExpression(); ASTExpression right = (ASTExpression)expression.getRHSExpression();
@ -1117,10 +1120,10 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
TypeInfo rightType =(TypeInfo)right.getResultType().iterator().next(); TypeInfo rightType =(TypeInfo)right.getResultType().iterator().next();
TypeInfo thirdType =(TypeInfo)third.getResultType().iterator().next(); TypeInfo thirdType =(TypeInfo)third.getResultType().iterator().next();
info = conditionalExpressionConversions(rightType, thirdType); info = conditionalExpressionConversions(rightType, thirdType);
}
result.add(info); result.add(info);
return result; return result;
} }
}
// new // new
if( ( expression.getExpressionKind() == IASTExpression.Kind.NEW_TYPEID ) if( ( expression.getExpressionKind() == IASTExpression.Kind.NEW_TYPEID )
|| ( expression.getExpressionKind() == IASTExpression.Kind.NEW_NEWTYPEID ) ) || ( 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 leftType =(TypeInfo)left.getResultType().iterator().next();
TypeInfo rightType =(TypeInfo)right.getResultType().iterator().next(); TypeInfo rightType =(TypeInfo)right.getResultType().iterator().next();
info = usualArithmeticConversions(leftType, rightType); info = usualArithmeticConversions(leftType, rightType);
}
result.add(info); result.add(info);
return result; return result;
} }
}
// types that resolve to LHS types // types that resolve to LHS types
if ((expression.getExpressionKind() == IASTExpression.Kind.PRIMARY_BRACKETED_EXPRESSION) if ((expression.getExpressionKind() == IASTExpression.Kind.PRIMARY_BRACKETED_EXPRESSION)
|| (expression.getExpressionKind() == IASTExpression.Kind.POSTFIX_INCREMENT) || (expression.getExpressionKind() == IASTExpression.Kind.POSTFIX_INCREMENT)
@ -1184,10 +1187,10 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
){ ){
ASTExpression left = (ASTExpression)expression.getLHSExpression(); ASTExpression left = (ASTExpression)expression.getLHSExpression();
if(left != null){ if(left != null){
TypeInfo leftType =(TypeInfo)left.getResultType().iterator().next(); info =(TypeInfo)left.getResultType().iterator().next();
result.add(leftType);
return result;
} }
result.add(info);
return result;
} }
// the cast changes the types to the type looked up in typeId = symbol // the cast changes the types to the type looked up in typeId = symbol
if(( expression.getExpressionKind() == IASTExpression.Kind.CASTEXPRESSION ) if(( expression.getExpressionKind() == IASTExpression.Kind.CASTEXPRESSION )
@ -1245,22 +1248,19 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
return result; return result;
} }
// if ( ( expression.getExpressionKind() == IASTExpression.Kind.POSTFIX_TYPENAME_IDENTIFIER ) if ( ( expression.getExpressionKind() == IASTExpression.Kind.POSTFIX_TYPENAME_IDENTIFIER )
// || ( expression.getExpressionKind() == IASTExpression.Kind.POSTFIX_TYPENAME_TEMPLATEID ) ) || ( expression.getExpressionKind() == IASTExpression.Kind.POSTFIX_TYPENAME_TEMPLATEID ) )
// { {
// IASTTypeId typeId = expression.getTypeId(); if(symbol != null){
// try info.setType(TypeInfo.t_type);
// { info.setTypeSymbol(symbol);
// info = typeId.getTypeSymbol().getTypeInfo(); }
// } result.add(info);
// catch (ASTNotImplementedException e) return result;
// { }
// // will not ever happen from within CompleteParseASTFactory } catch (Exception e){
// } throw new ASTSemanticException();
// result.add(info); }
// return result;
// }
return result; 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 2003-09-25 Alain Magloire
Add HelpContext IDs in the preference page. 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.CoreModel;
import org.eclipse.cdt.core.model.ICElement; 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.IMember;
import org.eclipse.cdt.core.model.IMethod; import org.eclipse.cdt.core.model.IMethod;
import org.eclipse.cdt.core.model.IMethodDeclaration; import org.eclipse.cdt.core.model.IMethodDeclaration;
@ -317,15 +315,7 @@ public class CCompletionProcessor implements IContentAssistProcessor {
IRegion region; IRegion region;
String frag = ""; String frag = "";
int pos = startPos; 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 // Move back the pos by one the position is 0-based
if (pos > 0) { if (pos > 0) {
pos--; pos--;