diff options
| author | Jayaprakash Arthanareeswaran | 2013-07-01 14:29:22 +0000 |
|---|---|---|
| committer | Jayaprakash Arthanareeswaran | 2013-07-01 14:29:22 +0000 |
| commit | 4eeaf0d0e03ab922557bc9369f948328bc88b0fc (patch) | |
| tree | ec36a7d906479026b315ad6d6e5e40b52e48e971 | |
| parent | bfe1e5f410410e285c8a77b5130cabdbc82cde90 (diff) | |
| download | eclipse.jdt.core-4eeaf0d0e03ab922557bc9369f948328bc88b0fc.tar.gz eclipse.jdt.core-4eeaf0d0e03ab922557bc9369f948328bc88b0fc.tar.xz eclipse.jdt.core-4eeaf0d0e03ab922557bc9369f948328bc88b0fc.zip | |
Fix for bug 405934 - [1.8][dom ast] thrown Exceptions with Type
Annotations should have malformed nodes for AST level less than 8
| -rw-r--r-- | org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverter17Test.java | 25 | ||||
| -rw-r--r-- | org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ASTConverter.java | 6 |
2 files changed, 30 insertions, 1 deletions
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverter17Test.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverter17Test.java index fdd9dbd6ea..8f9b890854 100644 --- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverter17Test.java +++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverter17Test.java @@ -47,6 +47,8 @@ import org.eclipse.jdt.core.dom.MethodDeclaration; import org.eclipse.jdt.core.dom.MethodInvocation; import org.eclipse.jdt.core.dom.NullLiteral; import org.eclipse.jdt.core.dom.NumberLiteral; +import org.eclipse.jdt.core.dom.QualifiedName; +import org.eclipse.jdt.core.dom.SimpleName; import org.eclipse.jdt.core.dom.SingleVariableDeclaration; import org.eclipse.jdt.core.dom.SwitchStatement; import org.eclipse.jdt.core.dom.TryStatement; @@ -963,4 +965,27 @@ public class ASTConverter17Test extends ConverterTestSetup { method = (MethodDeclaration) type.bodyDeclarations().get(1); assertEquals("Method should be malformed", ASTNode.MALFORMED, (method.getFlags() & ASTNode.MALFORMED)); } + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=405934 + * + * @deprecated as it uses deprecated methods + */ + public void test0022() throws JavaModelException { + String contents = + "public class X {\n" + + " void foo() throws @NonNull EOFException, java.io.@NonNull FileNotFoundException {}\n" + + "}\n"; + this.workingCopy = getWorkingCopy("/Converter17/src/X.java", false); + ASTNode node = buildAST(contents, this.workingCopy, false); + assertEquals("Not a compilation unit", ASTNode.COMPILATION_UNIT, node.getNodeType()); + CompilationUnit unit = (CompilationUnit) node; + TypeDeclaration type = (TypeDeclaration) unit.types().get(0); + node = (ASTNode) type.bodyDeclarations().get(0); + assertEquals("Not a method Declaration", ASTNode.METHOD_DECLARATION, node.getNodeType()); + MethodDeclaration method = (MethodDeclaration) node; + SimpleName exception1 = (SimpleName) method.thrownExceptions().get(0); + assertEquals("QualifiedName should be malformed", ASTNode.MALFORMED, (exception1.getFlags() & ASTNode.MALFORMED)); + QualifiedName exception2 = (QualifiedName) method.thrownExceptions().get(1); + assertEquals("QualifiedName should be malformed", ASTNode.MALFORMED, (exception2.getFlags() & ASTNode.MALFORMED)); + } } 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 4177a79c61..79f9331b11 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 @@ -500,7 +500,11 @@ class ASTConverter { Name thrownException; int i = 0; do { - thrownException = convert(thrownExceptions[i++]); + TypeReference typeRef = thrownExceptions[i++]; + thrownException = convert(typeRef); + if (typeRef.annotations != null && typeRef.annotations.length > 0) { + thrownException.setFlags(thrownException.getFlags() | ASTNode.MALFORMED); + } internalThownExceptions(methodDecl).add(thrownException); } while (i < thrownExceptionsLength); methodHeaderEnd = thrownException.getStartPosition() + thrownException.getLength(); |
