From 7f6a6ae5cafd12508a763586548dd6076b08c602 Mon Sep 17 00:00:00 2001 From: Sergey Prigogin Date: Wed, 2 Mar 2016 18:41:40 -0800 Subject: [PATCH] Removed use of a deprecated method. Change-Id: I00934f05c35e5ccba097c05904f8b68d897a71de --- .../cdt/core/parser/tests/ast2/AST2Tests.java | 14 ++++-- .../c/CASTArraySubscriptExpression.java | 45 +++++++++---------- 2 files changed, 31 insertions(+), 28 deletions(-) diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2Tests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2Tests.java index 5dca53d8e59..b607728ee83 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2Tests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2Tests.java @@ -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()); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTArraySubscriptExpression.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTArraySubscriptExpression.java index 0aea50d4b5b..192cf4105ea 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTArraySubscriptExpression.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTArraySubscriptExpression.java @@ -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; } }