Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSarika Sinha2019-02-28 09:13:47 -0500
committerManoj Palat2019-02-28 23:31:17 -0500
commit4e22de6b5c96cb008d4a18fa7ee6a605ce7e9a06 (patch)
tree6fbe425393f2b23d05b9321d110c36ec29a99076
parent58f84fa8bd45fe7d13fa8fec999d2aa78465dd08 (diff)
downloadeclipse.jdt.core-4e22de6b5c96cb008d4a18fa7ee6a605ce7e9a06.tar.gz
eclipse.jdt.core-4e22de6b5c96cb008d4a18fa7ee6a605ce7e9a06.tar.xz
eclipse.jdt.core-4e22de6b5c96cb008d4a18fa7ee6a605ce7e9a06.zip
Bug 542558 - [12][dom ast] DOM AST Support for Switch ExpressionsP20190301-0045
-rw-r--r--org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ASTConverter.java4
-rw-r--r--org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ASTMatcher.java2
-rw-r--r--org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/BreakStatement.java2
-rw-r--r--org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/SwitchCase.java13
-rw-r--r--org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/SwitchExpression.java1
-rw-r--r--org.eclipse.jdt.core/dom/org/eclipse/jdt/internal/core/dom/NaiveASTFlattener.java4
6 files changed, 16 insertions, 10 deletions
diff --git a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ASTConverter.java b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ASTConverter.java
index 3253a99b97..6d0a464a10 100644
--- a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ASTConverter.java
+++ b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ASTConverter.java
@@ -1310,10 +1310,10 @@ class ASTConverter {
if (this.ast.apiLevel >= AST.JLS12_INTERNAL) {
org.eclipse.jdt.internal.compiler.ast.Expression[] expressions = statement.constantExpressions;
if (expressions == null || expressions.length == 0) {
- switchCase.getExpressions().clear();
+ switchCase.expressions().clear();
} else {
for (org.eclipse.jdt.internal.compiler.ast.Expression expression : expressions) {
- switchCase.getExpressions().add(convert(expression));
+ switchCase.expressions().add(convert(expression));
}
}
} else {
diff --git a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ASTMatcher.java b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ASTMatcher.java
index defcaa152f..1e0259ef5f 100644
--- a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ASTMatcher.java
+++ b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ASTMatcher.java
@@ -2274,7 +2274,7 @@ public class ASTMatcher {
}
SwitchCase o = (SwitchCase) other;
return ( node.getAST().apiLevel >= AST.JLS12_INTERNAL
- ? safeSubtreeListMatch(node.getExpressions(), o.getExpressions())
+ ? safeSubtreeListMatch(node.expressions(), o.expressions())
: compareDeprecatedSwitchExpression(node, o));
}
diff --git a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/BreakStatement.java b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/BreakStatement.java
index 9013facc91..2441ce01dd 100644
--- a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/BreakStatement.java
+++ b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/BreakStatement.java
@@ -215,6 +215,7 @@ public class BreakStatement extends Statement {
* there is none.
*
* @return the expression, or <code>null</code> if there is none
+ * @exception UnsupportedOperationException if this operation is used below JLS12
* @since 3.17 BETA_JAVA_12
*/
public Expression getExpression() {
@@ -233,6 +234,7 @@ public class BreakStatement extends Statement {
* <li>the node belongs to a different AST</li>
* <li>the node already has a parent</li>
* </ul>
+ * @exception UnsupportedOperationException if this operation is used below JLS12
* @since 3.17 BETA_JAVA_12
*/
public void setExpression(Expression expression) {
diff --git a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/SwitchCase.java b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/SwitchCase.java
index 3792ed2c84..6e430a15a7 100644
--- a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/SwitchCase.java
+++ b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/SwitchCase.java
@@ -159,7 +159,7 @@ public class SwitchCase extends Statement {
@Override
final List internalGetChildListProperty(ChildListPropertyDescriptor property) {
if (property == EXPRESSIONS2_PROPERTY ) {
- return getExpressions();
+ return expressions();
}
// allow default implementation to flag the error
return super.internalGetChildListProperty(property);
@@ -177,8 +177,8 @@ public class SwitchCase extends Statement {
result.setSourceRange(getStartPosition(), getLength());
result.copyLeadingComment(this);
if (this.ast.apiLevel >= AST.JLS12_INTERNAL) {
- result.getExpressions().addAll(
- ASTNode.copySubtrees(target, getExpressions()));
+ result.expressions().addAll(
+ ASTNode.copySubtrees(target, expressions()));
} else {
result.setExpression(
(Expression) ASTNode.copySubtree(target, getExpression()));
@@ -232,9 +232,10 @@ public class SwitchCase extends Statement {
* <code>empty</code> if there is none (the "default:" case).
*
* @return the expression node, or <code>expression</code> if there is none
+ * @exception UnsupportedOperationException if this operation is used below JLS12
* @since 3.17 BETA_JAVA_12
*/
- public List getExpressions() {
+ public List expressions() {
if (this.expressions == null) {
unsupportedBelow12();
}
@@ -268,6 +269,7 @@ public class SwitchCase extends Statement {
* <code>true</code> indicates "->" and <code>false</code> indicates ":".
* @param switchLabeledRule <code>true</code> or </false>
+ * @exception UnsupportedOperationException if this operation is used below JLS12
* @since 3.17 BETA_JAVA_12
*/
public void setSwitchLabeledRule(boolean switchLabeledRule) {
@@ -280,6 +282,7 @@ public class SwitchCase extends Statement {
*<code>true</code> indicates "->" and <code>false</code> indicates ":".
*
* @return switchLabeledRule <code>true</code> or </false>
+ * @exception UnsupportedOperationException if this operation is used below JLS12
* @since 3.17 BETA_JAVA_12
*/
public boolean isSwitchLabeledRule() {
@@ -299,7 +302,7 @@ public class SwitchCase extends Statement {
*/
public boolean isDefault() {
if (this.ast.apiLevel >= AST.JLS12_INTERNAL) {
- return getExpressions().isEmpty();
+ return expressions().isEmpty();
}
return getExpression() == null;
}
diff --git a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/SwitchExpression.java b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/SwitchExpression.java
index 5060aff18e..2eea888249 100644
--- a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/SwitchExpression.java
+++ b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/SwitchExpression.java
@@ -108,6 +108,7 @@ public class SwitchExpression extends Expression {
* </p>
*
* @param ast the AST that is to own this node
+ * @exception UnsupportedOperationException if this operation is used below JLS12
*/
SwitchExpression(AST ast) {
super(ast);
diff --git a/org.eclipse.jdt.core/dom/org/eclipse/jdt/internal/core/dom/NaiveASTFlattener.java b/org.eclipse.jdt.core/dom/org/eclipse/jdt/internal/core/dom/NaiveASTFlattener.java
index bbc8630985..ec82e2e4c0 100644
--- a/org.eclipse.jdt.core/dom/org/eclipse/jdt/internal/core/dom/NaiveASTFlattener.java
+++ b/org.eclipse.jdt.core/dom/org/eclipse/jdt/internal/core/dom/NaiveASTFlattener.java
@@ -1500,8 +1500,8 @@ public class NaiveASTFlattener extends ASTVisitor {
@Override
public boolean visit(SwitchCase node) {
if (node.getAST().apiLevel() >= JLS12) {
- if (!node.getExpressions().isEmpty()) {
- for (Iterator it = node.getExpressions().iterator(); it.hasNext(); ) {
+ if (!node.expressions().isEmpty()) {
+ for (Iterator it = node.expressions().iterator(); it.hasNext(); ) {
Expression t = (Expression) it.next();
if (node.isDefault()) {
if (node.isSwitchLabeledRule()) {

Back to the top