diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverterAST3Test.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverterAST3Test.java
index 8442723f8dd..1622328c981 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverterAST3Test.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverterAST3Test.java
@@ -49,20 +49,6 @@ public ASTConverterAST3Test(String name) {
public static Test suite() {
return buildModelTestSuite(ASTConverterAST3Test.class);
}
- /**
- * Internal access method to MethodDeclaration#thrownExceptions() for avoiding deprecated warnings.
- * @deprecated
- */
- private static List internalThrownExceptions(MethodDeclaration methodDeclaration) {
- return methodDeclaration.thrownExceptions();
- }
-
- /**
- * @deprecated
- */
- private Type componentType(ArrayType array) {
- return array.getComponentType();
- }
public void test0001() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0001", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
@@ -2730,7 +2716,6 @@ public void test0123() throws JavaModelException {
/**
* Multiple local declaration => VariabledeclarationStatement
*/
- @SuppressWarnings("deprecation")
public void test0124() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0124", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
@@ -2746,14 +2731,15 @@ public void test0124() throws JavaModelException {
fragment = this.ast.newVariableDeclarationFragment();
fragment.setName(this.ast.newSimpleName("z"));//$NON-NLS-1$
fragment.setInitializer(this.ast.newNullLiteral());
- fragment.setExtraDimensions(1);
+ fragment.extraDimensions().add(this.ast.newDimension());
statement.fragments().add(fragment);
fragment = this.ast.newVariableDeclarationFragment();
fragment.setName(this.ast.newSimpleName("i"));//$NON-NLS-1$
statement.fragments().add(fragment);
fragment = this.ast.newVariableDeclarationFragment();
fragment.setName(this.ast.newSimpleName("j"));//$NON-NLS-1$
- fragment.setExtraDimensions(2);
+ fragment.extraDimensions().add(this.ast.newDimension());
+ fragment.extraDimensions().add(this.ast.newDimension());
statement.fragments().add(fragment);
statement.setType(this.ast.newPrimitiveType(PrimitiveType.INT));
assertTrue("Both AST trees should be identical", statement.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
@@ -2769,7 +2755,6 @@ public void test0124() throws JavaModelException {
/**
* Multiple local declaration => VariabledeclarationStatement
*/
- @SuppressWarnings("deprecation")
public void test0125() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0125", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
@@ -2785,14 +2770,15 @@ public void test0125() throws JavaModelException {
fragment = this.ast.newVariableDeclarationFragment();
fragment.setName(this.ast.newSimpleName("z"));//$NON-NLS-1$
fragment.setInitializer(this.ast.newNullLiteral());
- fragment.setExtraDimensions(1);
+ fragment.extraDimensions().add(this.ast.newDimension());
statement.fragments().add(fragment);
fragment = this.ast.newVariableDeclarationFragment();
fragment.setName(this.ast.newSimpleName("i"));//$NON-NLS-1$
statement.fragments().add(fragment);
fragment = this.ast.newVariableDeclarationFragment();
fragment.setName(this.ast.newSimpleName("j"));//$NON-NLS-1$
- fragment.setExtraDimensions(2);
+ fragment.extraDimensions().add(this.ast.newDimension());
+ fragment.extraDimensions().add(this.ast.newDimension());
statement.fragments().add(fragment);
statement.setType(this.ast.newArrayType(this.ast.newPrimitiveType(PrimitiveType.INT), 1));
assertTrue("Both AST trees should be identical", statement.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
@@ -2808,7 +2794,6 @@ public void test0125() throws JavaModelException {
/**
* ForStatement
*/
- @SuppressWarnings("deprecation")
public void test0126() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0126", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
@@ -2819,7 +2804,7 @@ public void test0126() throws JavaModelException {
VariableDeclarationFragment variableDeclarationFragment = this.ast.newVariableDeclarationFragment();
variableDeclarationFragment.setName(this.ast.newSimpleName("tab")); //$NON-NLS-1$
variableDeclarationFragment.setInitializer(this.ast.newNullLiteral());//$NON-NLS-1$
- variableDeclarationFragment.setExtraDimensions(1);
+ variableDeclarationFragment.extraDimensions().add(this.ast.newDimension());
VariableDeclarationExpression variableDeclarationExpression = this.ast.newVariableDeclarationExpression(variableDeclarationFragment);
variableDeclarationExpression.setType(this.ast.newArrayType(this.ast.newSimpleType(this.ast.newSimpleName("String")), 1));//$NON-NLS-1$
forStatement.initializers().add(variableDeclarationExpression);
@@ -2837,7 +2822,6 @@ public void test0126() throws JavaModelException {
/**
* ForStatement
*/
- @SuppressWarnings("deprecation")
public void test0127() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0127", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
@@ -2848,7 +2832,7 @@ public void test0127() throws JavaModelException {
VariableDeclarationFragment variableDeclarationFragment = this.ast.newVariableDeclarationFragment();
variableDeclarationFragment.setName(this.ast.newSimpleName("tab")); //$NON-NLS-1$
variableDeclarationFragment.setInitializer(this.ast.newNullLiteral());//$NON-NLS-1$
- variableDeclarationFragment.setExtraDimensions(1);
+ variableDeclarationFragment.extraDimensions().add(this.ast.newDimension());
VariableDeclarationExpression variableDeclarationExpression = this.ast.newVariableDeclarationExpression(variableDeclarationFragment);
variableDeclarationExpression.setType(this.ast.newSimpleType(this.ast.newSimpleName("String")));//$NON-NLS-1$
forStatement.initializers().add(variableDeclarationExpression);
@@ -2866,7 +2850,6 @@ public void test0127() throws JavaModelException {
/**
* ForStatement
*/
- @SuppressWarnings("deprecation")
public void test0128() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0128", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
@@ -2877,7 +2860,7 @@ public void test0128() throws JavaModelException {
VariableDeclarationFragment variableDeclarationFragment = this.ast.newVariableDeclarationFragment();
variableDeclarationFragment.setName(this.ast.newSimpleName("tab")); //$NON-NLS-1$
variableDeclarationFragment.setInitializer(this.ast.newNullLiteral());//$NON-NLS-1$
- variableDeclarationFragment.setExtraDimensions(1);
+ variableDeclarationFragment.extraDimensions().add(this.ast.newDimension());
VariableDeclarationExpression variableDeclarationExpression = this.ast.newVariableDeclarationExpression(variableDeclarationFragment);
variableDeclarationExpression.setType(this.ast.newSimpleType(this.ast.newSimpleName("String")));//$NON-NLS-1$
forStatement.initializers().add(variableDeclarationExpression);
@@ -2915,7 +2898,6 @@ public void test0129() throws JavaModelException {
/**
* FieldDeclaration
*/
- @SuppressWarnings("deprecation")
public void test0130() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0130", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
@@ -2933,7 +2915,7 @@ public void test0130() throws JavaModelException {
fieldDeclaration.setType(this.ast.newPrimitiveType(PrimitiveType.INT));
fragment = this.ast.newVariableDeclarationFragment();
fragment.setName(this.ast.newSimpleName("y"));//$NON-NLS-1$
- fragment.setExtraDimensions(1);
+ fragment.extraDimensions().add(this.ast.newDimension());
fragment.setInitializer(this.ast.newNullLiteral());
fieldDeclaration.fragments().add(fragment);
fragment = this.ast.newVariableDeclarationFragment();
@@ -2941,7 +2923,8 @@ public void test0130() throws JavaModelException {
fieldDeclaration.fragments().add(fragment);
fragment = this.ast.newVariableDeclarationFragment();
fragment.setName(this.ast.newSimpleName("j"));//$NON-NLS-1$
- fragment.setExtraDimensions(2);
+ fragment.extraDimensions().add(this.ast.newDimension());
+ fragment.extraDimensions().add(this.ast.newDimension());
fieldDeclaration.fragments().add(fragment);
assertTrue("Both AST trees should be identical", fieldDeclaration.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
checkSourceRange(node, "public int x= 10, y[] = null, i, j[][];", source); //$NON-NLS-1$
@@ -7664,18 +7647,8 @@ public void test0321() throws JavaModelException {
ITypeBinding typeBinding = arrayType.resolveBinding();
checkSourceRange(type, "java.lang.Object[][]", source); //$NON-NLS-1$
assertNotNull("No type binding", typeBinding); //$NON-NLS-1$
- Type elementType = componentType(arrayType);
- ITypeBinding typeBinding2 = elementType.resolveBinding();
- assertNotNull("No type binding2", typeBinding2); //$NON-NLS-1$
- assertEquals("wrong dimension", 1, typeBinding2.getDimensions()); //$NON-NLS-1$
- assertEquals("wrong name", "Object[]", typeBinding2.getName()); //$NON-NLS-1$ //$NON-NLS-2$
- assertTrue("Not an array type", elementType.isArrayType()); //$NON-NLS-1$
- Type elementType2 = componentType(((ArrayType) elementType));
- assertTrue("Not a simple type", elementType2.isSimpleType()); //$NON-NLS-1$
- ITypeBinding typeBinding3 = elementType2.resolveBinding();
- assertNotNull("No type binding3", typeBinding3); //$NON-NLS-1$
- assertEquals("wrong dimension", 0, typeBinding3.getDimensions()); //$NON-NLS-1$
- assertEquals("wrong name", "Object", typeBinding3.getName()); //$NON-NLS-1$ //$NON-NLS-2$
+ assertEquals("wrong dimension", 2, typeBinding.getDimensions());
+ assertEquals("wrong name", "Object[][]", typeBinding.getName());
}
/**
@@ -8005,18 +7978,13 @@ public void test0333() throws JavaModelException {
ITypeBinding typeBinding2 = arrayType.resolveBinding();
assertNotNull("no type binding2", typeBinding2); //$NON-NLS-1$
assertEquals("wrong name", "Object[][]", typeBinding2.getName()); //$NON-NLS-1$ //$NON-NLS-2$
+ assertEquals("wrong dimension", 2, typeBinding.getDimensions());
Type type = arrayType.getElementType();
assertTrue("Not a simple type", type instanceof SimpleType); //$NON-NLS-1$
SimpleType simpleType = (SimpleType) type;
ITypeBinding typeBinding3 = simpleType.resolveBinding();
assertNotNull("no type binding3", typeBinding3); //$NON-NLS-1$
assertEquals("wrong name", "Object", typeBinding3.getName()); //$NON-NLS-1$ //$NON-NLS-2$
- type = componentType(arrayType);
- assertTrue("Not an array type", type instanceof ArrayType); //$NON-NLS-1$
- ArrayType arrayType2 = (ArrayType) type;
- ITypeBinding typeBinding4 = arrayType2.resolveBinding();
- assertNotNull("no type binding4", typeBinding4); //$NON-NLS-1$
- assertEquals("wrong name", "Object[]", typeBinding4.getName()); //$NON-NLS-1$ //$NON-NLS-2$
}
/**
@@ -8046,6 +8014,7 @@ public void test0334() throws JavaModelException {
ITypeBinding typeBinding2 = arrayType.resolveBinding();
assertNotNull("no type binding2", typeBinding2); //$NON-NLS-1$
assertEquals("wrong name", "Object[][][]", typeBinding2.getName()); //$NON-NLS-1$ //$NON-NLS-2$
+ assertEquals("wrong dimension", 3, typeBinding2.getDimensions());
Type type = arrayType.getElementType();
assertTrue("Not a simple type", type instanceof SimpleType); //$NON-NLS-1$
SimpleType simpleType = (SimpleType) type;
@@ -8053,20 +8022,6 @@ public void test0334() throws JavaModelException {
ITypeBinding typeBinding3 = simpleType.resolveBinding();
assertNotNull("no type binding3", typeBinding3); //$NON-NLS-1$
assertEquals("wrong name", "Object", typeBinding3.getName()); //$NON-NLS-1$ //$NON-NLS-2$
- type = componentType(arrayType);
- assertTrue("Not an array type", type instanceof ArrayType); //$NON-NLS-1$
- ArrayType arrayType2 = (ArrayType) type;
- checkSourceRange(arrayType2, "Object[10][]", source); //$NON-NLS-1$
- ITypeBinding typeBinding4 = arrayType2.resolveBinding();
- assertNotNull("no type binding4", typeBinding4); //$NON-NLS-1$
- assertEquals("wrong name", "Object[][]", typeBinding4.getName()); //$NON-NLS-1$ //$NON-NLS-2$
- type = componentType(arrayType2);
- assertTrue("Not an array type", type instanceof ArrayType); //$NON-NLS-1$
- ArrayType arrayType3 = (ArrayType) type;
- ITypeBinding typeBinding5 = arrayType3.resolveBinding();
- assertNotNull("no type binding5", typeBinding5); //$NON-NLS-1$
- assertEquals("wrong name", "Object[]", typeBinding5.getName()); //$NON-NLS-1$ //$NON-NLS-2$
- checkSourceRange(arrayType3, "Object[10]", source); //$NON-NLS-1$
}
@@ -8172,9 +8127,9 @@ public void test0338() throws JavaModelException {
assertNotNull("not null", node); //$NON-NLS-1$
assertTrue("not a MethodDeclaration", node instanceof MethodDeclaration); //$NON-NLS-1$
MethodDeclaration methodDeclaration = (MethodDeclaration) node;
- List thrownExceptions = internalThrownExceptions(methodDeclaration);
+ List thrownExceptions = methodDeclaration.thrownExceptionTypes();
assertEquals("Wrong size", 1, thrownExceptions.size()); //$NON-NLS-1$
- Name name = (Name) thrownExceptions.get(0);
+ Name name = ((SimpleType)thrownExceptions.get(0)).getName();
IBinding binding = name.resolveBinding();
assertEquals("wrong type", IBinding.TYPE, binding.getKind()); //$NON-NLS-1$
assertEquals("wrong name", "IOException", binding.getName()); //$NON-NLS-1$ //$NON-NLS-2$
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverterAST4Test.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverterAST4Test.java
index 35a84b63636..a734e0d07cb 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverterAST4Test.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverterAST4Test.java
@@ -36,7 +36,7 @@ public class ASTConverterAST4Test extends ConverterTestSetup {
@Override
public void setUpSuite() throws Exception {
super.setUpSuite();
- this.ast = AST.newAST(getJLS4(), false);
+ this.ast = AST.newAST(getJLS8(), false);
}
public ASTConverterAST4Test(String name) {
@@ -49,25 +49,11 @@ public ASTConverterAST4Test(String name) {
public static Test suite() {
return buildModelTestSuite(ASTConverterAST4Test.class);
}
- /**
- * Internal access method to MethodDeclaration#thrownExceptions() for avoiding deprecated warnings.
- * @deprecated
- */
- private List internalThrownExceptions(MethodDeclaration methodDeclaration) {
- return methodDeclaration.thrownExceptions();
- }
-
- /**
- * @deprecated
- */
- private Type componentType(ArrayType array) {
- return array.getComponentType();
- }
public void test0001() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0001", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(getJLS4(), sourceUnit, false);
+ ASTNode result = runConversion(getJLS8(), sourceUnit, false);
// check that we have the right tree
CompilationUnit unit = this.ast.newCompilationUnit();
@@ -2730,7 +2716,6 @@ public void test0123() throws JavaModelException {
/**
* Multiple local declaration => VariabledeclarationStatement
*/
- @SuppressWarnings("deprecation")
public void test0124() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0124", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
@@ -2746,14 +2731,15 @@ public void test0124() throws JavaModelException {
fragment = this.ast.newVariableDeclarationFragment();
fragment.setName(this.ast.newSimpleName("z"));//$NON-NLS-1$
fragment.setInitializer(this.ast.newNullLiteral());
- fragment.setExtraDimensions(1);
+ fragment.extraDimensions().add(this.ast.newDimension());
statement.fragments().add(fragment);
fragment = this.ast.newVariableDeclarationFragment();
fragment.setName(this.ast.newSimpleName("i"));//$NON-NLS-1$
statement.fragments().add(fragment);
fragment = this.ast.newVariableDeclarationFragment();
fragment.setName(this.ast.newSimpleName("j"));//$NON-NLS-1$
- fragment.setExtraDimensions(2);
+ fragment.extraDimensions().add(this.ast.newDimension());
+ fragment.extraDimensions().add(this.ast.newDimension());
statement.fragments().add(fragment);
statement.setType(this.ast.newPrimitiveType(PrimitiveType.INT));
assertTrue("Both AST trees should be identical", statement.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
@@ -2769,7 +2755,6 @@ public void test0124() throws JavaModelException {
/**
* Multiple local declaration => VariabledeclarationStatement
*/
- @SuppressWarnings("deprecation")
public void test0125() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0125", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
@@ -2785,14 +2770,15 @@ public void test0125() throws JavaModelException {
fragment = this.ast.newVariableDeclarationFragment();
fragment.setName(this.ast.newSimpleName("z"));//$NON-NLS-1$
fragment.setInitializer(this.ast.newNullLiteral());
- fragment.setExtraDimensions(1);
+ fragment.extraDimensions().add(this.ast.newDimension());
statement.fragments().add(fragment);
fragment = this.ast.newVariableDeclarationFragment();
fragment.setName(this.ast.newSimpleName("i"));//$NON-NLS-1$
statement.fragments().add(fragment);
fragment = this.ast.newVariableDeclarationFragment();
fragment.setName(this.ast.newSimpleName("j"));//$NON-NLS-1$
- fragment.setExtraDimensions(2);
+ fragment.extraDimensions().add(this.ast.newDimension());
+ fragment.extraDimensions().add(this.ast.newDimension());
statement.fragments().add(fragment);
statement.setType(this.ast.newArrayType(this.ast.newPrimitiveType(PrimitiveType.INT), 1));
assertTrue("Both AST trees should be identical", statement.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
@@ -2808,7 +2794,6 @@ public void test0125() throws JavaModelException {
/**
* ForStatement
*/
- @SuppressWarnings("deprecation")
public void test0126() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0126", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
@@ -2819,7 +2804,7 @@ public void test0126() throws JavaModelException {
VariableDeclarationFragment variableDeclarationFragment = this.ast.newVariableDeclarationFragment();
variableDeclarationFragment.setName(this.ast.newSimpleName("tab")); //$NON-NLS-1$
variableDeclarationFragment.setInitializer(this.ast.newNullLiteral());//$NON-NLS-1$
- variableDeclarationFragment.setExtraDimensions(1);
+ variableDeclarationFragment.extraDimensions().add(this.ast.newDimension());
VariableDeclarationExpression variableDeclarationExpression = this.ast.newVariableDeclarationExpression(variableDeclarationFragment);
variableDeclarationExpression.setType(this.ast.newArrayType(this.ast.newSimpleType(this.ast.newSimpleName("String")), 1));//$NON-NLS-1$
forStatement.initializers().add(variableDeclarationExpression);
@@ -2837,7 +2822,6 @@ public void test0126() throws JavaModelException {
/**
* ForStatement
*/
- @SuppressWarnings("deprecation")
public void test0127() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0127", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
@@ -2848,7 +2832,7 @@ public void test0127() throws JavaModelException {
VariableDeclarationFragment variableDeclarationFragment = this.ast.newVariableDeclarationFragment();
variableDeclarationFragment.setName(this.ast.newSimpleName("tab")); //$NON-NLS-1$
variableDeclarationFragment.setInitializer(this.ast.newNullLiteral());//$NON-NLS-1$
- variableDeclarationFragment.setExtraDimensions(1);
+ variableDeclarationFragment.extraDimensions().add(this.ast.newDimension());
VariableDeclarationExpression variableDeclarationExpression = this.ast.newVariableDeclarationExpression(variableDeclarationFragment);
variableDeclarationExpression.setType(this.ast.newSimpleType(this.ast.newSimpleName("String")));//$NON-NLS-1$
forStatement.initializers().add(variableDeclarationExpression);
@@ -2866,7 +2850,6 @@ public void test0127() throws JavaModelException {
/**
* ForStatement
*/
- @SuppressWarnings("deprecation")
public void test0128() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0128", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
@@ -2877,7 +2860,7 @@ public void test0128() throws JavaModelException {
VariableDeclarationFragment variableDeclarationFragment = this.ast.newVariableDeclarationFragment();
variableDeclarationFragment.setName(this.ast.newSimpleName("tab")); //$NON-NLS-1$
variableDeclarationFragment.setInitializer(this.ast.newNullLiteral());//$NON-NLS-1$
- variableDeclarationFragment.setExtraDimensions(1);
+ variableDeclarationFragment.extraDimensions().add(this.ast.newDimension());
VariableDeclarationExpression variableDeclarationExpression = this.ast.newVariableDeclarationExpression(variableDeclarationFragment);
variableDeclarationExpression.setType(this.ast.newSimpleType(this.ast.newSimpleName("String")));//$NON-NLS-1$
forStatement.initializers().add(variableDeclarationExpression);
@@ -2915,7 +2898,6 @@ public void test0129() throws JavaModelException {
/**
* FieldDeclaration
*/
- @SuppressWarnings("deprecation")
public void test0130() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0130", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
@@ -2933,7 +2915,7 @@ public void test0130() throws JavaModelException {
fieldDeclaration.setType(this.ast.newPrimitiveType(PrimitiveType.INT));
fragment = this.ast.newVariableDeclarationFragment();
fragment.setName(this.ast.newSimpleName("y"));//$NON-NLS-1$
- fragment.setExtraDimensions(1);
+ fragment.extraDimensions().add(this.ast.newDimension());
fragment.setInitializer(this.ast.newNullLiteral());
fieldDeclaration.fragments().add(fragment);
fragment = this.ast.newVariableDeclarationFragment();
@@ -2941,7 +2923,8 @@ public void test0130() throws JavaModelException {
fieldDeclaration.fragments().add(fragment);
fragment = this.ast.newVariableDeclarationFragment();
fragment.setName(this.ast.newSimpleName("j"));//$NON-NLS-1$
- fragment.setExtraDimensions(2);
+ fragment.extraDimensions().add(this.ast.newDimension());
+ fragment.extraDimensions().add(this.ast.newDimension());
fieldDeclaration.fragments().add(fragment);
assertTrue("Both AST trees should be identical", fieldDeclaration.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
checkSourceRange(node, "public int x= 10, y[] = null, i, j[][];", source); //$NON-NLS-1$
@@ -7664,18 +7647,8 @@ public void test0321() throws JavaModelException {
ITypeBinding typeBinding = arrayType.resolveBinding();
checkSourceRange(type, "java.lang.Object[][]", source); //$NON-NLS-1$
assertNotNull("No type binding", typeBinding); //$NON-NLS-1$
- Type elementType = componentType(arrayType);
- ITypeBinding typeBinding2 = elementType.resolveBinding();
- assertNotNull("No type binding2", typeBinding2); //$NON-NLS-1$
- assertEquals("wrong dimension", 1, typeBinding2.getDimensions()); //$NON-NLS-1$
- assertEquals("wrong name", "Object[]", typeBinding2.getName()); //$NON-NLS-1$ //$NON-NLS-2$
- assertTrue("Not an array type", elementType.isArrayType()); //$NON-NLS-1$
- Type elementType2 = componentType(((ArrayType) elementType));
- assertTrue("Not a simple type", elementType2.isSimpleType()); //$NON-NLS-1$
- ITypeBinding typeBinding3 = elementType2.resolveBinding();
- assertNotNull("No type binding3", typeBinding3); //$NON-NLS-1$
- assertEquals("wrong dimension", 0, typeBinding3.getDimensions()); //$NON-NLS-1$
- assertEquals("wrong name", "Object", typeBinding3.getName()); //$NON-NLS-1$ //$NON-NLS-2$
+ assertEquals("wrong dimension", 2, typeBinding.getDimensions()); //$NON-NLS-1$
+ assertEquals("wrong name", "Object[][]", typeBinding.getName()); //$NON-NLS-1$ //$NON-NLS-2$
}
/**
@@ -8005,18 +7978,7 @@ public void test0333() throws JavaModelException {
ITypeBinding typeBinding2 = arrayType.resolveBinding();
assertNotNull("no type binding2", typeBinding2); //$NON-NLS-1$
assertEquals("wrong name", "Object[][]", typeBinding2.getName()); //$NON-NLS-1$ //$NON-NLS-2$
- Type type = arrayType.getElementType();
- assertTrue("Not a simple type", type instanceof SimpleType); //$NON-NLS-1$
- SimpleType simpleType = (SimpleType) type;
- ITypeBinding typeBinding3 = simpleType.resolveBinding();
- assertNotNull("no type binding3", typeBinding3); //$NON-NLS-1$
- assertEquals("wrong name", "Object", typeBinding3.getName()); //$NON-NLS-1$ //$NON-NLS-2$
- type = componentType(arrayType);
- assertTrue("Not an array type", type instanceof ArrayType); //$NON-NLS-1$
- ArrayType arrayType2 = (ArrayType) type;
- ITypeBinding typeBinding4 = arrayType2.resolveBinding();
- assertNotNull("no type binding4", typeBinding4); //$NON-NLS-1$
- assertEquals("wrong name", "Object[]", typeBinding4.getName()); //$NON-NLS-1$ //$NON-NLS-2$
+ assertEquals(2, typeBinding2.getDimensions());
}
/**
@@ -8046,6 +8008,7 @@ public void test0334() throws JavaModelException {
ITypeBinding typeBinding2 = arrayType.resolveBinding();
assertNotNull("no type binding2", typeBinding2); //$NON-NLS-1$
assertEquals("wrong name", "Object[][][]", typeBinding2.getName()); //$NON-NLS-1$ //$NON-NLS-2$
+ assertEquals(3, typeBinding2.getDimensions());
Type type = arrayType.getElementType();
assertTrue("Not a simple type", type instanceof SimpleType); //$NON-NLS-1$
SimpleType simpleType = (SimpleType) type;
@@ -8053,20 +8016,6 @@ public void test0334() throws JavaModelException {
ITypeBinding typeBinding3 = simpleType.resolveBinding();
assertNotNull("no type binding3", typeBinding3); //$NON-NLS-1$
assertEquals("wrong name", "Object", typeBinding3.getName()); //$NON-NLS-1$ //$NON-NLS-2$
- type = componentType(arrayType);
- assertTrue("Not an array type", type instanceof ArrayType); //$NON-NLS-1$
- ArrayType arrayType2 = (ArrayType) type;
- checkSourceRange(arrayType2, "Object[10][]", source); //$NON-NLS-1$
- ITypeBinding typeBinding4 = arrayType2.resolveBinding();
- assertNotNull("no type binding4", typeBinding4); //$NON-NLS-1$
- assertEquals("wrong name", "Object[][]", typeBinding4.getName()); //$NON-NLS-1$ //$NON-NLS-2$
- type = componentType(arrayType2);
- assertTrue("Not an array type", type instanceof ArrayType); //$NON-NLS-1$
- ArrayType arrayType3 = (ArrayType) type;
- ITypeBinding typeBinding5 = arrayType3.resolveBinding();
- assertNotNull("no type binding5", typeBinding5); //$NON-NLS-1$
- assertEquals("wrong name", "Object[]", typeBinding5.getName()); //$NON-NLS-1$ //$NON-NLS-2$
- checkSourceRange(arrayType3, "Object[10]", source); //$NON-NLS-1$
}
@@ -8172,9 +8121,9 @@ public void test0338() throws JavaModelException {
assertNotNull("not null", node); //$NON-NLS-1$
assertTrue("not a MethodDeclaration", node instanceof MethodDeclaration); //$NON-NLS-1$
MethodDeclaration methodDeclaration = (MethodDeclaration) node;
- List thrownExceptions = internalThrownExceptions(methodDeclaration);
+ List thrownExceptions = methodDeclaration.thrownExceptionTypes();
assertEquals("Wrong size", 1, thrownExceptions.size()); //$NON-NLS-1$
- Name name = (Name) thrownExceptions.get(0);
+ Name name = ((SimpleType) thrownExceptions.get(0)).getName();
IBinding binding = name.resolveBinding();
assertEquals("wrong type", IBinding.TYPE, binding.getKind()); //$NON-NLS-1$
assertEquals("wrong name", "IOException", binding.getName()); //$NON-NLS-1$ //$NON-NLS-2$
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverterJavadocTest.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverterJavadocTest.java
index 957791d9504..c2423efb5d3 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverterJavadocTest.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverterJavadocTest.java
@@ -1635,7 +1635,6 @@ public void testBug55221c() throws JavaModelException {
methodLength = compilUnit.getExtendedLength(method);
assumeEquals("Method declaration "+method+" does not end at the right position",method.getLength(), methodLength);
}
- /** @deprecated using deprecated code */
public void testBug55221d() throws JavaModelException {
this.sourceUnit = getCompilationUnit("Converter" , "src", "javadoc.testBug55221.d", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
ASTNode result = runConversion(this.sourceUnit, false);
@@ -1653,7 +1652,7 @@ public void testBug55221d() throws JavaModelException {
int methodLength = compilUnit.getExtendedLength(method);
assumeEquals("Method "+method+" does not have the right length", methodLength, method.getLength());
// get return type
- node = method.getReturnType();
+ node = method.getReturnType2();
assumeNotNull("We should get a non-null ast node", node);
assumeTrue("Not return type", node.getNodeType() == ASTNode.PRIMITIVE_TYPE); //$NON-NLS-1$
PrimitiveType returnType = (PrimitiveType) node;
@@ -1702,7 +1701,6 @@ public void testBug55223a() throws JavaModelException {
idx++;
}
}
- /** @deprecated using deprecated code */
public void testBug55223b() throws JavaModelException {
this.sourceUnit = getCompilationUnit("Converter" , "src", "javadoc.testBug55223", "TestB.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
ASTNode result = runConversion(this.sourceUnit, false);
@@ -1718,7 +1716,7 @@ public void testBug55223b() throws JavaModelException {
assumeEquals("Not a method declaration", ASTNode.METHOD_DECLARATION, node.getNodeType()); //$NON-NLS-1$
MethodDeclaration method = (MethodDeclaration) node;
// get return type
- node = method.getReturnType();
+ node = method.getReturnType2();
assumeNotNull("We should get a non-null ast node", node);
assumeTrue("Not return type", node.getNodeType() == ASTNode.SIMPLE_TYPE); //$NON-NLS-1$
SimpleType returnType = (SimpleType) node;
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverterTest.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverterTest.java
index ca77bd55b21..89bb19dda91 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverterTest.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverterTest.java
@@ -41,7 +41,7 @@ public class ASTConverterTest extends ConverterTestSetup {
@Override
public void setUpSuite() throws Exception {
super.setUpSuite();
- this.ast = AST.newAST(AST.JLS2, false);
+ this.ast = AST.newAST(AST.JLS8, false);
}
public ASTConverterTest(String name) {
@@ -54,22 +54,7 @@ public ASTConverterTest(String name) {
public static Test suite() {
return buildModelTestSuite(ASTConverterTest.class);
}
- /**
- * Internal access method to MethodDeclaration#thrownExceptions() for avoiding deprecated warnings.
- * @deprecated
- */
- private static List internalThrownExceptions(MethodDeclaration methodDeclaration) {
- return methodDeclaration.thrownExceptions();
- }
-
- /**
- * @deprecated
- */
- private Type componentType(ArrayType array) {
- return array.getComponentType();
- }
- /** @deprecated using deprecated code */
public void test0001() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0001", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
@@ -90,13 +75,13 @@ public void test0001() throws JavaModelException {
unit.imports().add(importDeclaration);
TypeDeclaration type = this.ast.newTypeDeclaration();
type.setInterface(false);
- type.setModifiers(Modifier.PUBLIC);
+ type.modifiers().addAll(this.ast.newModifiers(Modifier.PUBLIC));
type.setName(this.ast.newSimpleName("Test"));//$NON-NLS-1$
MethodDeclaration methodDeclaration = this.ast.newMethodDeclaration();
methodDeclaration.setConstructor(false);
- methodDeclaration.setModifiers(Modifier.PUBLIC | Modifier.STATIC);
+ methodDeclaration.modifiers().addAll(this.ast.newModifiers(Modifier.PUBLIC | Modifier.STATIC));
methodDeclaration.setName(this.ast.newSimpleName("main"));//$NON-NLS-1$
- methodDeclaration.setReturnType(this.ast.newPrimitiveType(PrimitiveType.VOID));
+ methodDeclaration.setReturnType2(this.ast.newPrimitiveType(PrimitiveType.VOID));
SingleVariableDeclaration variableDeclaration = this.ast.newSingleVariableDeclaration();
variableDeclaration.setType(this.ast.newArrayType(this.ast.newSimpleType(this.ast.newSimpleName("String"))));//$NON-NLS-1$
variableDeclaration.setName(this.ast.newSimpleName("args"));//$NON-NLS-1$
@@ -137,7 +122,6 @@ public void test0001() throws JavaModelException {
/**
* Test allocation expression: new Object() ==> ClassInstanceCreation
- * @deprecated using deprecated code
*/
public void test0002() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0002", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
@@ -146,14 +130,13 @@ public void test0002() throws JavaModelException {
ASTNode expression = getASTNodeToCompare((CompilationUnit) result);
assertNotNull("Expression should not be null", expression); //$NON-NLS-1$
ClassInstanceCreation classInstanceCreation = this.ast.newClassInstanceCreation();
- classInstanceCreation.setName(this.ast.newSimpleName("Object")); //$NON-NLS-1$
+ classInstanceCreation.setType(this.ast.newSimpleType(this.ast.newSimpleName("Object"))); //$NON-NLS-1$
assertTrue("Both AST trees should be identical", classInstanceCreation.subtreeMatch(new ASTMatcher(), expression)); //$NON-NLS-1$
checkSourceRange(expression, "new Object()", source); //$NON-NLS-1$
}
/**
* Test allocation expression: new java.lang.Object() ==> ClassInstanceCreation
- * @deprecated using deprecated code
*/
public void test0003() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0003", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
@@ -168,14 +151,13 @@ public void test0003() throws JavaModelException {
this.ast.newSimpleName("java"), //$NON-NLS-1$
this.ast.newSimpleName("lang")), //$NON-NLS-1$
this.ast.newSimpleName("Object"));//$NON-NLS-1$
- classInstanceCreation.setName(name);
+ classInstanceCreation.setType(this.ast.newSimpleType(name));
assertTrue("Both AST trees should be identical", classInstanceCreation.subtreeMatch(new ASTMatcher(), expression)); //$NON-NLS-1$
checkSourceRange(expression, "new java.lang.Object()", source); //$NON-NLS-1$
}
/**
* Test allocation expression: new java.lang.Exception("ERROR") ==> ClassInstanceCreation
- * @deprecated using deprecated code
*/
public void test0004() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0004", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
@@ -190,7 +172,7 @@ public void test0004() throws JavaModelException {
this.ast.newSimpleName("java"), //$NON-NLS-1$
this.ast.newSimpleName("lang")), //$NON-NLS-1$
this.ast.newSimpleName("Exception"));//$NON-NLS-1$
- classInstanceCreation.setName(name);
+ classInstanceCreation.setType(this.ast.newSimpleType(name));
StringLiteral literal = this.ast.newStringLiteral();
literal.setLiteralValue("ERROR"); //$NON-NLS-1$
classInstanceCreation.arguments().add(literal);
@@ -200,7 +182,6 @@ public void test0004() throws JavaModelException {
/**
* Test allocation expression: new java.lang.Object() {} ==> ClassInstanceCreation
- * @deprecated using deprecated code
*/
public void test0005() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0005", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
@@ -215,20 +196,19 @@ public void test0005() throws JavaModelException {
this.ast.newSimpleName("java"), //$NON-NLS-1$
this.ast.newSimpleName("lang")), //$NON-NLS-1$
this.ast.newSimpleName("Object"));//$NON-NLS-1$
- classInstanceCreation.setName(name);
+ classInstanceCreation.setType(this.ast.newSimpleType(name));
AnonymousClassDeclaration anonymousClassDeclaration = this.ast.newAnonymousClassDeclaration();
classInstanceCreation.setAnonymousClassDeclaration(anonymousClassDeclaration);
assertTrue("Both AST trees should be identical", classInstanceCreation.subtreeMatch(new ASTMatcher(), expression)); //$NON-NLS-1$
checkSourceRange(expression, "new java.lang.Object() {}", source); //$NON-NLS-1$
ClassInstanceCreation classInstanceCreation2 = (ClassInstanceCreation) expression;
- Name name2 = classInstanceCreation2.getName();
+ Name name2 = ((SimpleType)classInstanceCreation2.getType()).getName();
checkSourceRange(name2, "java.lang.Object", source); //$NON-NLS-1$
}
/**
* Test allocation expression: new java.lang.Runnable() { public void run() {}} ==> ClassInstanceCreation
- * @deprecated using deprecated code
*/
public void test0006() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0006", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
@@ -243,13 +223,13 @@ public void test0006() throws JavaModelException {
this.ast.newSimpleName("java"), //$NON-NLS-1$
this.ast.newSimpleName("lang")), //$NON-NLS-1$
this.ast.newSimpleName("Runnable"));//$NON-NLS-1$
- classInstanceCreation.setName(name);
+ classInstanceCreation.setType(this.ast.newSimpleType(name));
MethodDeclaration methodDeclaration = this.ast.newMethodDeclaration();
methodDeclaration.setBody(this.ast.newBlock());
methodDeclaration.setConstructor(false);
- methodDeclaration.setModifiers(Modifier.PUBLIC);
+ methodDeclaration.modifiers().addAll(this.ast.newModifiers(Modifier.PUBLIC));
methodDeclaration.setName(this.ast.newSimpleName("run"));//$NON-NLS-1$
- methodDeclaration.setReturnType(this.ast.newPrimitiveType(PrimitiveType.VOID));
+ methodDeclaration.setReturnType2(this.ast.newPrimitiveType(PrimitiveType.VOID));
AnonymousClassDeclaration anonymousClassDeclaration = this.ast.newAnonymousClassDeclaration();
anonymousClassDeclaration.bodyDeclarations().add(methodDeclaration);
classInstanceCreation.setAnonymousClassDeclaration(anonymousClassDeclaration);
@@ -259,7 +239,6 @@ public void test0006() throws JavaModelException {
/**
* Test allocation expression: new Test().new D() ==> ClassInstanceCreation
- * @deprecated using deprecated code
*/
public void test0007() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0007", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
@@ -271,9 +250,9 @@ public void test0007() throws JavaModelException {
ASTNode expression = (ASTNode) ((MethodInvocation) expressionStatement.getExpression()).arguments().get(0);
assertNotNull("Expression should not be null", expression); //$NON-NLS-1$
ClassInstanceCreation classInstanceCreation = this.ast.newClassInstanceCreation();
- classInstanceCreation.setName(this.ast.newSimpleName("D")); //$NON-NLS-1$
+ classInstanceCreation.setType(this.ast.newSimpleType(this.ast.newSimpleName("D"))); //$NON-NLS-1$
ClassInstanceCreation classInstanceCreationExpression = this.ast.newClassInstanceCreation();
- classInstanceCreationExpression.setName(this.ast.newSimpleName("Test")); //$NON-NLS-1$
+ classInstanceCreationExpression.setType(this.ast.newSimpleType(this.ast.newSimpleName("Test"))); //$NON-NLS-1$
classInstanceCreation.setExpression(classInstanceCreationExpression);
assertTrue("Both AST trees should be identical", classInstanceCreation.subtreeMatch(new ASTMatcher(), expression)); //$NON-NLS-1$
checkSourceRange(expression, "new Test().new D()", source); //$NON-NLS-1$
@@ -2011,7 +1990,6 @@ public void test0091() throws JavaModelException {
/**
* Argument ==> SingleVariableDeclaration
- * @deprecated using deprecated code
*/
public void test0092() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0092", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
@@ -2021,7 +1999,7 @@ public void test0092() throws JavaModelException {
SingleVariableDeclaration node = (SingleVariableDeclaration) method.parameters().get(0);
assertNotNull("Expression should not be null", node); //$NON-NLS-1$
SingleVariableDeclaration variableDeclaration = this.ast.newSingleVariableDeclaration();
- variableDeclaration.setModifiers(Modifier.FINAL);
+ variableDeclaration.modifiers().addAll(this.ast.newModifiers(Modifier.FINAL));
variableDeclaration.setType(this.ast.newSimpleType(this.ast.newSimpleName("String")));//$NON-NLS-1$
variableDeclaration.setName(this.ast.newSimpleName("s")); //$NON-NLS-1$
assertTrue("Both AST trees should be identical", variableDeclaration.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
@@ -2741,7 +2719,6 @@ public void test0123() throws JavaModelException {
/**
* Multiple local declaration => VariabledeclarationStatement
- * @deprecated using deprecated code
*/
public void test0124() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0124", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
@@ -2758,14 +2735,15 @@ public void test0124() throws JavaModelException {
fragment = this.ast.newVariableDeclarationFragment();
fragment.setName(this.ast.newSimpleName("z"));//$NON-NLS-1$
fragment.setInitializer(this.ast.newNullLiteral());
- fragment.setExtraDimensions(1);
+ fragment.extraDimensions().add(this.ast.newDimension());
statement.fragments().add(fragment);
fragment = this.ast.newVariableDeclarationFragment();
fragment.setName(this.ast.newSimpleName("i"));//$NON-NLS-1$
statement.fragments().add(fragment);
fragment = this.ast.newVariableDeclarationFragment();
fragment.setName(this.ast.newSimpleName("j"));//$NON-NLS-1$
- fragment.setExtraDimensions(2);
+ fragment.extraDimensions().add(this.ast.newDimension());
+ fragment.extraDimensions().add(this.ast.newDimension());
statement.fragments().add(fragment);
statement.setType(this.ast.newPrimitiveType(PrimitiveType.INT));
assertTrue("Both AST trees should be identical", statement.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
@@ -2780,7 +2758,6 @@ public void test0124() throws JavaModelException {
/**
* Multiple local declaration => VariabledeclarationStatement
- * @deprecated using deprecated code
*/
public void test0125() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0125", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
@@ -2797,14 +2774,15 @@ public void test0125() throws JavaModelException {
fragment = this.ast.newVariableDeclarationFragment();
fragment.setName(this.ast.newSimpleName("z"));//$NON-NLS-1$
fragment.setInitializer(this.ast.newNullLiteral());
- fragment.setExtraDimensions(1);
+ fragment.extraDimensions().add(this.ast.newDimension());
statement.fragments().add(fragment);
fragment = this.ast.newVariableDeclarationFragment();
fragment.setName(this.ast.newSimpleName("i"));//$NON-NLS-1$
statement.fragments().add(fragment);
fragment = this.ast.newVariableDeclarationFragment();
fragment.setName(this.ast.newSimpleName("j"));//$NON-NLS-1$
- fragment.setExtraDimensions(2);
+ fragment.extraDimensions().add(this.ast.newDimension());
+ fragment.extraDimensions().add(this.ast.newDimension());
statement.fragments().add(fragment);
statement.setType(this.ast.newArrayType(this.ast.newPrimitiveType(PrimitiveType.INT), 1));
assertTrue("Both AST trees should be identical", statement.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
@@ -2819,7 +2797,6 @@ public void test0125() throws JavaModelException {
/**
* ForStatement
- * @deprecated using deprecated code
*/
public void test0126() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0126", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
@@ -2831,7 +2808,7 @@ public void test0126() throws JavaModelException {
VariableDeclarationFragment variableDeclarationFragment = this.ast.newVariableDeclarationFragment();
variableDeclarationFragment.setName(this.ast.newSimpleName("tab")); //$NON-NLS-1$
variableDeclarationFragment.setInitializer(this.ast.newNullLiteral());//$NON-NLS-1$
- variableDeclarationFragment.setExtraDimensions(1);
+ variableDeclarationFragment.extraDimensions().add(this.ast.newDimension());
VariableDeclarationExpression variableDeclarationExpression = this.ast.newVariableDeclarationExpression(variableDeclarationFragment);
variableDeclarationExpression.setType(this.ast.newArrayType(this.ast.newSimpleType(this.ast.newSimpleName("String")), 1));//$NON-NLS-1$
forStatement.initializers().add(variableDeclarationExpression);
@@ -2848,7 +2825,6 @@ public void test0126() throws JavaModelException {
/**
* ForStatement
- * @deprecated using deprecated code
*/
public void test0127() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0127", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
@@ -2860,7 +2836,7 @@ public void test0127() throws JavaModelException {
VariableDeclarationFragment variableDeclarationFragment = this.ast.newVariableDeclarationFragment();
variableDeclarationFragment.setName(this.ast.newSimpleName("tab")); //$NON-NLS-1$
variableDeclarationFragment.setInitializer(this.ast.newNullLiteral());//$NON-NLS-1$
- variableDeclarationFragment.setExtraDimensions(1);
+ variableDeclarationFragment.extraDimensions().add(this.ast.newDimension());
VariableDeclarationExpression variableDeclarationExpression = this.ast.newVariableDeclarationExpression(variableDeclarationFragment);
variableDeclarationExpression.setType(this.ast.newSimpleType(this.ast.newSimpleName("String")));//$NON-NLS-1$
forStatement.initializers().add(variableDeclarationExpression);
@@ -2877,7 +2853,6 @@ public void test0127() throws JavaModelException {
/**
* ForStatement
- * @deprecated using deprecated code
*/
public void test0128() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0128", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
@@ -2889,7 +2864,7 @@ public void test0128() throws JavaModelException {
VariableDeclarationFragment variableDeclarationFragment = this.ast.newVariableDeclarationFragment();
variableDeclarationFragment.setName(this.ast.newSimpleName("tab")); //$NON-NLS-1$
variableDeclarationFragment.setInitializer(this.ast.newNullLiteral());//$NON-NLS-1$
- variableDeclarationFragment.setExtraDimensions(1);
+ variableDeclarationFragment.extraDimensions().add(this.ast.newDimension());
VariableDeclarationExpression variableDeclarationExpression = this.ast.newVariableDeclarationExpression(variableDeclarationFragment);
variableDeclarationExpression.setType(this.ast.newSimpleType(this.ast.newSimpleName("String")));//$NON-NLS-1$
forStatement.initializers().add(variableDeclarationExpression);
@@ -2926,7 +2901,6 @@ public void test0129() throws JavaModelException {
/**
* FieldDeclaration
- * @deprecated using deprecated code
*/
public void test0130() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0130", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
@@ -2941,11 +2915,11 @@ public void test0130() throws JavaModelException {
literal.setToken("10"); //$NON-NLS-1$
fragment.setInitializer(literal);
FieldDeclaration fieldDeclaration = this.ast.newFieldDeclaration(fragment);
- fieldDeclaration.setModifiers(Modifier.PUBLIC);
+ fieldDeclaration.modifiers().addAll(this.ast.newModifiers(Modifier.PUBLIC));
fieldDeclaration.setType(this.ast.newPrimitiveType(PrimitiveType.INT));
fragment = this.ast.newVariableDeclarationFragment();
fragment.setName(this.ast.newSimpleName("y"));//$NON-NLS-1$
- fragment.setExtraDimensions(1);
+ fragment.extraDimensions().add(this.ast.newDimension());
fragment.setInitializer(this.ast.newNullLiteral());
fieldDeclaration.fragments().add(fragment);
fragment = this.ast.newVariableDeclarationFragment();
@@ -2953,7 +2927,8 @@ public void test0130() throws JavaModelException {
fieldDeclaration.fragments().add(fragment);
fragment = this.ast.newVariableDeclarationFragment();
fragment.setName(this.ast.newSimpleName("j"));//$NON-NLS-1$
- fragment.setExtraDimensions(2);
+ fragment.extraDimensions().add(this.ast.newDimension());
+ fragment.extraDimensions().add(this.ast.newDimension());
fieldDeclaration.fragments().add(fragment);
assertTrue("Both AST trees should be identical", fieldDeclaration.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
checkSourceRange(node, "public int x= 10, y[] = null, i, j[][];", source); //$NON-NLS-1$
@@ -2967,7 +2942,6 @@ public void test0130() throws JavaModelException {
/**
* Argument with final modifier
- * @deprecated using deprecated code
*/
public void test0131() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0131", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
@@ -2981,7 +2955,7 @@ public void test0131() throws JavaModelException {
assertTrue("Parameters.length != 1", parameters.size() == 1); //$NON-NLS-1$
SingleVariableDeclaration arg = (SingleVariableDeclaration) ((MethodDeclaration) node).parameters().get(0);
SingleVariableDeclaration singleVariableDeclaration = this.ast.newSingleVariableDeclaration();
- singleVariableDeclaration.setModifiers(Modifier.FINAL);
+ singleVariableDeclaration.modifiers().addAll(this.ast.newModifiers(Modifier.FINAL));
singleVariableDeclaration.setName(this.ast.newSimpleName("i")); //$NON-NLS-1$
singleVariableDeclaration.setType(this.ast.newPrimitiveType(PrimitiveType.INT));
assertTrue("Both AST trees should be identical", singleVariableDeclaration.subtreeMatch(new ASTMatcher(), arg)); //$NON-NLS-1$
@@ -7760,18 +7734,9 @@ public void test0321() throws JavaModelException {
ITypeBinding typeBinding = arrayType.resolveBinding();
checkSourceRange(type, "java.lang.Object[][]", source); //$NON-NLS-1$
assertNotNull("No type binding", typeBinding); //$NON-NLS-1$
- Type elementType = componentType(arrayType);
- ITypeBinding typeBinding2 = elementType.resolveBinding();
- assertNotNull("No type binding2", typeBinding2); //$NON-NLS-1$
- assertEquals("wrong dimension", 1, typeBinding2.getDimensions()); //$NON-NLS-1$
- assertEquals("wrong name", "Object[]", typeBinding2.getName()); //$NON-NLS-1$ //$NON-NLS-2$
- assertTrue("Not an array type", elementType.isArrayType()); //$NON-NLS-1$
- Type elementType2 = componentType(((ArrayType) elementType));
- assertTrue("Not a simple type", elementType2.isSimpleType()); //$NON-NLS-1$
- ITypeBinding typeBinding3 = elementType2.resolveBinding();
- assertNotNull("No type binding3", typeBinding3); //$NON-NLS-1$
- assertEquals("wrong dimension", 0, typeBinding3.getDimensions()); //$NON-NLS-1$
- assertEquals("wrong name", "Object", typeBinding3.getName()); //$NON-NLS-1$ //$NON-NLS-2$
+ assertTrue(typeBinding.isArray());
+ assertEquals(2, typeBinding.getDimensions());
+ assertEquals("java.lang.Object", typeBinding.getElementType().getBinaryName());
}
/**
@@ -8101,18 +8066,15 @@ public void test0333() throws JavaModelException {
ITypeBinding typeBinding2 = arrayType.resolveBinding();
assertNotNull("no type binding2", typeBinding2); //$NON-NLS-1$
assertEquals("wrong name", "Object[][]", typeBinding2.getName()); //$NON-NLS-1$ //$NON-NLS-2$
+ assertTrue(typeBinding2.isArray());
+ assertEquals(2, typeBinding2.getDimensions());
+ assertEquals("java.lang.Object", typeBinding2.getElementType().getBinaryName());
Type type = arrayType.getElementType();
assertTrue("Not a simple type", type instanceof SimpleType); //$NON-NLS-1$
SimpleType simpleType = (SimpleType) type;
ITypeBinding typeBinding3 = simpleType.resolveBinding();
assertNotNull("no type binding3", typeBinding3); //$NON-NLS-1$
assertEquals("wrong name", "Object", typeBinding3.getName()); //$NON-NLS-1$ //$NON-NLS-2$
- type = componentType(arrayType);
- assertTrue("Not an array type", type instanceof ArrayType); //$NON-NLS-1$
- ArrayType arrayType2 = (ArrayType) type;
- ITypeBinding typeBinding4 = arrayType2.resolveBinding();
- assertNotNull("no type binding4", typeBinding4); //$NON-NLS-1$
- assertEquals("wrong name", "Object[]", typeBinding4.getName()); //$NON-NLS-1$ //$NON-NLS-2$
}
/**
@@ -8142,6 +8104,9 @@ public void test0334() throws JavaModelException {
ITypeBinding typeBinding2 = arrayType.resolveBinding();
assertNotNull("no type binding2", typeBinding2); //$NON-NLS-1$
assertEquals("wrong name", "Object[][][]", typeBinding2.getName()); //$NON-NLS-1$ //$NON-NLS-2$
+ assertTrue(typeBinding2.isArray());
+ assertEquals(3, typeBinding2.getDimensions());
+ assertEquals("java.lang.Object", typeBinding2.getElementType().getBinaryName());
Type type = arrayType.getElementType();
assertTrue("Not a simple type", type instanceof SimpleType); //$NON-NLS-1$
SimpleType simpleType = (SimpleType) type;
@@ -8149,26 +8114,11 @@ public void test0334() throws JavaModelException {
ITypeBinding typeBinding3 = simpleType.resolveBinding();
assertNotNull("no type binding3", typeBinding3); //$NON-NLS-1$
assertEquals("wrong name", "Object", typeBinding3.getName()); //$NON-NLS-1$ //$NON-NLS-2$
- type = componentType(arrayType);
- assertTrue("Not an array type", type instanceof ArrayType); //$NON-NLS-1$
- ArrayType arrayType2 = (ArrayType) type;
- checkSourceRange(arrayType2, "Object[10][]", source); //$NON-NLS-1$
- ITypeBinding typeBinding4 = arrayType2.resolveBinding();
- assertNotNull("no type binding4", typeBinding4); //$NON-NLS-1$
- assertEquals("wrong name", "Object[][]", typeBinding4.getName()); //$NON-NLS-1$ //$NON-NLS-2$
- type = componentType(arrayType2);
- assertTrue("Not an array type", type instanceof ArrayType); //$NON-NLS-1$
- ArrayType arrayType3 = (ArrayType) type;
- ITypeBinding typeBinding5 = arrayType3.resolveBinding();
- assertNotNull("no type binding5", typeBinding5); //$NON-NLS-1$
- assertEquals("wrong name", "Object[]", typeBinding5.getName()); //$NON-NLS-1$ //$NON-NLS-2$
- checkSourceRange(arrayType3, "Object[10]", source); //$NON-NLS-1$
}
/**
* http://dev.eclipse.org/bugs/show_bug.cgi?id=14526
- * @deprecated using deprecated code
*/
public void test0335() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0335", "ExceptionTestCaseTest.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
@@ -8182,7 +8132,7 @@ public void test0335() throws JavaModelException {
assertNotNull("not null", node); //$NON-NLS-1$
assertTrue("not a type declaration", node instanceof TypeDeclaration); //$NON-NLS-1$
TypeDeclaration typeDeclaration = (TypeDeclaration) node;
- Name name = typeDeclaration.getSuperclass();
+ Name name = ((SimpleType)typeDeclaration.getSuperclassType()).getName();
assertNotNull("no super class", name); //$NON-NLS-1$
assertTrue("not a qualified name", name.isQualifiedName()); //$NON-NLS-1$
QualifiedName qualifiedName = (QualifiedName) name;
@@ -8200,7 +8150,6 @@ public void test0335() throws JavaModelException {
/**
* http://dev.eclipse.org/bugs/show_bug.cgi?id=14526
- * @deprecated using deprecated code
*/
public void test0336() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0336", "SorterTest.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
@@ -8214,9 +8163,9 @@ public void test0336() throws JavaModelException {
assertNotNull("not null", node); //$NON-NLS-1$
assertTrue("not a type declaration", node instanceof TypeDeclaration); //$NON-NLS-1$
TypeDeclaration typeDeclaration = (TypeDeclaration) node;
- List superInterfaces = typeDeclaration.superInterfaces();
+ List superInterfaces = typeDeclaration.superInterfaceTypes();
assertEquals("wrong size", 1, superInterfaces.size()); //$NON-NLS-1$
- Name name = (Name) superInterfaces.get(0);
+ Name name = ((SimpleType) superInterfaces.get(0)).getName();
assertTrue("not a qualified name", name.isQualifiedName()); //$NON-NLS-1$
QualifiedName qualifiedName = (QualifiedName) name;
name = qualifiedName.getQualifier();
@@ -8265,17 +8214,10 @@ public void test0338() throws JavaModelException {
assertTrue("not a MethodDeclaration", node instanceof MethodDeclaration); //$NON-NLS-1$
MethodDeclaration methodDeclaration = (MethodDeclaration) node;
IBinding binding;
- if (node.getAST().apiLevel() < getJLS8()) {
- List thrownExceptions = internalThrownExceptions(methodDeclaration);
- assertEquals("Wrong size", 1, thrownExceptions.size()); //$NON-NLS-1$
- Name name = (Name) thrownExceptions.get(0);
- binding = name.resolveBinding();
- } else {
- List thrownExceptionTypes = methodDeclaration.thrownExceptionTypes();
- assertEquals("Wrong size", 1, thrownExceptionTypes.size()); //$NON-NLS-1$
- Type type = (Type) thrownExceptionTypes.get(0);
- binding = type.resolveBinding();
- }
+ List thrownExceptionTypes = methodDeclaration.thrownExceptionTypes();
+ assertEquals("Wrong size", 1, thrownExceptionTypes.size()); //$NON-NLS-1$
+ Type type = (Type) thrownExceptionTypes.get(0);
+ binding = type.resolveBinding();
assertEquals("wrong type", IBinding.TYPE, binding.getKind()); //$NON-NLS-1$
assertEquals("wrong name", "IOException", binding.getName()); //$NON-NLS-1$ //$NON-NLS-2$
}
@@ -9402,7 +9344,6 @@ public void test0378() throws JavaModelException {
/**
* http://dev.eclipse.org/bugs/show_bug.cgi?id=22161
- * @deprecated using deprecated code
*/
public void test0379() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0379", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
@@ -9412,7 +9353,7 @@ public void test0379() throws JavaModelException {
assertNotNull("Expression should not be null", expression); //$NON-NLS-1$
assertTrue("Not a class instance creation", expression.getNodeType() == ASTNode.CLASS_INSTANCE_CREATION); //$NON-NLS-1$
ClassInstanceCreation classInstanceCreation2 = (ClassInstanceCreation) expression;
- Name name2 = classInstanceCreation2.getName();
+ Name name2 = ((SimpleType)classInstanceCreation2.getType()).getName();
checkSourceRange(name2, "Object", source); //$NON-NLS-1$
}
@@ -9617,7 +9558,6 @@ public void test0389() throws JavaModelException {
/**
* http://dev.eclipse.org/bugs/show_bug.cgi?id=22154
- * @deprecated using deprecated code
*/
public void test0390() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0390", "A.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
@@ -9630,7 +9570,7 @@ public void test0390() throws JavaModelException {
assertNotNull(node);
assertTrue("Not a method declaration", node.getNodeType() == ASTNode.METHOD_DECLARATION); //$NON-NLS-1$
MethodDeclaration methodDeclaration = (MethodDeclaration) node;
- Type type = methodDeclaration.getReturnType();
+ Type type = methodDeclaration.getReturnType2();
ITypeBinding typeBinding = type.resolveBinding();
assertNotNull("No type binding", typeBinding); //$NON-NLS-1$
assertEquals("Wrong qualified name", "int", typeBinding.getQualifiedName()); //$NON-NLS-1$ //$NON-NLS-2$
@@ -9638,7 +9578,6 @@ public void test0390() throws JavaModelException {
/**
* http://dev.eclipse.org/bugs/show_bug.cgi?id=22154
- * @deprecated using deprecated code
*/
public void test0391() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0391", "A.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
@@ -9651,7 +9590,7 @@ public void test0391() throws JavaModelException {
assertNotNull(node);
assertTrue("Not a method declaration", node.getNodeType() == ASTNode.METHOD_DECLARATION); //$NON-NLS-1$
MethodDeclaration methodDeclaration = (MethodDeclaration) node;
- Type type = methodDeclaration.getReturnType();
+ Type type = methodDeclaration.getReturnType2();
ITypeBinding typeBinding = type.resolveBinding();
assertNotNull("No type binding", typeBinding); //$NON-NLS-1$
assertEquals("Wrong qualified name", "int[]", typeBinding.getQualifiedName()); //$NON-NLS-1$ //$NON-NLS-2$
@@ -9659,7 +9598,6 @@ public void test0391() throws JavaModelException {
/**
* http://dev.eclipse.org/bugs/show_bug.cgi?id=22154
- * @deprecated using deprecated code
*/
public void test0392() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0392", "A.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
@@ -9672,7 +9610,7 @@ public void test0392() throws JavaModelException {
assertNotNull(node);
assertTrue("Not a method declaration", node.getNodeType() == ASTNode.METHOD_DECLARATION); //$NON-NLS-1$
MethodDeclaration methodDeclaration = (MethodDeclaration) node;
- Type type = methodDeclaration.getReturnType();
+ Type type = methodDeclaration.getReturnType2();
ITypeBinding typeBinding = type.resolveBinding();
assertNotNull("No type binding", typeBinding); //$NON-NLS-1$
assertEquals("Wrong qualified name", "java.lang.String[]", typeBinding.getQualifiedName()); //$NON-NLS-1$ //$NON-NLS-2$
@@ -9680,7 +9618,6 @@ public void test0392() throws JavaModelException {
/**
* http://dev.eclipse.org/bugs/show_bug.cgi?id=23284
- * @deprecated using deprecated code
*/
public void test0393() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0393", "A.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
@@ -9694,7 +9631,7 @@ public void test0393() throws JavaModelException {
assertNotNull(node);
assertTrue("Not a method declaration", node.getNodeType() == ASTNode.METHOD_DECLARATION); //$NON-NLS-1$
MethodDeclaration methodDeclaration = (MethodDeclaration) node;
- Type type = methodDeclaration.getReturnType();
+ Type type = methodDeclaration.getReturnType2();
checkSourceRange(type, "String", source); //$NON-NLS-1$
ITypeBinding typeBinding = type.resolveBinding();
assertNotNull("No type binding", typeBinding); //$NON-NLS-1$
@@ -9711,7 +9648,6 @@ public void test0393() throws JavaModelException {
/**
* http://dev.eclipse.org/bugs/show_bug.cgi?id=23284
- * @deprecated using deprecated code
*/
public void test0394() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0394", "A.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
@@ -9725,7 +9661,7 @@ public void test0394() throws JavaModelException {
assertNotNull(node);
assertTrue("Not a method declaration", node.getNodeType() == ASTNode.METHOD_DECLARATION); //$NON-NLS-1$
MethodDeclaration methodDeclaration = (MethodDeclaration) node;
- Type type = methodDeclaration.getReturnType();
+ Type type = methodDeclaration.getReturnType2();
checkSourceRange(type, "String", source); //$NON-NLS-1$
ITypeBinding typeBinding = type.resolveBinding();
assertNotNull("No type binding", typeBinding); //$NON-NLS-1$
@@ -9736,7 +9672,6 @@ public void test0394() throws JavaModelException {
/**
* http://dev.eclipse.org/bugs/show_bug.cgi?id=23284
- * @deprecated using deprecated code
*/
public void test0395() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0395", "A.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
@@ -9750,7 +9685,7 @@ public void test0395() throws JavaModelException {
assertNotNull(node);
assertTrue("Not a method declaration", node.getNodeType() == ASTNode.METHOD_DECLARATION); //$NON-NLS-1$
MethodDeclaration methodDeclaration = (MethodDeclaration) node;
- Type type = methodDeclaration.getReturnType();
+ Type type = methodDeclaration.getReturnType2();
checkSourceRange(type, "String[]", source); //$NON-NLS-1$
ITypeBinding typeBinding = type.resolveBinding();
assertNotNull("No type binding", typeBinding); //$NON-NLS-1$
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverterTest2.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverterTest2.java
index be9edc6a564..9d2c4fb5d41 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverterTest2.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverterTest2.java
@@ -39,7 +39,7 @@ public class ASTConverterTest2 extends ConverterTestSetup {
@Override
public void setUpSuite() throws Exception {
super.setUpSuite();
- this.ast = AST.newAST(AST.JLS2, false);
+ this.ast = AST.newAST(AST.JLS8, false);
}
public ASTConverterTest2(String name) {
@@ -53,24 +53,8 @@ public ASTConverterTest2(String name) {
public static Test suite() {
return buildModelTestSuite(ASTConverterTest2.class);
}
- /**
- * Internal access method to MethodDeclaration#thrownExceptions() for avoiding deprecated warnings.
- * @deprecated
- */
- private static List internalThrownExceptions(MethodDeclaration methodDeclaration) {
- return methodDeclaration.thrownExceptions();
- }
-
- /**
- * @deprecated
- */
- private Type componentType(ArrayType array) {
- return array.getComponentType();
- }
-
/**
* http://dev.eclipse.org/bugs/show_bug.cgi?id=22560
- * @deprecated using deprecated code
*/
public void test0401() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0401", "A.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
@@ -88,7 +72,7 @@ public void test0401() throws JavaModelException {
Expression expression = returnStatement.getExpression();
assertNotNull("there is no expression", expression); //$NON-NLS-1$
// call the default initialization
- methodDeclaration.getReturnType();
+ methodDeclaration.getReturnType2();
ITypeBinding typeBinding = expression.resolveTypeBinding();
assertNotNull("No typebinding", typeBinding); //$NON-NLS-1$
assertEquals("wrong name", "int", typeBinding.getName()); //$NON-NLS-1$ //$NON-NLS-2$
@@ -280,7 +264,7 @@ public void test0408() throws JavaModelException {
assertNotNull(node);
assertTrue("Not a method declaration", node.getNodeType() == ASTNode.METHOD_DECLARATION); //$NON-NLS-1$
MethodDeclaration methodDeclaration = (MethodDeclaration) node;
- Type type = methodDeclaration.getReturnType();
+ Type type = methodDeclaration.getReturnType2();
assertTrue("Not a simple type", type.isSimpleType()); //$NON-NLS-1$
SimpleType simpleType = (SimpleType) type;
Name name = simpleType.getName();
@@ -316,7 +300,7 @@ public void test0409() throws JavaModelException {
compilationUnit.accept(bindingsCollectorVisitor);
assertEquals("wrong number", 3, bindingsCollectorVisitor.getUnresolvedNodesSet().size()); //$NON-NLS-1$
Map bindingsMap = bindingsCollectorVisitor.getBindingsMap();
- assertEquals("wrong number", 205, bindingsMap.size()); //$NON-NLS-1$
+ assertEquals("wrong number", 212, bindingsMap.size()); //$NON-NLS-1$
ASTNodesCollectorVisitor nodesCollector = new ASTNodesCollectorVisitor();
compilationUnit.accept(nodesCollector);
Set detachedNodes = nodesCollector.getDetachedAstNodes();
@@ -466,9 +450,9 @@ public void test0413() throws JavaModelException {
assertNotNull(node);
assertTrue("Not a method declaration", node.getNodeType() == ASTNode.METHOD_DECLARATION); //$NON-NLS-1$
MethodDeclaration methodDeclaration = (MethodDeclaration) node;
- List throwsException = internalThrownExceptions(methodDeclaration);
+ List throwsException = methodDeclaration.thrownExceptionTypes();
assertEquals("wrong size", 2, throwsException.size()); //$NON-NLS-1$
- Name name = (Name) throwsException.get(0);
+ Name name = ((SimpleType)throwsException.get(0)).getName();
IBinding binding = name.resolveBinding();
assertNotNull("No binding", binding); //$NON-NLS-1$
assertEquals("LIOException;", binding.getKey());
@@ -476,7 +460,6 @@ public void test0413() throws JavaModelException {
/**
* http://bugs.eclipse.org/bugs/show_bug.cgi?id=23734
- * @deprecated using deprecated code
*/
public void test0414() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0414", "A.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
@@ -488,7 +471,7 @@ public void test0414() throws JavaModelException {
assertNotNull(node);
assertTrue("Not a method declaration", node.getNodeType() == ASTNode.METHOD_DECLARATION); //$NON-NLS-1$
MethodDeclaration methodDeclaration = (MethodDeclaration) node;
- Type type = methodDeclaration.getReturnType();
+ Type type = methodDeclaration.getReturnType2();
ITypeBinding typeBinding = type.resolveBinding();
assertNotNull("No type binding", typeBinding); //$NON-NLS-1$
ASTNode declaringNode = unit.findDeclaringNode(typeBinding);
@@ -498,7 +481,7 @@ public void test0414() throws JavaModelException {
assertNotNull(node);
assertTrue("Not a method declaration", node.getNodeType() == ASTNode.METHOD_DECLARATION); //$NON-NLS-1$
MethodDeclaration methodDeclaration2 = (MethodDeclaration) node;
- Type type2 = methodDeclaration2.getReturnType();
+ Type type2 = methodDeclaration2.getReturnType2();
ITypeBinding typeBinding2 = type2.resolveBinding();
assertNotNull("No type binding", typeBinding2); //$NON-NLS-1$
ASTNode declaringNode2 = unit.findDeclaringNode(typeBinding2);
@@ -1301,7 +1284,6 @@ public void test0447() throws JavaModelException {
/**
* http://bugs.eclipse.org/bugs/show_bug.cgi?id=25330
- * @deprecated using deprecated code
*/
public void test0448() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0448", "A.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
@@ -1313,11 +1295,7 @@ public void test0448() throws JavaModelException {
assertEquals("Not a method declaration", node.getNodeType(), ASTNode.METHOD_DECLARATION);
MethodDeclaration methodDeclaration = (MethodDeclaration) node;
assertTrue("Not a constructor", methodDeclaration.isConstructor());
- ITypeBinding returnTypeBinding = methodDeclaration.getReturnType().resolveBinding();
- assertNotNull("No return type binding", returnTypeBinding);
- Block block = methodDeclaration.getBody();
- assertNotNull("No method body", block);
- assertEquals("wrong size", 0, block.statements().size());
+ assertNull(methodDeclaration.getReturnType2());
}
/**
@@ -1440,7 +1418,7 @@ public void test0451() throws JavaModelException {
assertNotNull("No node", node);
assertTrue("not a method declaration", node.getNodeType() == ASTNode.METHOD_DECLARATION); //$NON-NLS-1$
MethodDeclaration methodDeclaration = (MethodDeclaration) node;
- Type type = methodDeclaration.getReturnType();
+ Type type = methodDeclaration.getReturnType2();
checkSourceRange(type, "int", source);
}
@@ -2643,13 +2621,8 @@ public void test0493() throws JavaModelException {
checkSourceRange(type, "Class[][]", source);
assertTrue("not an array type", type.isArrayType()); //$NON-NLS-1$
ArrayType arrayType = (ArrayType) type;
- Type componentType = componentType(arrayType);
- assertTrue("not an array type", componentType.isArrayType()); //$NON-NLS-1$
- checkSourceRange(componentType, "Class[]", source);
- arrayType = (ArrayType) componentType;
- componentType = componentType(arrayType);
- assertTrue("is an array type", !componentType.isArrayType()); //$NON-NLS-1$
- checkSourceRange(componentType, "Class", source);
+ assertEquals(2, arrayType.getDimensions());
+ assertEquals("Class", ((SimpleType)arrayType.getElementType()).getName().getFullyQualifiedName());
}
/**
@@ -2669,17 +2642,8 @@ public void test0494() throws JavaModelException {
checkSourceRange(type, "Class[][][]", source);
assertTrue("not an array type", type.isArrayType()); //$NON-NLS-1$
ArrayType arrayType = (ArrayType) type;
- Type componentType = componentType(arrayType);
- assertTrue("not an array type", componentType.isArrayType()); //$NON-NLS-1$
- checkSourceRange(componentType, "Class[][]", source);
- arrayType = (ArrayType) componentType;
- componentType = componentType(arrayType);
- assertTrue("not an array type", componentType.isArrayType()); //$NON-NLS-1$
- checkSourceRange(componentType, "Class[]", source);
- arrayType = (ArrayType) componentType;
- componentType = componentType(arrayType);
- assertTrue("is an array type", !componentType.isArrayType()); //$NON-NLS-1$
- checkSourceRange(componentType, "Class", source);
+ assertEquals(3, arrayType.getDimensions());
+ assertEquals("Class", ((SimpleType)arrayType.getElementType()).getName().getFullyQualifiedName());
}
/**
@@ -2699,17 +2663,8 @@ public void test0495() throws JavaModelException {
checkSourceRange(type, "Class[][]", source);
assertTrue("not an array type", type.isArrayType()); //$NON-NLS-1$
ArrayType arrayType = (ArrayType) type;
- Type componentType = componentType(arrayType);
- assertTrue("not an array type", componentType.isArrayType()); //$NON-NLS-1$
- checkSourceRange(componentType, "Class[]", source);
- arrayType = (ArrayType) componentType;
- componentType = componentType(arrayType);
- assertTrue("is an array type", !componentType.isArrayType()); //$NON-NLS-1$
- checkSourceRange(componentType, "Class", source);
- List fragments = fieldDeclaration.fragments();
- assertEquals("wrong size", 1, fragments.size());
- VariableDeclarationFragment fragment = (VariableDeclarationFragment) fragments.get(0);
- assertEquals("wrong extra dimension", 1, fragment.getExtraDimensions());
+ assertEquals(2, arrayType.getDimensions());
+ assertEquals("Class", ((SimpleType)arrayType.getElementType()).getName().getFullyQualifiedName());
}
/**
@@ -2729,21 +2684,8 @@ public void test0496() throws JavaModelException {
checkSourceRange(type, "Class[][][][]", source);
assertTrue("not an array type", type.isArrayType()); //$NON-NLS-1$
ArrayType arrayType = (ArrayType) type;
- Type componentType = componentType(arrayType);
- assertTrue("not an array type", componentType.isArrayType()); //$NON-NLS-1$
- checkSourceRange(componentType, "Class[][][]", source);
- arrayType = (ArrayType) componentType;
- componentType = componentType(arrayType);
- assertTrue("not an array type", componentType.isArrayType()); //$NON-NLS-1$
- checkSourceRange(componentType, "Class[][]", source);
- arrayType = (ArrayType) componentType;
- componentType = componentType(arrayType);
- assertTrue("not an array type", componentType.isArrayType()); //$NON-NLS-1$
- checkSourceRange(componentType, "Class[]", source);
- arrayType = (ArrayType) componentType;
- componentType = componentType(arrayType);
- assertTrue("is an array type", !componentType.isArrayType()); //$NON-NLS-1$
- checkSourceRange(componentType, "Class", source);
+ assertEquals(4, arrayType.getDimensions());
+ assertEquals("Class", ((SimpleType)arrayType.getElementType()).getName().getFullyQualifiedName());
}
/**
@@ -2763,9 +2705,8 @@ public void test0497() throws JavaModelException {
checkSourceRange(type, "Class[]", source);
assertTrue("not an array type", type.isArrayType()); //$NON-NLS-1$
ArrayType arrayType = (ArrayType) type;
- Type componentType = componentType(arrayType);
- assertTrue("is an array type", !componentType.isArrayType()); //$NON-NLS-1$
- checkSourceRange(componentType, "Class", source);
+ assertEquals(1, arrayType.getDimensions());
+ assertEquals("Class", ((SimpleType)arrayType.getElementType()).getName().getFullyQualifiedName());
}
public void test0498() throws JavaModelException {
@@ -4033,7 +3974,6 @@ public void test0532() throws JavaModelException {
}
/**
* http://dev.eclipse.org/bugs/show_bug.cgi?id=48489
- * @deprecated using deprecated code
*/
public void test0533() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter", "src", "test0533", "A.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
@@ -4045,7 +3985,8 @@ public void test0533() throws JavaModelException {
assertNotNull("No node", node);
assertTrue("not a method declaration", node.getNodeType() == ASTNode.METHOD_DECLARATION);
MethodDeclaration declaration = (MethodDeclaration) node;
- ASTParser parser = ASTParser.newParser(AST.JLS2);
+ @SuppressWarnings("deprecation")
+ ASTParser parser = ASTParser.newParser(AST.JLS8);
parser.setKind(ASTParser.K_CLASS_BODY_DECLARATIONS);
parser.setSource(source);
parser.setSourceRange(declaration.getStartPosition(), declaration.getLength());
@@ -4058,7 +3999,6 @@ public void test0533() throws JavaModelException {
}
/**
* http://dev.eclipse.org/bugs/show_bug.cgi?id=48489
- * @deprecated using deprecated code
*/
public void test0534() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter", "src", "test0534", "A.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
@@ -4070,7 +4010,8 @@ public void test0534() throws JavaModelException {
assertNotNull("No node", node);
assertTrue("not a field declaration", node.getNodeType() == ASTNode.FIELD_DECLARATION);
FieldDeclaration declaration = (FieldDeclaration) node;
- ASTParser parser = ASTParser.newParser(AST.JLS2);
+ @SuppressWarnings("deprecation")
+ ASTParser parser = ASTParser.newParser(AST.JLS8);
parser.setKind(ASTParser.K_CLASS_BODY_DECLARATIONS);
parser.setSource(source);
parser.setSourceRange(declaration.getStartPosition(), declaration.getLength());
@@ -4083,7 +4024,6 @@ public void test0534() throws JavaModelException {
}
/**
* http://dev.eclipse.org/bugs/show_bug.cgi?id=48489
- * @deprecated using deprecated code
*/
public void test0535() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter", "src", "test0535", "A.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
@@ -4095,7 +4035,8 @@ public void test0535() throws JavaModelException {
assertNotNull("No node", node);
assertTrue("not an initializer", node.getNodeType() == ASTNode.INITIALIZER);
Initializer declaration = (Initializer) node;
- ASTParser parser = ASTParser.newParser(AST.JLS2);
+ @SuppressWarnings("deprecation")
+ ASTParser parser = ASTParser.newParser(AST.JLS8);
parser.setKind(ASTParser.K_CLASS_BODY_DECLARATIONS);
parser.setSource(source);
parser.setSourceRange(declaration.getStartPosition(), declaration.getLength());
@@ -4152,9 +4093,9 @@ public void test0538a() throws JavaModelException {
" int i;\n" +
"}"
);
- CompilationUnit unit = sourceUnit.reconcile(AST.JLS2, false, null, null);
- assertNotNull("No level 2 compilation unit", unit);
- assertEquals("Compilation unit has wrong AST level (2)", AST.JLS2, unit.getAST().apiLevel());
+ CompilationUnit unit = sourceUnit.reconcile(AST.JLS8, false, null, null);
+ assertNotNull("No level 8 compilation unit", unit);
+ assertEquals("Compilation unit has wrong AST level (8)", AST.JLS8, unit.getAST().apiLevel());
// TODO improve test for AST.JLS3
} finally {
sourceUnit.discardWorkingCopy();
@@ -4668,7 +4609,6 @@ public void test0545() throws JavaModelException {
/**
* https://bugs.eclipse.org/bugs/show_bug.cgi?id=59848
- * @deprecated using deprecated code
*/
public void test0546() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter", "src", "test0546", "A.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
@@ -4703,7 +4643,7 @@ public void test0546() throws JavaModelException {
SimpleName simpleName = (SimpleName) expression2;
ITypeBinding typeBinding4 = simpleName.resolveTypeBinding();
assertTrue("An anonymous type binding", !typeBinding4.isAnonymous());
- Name name = classInstanceCreation.getName();
+ Name name = ((SimpleType)classInstanceCreation.getType()).getName();
IBinding binding = name.resolveBinding();
assertEquals("Wrong type", IBinding.TYPE, binding.getKind());
ITypeBinding typeBinding5 = (ITypeBinding) binding;
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverterTestAST3_2.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverterTestAST3_2.java
index 902358e15de..e14c3509c43 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverterTestAST3_2.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverterTestAST3_2.java
@@ -52,20 +52,6 @@ public ASTConverterTestAST3_2(String name) {
public static Test suite() {
return buildModelTestSuite(ASTConverterTestAST3_2.class);
}
- /**
- * Internal access method to MethodDeclaration#thrownExceptions() for avoiding deprecated warnings.
- * @deprecated
- */
- private static List internalThrownExceptions(MethodDeclaration methodDeclaration) {
- return methodDeclaration.thrownExceptions();
- }
-
- /**
- * @deprecated
- */
- private Type componentType(ArrayType array) {
- return array.getComponentType();
- }
/**
* http://dev.eclipse.org/bugs/show_bug.cgi?id=22560
@@ -313,7 +299,7 @@ public void test0409() throws JavaModelException {
compilationUnit.accept(bindingsCollectorVisitor);
assertEquals("wrong number", 3, bindingsCollectorVisitor.getUnresolvedNodesSet().size()); //$NON-NLS-1$
Map bindingsMap = bindingsCollectorVisitor.getBindingsMap();
- assertEquals("wrong number", 211, bindingsMap.size()); //$NON-NLS-1$
+ assertEquals("wrong number", 212, bindingsMap.size()); //$NON-NLS-1$
ASTNodesCollectorVisitor nodesCollector = new ASTNodesCollectorVisitor();
compilationUnit.accept(nodesCollector);
Set detachedNodes = nodesCollector.getDetachedAstNodes();
@@ -463,9 +449,9 @@ public void test0413() throws JavaModelException {
assertNotNull(node);
assertTrue("Not a method declaration", node.getNodeType() == ASTNode.METHOD_DECLARATION); //$NON-NLS-1$
MethodDeclaration methodDeclaration = (MethodDeclaration) node;
- List throwsException = internalThrownExceptions(methodDeclaration);
+ List throwsException = methodDeclaration.thrownExceptionTypes();
assertEquals("wrong size", 2, throwsException.size()); //$NON-NLS-1$
- Name name = (Name) throwsException.get(0);
+ Name name = ((SimpleType) throwsException.get(0)).getName();
IBinding binding = name.resolveBinding();
assertNotNull("No binding", binding); //$NON-NLS-1$
assertEquals("LIOException;", binding.getKey());
@@ -2632,7 +2618,7 @@ public void test0492() throws JavaModelException {
public void test0493() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0493", "A.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(getJLS3(), sourceUnit, true);
+ ASTNode result = runConversion(getJLS8(), sourceUnit, true);
assertTrue("not a compilation unit", result.getNodeType() == ASTNode.COMPILATION_UNIT); //$NON-NLS-1$
CompilationUnit unit = (CompilationUnit) result;
assertEquals("Wrong number of problems", 0, unit.getProblems().length); //$NON-NLS-1$<
@@ -2643,13 +2629,8 @@ public void test0493() throws JavaModelException {
checkSourceRange(type, "Class[][]", source);
assertTrue("not an array type", type.isArrayType()); //$NON-NLS-1$
ArrayType arrayType = (ArrayType) type;
- Type componentType = componentType(arrayType);
- assertTrue("not an array type", componentType.isArrayType()); //$NON-NLS-1$
- checkSourceRange(componentType, "Class[]", source);
- arrayType = (ArrayType) componentType;
- componentType = componentType(arrayType);
- assertTrue("is an array type", !componentType.isArrayType()); //$NON-NLS-1$
- checkSourceRange(componentType, "Class", source);
+ assertEquals(2, arrayType.getDimensions());
+ assertEquals("Class", ((SimpleType)arrayType.getElementType()).getName().getFullyQualifiedName());
}
/**
@@ -2669,17 +2650,8 @@ public void test0494() throws JavaModelException {
checkSourceRange(type, "Class[][][]", source);
assertTrue("not an array type", type.isArrayType()); //$NON-NLS-1$
ArrayType arrayType = (ArrayType) type;
- Type componentType = componentType(arrayType);
- assertTrue("not an array type", componentType.isArrayType()); //$NON-NLS-1$
- checkSourceRange(componentType, "Class[][]", source);
- arrayType = (ArrayType) componentType;
- componentType = componentType(arrayType);
- assertTrue("not an array type", componentType.isArrayType()); //$NON-NLS-1$
- checkSourceRange(componentType, "Class[]", source);
- arrayType = (ArrayType) componentType;
- componentType = componentType(arrayType);
- assertTrue("is an array type", !componentType.isArrayType()); //$NON-NLS-1$
- checkSourceRange(componentType, "Class", source);
+ assertEquals(3, arrayType.getDimensions());
+ assertEquals("Class", ((SimpleType)arrayType.getElementType()).getName().getFullyQualifiedName());
}
/**
@@ -2699,17 +2671,8 @@ public void test0495() throws JavaModelException {
checkSourceRange(type, "Class[][]", source);
assertTrue("not an array type", type.isArrayType()); //$NON-NLS-1$
ArrayType arrayType = (ArrayType) type;
- Type componentType = componentType(arrayType);
- assertTrue("not an array type", componentType.isArrayType()); //$NON-NLS-1$
- checkSourceRange(componentType, "Class[]", source);
- arrayType = (ArrayType) componentType;
- componentType = componentType(arrayType);
- assertTrue("is an array type", !componentType.isArrayType()); //$NON-NLS-1$
- checkSourceRange(componentType, "Class", source);
- List fragments = fieldDeclaration.fragments();
- assertEquals("wrong size", 1, fragments.size());
- VariableDeclarationFragment fragment = (VariableDeclarationFragment) fragments.get(0);
- assertEquals("wrong extra dimension", 1, fragment.getExtraDimensions());
+ assertEquals(2, arrayType.getDimensions());
+ assertEquals("Class", ((SimpleType)arrayType.getElementType()).getName().getFullyQualifiedName());
}
/**
@@ -2718,7 +2681,7 @@ public void test0495() throws JavaModelException {
public void test0496() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0496", "A.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(getJLS3(), sourceUnit, true);
+ ASTNode result = runConversion(getJLS8(), sourceUnit, true);
assertTrue("not a compilation unit", result.getNodeType() == ASTNode.COMPILATION_UNIT); //$NON-NLS-1$
CompilationUnit unit = (CompilationUnit) result;
assertEquals("Wrong number of problems", 0, unit.getProblems().length); //$NON-NLS-1$<
@@ -2729,21 +2692,8 @@ public void test0496() throws JavaModelException {
checkSourceRange(type, "Class[][][][]", source);
assertTrue("not an array type", type.isArrayType()); //$NON-NLS-1$
ArrayType arrayType = (ArrayType) type;
- Type componentType = componentType(arrayType);
- assertTrue("not an array type", componentType.isArrayType()); //$NON-NLS-1$
- checkSourceRange(componentType, "Class[][][]", source);
- arrayType = (ArrayType) componentType;
- componentType = componentType(arrayType);
- assertTrue("not an array type", componentType.isArrayType()); //$NON-NLS-1$
- checkSourceRange(componentType, "Class[][]", source);
- arrayType = (ArrayType) componentType;
- componentType = componentType(arrayType);
- assertTrue("not an array type", componentType.isArrayType()); //$NON-NLS-1$
- checkSourceRange(componentType, "Class[]", source);
- arrayType = (ArrayType) componentType;
- componentType = componentType(arrayType);
- assertTrue("is an array type", !componentType.isArrayType()); //$NON-NLS-1$
- checkSourceRange(componentType, "Class", source);
+ assertEquals(4, arrayType.getDimensions());
+ assertEquals("Class", ((SimpleType)arrayType.getElementType()).getName().getFullyQualifiedName());
}
/**
@@ -2763,9 +2713,8 @@ public void test0497() throws JavaModelException {
checkSourceRange(type, "Class[]", source);
assertTrue("not an array type", type.isArrayType()); //$NON-NLS-1$
ArrayType arrayType = (ArrayType) type;
- Type componentType = componentType(arrayType);
- assertTrue("is an array type", !componentType.isArrayType()); //$NON-NLS-1$
- checkSourceRange(componentType, "Class", source);
+ assertEquals(1, arrayType.getDimensions());
+ assertEquals("Class", ((SimpleType)arrayType.getElementType()).getName().getFullyQualifiedName());
}
public void test0498() throws JavaModelException {
@@ -4133,7 +4082,7 @@ public void test0537b() throws JavaModelException {
*/
public void test0537c() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter", "src", "test0537", "C.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- ASTNode result = runConversion(getJLS3(), sourceUnit, false);
+ ASTNode result = runConversion(getJLS8(), sourceUnit, false);
assertNotNull("No compilation unit", result);
}
/**
@@ -4150,9 +4099,9 @@ public void test0538a() throws JavaModelException {
" int i;\n" +
"}"
);
- CompilationUnit unit = sourceUnit.reconcile(AST.JLS2, false, null, null);
+ CompilationUnit unit = sourceUnit.reconcile(AST.JLS8, false, null, null);
assertNotNull("No level 2 compilation unit", unit);
- assertEquals("Compilation unit has wrong AST level (2)", AST.JLS2, unit.getAST().apiLevel());
+ assertEquals("Compilation unit has wrong AST level (8)", AST.JLS8, unit.getAST().apiLevel());
// TODO improve test for getJLS3()
} finally {
sourceUnit.discardWorkingCopy();
@@ -9473,14 +9422,8 @@ public void test0683() throws JavaModelException {
ArrayCreation arrayCreation = (ArrayCreation) node;
ArrayType arrayType = arrayCreation.getType();
checkSourceRange(arrayType, "String[0][b[10]][]", sourceUnit.getSource());
- node = componentType(arrayType);
- assertEquals("Not an array type", ASTNode.ARRAY_TYPE, node.getNodeType());
- arrayType = (ArrayType)node;
- checkSourceRange(arrayType, "String[0][b[10]]", sourceUnit.getSource());
- node = componentType(arrayType);
- assertEquals("Not an array type", ASTNode.ARRAY_TYPE, node.getNodeType());
- arrayType = (ArrayType)node;
- checkSourceRange(arrayType, "String[0]", sourceUnit.getSource());
+ assertEquals(3, arrayType.getDimensions());
+ assertEquals("String", ((SimpleType)arrayType.getElementType()).getName().getFullyQualifiedName());
}
/**
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverterTestAST4_2.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverterTestAST4_2.java
index 653877c4420..a5ff9d8eb6e 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverterTestAST4_2.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverterTestAST4_2.java
@@ -53,20 +53,6 @@ public ASTConverterTestAST4_2(String name) {
public static Test suite() {
return buildModelTestSuite(ASTConverterTestAST4_2.class);
}
- /**
- * Internal access method to MethodDeclaration#thrownExceptions() for avoiding deprecated warnings.
- * @deprecated
- */
- private static List internalThrownExceptions(MethodDeclaration methodDeclaration) {
- return methodDeclaration.thrownExceptions();
- }
-
- /**
- * @deprecated
- */
- private Type componentType(ArrayType array) {
- return array.getElementType();
- }
/**
* http://dev.eclipse.org/bugs/show_bug.cgi?id=22560
@@ -306,7 +292,7 @@ public void test0409() throws JavaModelException {
newOptions.put(JavaCore.COMPILER_SOURCE, CompilerOptions.getFirstSupportedJavaVersion());
JavaCore.setOptions(newOptions);
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0409", "A.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- ASTNode result = runConversion(getJLS4(), sourceUnit, true);
+ ASTNode result = runConversion(getJLS8(), sourceUnit, true);
assertTrue("Not a compilation unit", result.getNodeType() == ASTNode.COMPILATION_UNIT); //$NON-NLS-1$
CompilationUnit compilationUnit = (CompilationUnit) result;
assertProblemsSize(compilationUnit, 0);
@@ -314,7 +300,7 @@ public void test0409() throws JavaModelException {
compilationUnit.accept(bindingsCollectorVisitor);
assertEquals("wrong number", 3, bindingsCollectorVisitor.getUnresolvedNodesSet().size()); //$NON-NLS-1$
Map bindingsMap = bindingsCollectorVisitor.getBindingsMap();
- assertEquals("wrong number", 211, bindingsMap.size()); //$NON-NLS-1$
+ assertEquals("wrong number", 212, bindingsMap.size()); //$NON-NLS-1$
ASTNodesCollectorVisitor nodesCollector = new ASTNodesCollectorVisitor();
compilationUnit.accept(nodesCollector);
Set detachedNodes = nodesCollector.getDetachedAstNodes();
@@ -456,7 +442,7 @@ public void test0412() throws JavaModelException {
*/
public void test0413() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0413", "A.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- ASTNode result = runConversion(getJLS4(), sourceUnit, true, false, true);
+ ASTNode result = runConversion(getJLS8(), sourceUnit, true, false, true);
assertTrue("not a compilation unit", result.getNodeType() == ASTNode.COMPILATION_UNIT); //$NON-NLS-1$
CompilationUnit unit = (CompilationUnit) result;
assertEquals("Wrong number of problems", 2, unit.getProblems().length); //$NON-NLS-1$
@@ -464,9 +450,9 @@ public void test0413() throws JavaModelException {
assertNotNull(node);
assertTrue("Not a method declaration", node.getNodeType() == ASTNode.METHOD_DECLARATION); //$NON-NLS-1$
MethodDeclaration methodDeclaration = (MethodDeclaration) node;
- List throwsException = internalThrownExceptions(methodDeclaration);
+ List throwsException = methodDeclaration.thrownExceptionTypes();
assertEquals("wrong size", 2, throwsException.size()); //$NON-NLS-1$
- Name name = (Name) throwsException.get(0);
+ Name name = ((SimpleType) throwsException.get(0)).getName();
IBinding binding = name.resolveBinding();
assertNotNull("No binding", binding); //$NON-NLS-1$
assertEquals("LIOException;", binding.getKey());
@@ -478,7 +464,7 @@ public void test0413() throws JavaModelException {
*/
public void test0414() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0414", "A.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- ASTNode result = runConversion(getJLS4(), sourceUnit, true);
+ ASTNode result = runConversion(getJLS8(), sourceUnit, true);
assertTrue("not a compilation unit", result.getNodeType() == ASTNode.COMPILATION_UNIT); //$NON-NLS-1$
CompilationUnit unit = (CompilationUnit) result;
assertEquals("Wrong number of problems", 0, unit.getProblems().length); //$NON-NLS-1$
@@ -2633,7 +2619,7 @@ public void test0492() throws JavaModelException {
public void test0497() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0497", "A.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(getJLS4(), sourceUnit, true);
+ ASTNode result = runConversion(getJLS8(), sourceUnit, true);
assertTrue("not a compilation unit", result.getNodeType() == ASTNode.COMPILATION_UNIT); //$NON-NLS-1$
CompilationUnit unit = (CompilationUnit) result;
assertEquals("Wrong number of problems", 0, unit.getProblems().length); //$NON-NLS-1$<
@@ -2644,14 +2630,14 @@ public void test0497() throws JavaModelException {
checkSourceRange(type, "Class[]", source);
assertTrue("not an array type", type.isArrayType()); //$NON-NLS-1$
ArrayType arrayType = (ArrayType) type;
- Type componentType = componentType(arrayType);
+ Type componentType = arrayType.getElementType();
assertTrue("is an array type", !componentType.isArrayType()); //$NON-NLS-1$
checkSourceRange(componentType, "Class", source);
}
public void test0498() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0498", "A.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- ASTNode result = runConversion(getJLS4(), sourceUnit, true);
+ ASTNode result = runConversion(getJLS8(), sourceUnit, true);
assertTrue("not a compilation unit", result.getNodeType() == ASTNode.COMPILATION_UNIT); //$NON-NLS-1$
}
@@ -2660,7 +2646,7 @@ public void test0498() throws JavaModelException {
*/
public void test0499() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0499", "A.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- ASTNode result = runConversion(getJLS4(), sourceUnit, true);
+ ASTNode result = runConversion(getJLS8(), sourceUnit, true);
assertTrue("not a compilation unit", result.getNodeType() == ASTNode.COMPILATION_UNIT); //$NON-NLS-1$
CompilationUnit unit = (CompilationUnit) result;
assertEquals("Wrong number of problems", 1, unit.getProblems().length); //$NON-NLS-1$
@@ -4031,9 +4017,9 @@ public void test0538a() throws JavaModelException {
" int i;\n" +
"}"
);
- CompilationUnit unit = sourceUnit.reconcile(AST.JLS2, false, null, null);
- assertNotNull("No level 2 compilation unit", unit);
- assertEquals("Compilation unit has wrong AST level (2)", AST.JLS2, unit.getAST().apiLevel());
+ CompilationUnit unit = sourceUnit.reconcile(AST.JLS8, false, null, null);
+ assertNotNull("No level 8 compilation unit", unit);
+ assertEquals("Compilation unit has wrong AST level (8)", AST.JLS8, unit.getAST().apiLevel());
// TODO improve test for getJLS4()
} finally {
sourceUnit.discardWorkingCopy();
@@ -6353,7 +6339,7 @@ public void test0612() throws JavaModelException {
checkSourceRange(type, "boolean[]", contents);
assertTrue("Not an array type", type.isArrayType());
ArrayType arrayType = (ArrayType) type;
- Type componentType = componentType(arrayType);
+ Type componentType = arrayType.getElementType();
assertTrue("Not a primitive type", componentType.isPrimitiveType());
PrimitiveType primitiveType = (PrimitiveType) componentType;
assertEquals("Not boolean", PrimitiveType.BOOLEAN, primitiveType.getPrimitiveTypeCode());
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverterTestAST8_2.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverterTestAST8_2.java
index 663e35baf0f..5d6ec439b4c 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverterTestAST8_2.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverterTestAST8_2.java
@@ -54,20 +54,6 @@ public ASTConverterTestAST8_2(String name) {
public static Test suite() {
return buildModelTestSuite(ASTConverterTestAST8_2.class);
}
- /**
- * Internal access method to MethodDeclaration#thrownExceptions() for avoiding deprecated warnings.
- * @deprecated
- */
- private static List internalThrownExceptions(MethodDeclaration methodDeclaration) {
- return methodDeclaration.thrownExceptions();
- }
-
- /**
- * @deprecated
- */
- private Type componentType(ArrayType array) {
- return array.getComponentType();
- }
/**
* http://dev.eclipse.org/bugs/show_bug.cgi?id=22560
@@ -467,17 +453,10 @@ public void test0413() throws JavaModelException {
assertTrue("Not a method declaration", node.getNodeType() == ASTNode.METHOD_DECLARATION); //$NON-NLS-1$
MethodDeclaration methodDeclaration = (MethodDeclaration) node;
IBinding binding;
- if (node.getAST().apiLevel() < getJLS8()) {
- List throwsException = internalThrownExceptions(methodDeclaration);
- assertEquals("wrong size", 2, throwsException.size()); //$NON-NLS-1$
- Name name = (Name) throwsException.get(0);
- binding = name.resolveBinding();
- } else {
- List throwsExceptionTypes = methodDeclaration.thrownExceptionTypes();
- assertEquals("wrong size", 2, throwsExceptionTypes.size()); //$NON-NLS-1$
- Type type = (Type) throwsExceptionTypes.get(0);
- binding = type.resolveBinding();
- }
+ List throwsExceptionTypes = methodDeclaration.thrownExceptionTypes();
+ assertEquals("wrong size", 2, throwsExceptionTypes.size()); //$NON-NLS-1$
+ Type type = (Type) throwsExceptionTypes.get(0);
+ binding = type.resolveBinding();
assertNotNull("No binding", binding); //$NON-NLS-1$
assertEquals("LIOException;", binding.getKey());
assertTrue("Binding should be marked as recovered", binding.isRecovered());
@@ -2742,7 +2721,7 @@ public void test0497() throws JavaModelException {
checkSourceRange(type, "Class[]", source);
assertTrue("not an array type", type.isArrayType()); //$NON-NLS-1$
ArrayType arrayType = (ArrayType) type;
- type = this.ast.apiLevel() < getJLS8() ? componentType(arrayType) : arrayType.getElementType();
+ type = arrayType.getElementType();
assertTrue("is an array type", !type.isArrayType()); //$NON-NLS-1$
checkSourceRange(type, "Class", source);
}
@@ -4129,9 +4108,9 @@ public void test0538a() throws JavaModelException {
" int i;\n" +
"}"
);
- CompilationUnit unit = sourceUnit.reconcile(AST.JLS2, false, null, null);
- assertNotNull("No level 2 compilation unit", unit);
- assertEquals("Compilation unit has wrong AST level (2)", AST.JLS2, unit.getAST().apiLevel());
+ CompilationUnit unit = sourceUnit.reconcile(AST.JLS8, false, null, null);
+ assertNotNull("No level 8 compilation unit", unit);
+ assertEquals("Compilation unit has wrong AST level (8)", AST.JLS8, unit.getAST().apiLevel());
// TODO improve test for getJLS8()
} finally {
sourceUnit.discardWorkingCopy();
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTStructuralPropertyTest.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTStructuralPropertyTest.java
index 05454e4dafa..dc15970fe4d 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTStructuralPropertyTest.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTStructuralPropertyTest.java
@@ -41,9 +41,6 @@ public static Test suite() {
Method[] methods = c.getMethods();
for (int i = 0, max = methods.length; i < max; i++) {
if (methods[i].getName().startsWith("test")) { //$NON-NLS-1$
- suite.addTest(new ASTStructuralPropertyTest(methods[i].getName(), AST.JLS2));
- suite.addTest(new ASTStructuralPropertyTest(methods[i].getName(), AST.JLS3));
- suite.addTest(new ASTStructuralPropertyTest(methods[i].getName(), AST.JLS4));
suite.addTest(new ASTStructuralPropertyTest(methods[i].getName(), AST.JLS8));
}
}
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTTest.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTTest.java
index 3f08cd032fe..85bef361308 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTTest.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTTest.java
@@ -763,9 +763,6 @@ public static Test suite() {
Method[] methods = c.getMethods();
for (int i = 0, max = methods.length; i < max; i++) {
if (methods[i].getName().startsWith("test")) { //$NON-NLS-1$
- suite.addTest(new ASTTest(methods[i].getName(), AST.JLS2));
- suite.addTest(new ASTTest(methods[i].getName(), JLS3_INTERNAL));
- suite.addTest(new ASTTest(methods[i].getName(), AST.JLS4));
suite.addTest(new ASTTest(methods[i].getName(), getJLS8()));
suite.addTest(new ASTTest(methods[i].getName(), AST_INTERNAL_JLS23));
}
@@ -1312,46 +1309,31 @@ void genericPropertyListTest(ASTNode node, List children, Property prop) {
@SuppressWarnings("deprecation")
private static int getApiLevel(String s) {
- if (s == null)
- return AST.JLS12;
- switch (s) {
- case JavaCore.VERSION_1_2 : return AST.JLS2;
- case JavaCore.VERSION_1_3: return AST.JLS3;
- case JavaCore.VERSION_1_4: return AST.JLS4;
- case JavaCore.VERSION_1_5: return AST.JLS4;
- case JavaCore.VERSION_1_6: return AST.JLS4;
- case JavaCore.VERSION_1_7: return AST.JLS4;
- case JavaCore.VERSION_1_8: return AST.JLS8;
- case JavaCore.VERSION_9: return AST.JLS9;
- case JavaCore.VERSION_10: return AST.JLS10;
- case JavaCore.VERSION_11: return AST.JLS11;
- case JavaCore.VERSION_12: return AST.JLS12;
- case JavaCore.VERSION_13: return AST.JLS13;
- case JavaCore.VERSION_14: return AST.JLS14;
- case JavaCore.VERSION_15: return AST.JLS15;
- case JavaCore.VERSION_16: return AST.JLS16;
- case JavaCore.VERSION_17: return AST.JLS17;
- case JavaCore.VERSION_18: return AST.JLS18;
- case JavaCore.VERSION_19: return AST.JLS19;
- case JavaCore.VERSION_20: return AST.JLS20;
- default: return AST.JLS2;
- }
+ try {
+ int apiLevel = Integer.valueOf(s);
+ if (AST.isSupportedVersion(apiLevel)) {
+ return apiLevel;
+ }
+ } catch (NumberFormatException e) {
+ if (s.equals(JavaCore.VERSION_1_8)) {
+ return AST.JLS8;
+ }
+ }
+ return AST.getJLSLatest();
+
}
/** @deprecated using deprecated code */
public void testAST() {
- assertSame(AST.JLS2, 2);
- assertSame(JLS3_INTERNAL, 3);
-
AST a0 = new AST(); // deprecated, now 3 from JavaCore.defaultOptions
- int apiLevelCal = ASTTest.getApiLevel(JavaCore.getDefaultOptions().get(JavaCore.COMPILER_SOURCE));
+ int apiLevelCal = getApiLevel(JavaCore.getDefaultOptions().get(JavaCore.COMPILER_SOURCE));
assertTrue(a0.apiLevel() == apiLevelCal);
AST a1 = new AST(new HashMap()); // deprecated, but still 2.0
- assertTrue(a1.apiLevel() == AST.JLS2);
+ assertEquals(AST.JLS8,a1.apiLevel());
AST a2 = AST.newAST(AST.JLS2, false);
- assertTrue(a2.apiLevel() == AST.JLS2);
+ assertEquals(AST.JLS8, a2.apiLevel());
AST a3 = AST.newAST(JLS3_INTERNAL, false);
- assertTrue(a3.apiLevel() == JLS3_INTERNAL);
+ assertEquals(AST.JLS8, a3.apiLevel());
// modification count is always non-negative
assertTrue(this.ast.modificationCount() >= 0);
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/SortCompilationUnitElementsTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/SortCompilationUnitElementsTests.java
index e20057f1fb7..6522ee3ff52 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/SortCompilationUnitElementsTests.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/SortCompilationUnitElementsTests.java
@@ -1878,8 +1878,8 @@ public int compare(Object o1, Object o2) {
Javadoc javadoc2 = bodyDeclaration2.getJavadoc();
if (javadoc1 != null && javadoc2 != null) {
var comment1 = ((AbstractTextElement)((TagElement)javadoc1.tags().get(0)).fragments().get(0)).getText();
- var comment2 = ((AbstractTextElement)((TagElement)javadoc2.tags().get(0)).fragments().get(0)).getText();
- return comment1.compareTo(comment2);
+ var comment2 = ((AbstractTextElement)((TagElement)javadoc2.tags().get(0)).fragments().get(0)).getText();
+ return comment1.compareTo(comment2);
}
final int sourceStart1 = ((Integer) bodyDeclaration1.getProperty(CompilationUnitSorter.RELATIVE_ORDER)).intValue();
final int sourceStart2 = ((Integer) bodyDeclaration2.getProperty(CompilationUnitSorter.RELATIVE_ORDER)).intValue();
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/rewrite/describing/ASTRewritingTest.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/rewrite/describing/ASTRewritingTest.java
index 728508b8534..80158b573f4 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/rewrite/describing/ASTRewritingTest.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/rewrite/describing/ASTRewritingTest.java
@@ -188,7 +188,10 @@ protected static TestSuite createSuite(Class testClass, int classSince) {
String suffix = name.substring(index + ONLY_AST_STRING.length() + 1);
String[] levels = suffix.split(STRING_);
for (int l= 0; l < levels.length; l++) {
- suite.addTest((Test) cons.newInstance(new Object[]{name, Integer.valueOf(levels[l])}));
+ int level = Integer.valueOf(levels[l]);
+ if (AST.isSupportedVersion(level)) {
+ suite.addTest((Test) cons.newInstance(name, level));
+ }
}
} else {
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/rewrite/modifying/ASTRewritingModifyingInsertTest.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/rewrite/modifying/ASTRewritingModifyingInsertTest.java
index 42113081a94..baefe947798 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/rewrite/modifying/ASTRewritingModifyingInsertTest.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/rewrite/modifying/ASTRewritingModifyingInsertTest.java
@@ -448,7 +448,6 @@ public void test0007() throws Exception {
// assertEqualString(preview, buf.toString());
// }
- /** @deprecated using deprecated code */
public void test0010() throws Exception {
String source = "\n";
CompilationUnit astRoot= createCU(source.toCharArray());
@@ -495,7 +494,6 @@ public void test0011() throws Exception {
assertEqualString(preview, buf.toString());
}
- /** @deprecated using deprecated code */
public void test0012() throws Exception {
String source = "\n";
CompilationUnit astRoot= createCU(source.toCharArray());
diff --git a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/AST.java b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/AST.java
index 4a8f023d5cf..7b423b90f2f 100644
--- a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/AST.java
+++ b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/AST.java
@@ -1131,36 +1131,10 @@ public AST() {
*/
private AST(int level, boolean previewEnabled) {
this.previewEnabled = previewEnabled;
+ if (ALL_VERSIONS.contains(level) && !SUPPORTED_VERSIONS.contains(level)) {
+ level = SUPPORTED_VERSIONS.get(0);
+ }
switch(level) {
- case JLS2_INTERNAL :
- case JLS3_INTERNAL :
- this.apiLevel = level;
- // initialize a scanner
- this.scanner = new Scanner(
- true /*comment*/,
- true /*whitespace*/,
- false /*nls*/,
- ClassFileConstants.JDK1_3 /*sourceLevel*/,
- ClassFileConstants.JDK1_5 /*complianceLevel*/,
- null/*taskTag*/,
- null/*taskPriorities*/,
- true/*taskCaseSensitive*/,
- false/*isPreviewEnabled*/);
- break;
- case JLS4_INTERNAL :
- this.apiLevel = level;
- // initialize a scanner
- this.scanner = new Scanner(
- true /*comment*/,
- true /*whitespace*/,
- false /*nls*/,
- ClassFileConstants.JDK1_7 /*sourceLevel*/,
- ClassFileConstants.JDK1_7 /*complianceLevel*/,
- null/*taskTag*/,
- null/*taskPriorities*/,
- true/*taskCaseSensitive*/,
- false/*isPreviewEnabled*/);
- break;
case JLS8_INTERNAL :
this.apiLevel = level;
// initialize a scanner
@@ -1234,8 +1208,6 @@ private AST(int level, boolean previewEnabled) {
* indicates the api level and source compatibility mode (as per JavaCore
) - defaults to 1.3
*
"1.3"
means the source code is as per JDK 1.3 and api level {@link #JLS3}."1.4", "1.5", "1.6", "1.7"
implies the respective source JDK levels 1.4, 1.5, 1.6, 1.7 and api level {@link #JLS4}."1.8"
implies the respective source JDK level 1.8 and api level {@link #JLS8}."9", "10", "11" up to "23"
implies the respective JDK levels 9, 10, 11 up to 23
* and api levels {@link #JLS9}, {@link #JLS10}, {@link #JLS11} up to {@link #JLS23}.