diff options
| author | M N Palat | 2013-09-25 00:03:27 +0000 |
|---|---|---|
| committer | M N Palat | 2013-09-25 00:03:27 +0000 |
| commit | b42e8d4e3737175b925c20ff2d83cccd857d4944 (patch) | |
| tree | 7a9596ca3e6aabd062a3524758f21bcbc65cf5df | |
| parent | cbe22d350fa314e6e5df169cf670cab9bb8c2a20 (diff) | |
| download | eclipse.jdt.core-b42e8d4e3737175b925c20ff2d83cccd857d4944.tar.gz eclipse.jdt.core-b42e8d4e3737175b925c20ff2d83cccd857d4944.tar.xz eclipse.jdt.core-b42e8d4e3737175b925c20ff2d83cccd857d4944.zip | |
Fix for 417659 - [dom][ast][1.8] test failures - ast structure - when
debug tracing is on (fixes 5 rewrite failures)
2 files changed, 19 insertions, 24 deletions
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/rewrite/describing/ASTRewritingMethodDeclTest.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/rewrite/describing/ASTRewritingMethodDeclTest.java index 7a21225034..ac133dd7fb 100644 --- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/rewrite/describing/ASTRewritingMethodDeclTest.java +++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/rewrite/describing/ASTRewritingMethodDeclTest.java @@ -993,7 +993,7 @@ public class ASTRewritingMethodDeclTest extends ASTRewritingTest { List thrownExceptions= getThrownExceptions(methodDecl); assertTrue("must be 0 thrown exceptions", thrownExceptions.size() == 0); - Name newThrownException= ast.newSimpleName("InterruptedException"); + ASTNode newThrownException= createNewExceptionType(ast, "InterruptedException"); rewrite.getListRewrite(methodDecl, getMethodThrownExceptionsProperty(ast)).insertFirst(newThrownException, null); } @@ -1015,7 +1015,7 @@ public class ASTRewritingMethodDeclTest extends ASTRewritingTest { assertTrue("must be 1 thrown exceptions", thrownExceptions.size() == 1); ASTNode firstException= (ASTNode) thrownExceptions.get(0); - Name newThrownException= ast.newSimpleName("InterruptedException"); + ASTNode newThrownException= createNewExceptionType(ast, "InterruptedException"); rewrite.getListRewrite(methodDecl, getMethodThrownExceptionsProperty(ast)).insertBefore(newThrownException, firstException, null); } { // insert after last param & insert after first exception & add synchronized, static @@ -1035,7 +1035,7 @@ public class ASTRewritingMethodDeclTest extends ASTRewritingTest { assertTrue("must be 1 thrown exceptions", thrownExceptions.size() == 1); ASTNode firstException= (ASTNode) thrownExceptions.get(0); - Name newThrownException= ast.newSimpleName("InterruptedException"); + ASTNode newThrownException= createNewExceptionType(ast, "InterruptedException"); rewrite.getListRewrite(methodDecl, getMethodThrownExceptionsProperty(ast)).insertAfter(newThrownException, firstException, null); } @@ -1057,7 +1057,7 @@ public class ASTRewritingMethodDeclTest extends ASTRewritingTest { assertTrue("must be 2 thrown exceptions", thrownExceptions.size() == 2); ASTNode firstException= (ASTNode) thrownExceptions.get(0); - Name newThrownException= ast.newSimpleName("InterruptedException"); + ASTNode newThrownException= createNewExceptionType(ast, "InterruptedException"); rewrite.getListRewrite(methodDecl, getMethodThrownExceptionsProperty(ast)).insertAfter(newThrownException, firstException, null); } { // insert 2 params after first & replace the second exception and insert new after @@ -1077,10 +1077,10 @@ public class ASTRewritingMethodDeclTest extends ASTRewritingTest { List thrownExceptions= getThrownExceptions(methodDecl); assertTrue("must be 2 thrown exceptions", thrownExceptions.size() == 2); - Name newThrownException1= ast.newSimpleName("InterruptedException"); + ASTNode newThrownException1= createNewExceptionType(ast, "InterruptedException"); rewrite.getListRewrite(methodDecl, getMethodThrownExceptionsProperty(ast)).insertLast(newThrownException1, null); - Name newThrownException2= ast.newSimpleName("ArrayStoreException"); + ASTNode newThrownException2= createNewExceptionType(ast, "ArrayStoreException"); rewrite.replace((ASTNode) thrownExceptions.get(1), newThrownException2, null); } { // insert 2 params after last & remove the last exception and insert new after @@ -1103,7 +1103,7 @@ public class ASTRewritingMethodDeclTest extends ASTRewritingTest { ASTNode lastException= (ASTNode) thrownExceptions.get(2); rewrite.remove(lastException, null); - Name newThrownException= ast.newSimpleName("InterruptedException"); + ASTNode newThrownException= createNewExceptionType(ast, "InterruptedException"); rewrite.getListRewrite(methodDecl, getMethodThrownExceptionsProperty(ast)).insertBefore(newThrownException, lastException, null); } { // insert at first and last position & remove 2nd, add after 2nd, remove 3rd @@ -1126,7 +1126,7 @@ public class ASTRewritingMethodDeclTest extends ASTRewritingTest { rewrite.remove(secondException, null); rewrite.remove(lastException, null); - Name newThrownException= ast.newSimpleName("InterruptedException"); + ASTNode newThrownException= createNewExceptionType(ast, "InterruptedException"); rewrite.getListRewrite(methodDecl, getMethodThrownExceptionsProperty(ast)).insertAfter(newThrownException, secondException, null); } diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/rewrite/describing/ASTRewritingReferenceExpressionTest.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/rewrite/describing/ASTRewritingReferenceExpressionTest.java index 75dd62cce6..a6213b371f 100644 --- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/rewrite/describing/ASTRewritingReferenceExpressionTest.java +++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/rewrite/describing/ASTRewritingReferenceExpressionTest.java @@ -100,10 +100,9 @@ public class ASTRewritingReferenceExpressionTest extends ASTRewritingTest { variableDeclarationStatement = (VariableDeclarationStatement) methodDecl.getBody().statements().get(1); variableDeclarationFragment = (VariableDeclarationFragment) variableDeclarationStatement.fragments().get(0); creationReference = (CreationReference) variableDeclarationFragment.getInitializer(); - typeParameter= ast.newTypeParameter(); - typeParameter.setName(ast.newSimpleName("Integer")); + SimpleType simpleType = ast.newSimpleType(ast.newSimpleName("Integer")); listRewrite = rewrite.getListRewrite(creationReference, CreationReference.TYPE_ARGUMENTS_PROPERTY); - listRewrite.insertLast(typeParameter, null); + listRewrite.insertLast(simpleType, null); // case 3: delete a type argument. variableDeclarationStatement = (VariableDeclarationStatement) methodDecl.getBody().statements().get(2); @@ -129,15 +128,14 @@ public class ASTRewritingReferenceExpressionTest extends ASTRewritingTest { variableDeclarationFragment = (VariableDeclarationFragment) variableDeclarationStatement.fragments().get(0); creationReference = (CreationReference) variableDeclarationFragment.getInitializer(); listRewrite = rewrite.getListRewrite(creationReference, CreationReference.TYPE_ARGUMENTS_PROPERTY); - typeParameter= ast.newTypeParameter(); - typeParameter.setName(ast.newSimpleName("String")); - listRewrite.insertFirst(typeParameter, null); + simpleType = ast.newSimpleType(ast.newSimpleName("String")); + listRewrite.insertFirst(simpleType, null); // case 8: change a CreationReference to a TypeMethodReference. variableDeclarationStatement = (VariableDeclarationStatement) methodDecl.getBody().statements().get(7); variableDeclarationFragment = (VariableDeclarationFragment) variableDeclarationStatement.fragments().get(0); creationReference = (CreationReference) variableDeclarationFragment.getInitializer(); - SimpleType simpleType = ast.newSimpleType(ast.newQualifiedName(ast.newSimpleName("Y"), ast.newSimpleName("Z"))); + simpleType = ast.newSimpleType(ast.newQualifiedName(ast.newSimpleName("Y"), ast.newSimpleName("Z"))); rewrite.replace(creationReference.getType(), simpleType, null); } @@ -270,10 +268,9 @@ public class ASTRewritingReferenceExpressionTest extends ASTRewritingTest { VariableDeclarationStatement variableDeclarationStatement = (VariableDeclarationStatement) methodDecl.getBody().statements().get(2); VariableDeclarationFragment variableDeclarationFragment = (VariableDeclarationFragment) variableDeclarationStatement.fragments().get(0); ExpressionMethodReference expressionMethodReference = (ExpressionMethodReference) variableDeclarationFragment.getInitializer(); - TypeParameter typeParameter= ast.newTypeParameter(); - typeParameter.setName(ast.newSimpleName("String")); + SimpleType simpleType = ast.newSimpleType((ast.newSimpleName("String"))); rewrite.replace(expressionMethodReference.getExpression(), ast.newSimpleName("z"), null); - rewrite.getListRewrite(expressionMethodReference, ExpressionMethodReference.TYPE_ARGUMENTS_PROPERTY).insertFirst(typeParameter, null); + rewrite.getListRewrite(expressionMethodReference, ExpressionMethodReference.TYPE_ARGUMENTS_PROPERTY).insertFirst(simpleType, null); rewrite.replace(expressionMethodReference.getName(), ast.newSimpleName("bar"), null); variableDeclarationStatement = (VariableDeclarationStatement) methodDecl.getBody().statements().get(3); @@ -356,11 +353,10 @@ public class ASTRewritingReferenceExpressionTest extends ASTRewritingTest { VariableDeclarationStatement variableDeclarationStatement = (VariableDeclarationStatement) methodDecl.getBody().statements().get(0); VariableDeclarationFragment variableDeclarationFragment = (VariableDeclarationFragment) variableDeclarationStatement.fragments().get(0); TypeMethodReference typeMethodReference = (TypeMethodReference) variableDeclarationFragment.getInitializer(); - TypeParameter typeParameter= ast.newTypeParameter(); - typeParameter.setName(ast.newSimpleName("Integer")); + SimpleType simpleType = ast.newSimpleType((ast.newSimpleName("Integer"))); Type newType = ast.newSimpleType(ast.newSimpleName("W")); rewrite.replace(typeMethodReference.getType(), newType, null); - rewrite.getListRewrite(typeMethodReference, TypeMethodReference.TYPE_ARGUMENTS_PROPERTY).insertFirst(typeParameter, null); + rewrite.getListRewrite(typeMethodReference, TypeMethodReference.TYPE_ARGUMENTS_PROPERTY).insertFirst(simpleType, null); rewrite.replace(typeMethodReference.getName(), ast.newSimpleName("bar"), null); variableDeclarationStatement = (VariableDeclarationStatement) methodDecl.getBody().statements().get(1); @@ -450,9 +446,8 @@ public class ASTRewritingReferenceExpressionTest extends ASTRewritingTest { variableDeclarationFragment = (VariableDeclarationFragment) variableDeclarationStatement.fragments().get(0); superMethodReference = (SuperMethodReference) variableDeclarationFragment.getInitializer(); rewrite.remove(superMethodReference.getQualifier(), null); - TypeParameter typeParameter= ast.newTypeParameter(); - typeParameter.setName(ast.newSimpleName("String")); - rewrite.getListRewrite(superMethodReference, SuperMethodReference.TYPE_ARGUMENTS_PROPERTY).insertFirst(typeParameter, null); + SimpleType simpleType = ast.newSimpleType(ast.newSimpleName("String")); + rewrite.getListRewrite(superMethodReference, SuperMethodReference.TYPE_ARGUMENTS_PROPERTY).insertFirst(simpleType, null); rewrite.replace(superMethodReference.getName(), ast.newSimpleName("foo"), null); } |
