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

Fixed a typo.

This commit is contained in:
Sergey Prigogin 2010-03-01 05:14:49 +00:00
parent af930f51f9
commit a71b6c6659
6 changed files with 96 additions and 84 deletions

View file

@ -44,14 +44,14 @@ public interface ICPPASTTemplateDeclaration extends IASTDeclaration {
"ICPPASTTemplateDeclaration.OWNED_DECLARATION - Subdeclaration maintained grammatically"); //$NON-NLS-1$ "ICPPASTTemplateDeclaration.OWNED_DECLARATION - Subdeclaration maintained grammatically"); //$NON-NLS-1$
/** /**
* Get templated declaration. * Get template declaration.
* *
* @return <code>IASTDeclaration</code> * @return <code>IASTDeclaration</code>
*/ */
public IASTDeclaration getDeclaration(); public IASTDeclaration getDeclaration();
/** /**
* Set the templated declaration. * Set the template declaration.
* *
* @param declaration * @param declaration
* <code>IASTDeclaration</code> * <code>IASTDeclaration</code>
@ -67,18 +67,24 @@ public interface ICPPASTTemplateDeclaration extends IASTDeclaration {
/** /**
* Get template parameters. * Get template parameters.
* *
* @return <code>ICPPASTTemplateParameter []</code> * @return <code>ICPPASTTemplateParameter[]</code>
*/ */
public ICPPASTTemplateParameter[] getTemplateParameters(); public ICPPASTTemplateParameter[] getTemplateParameters();
/** /**
* Add a template parameter. * Add a template parameter.
* *
* @param parm * @param parm <code>ICPPASTTemplateParameter</code>
* <code>ICPPASTTemplateParameter</code> * @since 5.2
*/ */
public void addTemplateParameter(ICPPASTTemplateParameter parm);
/**
* @deprecated Use addTemplateParameter.
*/
@Deprecated
public void addTemplateParamter(ICPPASTTemplateParameter parm); public void addTemplateParamter(ICPPASTTemplateParameter parm);
/** /**
* get the template scope representing this declaration in the logical tree * get the template scope representing this declaration in the logical tree
* @return <code>ICPPTemplateScope</code> * @return <code>ICPPTemplateScope</code>

View file

@ -32,7 +32,8 @@ public class CPPASTTemplateDeclaration extends ASTNode implements
private short nestingLevel= -1; private short nestingLevel= -1;
private IASTDeclaration declaration; private IASTDeclaration declaration;
private ICPPTemplateScope templateScope; private ICPPTemplateScope templateScope;
private ICPPASTTemplateParameter[] parameters = null;
private int parametersPos= -1;
public CPPASTTemplateDeclaration() { public CPPASTTemplateDeclaration() {
} }
@ -45,8 +46,8 @@ public class CPPASTTemplateDeclaration extends ASTNode implements
CPPASTTemplateDeclaration copy = new CPPASTTemplateDeclaration(); CPPASTTemplateDeclaration copy = new CPPASTTemplateDeclaration();
copy.setDeclaration(declaration == null ? null : declaration.copy()); copy.setDeclaration(declaration == null ? null : declaration.copy());
copy.exported = exported; copy.exported = exported;
for(ICPPASTTemplateParameter param : getTemplateParameters()) for (ICPPASTTemplateParameter param : getTemplateParameters())
copy.addTemplateParamter(param == null ? null : param.copy()); copy.addTemplateParameter(param == null ? null : param.copy());
copy.setOffsetAndLength(this); copy.setOffsetAndLength(this);
return copy; return copy;
} }
@ -73,61 +74,63 @@ public class CPPASTTemplateDeclaration extends ASTNode implements
} }
} }
public ICPPASTTemplateParameter [] getTemplateParameters() { public ICPPASTTemplateParameter[] getTemplateParameters() {
if( parameters == null ) return ICPPASTTemplateParameter.EMPTY_TEMPLATEPARAMETER_ARRAY; if (parameters == null) return ICPPASTTemplateParameter.EMPTY_TEMPLATEPARAMETER_ARRAY;
parameters = (ICPPASTTemplateParameter[]) ArrayUtil.removeNullsAfter( ICPPASTTemplateParameter.class, parameters, parametersPos ); parameters = (ICPPASTTemplateParameter[]) ArrayUtil.removeNullsAfter(ICPPASTTemplateParameter.class, parameters, parametersPos);
return parameters; return parameters;
} }
public void addTemplateParamter(ICPPASTTemplateParameter parm) { public void addTemplateParameter(ICPPASTTemplateParameter parm) {
assertNotFrozen(); assertNotFrozen();
if (parm != null) { if (parm != null) {
parameters = (ICPPASTTemplateParameter[]) ArrayUtil.append( ICPPASTTemplateParameter.class, parameters, ++parametersPos, parm ); parameters = (ICPPASTTemplateParameter[]) ArrayUtil.append(ICPPASTTemplateParameter.class, parameters, ++parametersPos, parm);
parm.setParent(this); parm.setParent(this);
parm.setPropertyInParent(PARAMETER); parm.setPropertyInParent(PARAMETER);
} }
} }
private ICPPASTTemplateParameter [] parameters = null; @Deprecated
private int parametersPos=-1; public void addTemplateParamter(ICPPASTTemplateParameter param) {
addTemplateParameter(param);
}
@Override @Override
public boolean accept( ASTVisitor action ){ public boolean accept(ASTVisitor action) {
if( action.shouldVisitDeclarations ){ if (action.shouldVisitDeclarations) {
switch( action.visit( this ) ){ switch (action.visit(this)) {
case ASTVisitor.PROCESS_ABORT : return false; case ASTVisitor.PROCESS_ABORT: return false;
case ASTVisitor.PROCESS_SKIP : return true; case ASTVisitor.PROCESS_SKIP: return true;
default : break; default: break;
} }
} }
ICPPASTTemplateParameter [] params = getTemplateParameters(); ICPPASTTemplateParameter[] params = getTemplateParameters();
for ( int i = 0; i < params.length; i++ ) { for (int i = 0; i < params.length; i++) {
if( !params[i].accept( action ) ) return false; if (!params[i].accept(action)) return false;
} }
if( declaration != null ) if( !declaration.accept( action ) ) return false; if (declaration != null && !declaration.accept(action)) return false;
if( action.shouldVisitDeclarations ){ if (action.shouldVisitDeclarations) {
switch( action.leave( this ) ){ switch (action.leave(this)) {
case ASTVisitor.PROCESS_ABORT : return false; case ASTVisitor.PROCESS_ABORT: return false;
case ASTVisitor.PROCESS_SKIP : return true; case ASTVisitor.PROCESS_SKIP: return true;
default : break; default: break;
} }
} }
return true; return true;
} }
public ICPPTemplateScope getScope() { public ICPPTemplateScope getScope() {
if( templateScope == null ) if (templateScope == null)
templateScope = new CPPTemplateScope( this ); templateScope = new CPPTemplateScope(this);
return templateScope; return templateScope;
} }
public void replace(IASTNode child, IASTNode other) { public void replace(IASTNode child, IASTNode other) {
if( declaration == child ) if (declaration == child) {
{ other.setParent(child.getParent());
other.setParent( child.getParent() ); other.setPropertyInParent(child.getPropertyInParent());
other.setPropertyInParent( child.getPropertyInParent() );
declaration = (IASTDeclaration) other; declaration = (IASTDeclaration) other;
} }
} }

View file

@ -61,22 +61,22 @@ public class CPPASTTemplateSpecialization extends ASTNode implements
} }
@Override @Override
public boolean accept( ASTVisitor action ){ public boolean accept(ASTVisitor action) {
if( action.shouldVisitDeclarations ){ if (action.shouldVisitDeclarations) {
switch( action.visit( this ) ){ switch (action.visit(this)) {
case ASTVisitor.PROCESS_ABORT : return false; case ASTVisitor.PROCESS_ABORT: return false;
case ASTVisitor.PROCESS_SKIP : return true; case ASTVisitor.PROCESS_SKIP: return true;
default : break; default: break;
} }
} }
if( declaration != null ) if( !declaration.accept( action ) ) return false; if (declaration != null && !declaration.accept(action)) return false;
if( action.shouldVisitDeclarations ){ if (action.shouldVisitDeclarations) {
switch( action.leave( this ) ){ switch (action.leave(this)) {
case ASTVisitor.PROCESS_ABORT : return false; case ASTVisitor.PROCESS_ABORT: return false;
case ASTVisitor.PROCESS_SKIP : return true; case ASTVisitor.PROCESS_SKIP: return true;
default : break; default: break;
} }
} }
return true; return true;
@ -94,20 +94,25 @@ public class CPPASTTemplateSpecialization extends ASTNode implements
return ICPPASTTemplateParameter.EMPTY_TEMPLATEPARAMETER_ARRAY; return ICPPASTTemplateParameter.EMPTY_TEMPLATEPARAMETER_ARRAY;
} }
public void addTemplateParamter(ICPPASTTemplateParameter parm) { public void addTemplateParameter(ICPPASTTemplateParameter param) {
assertNotFrozen(); assertNotFrozen();
} }
@Deprecated
public void addTemplateParamter(ICPPASTTemplateParameter param) {
addTemplateParameter(param);
}
public ICPPTemplateScope getScope() { public ICPPTemplateScope getScope() {
if( templateScope == null ) if (templateScope == null)
templateScope = new CPPTemplateScope( this ); templateScope = new CPPTemplateScope(this);
return templateScope; return templateScope;
} }
public void replace(IASTNode child, IASTNode other) { public void replace(IASTNode child, IASTNode other) {
if( declaration == child ) { if (declaration == child) {
other.setParent( child.getParent() ); other.setParent(child.getParent());
other.setPropertyInParent( child.getPropertyInParent() ); other.setPropertyInParent(child.getPropertyInParent());
declaration = (IASTDeclaration) other; declaration = (IASTDeclaration) other;
} }
} }

View file

@ -295,7 +295,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
name= nodeFactory.newName(image); name= nodeFactory.newName(image);
setRange(name, destructorOffset, nt.getEndOffset()); setRange(name, destructorOffset, nt.getEndOffset());
} }
switch(nt.getType()) { switch (nt.getType()) {
case IToken.tEOC: case IToken.tEOC:
case IToken.tCOMPLETION: case IToken.tCOMPLETION:
createCompletionNode(nt).addName(name); createCompletionNode(nt).addName(name);
@ -306,7 +306,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
private IASTName addTemplateArguments(IASTName templateName, CastExprCtx ctx) throws EndOfFileException, BacktrackException { private IASTName addTemplateArguments(IASTName templateName, CastExprCtx ctx) throws EndOfFileException, BacktrackException {
boolean isAmbiguous= false; boolean isAmbiguous= false;
switch(canBeTemplateArguments(ctx)) { switch (canBeTemplateArguments(ctx)) {
case -1: case -1:
return templateName; return templateName;
case 0: case 0:
@ -319,7 +319,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
try { try {
List<IASTNode> list = templateArgumentList(isAmbiguous); List<IASTNode> list = templateArgumentList(isAmbiguous);
IToken end= LA(1); IToken end= LA(1);
switch(end.getType()) { switch (end.getType()) {
case IToken.tGT_in_SHIFTR: case IToken.tGT_in_SHIFTR:
case IToken.tGT: case IToken.tGT:
consume(); consume();
@ -342,9 +342,9 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
for (IASTNode n : args) { for (IASTNode n : args) {
if (n instanceof IASTTypeId) { if (n instanceof IASTTypeId) {
result.addTemplateArgument((IASTTypeId) n); result.addTemplateArgument((IASTTypeId) n);
} else if(n instanceof IASTExpression) { } else if (n instanceof IASTExpression) {
result.addTemplateArgument((IASTExpression) n); result.addTemplateArgument((IASTExpression) n);
} else if(n instanceof ICPPASTAmbiguousTemplateArgument) { } else if (n instanceof ICPPASTAmbiguousTemplateArgument) {
result.addTemplateArgument((ICPPASTAmbiguousTemplateArgument) n); result.addTemplateArgument((ICPPASTAmbiguousTemplateArgument) n);
} }
} }
@ -368,7 +368,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
int limit= 10000; int limit= 10000;
while(--limit > 0) { while(--limit > 0) {
switch(consume().getType()) { switch (consume().getType()) {
case IToken.tEOC: case IToken.tEOC:
case IToken.tCOMPLETION: case IToken.tCOMPLETION:
return ctx == CastExprCtx.eNotBExpr ? 0 : -1; return ctx == CastExprCtx.eNotBExpr ? 0 : -1;
@ -392,7 +392,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
// do the same check for the enclosing template // do the same check for the enclosing template
lt1= LTcatchEOF(2); lt1= LTcatchEOF(2);
} }
switch(lt1) { switch (lt1) {
// Can be some cast-expression or continuation after template-id // Can be some cast-expression or continuation after template-id
case IToken.tCOLONCOLON: // CT<int>::member case IToken.tCOLONCOLON: // CT<int>::member
case IToken.tLPAREN: // ft<int>(args) case IToken.tLPAREN: // ft<int>(args)
@ -704,7 +704,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
// Brace initializers are allowed on the right hand side of an expression // Brace initializers are allowed on the right hand side of an expression
boolean allowBraceInitializer= false; boolean allowBraceInitializer= false;
lt1= LT(1); lt1= LT(1);
switch(lt1) { switch (lt1) {
case IToken.tQUESTION: case IToken.tQUESTION:
if (ctx == BinaryExprCtx.eAmbigTmplID) { if (ctx == BinaryExprCtx.eAmbigTmplID) {
throwBacktrack(LA(1)); throwBacktrack(LA(1));
@ -1408,7 +1408,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
} }
private ICPPASTLiteralExpression stringLiteral() throws EndOfFileException, BacktrackException { private ICPPASTLiteralExpression stringLiteral() throws EndOfFileException, BacktrackException {
switch(LT(1)) { switch (LT(1)) {
case IToken.tSTRING: case IToken.tSTRING:
case IToken.tLSTRING: case IToken.tLSTRING:
case IToken.tUTF16STRING: case IToken.tUTF16STRING:
@ -1438,7 +1438,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
} }
final int endOffset= consumeOrEOC(IToken.tRPAREN).getEndOffset(); final int endOffset= consumeOrEOC(IToken.tRPAREN).getEndOffset();
int operator; int operator;
switch(optype) { switch (optype) {
case IToken.t_dynamic_cast: case IToken.t_dynamic_cast:
operator = ICPPASTCastExpression.op_dynamic_cast; operator = ICPPASTCastExpression.op_dynamic_cast;
break; break;
@ -1588,7 +1588,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
final int offset= LA(1).getOffset(); final int offset= LA(1).getOffset();
boolean exported = false; boolean exported = false;
int explicitInstMod= 0; int explicitInstMod= 0;
switch(LT(1)) { switch (LT(1)) {
case IToken.t_export: case IToken.t_export:
exported = true; exported = true;
consume(); consume();
@ -1640,7 +1640,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
templateDecl.setExported(exported); templateDecl.setExported(exported);
for (int i = 0; i < parms.size(); ++i) { for (int i = 0; i < parms.size(); ++i) {
ICPPASTTemplateParameter parm = parms.get(i); ICPPASTTemplateParameter parm = parms.get(i);
templateDecl.addTemplateParamter(parm); templateDecl.addTemplateParameter(parm);
} }
return templateDecl; return templateDecl;
} }
@ -2580,7 +2580,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
verifyDtor(declspec, dtor1, option); verifyDtor(declspec, dtor1, option);
int lt1= LTcatchEOF(1); int lt1= LTcatchEOF(1);
switch(lt1) { switch (lt1) {
case 0: case 0:
return dtor1; return dtor1;
@ -2925,7 +2925,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
// Mark initializer lists directly as pack expansions // Mark initializer lists directly as pack expansions
((ICPPASTPackExpandable) clause).setIsPackExpansion(true); ((ICPPASTPackExpandable) clause).setIsPackExpansion(true);
adjustEndOffset(clause, endOffset); adjustEndOffset(clause, endOffset);
} else if (clause instanceof IASTExpression){ } else if (clause instanceof IASTExpression) {
// Wrap pack expanded assignment expressions // Wrap pack expanded assignment expressions
IASTExpression packExpansion= nodeFactory.newPackExpansionExpression((IASTExpression) clause); IASTExpression packExpansion= nodeFactory.newPackExpansionExpression((IASTExpression) clause);
clause= setRange(packExpansion, clause, endOffset); clause= setRange(packExpansion, clause, endOffset);
@ -2937,7 +2937,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
result.add(clause); result.add(clause);
if (LT(1) != IToken.tCOMMA) if (LT(1) != IToken.tCOMMA)
break; break;
switch(LT(2)) { switch (LT(2)) {
case IToken.tRBRACE: case IToken.tRBRACE:
case IToken.tRPAREN: case IToken.tRPAREN:
case IToken.tEOC: case IToken.tEOC:
@ -3126,7 +3126,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
IASTName name= null; IASTName name= null;
int coloncolon= LT(1) == IToken.tCOLONCOLON ? 1 : 0; int coloncolon= LT(1) == IToken.tCOLONCOLON ? 1 : 0;
loop: while (LTcatchEOF(coloncolon+1) == IToken.tIDENTIFIER) { loop: while (LTcatchEOF(coloncolon+1) == IToken.tIDENTIFIER) {
switch(LTcatchEOF(coloncolon+2)) { switch (LTcatchEOF(coloncolon+2)) {
case IToken.tCOLONCOLON: case IToken.tCOLONCOLON:
coloncolon+= 2; coloncolon+= 2;
break; break;
@ -3180,7 +3180,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
IASTPointer pointer; IASTPointer pointer;
if (name != null) { if (name != null) {
if(isRestrict) { if (isRestrict) {
IGPPASTPointerToMember gppp2m = nodeFactory.newPointerToMemberGPP(name); IGPPASTPointerToMember gppp2m = nodeFactory.newPointerToMemberGPP(name);
gppp2m.setRestrict(true); gppp2m.setRestrict(true);
pointer= gppp2m; pointer= gppp2m;
@ -3188,7 +3188,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
pointer= nodeFactory.newPointerToMember(name); pointer= nodeFactory.newPointerToMember(name);
} }
} else { } else {
if(isRestrict) { if (isRestrict) {
IGPPASTPointer gpppo = nodeFactory.newPointerGPP(); IGPPASTPointer gpppo = nodeFactory.newPointerGPP();
gpppo.setRestrict(true); gpppo.setRestrict(true);
pointer= gpppo; pointer= gpppo;
@ -3337,7 +3337,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
// cv-qualifiers // cv-qualifiers
cvloop: while(true) { cvloop: while(true) {
switch(LT(1)) { switch (LT(1)) {
case IToken.t_const: case IToken.t_const:
fc.setConst(true); fc.setConst(true);
endOffset= consume().getEndOffset(); endOffset= consume().getEndOffset();
@ -3918,9 +3918,9 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
if (condition != null && (condition instanceof IASTExpression || condition instanceof IASTDeclaration)) if (condition != null && (condition instanceof IASTExpression || condition instanceof IASTDeclaration))
// shouldn't be possible but failure in condition() makes it so // shouldn't be possible but failure in condition() makes it so
{ {
if( condition instanceof IASTExpression ) if (condition instanceof IASTExpression)
new_if_statement.setConditionExpression((IASTExpression) condition); new_if_statement.setConditionExpression((IASTExpression) condition);
else if( condition instanceof IASTDeclaration ) else if (condition instanceof IASTDeclaration)
new_if_statement.setConditionDeclaration((IASTDeclaration) condition); new_if_statement.setConditionDeclaration((IASTDeclaration) condition);
} }
if (thenClause != null) { if (thenClause != null) {
@ -4003,10 +4003,9 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
ICPPASTSwitchStatement switch_statement = nodeFactory.newSwitchStatement(); ICPPASTSwitchStatement switch_statement = nodeFactory.newSwitchStatement();
((ASTNode) switch_statement).setOffsetAndLength(startOffset, ((ASTNode) switch_statement).setOffsetAndLength(startOffset,
(switch_body != null ? calculateEndOffset(switch_body) : LA(1).getEndOffset()) - startOffset); (switch_body != null ? calculateEndOffset(switch_body) : LA(1).getEndOffset()) - startOffset);
if( switch_condition instanceof IASTExpression ) { if (switch_condition instanceof IASTExpression) {
switch_statement.setControllerExpression((IASTExpression) switch_condition); switch_statement.setControllerExpression((IASTExpression) switch_condition);
} } else if (switch_condition instanceof IASTDeclaration) {
else if( switch_condition instanceof IASTDeclaration ) {
switch_statement.setControllerDeclaration((IASTDeclaration) switch_condition); switch_statement.setControllerDeclaration((IASTDeclaration) switch_condition);
} }
@ -4066,10 +4065,9 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
for_statement.setInitializerStatement(init); for_statement.setInitializerStatement(init);
if (for_condition != null) { if (for_condition != null) {
if( for_condition instanceof IASTExpression ) { if (for_condition instanceof IASTExpression) {
for_statement.setConditionExpression((IASTExpression) for_condition); for_statement.setConditionExpression((IASTExpression) for_condition);
} } else if (for_condition instanceof IASTDeclaration) {
else if( for_condition instanceof IASTDeclaration ) {
for_statement.setConditionDeclaration((IASTDeclaration) for_condition); for_statement.setConditionDeclaration((IASTDeclaration) for_condition);
} }
} }

View file

@ -673,7 +673,7 @@ public class ExtractFunctionRefactoring extends CRefactoring {
templateDeclaration.setParent(unit); templateDeclaration.setParent(unit);
for(ICPPASTTemplateParameter templateParameter : ((ICPPASTTemplateDeclaration) insertpoint.getParent()).getTemplateParameters()) { for(ICPPASTTemplateParameter templateParameter : ((ICPPASTTemplateDeclaration) insertpoint.getParent()).getTemplateParameters()) {
templateDeclaration.addTemplateParamter(templateParameter.copy()); templateDeclaration.addTemplateParameter(templateParameter.copy());
} }
templateDeclaration.setDeclaration(func); templateDeclaration.setDeclaration(func);

View file

@ -232,7 +232,7 @@ public class ImplementMethodRefactoring extends CRefactoring {
templateDeclaration.setParent(unit); templateDeclaration.setParent(unit);
for(ICPPASTTemplateParameter templateParameter : ((ICPPASTTemplateDeclaration) declarationParent.getParent().getParent() ).getTemplateParameters()) { for(ICPPASTTemplateParameter templateParameter : ((ICPPASTTemplateDeclaration) declarationParent.getParent().getParent() ).getTemplateParameters()) {
templateDeclaration.addTemplateParamter(templateParameter.copy()); templateDeclaration.addTemplateParameter(templateParameter.copy());
} }
templateDeclaration.setDeclaration(func); templateDeclaration.setDeclaration(func);