1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-23 17:05:26 +02:00

Removed use of a deprecated method.

Change-Id: I00934f05c35e5ccba097c05904f8b68d897a71de
This commit is contained in:
Sergey Prigogin 2016-03-02 18:41:40 -08:00
parent 2c9820b2b0
commit 7f6a6ae5ca
2 changed files with 31 additions and 28 deletions

View file

@ -5356,13 +5356,13 @@ public class AST2Tests extends AST2TestBase {
return ((ASTNode) expr).getOffset() + ((ASTNode) expr).getLength();
}
private String polishNotation(IASTExpression expr) {
private String polishNotation(IASTInitializerClause expr) {
StringBuilder buf= new StringBuilder();
polishNotation(expr, buf);
return buf.toString();
}
private void polishNotation(IASTExpression expr, StringBuilder buf) {
private void polishNotation(IASTInitializerClause expr, StringBuilder buf) {
if (expr instanceof IASTConditionalExpression) {
IASTConditionalExpression bexpr= (IASTConditionalExpression) expr;
polishNotation(bexpr.getLogicalConditionExpression(), buf);
@ -5398,7 +5398,7 @@ public class AST2Tests extends AST2TestBase {
polishNotation(f.getFunctionNameExpression(), buf);
buf.append(',');
for (IASTInitializerClause arg : f.getArguments()) {
polishNotation((IASTExpression) arg, buf);
polishNotation(arg, buf);
buf.append(',');
}
buf.append("()");
@ -5406,7 +5406,7 @@ public class AST2Tests extends AST2TestBase {
IASTArraySubscriptExpression f= (IASTArraySubscriptExpression) expr;
polishNotation(f.getArrayExpression(), buf);
buf.append(',');
polishNotation(f.getSubscriptExpression(), buf);
polishNotation(f.getArgument(), buf);
buf.append(",[]");
} else if (expr instanceof IASTFieldReference) {
IASTFieldReference f= (IASTFieldReference) expr;
@ -5433,6 +5433,12 @@ public class AST2Tests extends AST2TestBase {
buf.append(ASTStringUtil.getUnaryOperatorString(unaryExpr));
break;
}
} else if (expr instanceof IASTInitializerList) {
buf.append('{');
for (IASTInitializerClause clause : ((IASTInitializerList) expr).getClauses()) {
polishNotation(clause, buf);
}
buf.append('}');
} else {
buf.append(expr.getRawSignature());
}

View file

@ -24,11 +24,10 @@ import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
/**
* Array subscript expression for c
* Array subscript expression for C.
*/
public class CASTArraySubscriptExpression extends ASTNode implements
IASTArraySubscriptExpression, IASTAmbiguityParent {
private IASTExpression array;
private IASTExpression subscript;
@ -85,7 +84,7 @@ public class CASTArraySubscriptExpression extends ASTNode implements
@Override
public IASTInitializerClause getArgument() {
return getSubscriptExpression();
return subscript;
}
@Override
@ -98,23 +97,23 @@ public class CASTArraySubscriptExpression extends ASTNode implements
}
@Override
public boolean accept( ASTVisitor action ){
if( action.shouldVisitExpressions ){
switch( action.visit( this ) ){
case ASTVisitor.PROCESS_ABORT : return false;
case ASTVisitor.PROCESS_SKIP : return true;
default : break;
public boolean accept(ASTVisitor action) {
if (action.shouldVisitExpressions) {
switch (action.visit(this)) {
case ASTVisitor.PROCESS_ABORT: return false;
case ASTVisitor.PROCESS_SKIP: return true;
default: break;
}
}
if( array != null ) if( !array.accept( action ) ) return false;
if( subscript != null ) if( !subscript.accept( action ) ) return false;
if (array != null && !array.accept(action)) return false;
if (subscript != null && !subscript.accept(action)) return false;
if( action.shouldVisitExpressions ){
switch( action.leave( this ) ){
case ASTVisitor.PROCESS_ABORT : return false;
case ASTVisitor.PROCESS_SKIP : return true;
default : break;
if (action.shouldVisitExpressions) {
switch (action.leave(this)) {
case ASTVisitor.PROCESS_ABORT: return false;
case ASTVisitor.PROCESS_SKIP: return true;
default: break;
}
}
return true;
@ -122,16 +121,14 @@ public class CASTArraySubscriptExpression extends ASTNode implements
@Override
public void replace(IASTNode child, IASTNode other) {
if( child == array )
{
other.setPropertyInParent( child.getPropertyInParent() );
other.setParent( child.getParent() );
if (child == array) {
other.setPropertyInParent(child.getPropertyInParent());
other.setParent(child.getParent());
array = (IASTExpression) other;
}
if( child == subscript)
{
other.setPropertyInParent( child.getPropertyInParent() );
other.setParent( child.getParent() );
if (child == subscript) {
other.setPropertyInParent(child.getPropertyInParent());
other.setParent(child.getParent());
subscript = (IASTExpression) other;
}
}