diff options
author | Markus Keller | 2016-08-22 18:07:39 +0000 |
---|---|---|
committer | Markus Keller | 2016-08-22 18:12:11 +0000 |
commit | 5b554299cb005ff0153d8fe479bc087dc19a19ce (patch) | |
tree | 461a96b297b3dd2253065208a3c31118af40933f | |
parent | 5c83e7a4a08150ff31eef9f7d80db9ef25943b59 (diff) | |
download | eclipse.jdt.core-5b554299cb005ff0153d8fe479bc087dc19a19ce.tar.gz eclipse.jdt.core-5b554299cb005ff0153d8fe479bc087dc19a19ce.tar.xz eclipse.jdt.core-5b554299cb005ff0153d8fe479bc087dc19a19ce.zip |
Bug 497719: [1.9] [dom/ast] support for resource references in TryStatementY20160825-1000
completed Javadocs and fixed usages in jdt.core
Change-Id: I60dd3082d16fe9d2023e9e2ac2df82320facc591
5 files changed, 19 insertions, 12 deletions
diff --git a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/TryStatement.java b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/TryStatement.java index 10b11e2028..00f990d7c4 100644 --- a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/TryStatement.java +++ b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/TryStatement.java @@ -32,6 +32,8 @@ import java.util.List; * Not all node arrangements will represent legal Java constructs. In particular, * at least one resource, catch clause, or finally block must be present.</p> * + * <p>A resource is either a {@link VariableDeclarationExpression} or (since JLS9) a {@link Name}.</p> + * * @since 2.0 * @noinstantiate This class is not intended to be instantiated by clients. */ @@ -139,7 +141,7 @@ public class TryStatement extends Statement { case AST.JLS3_INTERNAL : return PROPERTY_DESCRIPTORS; case AST.JLS4_INTERNAL : - case AST.JLS8 : + case AST.JLS8_INTERNAL : return PROPERTY_DESCRIPTORS_4_0; default : return PROPERTY_DESCRIPTORS_9_0; @@ -147,9 +149,11 @@ public class TryStatement extends Statement { } /** - * The resource expressions (element type: {@link VariableDeclarationExpression}). - * Null in JLS2 and JLS3. Added in JLS4; defaults to an empty list - * (see constructor). + * The resource expressions (element type: {@link Expression}). + * Null in JLS2 and JLS3. Added in JLS4. + * In the deprecated JLS4 and JLS8 APIs, this used to be + * (element type: {@link VariableDeclarationExpression}). + * Defaults to an empty list (see constructor). * @since 3.7 */ private ASTNode.NodeList resources = null; @@ -370,9 +374,12 @@ public class TryStatement extends Statement { /** * Returns the live ordered list of resources for this try statement (added in JLS4 API). + * + * <p>A resource is either a {@link VariableDeclarationExpression} or (since JLS9) a {@link Name}.</p> * - * @return the live list of resources - * (element type: {@link VariableDeclarationExpression}) + * @return the live list of resources (element type: {@link Expression}). + * In the deprecated JLS4 and JLS8 APIs, this used to be + * (element type: {@link VariableDeclarationExpression}). * @exception UnsupportedOperationException if this operation is used * in a JLS2 or JLS3 AST * @since 3.7.1 diff --git a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/rewrite/ImportRewrite.java b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/rewrite/ImportRewrite.java index 4cb4138c16..d3e332bc57 100644 --- a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/rewrite/ImportRewrite.java +++ b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/rewrite/ImportRewrite.java @@ -1145,7 +1145,7 @@ public final class ImportRewrite { CompilationUnit usedAstRoot= this.astRoot; if (usedAstRoot == null) { - ASTParser parser= ASTParser.newParser(AST.JLS8); + ASTParser parser= ASTParser.newParser(AST.JLS9); parser.setSource(this.compilationUnit); parser.setFocalPosition(0); // reduced AST parser.setResolveBindings(false); 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 44352be790..1d816cb1d8 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 @@ -1681,7 +1681,7 @@ public class NaiveASTFlattener extends ASTVisitor { if (!resources.isEmpty()) { this.buffer.append('('); for (Iterator it = resources.iterator(); it.hasNext(); ) { - VariableDeclarationExpression variable = (VariableDeclarationExpression) it.next(); + Expression variable = (Expression) it.next(); variable.accept(this); if (it.hasNext()) { this.buffer.append(';'); diff --git a/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/DefaultCodeFormatter.java b/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/DefaultCodeFormatter.java index 30ba78969d..9b709ed603 100644 --- a/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/DefaultCodeFormatter.java +++ b/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/DefaultCodeFormatter.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2015 IBM Corporation and others. + * Copyright (c) 2000, 2016 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -226,7 +226,7 @@ public class DefaultCodeFormatter extends CodeFormatter { CommentWrapExecutor commentWrapper = new CommentWrapExecutor(this.tokenManager, this.workingOptions); switch (kind) { case K_JAVA_DOC: - ASTParser parser = ASTParser.newParser(AST.JLS8); + ASTParser parser = ASTParser.newParser(AST.JLS9); for (Token token : this.tokens) { if (token.tokenType == TokenNameCOMMENT_JAVADOC) { parser.setSourceRange(token.originalStart, token.countChars()); @@ -286,7 +286,7 @@ public class DefaultCodeFormatter extends CodeFormatter { } private ASTNode parseSourceCode(int kind) { - ASTParser parser = ASTParser.newParser(AST.JLS8); + ASTParser parser = ASTParser.newParser(AST.JLS9); Map<String, String> parserOptions = JavaCore.getOptions(); parserOptions.put(CompilerOptions.OPTION_Source, this.sourceLevel); parserOptions.put(CompilerOptions.OPTION_DocCommentSupport, CompilerOptions.ENABLED); diff --git a/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/SpacePreparator.java b/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/SpacePreparator.java index 0e6b4b8ba1..3a9b4acc94 100644 --- a/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/SpacePreparator.java +++ b/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/SpacePreparator.java @@ -363,7 +363,7 @@ public class SpacePreparator extends ASTVisitor { @Override
public boolean visit(TryStatement node) {
- List<VariableDeclarationExpression> resources = node.resources();
+ List<Expression> resources = node.resources();
if (!resources.isEmpty()) {
handleToken(node, TokenNameLPAREN, this.options.insert_space_before_opening_paren_in_try,
this.options.insert_space_after_opening_paren_in_try);
|