Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make AST map pre 1.8 versions to 1.8 #3533

Merged
merged 1 commit into from
Feb 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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$
Expand Down Expand Up @@ -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();
Expand All @@ -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$
Expand All @@ -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();
Expand All @@ -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$
Expand All @@ -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();
Expand All @@ -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);
Expand All @@ -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();
Expand All @@ -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);
Expand All @@ -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();
Expand All @@ -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);
Expand Down Expand Up @@ -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();
Expand All @@ -2933,15 +2915,16 @@ 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();
fragment.setName(this.ast.newSimpleName("i"));//$NON-NLS-1$
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$
Expand Down Expand Up @@ -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());
}

/**
Expand Down Expand Up @@ -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$
}

/**
Expand Down Expand Up @@ -8046,27 +8014,14 @@ 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;
checkSourceRange(simpleType, "Object", source); //$NON-NLS-1$
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$
}


Expand Down Expand Up @@ -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$
Expand Down
Loading
Loading