[230291] remove dead code
diff --git a/tests/org.eclipse.wst.jsdt.core.tests.model/src/org/eclipse/wst/jsdt/core/tests/dom/ASTConverter15Test.java b/tests/org.eclipse.wst.jsdt.core.tests.model/src/org/eclipse/wst/jsdt/core/tests/dom/ASTConverter15Test.java
index 3c8c186..df60819 100644
--- a/tests/org.eclipse.wst.jsdt.core.tests.model/src/org/eclipse/wst/jsdt/core/tests/dom/ASTConverter15Test.java
+++ b/tests/org.eclipse.wst.jsdt.core.tests.model/src/org/eclipse/wst/jsdt/core/tests/dom/ASTConverter15Test.java
@@ -12,7 +12,6 @@
package org.eclipse.wst.jsdt.core.tests.dom;
import java.io.IOException;
-import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -23,14 +22,68 @@
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.wst.jsdt.core.BindingKey;
-import org.eclipse.wst.jsdt.core.IJavaScriptUnit;
import org.eclipse.wst.jsdt.core.IJavaScriptElement;
import org.eclipse.wst.jsdt.core.IJavaScriptProject;
+import org.eclipse.wst.jsdt.core.IJavaScriptUnit;
import org.eclipse.wst.jsdt.core.IType;
import org.eclipse.wst.jsdt.core.JavaScriptCore;
import org.eclipse.wst.jsdt.core.JavaScriptModelException;
import org.eclipse.wst.jsdt.core.Signature;
-import org.eclipse.wst.jsdt.core.dom.*;
+import org.eclipse.wst.jsdt.core.dom.AST;
+import org.eclipse.wst.jsdt.core.dom.ASTMatcher;
+import org.eclipse.wst.jsdt.core.dom.ASTNode;
+import org.eclipse.wst.jsdt.core.dom.ASTVisitor;
+import org.eclipse.wst.jsdt.core.dom.AbstractTypeDeclaration;
+import org.eclipse.wst.jsdt.core.dom.ArrayType;
+import org.eclipse.wst.jsdt.core.dom.AssertStatement;
+import org.eclipse.wst.jsdt.core.dom.Block;
+import org.eclipse.wst.jsdt.core.dom.BodyDeclaration;
+import org.eclipse.wst.jsdt.core.dom.CastExpression;
+import org.eclipse.wst.jsdt.core.dom.ClassInstanceCreation;
+import org.eclipse.wst.jsdt.core.dom.ConstructorInvocation;
+import org.eclipse.wst.jsdt.core.dom.EnhancedForStatement;
+import org.eclipse.wst.jsdt.core.dom.Expression;
+import org.eclipse.wst.jsdt.core.dom.ExpressionStatement;
+import org.eclipse.wst.jsdt.core.dom.FieldAccess;
+import org.eclipse.wst.jsdt.core.dom.FieldDeclaration;
+import org.eclipse.wst.jsdt.core.dom.FunctionDeclaration;
+import org.eclipse.wst.jsdt.core.dom.FunctionInvocation;
+import org.eclipse.wst.jsdt.core.dom.IBinding;
+import org.eclipse.wst.jsdt.core.dom.IExtendedModifier;
+import org.eclipse.wst.jsdt.core.dom.IFunctionBinding;
+import org.eclipse.wst.jsdt.core.dom.IPackageBinding;
+import org.eclipse.wst.jsdt.core.dom.ITypeBinding;
+import org.eclipse.wst.jsdt.core.dom.IVariableBinding;
+import org.eclipse.wst.jsdt.core.dom.IfStatement;
+import org.eclipse.wst.jsdt.core.dom.ImportDeclaration;
+import org.eclipse.wst.jsdt.core.dom.Initializer;
+import org.eclipse.wst.jsdt.core.dom.InstanceofExpression;
+import org.eclipse.wst.jsdt.core.dom.JavaScriptUnit;
+import org.eclipse.wst.jsdt.core.dom.Modifier;
+import org.eclipse.wst.jsdt.core.dom.Name;
+import org.eclipse.wst.jsdt.core.dom.NullLiteral;
+import org.eclipse.wst.jsdt.core.dom.NumberLiteral;
+import org.eclipse.wst.jsdt.core.dom.ParameterizedType;
+import org.eclipse.wst.jsdt.core.dom.QualifiedName;
+import org.eclipse.wst.jsdt.core.dom.QualifiedType;
+import org.eclipse.wst.jsdt.core.dom.ReturnStatement;
+import org.eclipse.wst.jsdt.core.dom.SimpleName;
+import org.eclipse.wst.jsdt.core.dom.SimpleType;
+import org.eclipse.wst.jsdt.core.dom.SingleVariableDeclaration;
+import org.eclipse.wst.jsdt.core.dom.Statement;
+import org.eclipse.wst.jsdt.core.dom.SuperConstructorInvocation;
+import org.eclipse.wst.jsdt.core.dom.SuperFieldAccess;
+import org.eclipse.wst.jsdt.core.dom.SwitchCase;
+import org.eclipse.wst.jsdt.core.dom.SwitchStatement;
+import org.eclipse.wst.jsdt.core.dom.TryStatement;
+import org.eclipse.wst.jsdt.core.dom.Type;
+import org.eclipse.wst.jsdt.core.dom.TypeDeclaration;
+import org.eclipse.wst.jsdt.core.dom.TypeDeclarationStatement;
+import org.eclipse.wst.jsdt.core.dom.TypeLiteral;
+import org.eclipse.wst.jsdt.core.dom.TypeParameter;
+import org.eclipse.wst.jsdt.core.dom.VariableDeclarationFragment;
+import org.eclipse.wst.jsdt.core.dom.VariableDeclarationStatement;
+import org.eclipse.wst.jsdt.core.dom.WildcardType;
import org.eclipse.wst.jsdt.core.tests.util.Util;
public class ASTConverter15Test extends ConverterTestSetup {
@@ -128,165 +181,6 @@
assertProblemsSize(compilationUnit, 0);
}
- public void test0003() throws JavaScriptModelException {
- IJavaScriptUnit sourceUnit = getCompilationUnit("Converter15" , "src", "test0003", "X.js"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runJLS3Conversion(sourceUnit, true, true);
- assertTrue("Not a compilation unit", result.getNodeType() == ASTNode.JAVASCRIPT_UNIT);
- JavaScriptUnit compilationUnit = (JavaScriptUnit) result;
- assertProblemsSize(compilationUnit, 0);
- List types = compilationUnit.types();
- assertEquals("Wrong number of types", 3, types.size());
- AbstractTypeDeclaration typeDeclaration = (AbstractTypeDeclaration) types.get(2);
- assertEquals("wrong type", ASTNode.TYPE_DECLARATION, typeDeclaration.getNodeType());
- TypeDeclaration typeDeclaration2 = (TypeDeclaration) typeDeclaration;
- List modifiers = typeDeclaration2.modifiers();
- assertEquals("Wrong number of modifiers", 2, modifiers.size());
- ASTNode modifier = (ASTNode) modifiers.get(0);
- checkSourceRange(modifier, "@Author(@Name(first=\"Joe\", last=\"Hacker\"))", source);
- assertEquals("wrong type", ASTNode.SINGLE_MEMBER_ANNOTATION, modifier.getNodeType());
- SingleMemberAnnotation annotation = (SingleMemberAnnotation) modifier;
- checkSourceRange(annotation.getTypeName(), "Author", source);
- Expression value = annotation.getValue();
- assertEquals("wrong type", ASTNode.NORMAL_ANNOTATION, value.getNodeType());
- NormalAnnotation normalAnnotation = (NormalAnnotation) value;
- checkSourceRange(normalAnnotation.getTypeName(), "Name", source);
- List values = normalAnnotation.values();
- assertEquals("wrong size", 2, values.size());
- MemberValuePair memberValuePair = (MemberValuePair) values.get(0);
- checkSourceRange(memberValuePair, "first=\"Joe\"", source);
- checkSourceRange(memberValuePair.getName(), "first", source);
- checkSourceRange(memberValuePair.getValue(), "\"Joe\"", source);
- memberValuePair = (MemberValuePair) values.get(1);
- checkSourceRange(memberValuePair, "last=\"Hacker\"", source);
- checkSourceRange(memberValuePair.getName(), "last", source);
- checkSourceRange(memberValuePair.getValue(), "\"Hacker\"", source);
- modifier = (ASTNode) modifiers.get(1);
- checkSourceRange(modifier, "public", source);
- }
-
- public void test0004() throws JavaScriptModelException {
- IJavaScriptUnit sourceUnit = getCompilationUnit("Converter15" , "src", "test0004", "X.js"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runJLS3Conversion(sourceUnit, true, true);
- assertTrue("Not a compilation unit", result.getNodeType() == ASTNode.JAVASCRIPT_UNIT);
- JavaScriptUnit compilationUnit = (JavaScriptUnit) result;
- assertProblemsSize(compilationUnit, 0);
- List types = compilationUnit.types();
- assertEquals("Wrong number of types", 3, types.size());
- AbstractTypeDeclaration typeDeclaration = (AbstractTypeDeclaration) types.get(2);
- assertEquals("wrong type", ASTNode.TYPE_DECLARATION, typeDeclaration.getNodeType());
- TypeDeclaration typeDeclaration2 = (TypeDeclaration) typeDeclaration;
- List modifiers = typeDeclaration2.modifiers();
- assertEquals("Wrong number of modifiers", 2, modifiers.size());
- ASTNode modifier = (ASTNode) modifiers.get(1);
- checkSourceRange(modifier, "@Author(@Name(first=\"Joe\", last=\"Hacker\"))", source);
- assertEquals("wrong type", ASTNode.SINGLE_MEMBER_ANNOTATION, modifier.getNodeType());
- SingleMemberAnnotation annotation = (SingleMemberAnnotation) modifier;
- checkSourceRange(annotation.getTypeName(), "Author", source);
- Expression value = annotation.getValue();
- assertEquals("wrong type", ASTNode.NORMAL_ANNOTATION, value.getNodeType());
- NormalAnnotation normalAnnotation = (NormalAnnotation) value;
- checkSourceRange(normalAnnotation.getTypeName(), "Name", source);
- List values = normalAnnotation.values();
- assertEquals("wrong size", 2, values.size());
- MemberValuePair memberValuePair = (MemberValuePair) values.get(0);
- checkSourceRange(memberValuePair, "first=\"Joe\"", source);
- checkSourceRange(memberValuePair.getName(), "first", source);
- checkSourceRange(memberValuePair.getValue(), "\"Joe\"", source);
- memberValuePair = (MemberValuePair) values.get(1);
- checkSourceRange(memberValuePair, "last=\"Hacker\"", source);
- checkSourceRange(memberValuePair.getName(), "last", source);
- checkSourceRange(memberValuePair.getValue(), "\"Hacker\"", source);
- modifier = (ASTNode) modifiers.get(0);
- checkSourceRange(modifier, "public", source);
- }
-
- public void test0005() throws JavaScriptModelException {
- IJavaScriptUnit sourceUnit = getCompilationUnit("Converter15" , "src", "test0005", "X.js"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runJLS3Conversion(sourceUnit, true, true);
- assertTrue("Not a compilation unit", result.getNodeType() == ASTNode.JAVASCRIPT_UNIT);
- JavaScriptUnit compilationUnit = (JavaScriptUnit) result;
- assertProblemsSize(compilationUnit, 0);
- List types = compilationUnit.types();
- assertEquals("Wrong number of types", 4, types.size());
- AbstractTypeDeclaration typeDeclaration = (AbstractTypeDeclaration) types.get(3);
- assertEquals("wrong type", ASTNode.TYPE_DECLARATION, typeDeclaration.getNodeType());
- TypeDeclaration typeDeclaration2 = (TypeDeclaration) typeDeclaration;
- List modifiers = typeDeclaration2.modifiers();
- assertEquals("Wrong number of modifiers", 3, modifiers.size());
- ASTNode modifier = (ASTNode) modifiers.get(0);
- checkSourceRange(modifier, "@Retention", source);
- assertEquals("wrong type", ASTNode.MARKER_ANNOTATION, modifier.getNodeType());
- MarkerAnnotation markerAnnotation = (MarkerAnnotation) modifier;
- checkSourceRange(markerAnnotation.getTypeName(), "Retention", source);
- modifier = (ASTNode) modifiers.get(2);
- checkSourceRange(modifier, "@Author(@Name(first=\"Joe\", last=\"Hacker\", age=32))", source);
- assertEquals("wrong type", ASTNode.SINGLE_MEMBER_ANNOTATION, modifier.getNodeType());
- SingleMemberAnnotation annotation = (SingleMemberAnnotation) modifier;
- checkSourceRange(annotation.getTypeName(), "Author", source);
- Expression value = annotation.getValue();
- assertEquals("wrong type", ASTNode.NORMAL_ANNOTATION, value.getNodeType());
- NormalAnnotation normalAnnotation = (NormalAnnotation) value;
- checkSourceRange(normalAnnotation.getTypeName(), "Name", source);
- List values = normalAnnotation.values();
- assertEquals("wrong size", 3, values.size());
- MemberValuePair memberValuePair = (MemberValuePair) values.get(0);
- checkSourceRange(memberValuePair, "first=\"Joe\"", source);
- checkSourceRange(memberValuePair.getName(), "first", source);
- checkSourceRange(memberValuePair.getValue(), "\"Joe\"", source);
- memberValuePair = (MemberValuePair) values.get(1);
- checkSourceRange(memberValuePair, "last=\"Hacker\"", source);
- checkSourceRange(memberValuePair.getName(), "last", source);
- checkSourceRange(memberValuePair.getValue(), "\"Hacker\"", source);
- memberValuePair = (MemberValuePair) values.get(2);
- checkSourceRange(memberValuePair, "age=32", source);
- checkSourceRange(memberValuePair.getName(), "age", source);
- checkSourceRange(memberValuePair.getValue(), "32", source);
- modifier = (ASTNode) modifiers.get(1);
- checkSourceRange(modifier, "public", source);
-
- typeDeclaration = (AbstractTypeDeclaration) types.get(0);
- assertEquals("wrong type", ASTNode.ANNOTATION_TYPE_DECLARATION, typeDeclaration.getNodeType());
- AnnotationTypeDeclaration annotationTypeDeclaration = (AnnotationTypeDeclaration) typeDeclaration;
- List bodyDeclarations = annotationTypeDeclaration.bodyDeclarations();
- assertEquals("Wrong size", 3, bodyDeclarations.size());
- BodyDeclaration bodyDeclaration = (BodyDeclaration) bodyDeclarations.get(0);
- assertEquals("wrong type", ASTNode.ANNOTATION_TYPE_MEMBER_DECLARATION, bodyDeclaration.getNodeType());
- AnnotationTypeMemberDeclaration annotationTypeMemberDeclaration = (AnnotationTypeMemberDeclaration) bodyDeclaration;
- IFunctionBinding methodBinding = annotationTypeMemberDeclaration.resolveBinding();
- assertNotNull("No binding", methodBinding);
- checkSourceRange(annotationTypeMemberDeclaration, "String first() default \"Joe\";", source);
- Expression expression = annotationTypeMemberDeclaration.getDefault();
- checkSourceRange(expression, "\"Joe\"", source);
- bodyDeclaration = (BodyDeclaration) bodyDeclarations.get(2);
- assertEquals("wrong type", ASTNode.ANNOTATION_TYPE_MEMBER_DECLARATION, bodyDeclaration.getNodeType());
- annotationTypeMemberDeclaration = (AnnotationTypeMemberDeclaration) bodyDeclaration;
- checkSourceRange(annotationTypeMemberDeclaration, "int age();", source);
- expression = annotationTypeMemberDeclaration.getDefault();
- assertNull("Got a default", expression);
- }
-
- public void test0006() throws JavaScriptModelException {
- IJavaScriptUnit sourceUnit = getCompilationUnit("Converter15" , "src", "test0006", "X.js"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(AST.JLS3, sourceUnit, true);
- assertTrue("Not a compilation unit", result.getNodeType() == ASTNode.JAVASCRIPT_UNIT);
- JavaScriptUnit compilationUnit = (JavaScriptUnit) result;
- final String expectedOutput = "Package annotations must be in file package-info.js";
- assertProblemsSize(compilationUnit, 1, expectedOutput);
- PackageDeclaration packageDeclaration = compilationUnit.getPackage();
- assertNotNull("No package declaration", packageDeclaration);
- checkSourceRange(packageDeclaration, "@Retention package test0006;", source);
- List annotations = packageDeclaration.annotations();
- assertEquals("Wrong size", 1, annotations.size());
- Annotation annotation = (Annotation) annotations.get(0);
- checkSourceRange(annotation, "@Retention", source);
- assertEquals("Not a marker annotation", annotation.getNodeType(), ASTNode.MARKER_ANNOTATION);
- MarkerAnnotation markerAnnotation = (MarkerAnnotation) annotation;
- checkSourceRange(markerAnnotation.getTypeName(), "Retention", source);
- }
public void test0007() throws JavaScriptModelException {
IJavaScriptUnit sourceUnit = getCompilationUnit("Converter15" , "src", "test0007", "X.js"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
@@ -821,220 +715,6 @@
checkSourceRange(type, "E", source);
}
- public void test0026() throws JavaScriptModelException {
- IJavaScriptUnit sourceUnit = getCompilationUnit("Converter15" , "src", "test0026", "X.js"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- ASTNode result = runJLS3Conversion(sourceUnit, true, true);
- assertTrue("Not a compilation unit", result.getNodeType() == ASTNode.JAVASCRIPT_UNIT);
- JavaScriptUnit compilationUnit = (JavaScriptUnit) result;
- assertProblemsSize(compilationUnit, 0);
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode node = getASTNode(compilationUnit, 0);
- assertEquals("Not an enum declaration", ASTNode.ENUM_DECLARATION, node.getNodeType());
- EnumDeclaration enumDeclaration = (EnumDeclaration) node;
- ITypeBinding typeBinding2 = enumDeclaration.resolveBinding();
- assertNotNull("No binding", typeBinding2);
- List modifiers = enumDeclaration.modifiers();
- assertEquals("Wrong number of modifiers", 1, modifiers.size());
- IExtendedModifier extendedModifier = (IExtendedModifier) modifiers.get(0);
- assertTrue("Not a modifier", extendedModifier instanceof Modifier);
- Modifier modifier = (Modifier) extendedModifier;
- checkSourceRange(modifier, "public", source);
- assertEquals("wrong name", "X", enumDeclaration.getName().getIdentifier());
- List enumConstants = enumDeclaration.enumConstants();
- assertEquals("wrong size", 4, enumConstants.size());
- List bodyDeclarations = enumDeclaration.bodyDeclarations();
- assertEquals("wrong size", 2, bodyDeclarations.size());
- EnumConstantDeclaration enumConstantDeclaration = (EnumConstantDeclaration) enumConstants.get(0);
- IFunctionBinding methodBinding = enumConstantDeclaration.resolveConstructorBinding();
- assertNotNull("No binding", methodBinding);
- assertTrue("Not a constructor", methodBinding.isConstructor());
- checkSourceRange(enumConstantDeclaration.getName(), "PLUS", source);
- checkSourceRange(enumConstantDeclaration, "PLUS {\n" +
- " @Override\n" +
- " double eval(double x, double y) { return x + y; }\n" +
- " }", source);
- assertEquals("wrong size", 0, enumConstantDeclaration.arguments().size());
- AnonymousClassDeclaration anonymousClassDeclaration = enumConstantDeclaration.getAnonymousClassDeclaration();
- assertNotNull("No anonymous class", anonymousClassDeclaration);
- checkSourceRange(anonymousClassDeclaration, "{\n" +
- " @Override\n" +
- " double eval(double x, double y) { return x + y; }\n" +
- " }", source);
- ITypeBinding typeBinding = anonymousClassDeclaration.resolveBinding();
- assertNotNull("No binding", typeBinding);
- assertTrue("Not a enum type", typeBinding.isEnum());
- bodyDeclarations = anonymousClassDeclaration.bodyDeclarations();
- assertEquals("wrong size", 1, bodyDeclarations.size());
- BodyDeclaration bodyDeclaration = (BodyDeclaration) bodyDeclarations.get(0);
- assertEquals("Not a method declaration", ASTNode.FUNCTION_DECLARATION, bodyDeclaration.getNodeType());
- FunctionDeclaration methodDeclaration = (FunctionDeclaration) bodyDeclaration;
- checkSourceRange(methodDeclaration.getName(), "eval", source);
- checkSourceRange(methodDeclaration, "@Override\n double eval(double x, double y) { return x + y; }", source);
- assertEquals("wrong size", 0, enumConstantDeclaration.arguments().size());
-
- enumConstantDeclaration = (EnumConstantDeclaration) enumConstants.get(1);
- methodBinding = enumConstantDeclaration.resolveConstructorBinding();
- assertNotNull("No binding", methodBinding);
- assertTrue("Not a constructor", methodBinding.isConstructor());
- checkSourceRange(enumConstantDeclaration.getName(), "MINUS", source);
- checkSourceRange(enumConstantDeclaration, "MINUS {\n" +
- " @Override\n" +
- " double eval(double x, double y) { return x - y; }\n" +
- " }", source);
- anonymousClassDeclaration = enumConstantDeclaration.getAnonymousClassDeclaration();
- typeBinding = anonymousClassDeclaration.resolveBinding();
- assertNotNull("No binding", typeBinding);
- assertTrue("Not a enum type", typeBinding.isEnum());
- assertNotNull("No anonymous class", anonymousClassDeclaration);
- checkSourceRange(anonymousClassDeclaration, "{\n" +
- " @Override\n" +
- " double eval(double x, double y) { return x - y; }\n" +
- " }", source);
- bodyDeclarations = anonymousClassDeclaration.bodyDeclarations();
- assertEquals("wrong size", 1, bodyDeclarations.size());
- bodyDeclaration = (BodyDeclaration) bodyDeclarations.get(0);
- assertEquals("Not a method declaration", ASTNode.FUNCTION_DECLARATION, bodyDeclaration.getNodeType());
- methodDeclaration = (FunctionDeclaration) bodyDeclaration;
- checkSourceRange(methodDeclaration.getName(), "eval", source);
- checkSourceRange(methodDeclaration, "@Override\n double eval(double x, double y) { return x - y; }", source);
- assertEquals("wrong size", 0, enumConstantDeclaration.arguments().size());
-
- enumConstantDeclaration = (EnumConstantDeclaration) enumConstants.get(2);
- methodBinding = enumConstantDeclaration.resolveConstructorBinding();
- assertNotNull("No binding", methodBinding);
- assertTrue("Not a constructor", methodBinding.isConstructor());
- checkSourceRange(enumConstantDeclaration.getName(), "TIMES", source);
- checkSourceRange(enumConstantDeclaration, "TIMES {\n" +
- " @Override\n" +
- " double eval(double x, double y) { return x * y; }\n" +
- " }", source);
- anonymousClassDeclaration = enumConstantDeclaration.getAnonymousClassDeclaration();
- assertNotNull("No anonymous class", anonymousClassDeclaration);
- checkSourceRange(anonymousClassDeclaration, "{\n" +
- " @Override\n" +
- " double eval(double x, double y) { return x * y; }\n" +
- " }", source);
- typeBinding = anonymousClassDeclaration.resolveBinding();
- assertNotNull("No binding", typeBinding);
- assertTrue("Not a enum type", typeBinding.isEnum());
- bodyDeclarations = anonymousClassDeclaration.bodyDeclarations();
- assertEquals("wrong size", 1, bodyDeclarations.size());
- bodyDeclaration = (BodyDeclaration) bodyDeclarations.get(0);
- assertEquals("Not a method declaration", ASTNode.FUNCTION_DECLARATION, bodyDeclaration.getNodeType());
- methodDeclaration = (FunctionDeclaration) bodyDeclaration;
- checkSourceRange(methodDeclaration.getName(), "eval", source);
- checkSourceRange(methodDeclaration, "@Override\n double eval(double x, double y) { return x * y; }", source);
- assertEquals("wrong size", 0, enumConstantDeclaration.arguments().size());
-
- enumConstantDeclaration = (EnumConstantDeclaration) enumConstants.get(3);
- methodBinding = enumConstantDeclaration.resolveConstructorBinding();
- assertNotNull("No binding", methodBinding);
- assertTrue("Not a constructor", methodBinding.isConstructor());
- checkSourceRange(enumConstantDeclaration.getName(), "DIVIDED_BY", source);
- checkSourceRange(enumConstantDeclaration, "DIVIDED_BY {\n" +
- " @Override\n" +
- " double eval(double x, double y) { return x / y; }\n" +
- " }", source);
- anonymousClassDeclaration = enumConstantDeclaration.getAnonymousClassDeclaration();
- assertNotNull("No anonymous class", anonymousClassDeclaration);
- checkSourceRange(anonymousClassDeclaration, "{\n" +
- " @Override\n" +
- " double eval(double x, double y) { return x / y; }\n" +
- " }", source);
- typeBinding = anonymousClassDeclaration.resolveBinding();
- assertNotNull("No binding", typeBinding);
- assertTrue("Not a enum type", typeBinding.isEnum());
- bodyDeclarations = anonymousClassDeclaration.bodyDeclarations();
- assertEquals("wrong size", 1, bodyDeclarations.size());
- bodyDeclaration = (BodyDeclaration) bodyDeclarations.get(0);
- assertEquals("Not a method declaration", ASTNode.FUNCTION_DECLARATION, bodyDeclaration.getNodeType());
- methodDeclaration = (FunctionDeclaration) bodyDeclaration;
- checkSourceRange(methodDeclaration.getName(), "eval", source);
- checkSourceRange(methodDeclaration, "@Override\n double eval(double x, double y) { return x / y; }", source);
- assertEquals("wrong size", 0, enumConstantDeclaration.arguments().size());
- }
-
- public void test0027() throws JavaScriptModelException {
- IJavaScriptUnit sourceUnit = getCompilationUnit("Converter15" , "src", "test0027", "X.js"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- ASTNode result = runJLS3Conversion(sourceUnit, true, true);
- assertTrue("Not a compilation unit", result.getNodeType() == ASTNode.JAVASCRIPT_UNIT);
- JavaScriptUnit compilationUnit = (JavaScriptUnit) result;
- assertProblemsSize(compilationUnit, 0);
- ASTNode node = getASTNode(compilationUnit, 0);
- char[] source = sourceUnit.getSource().toCharArray();
- assertEquals("Not an enum declaration", ASTNode.ENUM_DECLARATION, node.getNodeType());
- EnumDeclaration enumDeclaration = (EnumDeclaration) node;
- List modifiers = enumDeclaration.modifiers();
- assertEquals("Wrong number of modifiers", 1, modifiers.size());
- IExtendedModifier extendedModifier = (IExtendedModifier) modifiers.get(0);
- assertTrue("Not a modifier", extendedModifier instanceof Modifier);
- Modifier modifier = (Modifier) extendedModifier;
- checkSourceRange(modifier, "public", source);
- assertEquals("wrong name", "X", enumDeclaration.getName().getIdentifier());
- List enumConstants = enumDeclaration.enumConstants();
- assertEquals("wrong size", 4, enumConstants.size());
- EnumConstantDeclaration enumConstantDeclaration = (EnumConstantDeclaration) enumConstants.get(0);
- IFunctionBinding methodBinding = enumConstantDeclaration.resolveConstructorBinding();
- assertNotNull("No binding", methodBinding);
- assertTrue("Not a constructor", methodBinding.isConstructor());
- checkSourceRange(enumConstantDeclaration.getName(), "PENNY", source);
- checkSourceRange(enumConstantDeclaration, "PENNY(1)", source);
- List arguments = enumConstantDeclaration.arguments();
- assertEquals("wrong size", 1, arguments.size());
- Expression argument = (Expression) arguments.get(0);
- checkSourceRange(argument, "1", source);
- assertEquals("not an number literal", ASTNode.NUMBER_LITERAL, argument.getNodeType());
- IVariableBinding binding = enumConstantDeclaration.resolveVariable();
- assertNotNull("No binding", binding);
- assertEquals("Wrong name", "PENNY", binding.getName());
- ASTNode node2 = compilationUnit.findDeclaringNode(binding);
- assertTrue("Different node", node2 == enumConstantDeclaration);
-
- enumConstantDeclaration = (EnumConstantDeclaration) enumConstants.get(1);
- methodBinding = enumConstantDeclaration.resolveConstructorBinding();
- assertNotNull("No binding", methodBinding);
- assertTrue("Not a constructor", methodBinding.isConstructor());
- checkSourceRange(enumConstantDeclaration.getName(), "NICKEL", source);
- checkSourceRange(enumConstantDeclaration, "NICKEL(5)", source);
- arguments = enumConstantDeclaration.arguments();
- assertEquals("wrong size", 1, arguments.size());
- argument = (Expression) arguments.get(0);
- checkSourceRange(argument, "5", source);
- assertEquals("not an number literal", ASTNode.NUMBER_LITERAL, argument.getNodeType());
- binding = enumConstantDeclaration.resolveVariable();
- assertNotNull("No binding", binding);
- assertEquals("Wrong name", "NICKEL", binding.getName());
-
- enumConstantDeclaration = (EnumConstantDeclaration) enumConstants.get(2);
- methodBinding = enumConstantDeclaration.resolveConstructorBinding();
- assertNotNull("No binding", methodBinding);
- assertTrue("Not a constructor", methodBinding.isConstructor());
- checkSourceRange(enumConstantDeclaration.getName(), "DIME", source);
- checkSourceRange(enumConstantDeclaration, "DIME(10)", source);
- arguments = enumConstantDeclaration.arguments();
- assertEquals("wrong size", 1, arguments.size());
- argument = (Expression) arguments.get(0);
- checkSourceRange(argument, "10", source);
- assertEquals("not an number literal", ASTNode.NUMBER_LITERAL, argument.getNodeType());
- binding = enumConstantDeclaration.resolveVariable();
- assertNotNull("No binding", binding);
- assertEquals("Wrong name", "DIME", binding.getName());
-
-
- enumConstantDeclaration = (EnumConstantDeclaration) enumConstants.get(3);
- methodBinding = enumConstantDeclaration.resolveConstructorBinding();
- assertNotNull("No binding", methodBinding);
- checkSourceRange(enumConstantDeclaration.getName(), "QUARTER", source);
- checkSourceRange(enumConstantDeclaration, "QUARTER(25)", source);
- arguments = enumConstantDeclaration.arguments();
- assertEquals("wrong size", 1, arguments.size());
- argument = (Expression) arguments.get(0);
- checkSourceRange(argument, "25", source);
- assertEquals("not an number literal", ASTNode.NUMBER_LITERAL, argument.getNodeType());
- binding = enumConstantDeclaration.resolveVariable();
- assertNotNull("No binding", binding);
- assertEquals("Wrong name", "QUARTER", binding.getName());
- }
public void test0028() throws JavaScriptModelException {
IJavaScriptUnit sourceUnit = getCompilationUnit("Converter15" , "src", "test0028", "X.js"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
@@ -1501,65 +1181,6 @@
assertProblemsSize(compilationUnit, 0);
}
- /**
- * Test for https://bugs.eclipse.org/bugs/show_bug.cgi?id=73561
- */
- public void test0048() throws JavaScriptModelException {
- IJavaScriptUnit sourceUnit = getCompilationUnit("Converter15" , "src", "test0048", "X.js"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runJLS3Conversion(sourceUnit, true, true);
- assertNotNull(result);
- assertTrue("Not a compilation unit", result.getNodeType() == ASTNode.JAVASCRIPT_UNIT);
- JavaScriptUnit compilationUnit = (JavaScriptUnit) result;
- assertProblemsSize(compilationUnit, 0);
- ASTNode node = getASTNode(compilationUnit, 0);
- assertEquals("Not an enum declaration", ASTNode.ENUM_DECLARATION, node.getNodeType());
- EnumDeclaration enumDeclaration = (EnumDeclaration) node;
- List enumConstants = enumDeclaration.enumConstants();
- assertEquals("wrong size", 2, enumConstants.size());
- EnumConstantDeclaration enumConstantDeclaration = (EnumConstantDeclaration) enumConstants.get(0);
- IFunctionBinding methodBinding = enumConstantDeclaration.resolveConstructorBinding();
- assertNotNull("No binding", methodBinding);
- assertTrue("Not a constructor", methodBinding.isConstructor());
- checkSourceRange(enumConstantDeclaration, "GREEN(0, 1)", source);
- checkSourceRange(enumConstantDeclaration.getName(), "GREEN", source);
- enumConstantDeclaration = (EnumConstantDeclaration) enumConstants.get(1);
- methodBinding = enumConstantDeclaration.resolveConstructorBinding();
- assertNotNull("No binding", methodBinding);
- assertTrue("Not a constructor", methodBinding.isConstructor());
- checkSourceRange(enumConstantDeclaration.getName(), "RED", source);
- checkSourceRange(enumConstantDeclaration, "RED()", source);
- }
-
- /**
- * Test for https://bugs.eclipse.org/bugs/show_bug.cgi?id=73561
- */
- public void test0049() throws JavaScriptModelException {
- IJavaScriptUnit sourceUnit = getCompilationUnit("Converter15" , "src", "test0049", "X.js"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runJLS3Conversion(sourceUnit, true, true);
- assertNotNull(result);
- assertTrue("Not a compilation unit", result.getNodeType() == ASTNode.JAVASCRIPT_UNIT);
- JavaScriptUnit compilationUnit = (JavaScriptUnit) result;
- assertProblemsSize(compilationUnit, 0);
- ASTNode node = getASTNode(compilationUnit, 0);
- assertEquals("Not an enum declaration", ASTNode.ENUM_DECLARATION, node.getNodeType());
- EnumDeclaration enumDeclaration = (EnumDeclaration) node;
- List enumConstants = enumDeclaration.enumConstants();
- assertEquals("wrong size", 2, enumConstants.size());
- EnumConstantDeclaration enumConstantDeclaration = (EnumConstantDeclaration) enumConstants.get(0);
- IFunctionBinding methodBinding = enumConstantDeclaration.resolveConstructorBinding();
- assertNotNull("No binding", methodBinding);
- assertTrue("Not a constructor", methodBinding.isConstructor());
- checkSourceRange(enumConstantDeclaration, "GREEN(0, 1)", source);
- checkSourceRange(enumConstantDeclaration.getName(), "GREEN", source);
- enumConstantDeclaration = (EnumConstantDeclaration) enumConstants.get(1);
- methodBinding = enumConstantDeclaration.resolveConstructorBinding();
- assertNotNull("No binding", methodBinding);
- assertTrue("Not a constructor", methodBinding.isConstructor());
- checkSourceRange(enumConstantDeclaration.getName(), "RED", source);
- checkSourceRange(enumConstantDeclaration, "RED", source);
- }
/**
* Ellipsis
@@ -1626,54 +1247,7 @@
JavaScriptUnit compilationUnit = (JavaScriptUnit) result;
assertProblemsSize(compilationUnit, 0);
}
-
- /**
- * https://bugs.eclipse.org/bugs/show_bug.cgi?id=76100
- */
- public void test0053() throws JavaScriptModelException {
- IJavaScriptUnit sourceUnit = getCompilationUnit("Converter15" , "src", "test0053", "X.js"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- ASTNode result = runJLS3Conversion(sourceUnit, true, true);
- assertNotNull(result);
- assertTrue("Not a compilation unit", result.getNodeType() == ASTNode.JAVASCRIPT_UNIT);
- JavaScriptUnit compilationUnit = (JavaScriptUnit) result;
- assertProblemsSize(compilationUnit, 0);
- ASTNode node = getASTNode(compilationUnit, 0);
- assertEquals("Not an annotation type declaration", ASTNode.ANNOTATION_TYPE_DECLARATION, node.getNodeType());
- AnnotationTypeDeclaration annotationTypeDeclaration = (AnnotationTypeDeclaration) node;
- assertNotNull("No javadoc", annotationTypeDeclaration.getJavadoc());
- }
-
- /**
- * https://bugs.eclipse.org/bugs/show_bug.cgi?id=76100
- */
- public void test0054() throws JavaScriptModelException {
- IJavaScriptUnit sourceUnit = getCompilationUnit("Converter15" , "src", "test0054", "X.js"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- ASTNode result = runJLS3Conversion(sourceUnit, true, true);
- assertNotNull(result);
- assertTrue("Not a compilation unit", result.getNodeType() == ASTNode.JAVASCRIPT_UNIT);
- JavaScriptUnit compilationUnit = (JavaScriptUnit) result;
- assertProblemsSize(compilationUnit, 0);
- ASTNode node = getASTNode(compilationUnit, 0);
- assertEquals("Not an annotation type declaration", ASTNode.ENUM_DECLARATION, node.getNodeType());
- EnumDeclaration enumDeclaration = (EnumDeclaration) node;
- assertNotNull("No javadoc", enumDeclaration.getJavadoc());
- }
-
- /**
- * https://bugs.eclipse.org/bugs/show_bug.cgi?id=76100
- */
- public void test0055() throws JavaScriptModelException {
- IJavaScriptUnit sourceUnit = getCompilationUnit("Converter15" , "src", "test0055", "X.js"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- ASTNode result = runJLS3Conversion(sourceUnit, true, true);
- assertNotNull(result);
- assertTrue("Not a compilation unit", result.getNodeType() == ASTNode.JAVASCRIPT_UNIT);
- JavaScriptUnit compilationUnit = (JavaScriptUnit) result;
- assertProblemsSize(compilationUnit, 0);
- ASTNode node = getASTNode(compilationUnit, 0);
- assertEquals("Not an annotation type declaration", ASTNode.ANNOTATION_TYPE_DECLARATION, node.getNodeType());
- AnnotationTypeDeclaration annotationTypeDeclaration = (AnnotationTypeDeclaration) node;
- assertNotNull("No javadoc", annotationTypeDeclaration.getJavadoc());
- }
+
/**
*
@@ -1689,25 +1263,6 @@
}
/**
- * https://bugs.eclipse.org/bugs/show_bug.cgi?id=77175
- */
- public void test0057() throws JavaScriptModelException {
- IJavaScriptUnit sourceUnit = getCompilationUnit("Converter15" , "src", "test0057", "X.js"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- ASTNode result = runJLS3Conversion(sourceUnit, true, true);
- assertNotNull(result);
- assertTrue("Not a compilation unit", result.getNodeType() == ASTNode.JAVASCRIPT_UNIT);
- JavaScriptUnit compilationUnit = (JavaScriptUnit) result;
- assertProblemsSize(compilationUnit, 0);
- ASTNode node = getASTNode(compilationUnit, 0);
- assertEquals("Not an enum declaration", ASTNode.ENUM_DECLARATION, node.getNodeType());
- EnumDeclaration enumDeclaration = (EnumDeclaration) node;
- ITypeBinding typeBinding = enumDeclaration.resolveBinding();
- assertNotNull("No binding", typeBinding);
- assertTrue("Not an enum type", typeBinding.isEnum());
- assertTrue("Not a top level type", typeBinding.isTopLevel());
- }
-
- /**
* https://bugs.eclipse.org/bugs/show_bug.cgi?id=77249
*/
public void test0058() throws JavaScriptModelException {
@@ -2774,33 +2329,6 @@
});
}
- /*
- * Check bindings for annotation type declaration
- */
- public void test0091() throws JavaScriptModelException {
- this.workingCopy = getWorkingCopy("/Converter15/src/p/X.js", true/*resolve*/);
- ASTNode node = buildAST(
- "package p;\n" +
- "@interface X {\n" +
- " int id() default 0;\n" +
- "}",
- this.workingCopy);
- assertEquals("Not a compilation unit", ASTNode.JAVASCRIPT_UNIT, node.getNodeType());
- JavaScriptUnit compilationUnit = (JavaScriptUnit) node;
- node = getASTNode(compilationUnit, 0);
- assertEquals("Not an annotation type declaration", ASTNode.ANNOTATION_TYPE_DECLARATION, node.getNodeType());
- AnnotationTypeDeclaration annotationTypeDeclaration = (AnnotationTypeDeclaration) node;
- ITypeBinding binding = annotationTypeDeclaration.resolveBinding();
- assertNotNull("No binding", binding);
- assertTrue("Not an annotation", binding.isAnnotation());
- assertEquals("Wrong name", "X", binding.getName());
- node = getASTNode(compilationUnit, 0, 0);
- assertEquals("Not an annotation type member declaration", ASTNode.ANNOTATION_TYPE_MEMBER_DECLARATION, node.getNodeType());
- AnnotationTypeMemberDeclaration memberDeclaration = (AnnotationTypeMemberDeclaration) node;
- IFunctionBinding methodBinding = memberDeclaration.resolveBinding();
- assertNotNull("No binding", methodBinding);
- assertEquals("Wrong name", "id", methodBinding.getName());
- }
/*
* https://bugs.eclipse.org/bugs/show_bug.cgi?id=80960
@@ -2859,35 +2387,6 @@
assertNotNull("No java element", element);
}
-
- public void test0094() throws JavaScriptModelException {
- String contents =
- "import java.lang.annotation.Target;\n" +
- "import java.lang.annotation.Retention;\n" +
- "\n" +
- "@Retention(RetentionPolicy.SOURCE)\n" +
- "@Target(ElementType.METHOD)\n" +
- "@interface ThrowAwayMethod {\n" +
- "\n" +
- " /**\n" +
- " * Comment for <code>test</code>\n" +
- " */\n" +
- " protected final Test test;\n" +
- "\n" +
- " /**\n" +
- " * @param test\n" +
- " */\n" +
- " ThrowAwayMethod(Test test) {\n" +
- " this.test= test;\n" +
- " }\n" +
- "}";
- this.workingCopy = getWorkingCopy("/Converter15/src/ThrowAwayMethod.js", true/*resolve*/);
- ASTNode node = buildAST(
- contents,
- this.workingCopy,
- false);
- assertEquals("Not a compilation unit", ASTNode.JAVASCRIPT_UNIT, node.getNodeType());
- }
/*
* Ensures that resolving a generic method with a non existing parameter type doesn't throw a NPE when computing its binding key.
@@ -2908,85 +2407,7 @@
binding);
}
- /*
- * https://bugs.eclipse.org/bugs/show_bug.cgi?id=82140
- */
- public void test0096() throws JavaScriptModelException {
- String contents =
- "public @interface An1 {\n" +
- " String value();\n" +
- " String item() default \"Hello\";\n" +
- "\n" +
- "}\n" +
- "\n" +
- "@An1(value=\"X\") class A {\n" +
- " \n" +
- "}";
- this.workingCopy = getWorkingCopy("/Converter15/src/An1.js", true/*resolve*/);
- ASTNode node = buildAST(
- contents,
- this.workingCopy);
- assertEquals("Not a compilation unit", ASTNode.JAVASCRIPT_UNIT, node.getNodeType());
- JavaScriptUnit compilationUnit = (JavaScriptUnit) node;
- node = getASTNode(compilationUnit, 1);
- assertEquals("Not a type declaration", ASTNode.TYPE_DECLARATION, node.getNodeType());
- TypeDeclaration typeDeclaration = (TypeDeclaration) node;
- assertEquals("Wrong name", "A", typeDeclaration.getName().getIdentifier());
- List modifiers = typeDeclaration.modifiers();
- assertEquals("Wrong size", 1, modifiers.size());
- IExtendedModifier modifier = (IExtendedModifier) modifiers.get(0);
- assertTrue("Not an annotation", modifier instanceof Annotation);
- checkSourceRange((Annotation) modifier, "@An1(value=\"X\")", contents.toCharArray());
- }
- /*
- * https://bugs.eclipse.org/bugs/show_bug.cgi?id=82140
- */
- public void test0097() throws JavaScriptModelException {
- String contents =
- "@interface An1 {}\n" +
- "@interface An2 {}\n" +
- "@interface An3 {}\n" +
- "@An2 class X {\n" +
- " @An1 Object o;\n" +
- " @An3 void foo() {\n" +
- " \n" +
- " }\n" +
- "}";
- this.workingCopy = getWorkingCopy("/Converter15/src/X.js", true/*resolve*/);
- ASTNode node = buildAST(
- contents,
- this.workingCopy);
- assertEquals("Not a compilation unit", ASTNode.JAVASCRIPT_UNIT, node.getNodeType());
- JavaScriptUnit compilationUnit = (JavaScriptUnit) node;
- assertProblemsSize(compilationUnit, 0);
- node = getASTNode(compilationUnit, 3);
- assertEquals("Not a type declaration", ASTNode.TYPE_DECLARATION, node.getNodeType());
- TypeDeclaration typeDeclaration = (TypeDeclaration) node;
- List modifiers = typeDeclaration.modifiers();
- assertEquals("Wrong size", 1, modifiers.size());
- IExtendedModifier modifier = (IExtendedModifier) modifiers.get(0);
- assertTrue("Not an annotation", modifier instanceof Annotation);
- checkSourceRange((Annotation) modifier, "@An2", contents.toCharArray());
-
- node = getASTNode(compilationUnit, 3, 0);
- assertEquals("Not a field declaration", ASTNode.FIELD_DECLARATION, node.getNodeType());
- FieldDeclaration fieldDeclaration = (FieldDeclaration) node;
- modifiers = fieldDeclaration.modifiers();
- assertEquals("Wrong size", 1, modifiers.size());
- modifier = (IExtendedModifier) modifiers.get(0);
- assertTrue("Not an annotation", modifier instanceof Annotation);
- checkSourceRange((Annotation) modifier, "@An1", contents.toCharArray());
-
- node = getASTNode(compilationUnit, 3, 1);
- assertEquals("Not a field declaration", ASTNode.FUNCTION_DECLARATION, node.getNodeType());
- FunctionDeclaration methodDeclaration = (FunctionDeclaration) node;
- modifiers = methodDeclaration.modifiers();
- assertEquals("Wrong size", 1, modifiers.size());
- modifier = (IExtendedModifier) modifiers.get(0);
- assertTrue("Not an annotation", modifier instanceof Annotation);
- checkSourceRange((Annotation) modifier, "@An3", contents.toCharArray());
- }
/*
* https://bugs.eclipse.org/bugs/show_bug.cgi?id=82140
@@ -3009,120 +2430,7 @@
assertEquals("Wrong size", 0, modifiers.size());
}
- /*
- * https://bugs.eclipse.org/bugs/show_bug.cgi?id=82141
- */
- public void test0099() throws JavaScriptModelException {
- String contents =
- "public class X {\n" +
- " @Override @Annot(value=\"Hello\") public String toString() {\n" +
- " return super.toString();\n" +
- " }\n" +
- " @Annot(\"Hello\") void bar() {\n" +
- " }\n" +
- " @interface Annot {\n" +
- " String value();\n" +
- " }\n" +
- "}";
- this.workingCopy = getWorkingCopy("/Converter15/src/X.js", true/*resolve*/);
- ASTNode node = buildAST(
- contents,
- this.workingCopy);
- assertEquals("Not a compilation unit", ASTNode.JAVASCRIPT_UNIT, node.getNodeType());
- JavaScriptUnit compilationUnit = (JavaScriptUnit) node;
- assertProblemsSize(compilationUnit, 0);
- node = getASTNode(compilationUnit, 0, 0);
- assertEquals("Not a method declaration", ASTNode.FUNCTION_DECLARATION, node.getNodeType());
- FunctionDeclaration methodDeclaration = (FunctionDeclaration) node;
- List modifiers = methodDeclaration.modifiers();
- assertEquals("Wrong size", 3, modifiers.size());
- IExtendedModifier modifier = (IExtendedModifier) modifiers.get(0);
- assertTrue("Wrong type", modifier instanceof Annotation);
- Annotation annotation = (Annotation) modifier;
- ITypeBinding binding = annotation.resolveTypeBinding();
- assertNotNull("No binding", binding);
-
- modifier = (IExtendedModifier) modifiers.get(1);
- assertTrue("Wrong type", modifier instanceof Annotation);
- annotation = (Annotation) modifier;
- binding = annotation.resolveTypeBinding();
- assertNotNull("No binding", binding);
- assertEquals("Wrong type", ASTNode.NORMAL_ANNOTATION, annotation.getNodeType());
- NormalAnnotation normalAnnotation = (NormalAnnotation) annotation;
- List values = normalAnnotation.values();
- assertEquals("wrong size", 1, values.size());
- MemberValuePair valuePair = (MemberValuePair) values.get(0);
- SimpleName name = valuePair.getName();
- IBinding binding2 = name.resolveBinding();
- assertNotNull("No binding", binding2);
- ITypeBinding typeBinding = name.resolveTypeBinding();
- assertNotNull("No binding", typeBinding);
-
- node = getASTNode(compilationUnit, 0, 1);
- assertEquals("Not a method declaration", ASTNode.FUNCTION_DECLARATION, node.getNodeType());
- methodDeclaration = (FunctionDeclaration) node;
- modifiers = methodDeclaration.modifiers();
- assertEquals("Wrong size", 1, modifiers.size());
- modifier = (IExtendedModifier) modifiers.get(0);
- assertTrue("Wrong type", modifier instanceof Annotation);
- annotation = (Annotation) modifier;
- binding = annotation.resolveTypeBinding();
- assertNotNull("No binding", binding);
- }
- /*
- * https://bugs.eclipse.org/bugs/show_bug.cgi?id=82216
- */
- public void test0100() throws JavaScriptModelException {
- String contents =
- "public enum E {\n" +
- " A, B, C;\n" +
- " public static final E D = B;\n" +
- " public static final String F = \"Hello\";\n" +
- "}";
- this.workingCopy = getWorkingCopy("/Converter15/src/E.js", true/*resolve*/);
- ASTNode node = buildAST(
- contents,
- this.workingCopy);
- assertEquals("Not a compilation unit", ASTNode.JAVASCRIPT_UNIT, node.getNodeType());
- JavaScriptUnit compilationUnit = (JavaScriptUnit) node;
- assertProblemsSize(compilationUnit, 0);
- node = getASTNode(compilationUnit, 0);
- assertEquals("Not an enum declaration", ASTNode.ENUM_DECLARATION, node.getNodeType());
- EnumDeclaration enumDeclaration = (EnumDeclaration) node;
- List enumConstants = enumDeclaration.enumConstants();
- assertEquals("wrong size", 3, enumConstants.size());
- EnumConstantDeclaration enumConstantDeclaration = (EnumConstantDeclaration) enumConstants.get(0);
- IFunctionBinding methodBinding = enumConstantDeclaration.resolveConstructorBinding();
- assertNotNull("No binding", methodBinding);
- assertTrue("Not a constructor", methodBinding.isConstructor());
- IVariableBinding variableBinding = enumConstantDeclaration.resolveVariable();
- assertNotNull("no binding", variableBinding);
- assertNull("is constant", variableBinding.getConstantValue());
- assertTrue("Not an enum constant", variableBinding.isEnumConstant());
-
- node = getASTNode(compilationUnit, 0, 0);
- assertEquals("Not a field declaration", ASTNode.FIELD_DECLARATION, node.getNodeType());
- FieldDeclaration fieldDeclaration = (FieldDeclaration) node;
- List fragments = fieldDeclaration.fragments();
- assertEquals("Wrong size", 1, fragments.size());
- VariableDeclarationFragment fragment = (VariableDeclarationFragment) fragments.get(0);
- assertEquals("wrong name", "D", fragment.getName().getIdentifier());
- variableBinding = fragment.resolveBinding();
- assertNotNull("no binding", variableBinding);
- assertFalse("An enum constant", variableBinding.isEnumConstant());
-
- node = getASTNode(compilationUnit, 0, 1);
- assertEquals("Not a field declaration", ASTNode.FIELD_DECLARATION, node.getNodeType());
- fieldDeclaration = (FieldDeclaration) node;
- fragments = fieldDeclaration.fragments();
- assertEquals("Wrong size", 1, fragments.size());
- fragment = (VariableDeclarationFragment) fragments.get(0);
- assertEquals("wrong name", "F", fragment.getName().getIdentifier());
- variableBinding = fragment.resolveBinding();
- assertNotNull("no binding", variableBinding);
- assertNotNull("is constant", variableBinding.getConstantValue());
- }
/*
* https://bugs.eclipse.org/bugs/show_bug.cgi?id=68823
@@ -3275,180 +2583,9 @@
assertTrue("Wrong type", kind == IBinding.VARIABLE || kind == IBinding.METHOD);
}
- /*
- * https://bugs.eclipse.org/bugs/show_bug.cgi?id=83011
- */
- public void test0105() throws JavaScriptModelException {
- String contents =
- "@interface Ann {}\n" +
- "\n" +
- "@Ann public class X {}\n";
- this.workingCopy = getWorkingCopy("/Converter15/src/X.js", true/*resolve*/);
- ASTNode node = buildAST(
- contents,
- this.workingCopy);
- assertEquals("Not a compilation unit", ASTNode.JAVASCRIPT_UNIT, node.getNodeType());
- JavaScriptUnit compilationUnit = (JavaScriptUnit) node;
- assertProblemsSize(compilationUnit, 0);
- node = getASTNode(compilationUnit, 1);
- assertEquals("Not a type declaration", ASTNode.TYPE_DECLARATION, node.getNodeType());
- TypeDeclaration typeDeclaration = (TypeDeclaration) node;
- List modifiers = typeDeclaration.modifiers();
- assertEquals("Wrong size", 2, modifiers.size());
- IExtendedModifier extendedModifier = (IExtendedModifier) modifiers.get(0);
- assertTrue("Not a marker annotation", extendedModifier instanceof MarkerAnnotation);
- MarkerAnnotation markerAnnotation = (MarkerAnnotation) extendedModifier;
- ITypeBinding binding = markerAnnotation.resolveTypeBinding();
- assertNotNull("No binding", binding);
- Name name = markerAnnotation.getTypeName();
- binding = name.resolveTypeBinding();
- assertNotNull("No binding", binding);
- }
-
- /*
- * https://bugs.eclipse.org/bugs/show_bug.cgi?id=83011
- */
- public void test0106() throws JavaScriptModelException {
- String contents =
- "package p;\n" +
- "@interface Ann {}\n" +
- "\n" +
- "@p.Ann public class X {}\n";
- this.workingCopy = getWorkingCopy("/Converter15/src/p/X.js", true/*resolve*/);
- ASTNode node = buildAST(
- contents,
- this.workingCopy);
- assertEquals("Not a compilation unit", ASTNode.JAVASCRIPT_UNIT, node.getNodeType());
- JavaScriptUnit compilationUnit = (JavaScriptUnit) node;
- assertProblemsSize(compilationUnit, 0);
- node = getASTNode(compilationUnit, 1);
- assertEquals("Not a type declaration", ASTNode.TYPE_DECLARATION, node.getNodeType());
- TypeDeclaration typeDeclaration = (TypeDeclaration) node;
- List modifiers = typeDeclaration.modifiers();
- assertEquals("Wrong size", 2, modifiers.size());
- IExtendedModifier extendedModifier = (IExtendedModifier) modifiers.get(0);
- assertTrue("Not a marker annotation", extendedModifier instanceof MarkerAnnotation);
- MarkerAnnotation markerAnnotation = (MarkerAnnotation) extendedModifier;
- ITypeBinding typeBinding = markerAnnotation.resolveTypeBinding();
- assertNotNull("No binding", typeBinding);
- Name name = markerAnnotation.getTypeName();
- typeBinding = name.resolveTypeBinding();
- assertNotNull("No binding", typeBinding);
- IBinding binding = name.resolveBinding();
- assertNotNull("No binding", binding);
- assertEquals("Wrong kind of binding", IBinding.TYPE, binding.getKind());
- assertEquals("Not a qualified name", ASTNode.QUALIFIED_NAME, name.getNodeType());
- QualifiedName qualifiedName = (QualifiedName) name;
- SimpleName simpleName = qualifiedName.getName();
- binding = simpleName.resolveBinding();
- assertNotNull("No binding", binding);
- name = qualifiedName.getQualifier();
- binding = name.resolveBinding();
- assertNotNull("No binding", binding);
- assertEquals("Wrong kind of binding", IBinding.PACKAGE, binding.getKind());
- }
- /*
- * https://bugs.eclipse.org/bugs/show_bug.cgi?id=83013
- */
- public void test0107() throws JavaScriptModelException {
- String contents =
- "@interface A {\n" +
- " String value() default \"\";\n" +
- "}\n" +
- "@interface Main {\n" +
- " A child() default @A(\"Void\");\n" +
- "}\n" +
- "@Main(child=@A(\"\")) @A class X {}\n";
- this.workingCopy = getWorkingCopy("/Converter15/src/X.js", true/*resolve*/);
- ASTNode node = buildAST(
- contents,
- this.workingCopy);
- assertEquals("Not a compilation unit", ASTNode.JAVASCRIPT_UNIT, node.getNodeType());
- JavaScriptUnit compilationUnit = (JavaScriptUnit) node;
- assertProblemsSize(compilationUnit, 0);
- node = getASTNode(compilationUnit, 2);
- assertEquals("Not a type declaration", ASTNode.TYPE_DECLARATION, node.getNodeType());
- checkSourceRange(node, "@Main(child=@A(\"\")) @A class X {}", contents.toCharArray());
- }
- /*
- * https://bugs.eclipse.org/bugs/show_bug.cgi?id=83228
- */
- public void test0108() throws JavaScriptModelException {
- String contents =
- "class X<E> {\n" +
- " enum Numbers {\n" +
- " ONE {\n" +
- " Numbers getSquare() {\n" +
- " return ONE;\n" +
- " }\n" +
- " };\n" +
- " abstract Numbers getSquare();\n" +
- " }\n" +
- "}\n";
- this.workingCopy = getWorkingCopy("/Converter15/src/X.js", true/*resolve*/);
- ASTNode node = buildAST(
- contents,
- this.workingCopy);
- assertEquals("Not a compilation unit", ASTNode.JAVASCRIPT_UNIT, node.getNodeType());
- JavaScriptUnit compilationUnit = (JavaScriptUnit) node;
- assertProblemsSize(compilationUnit, 0);
- node = getASTNode(compilationUnit, 0, 0);
- EnumDeclaration enumDeclaration = (EnumDeclaration) node;
-
- List bodyDeclarations = enumDeclaration.bodyDeclarations();
- assertEquals("Wrong size", 1, bodyDeclarations.size());
- FunctionDeclaration methodDeclaration = (FunctionDeclaration) bodyDeclarations.get(0);
- Type returnType = methodDeclaration.getReturnType2();
- ITypeBinding typeBinding = returnType.resolveBinding();
- List enumConstants = enumDeclaration.enumConstants();
- assertEquals("Wrong size", 1, enumConstants.size());
- EnumConstantDeclaration constantDeclaration = (EnumConstantDeclaration) enumConstants.get(0);
- AnonymousClassDeclaration anonymousClassDeclaration = constantDeclaration.getAnonymousClassDeclaration();
- assertNotNull("No anonymous", anonymousClassDeclaration);
- bodyDeclarations = anonymousClassDeclaration.bodyDeclarations();
- assertEquals("Wrong size", 1, bodyDeclarations.size());
- BodyDeclaration bodyDeclaration = (BodyDeclaration) bodyDeclarations.get(0);
- assertEquals("Not a method declaration", ASTNode.FUNCTION_DECLARATION, bodyDeclaration.getNodeType());
- methodDeclaration = (FunctionDeclaration) bodyDeclaration;
- Type type = methodDeclaration.getReturnType2();
- assertEquals("Not a simple type", ASTNode.SIMPLE_TYPE, type.getNodeType());
- SimpleType simpleType = (SimpleType) type;
- Name name = simpleType.getName();
- assertEquals("Not a simple name", ASTNode.SIMPLE_NAME, name.getNodeType());
- SimpleName simpleName = (SimpleName) name;
- ITypeBinding typeBinding2 = simpleName.resolveTypeBinding();
-
- assertTrue("Not equals", typeBinding.isEqualTo(typeBinding2));
- assertTrue("Not identical", typeBinding == typeBinding2);
- }
-
- /*
- * https://bugs.eclipse.org/bugs/show_bug.cgi?id=883297
- */
- public void test0109() throws JavaScriptModelException {
- String contents =
- "@Annot(value=\"Hello\", count=-1)\n" +
- "@interface Annot {\n" +
- " String value();\n" +
- " int count();\n" +
- "}";
- this.workingCopy = getWorkingCopy("/Converter15/src/Annot.js", true/*resolve*/);
- ASTNode node = buildAST(
- contents,
- this.workingCopy);
- assertEquals("Not a compilation unit", ASTNode.JAVASCRIPT_UNIT, node.getNodeType());
- JavaScriptUnit compilationUnit = (JavaScriptUnit) node;
- assertProblemsSize(compilationUnit, 0);
- node = getASTNode(compilationUnit, 0);
- AnnotationTypeDeclaration annotationTypeDeclaration = (AnnotationTypeDeclaration) node;
- ITypeBinding typeBinding = annotationTypeDeclaration.resolveBinding();
- assertNotNull("No type binding", typeBinding);
- IFunctionBinding[] methods = typeBinding.getDeclaredMethods();
- assertEquals("Wrong size", 2, methods.length);
- }
/*
* Ensures that the type declaration of a top level type binding is correct.
@@ -4222,47 +3359,6 @@
assertEquals("wrong name", "test0139a", packageBinding.getName());
}
- /**
- * https://bugs.eclipse.org/bugs/show_bug.cgi?id=85115
- * https://bugs.eclipse.org/bugs/show_bug.cgi?id=85215
- */
- public void test0140() throws JavaScriptModelException {
- IJavaScriptUnit sourceUnit = getCompilationUnit("Converter15" , "src", "test0140", "X.js"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- ASTNode result = runJLS3Conversion(sourceUnit, true, false);
- assertNotNull(result);
- assertTrue("Not a compilation unit", result.getNodeType() == ASTNode.JAVASCRIPT_UNIT);
- JavaScriptUnit compilationUnit = (JavaScriptUnit) result;
- assertProblemsSize(compilationUnit, 0);
- ASTNode node = getASTNode(compilationUnit, 0);
- assertNotNull("No node", node);
- assertEquals("Not an enum declaration", ASTNode.ENUM_DECLARATION, node.getNodeType());
- EnumDeclaration enumDeclaration = (EnumDeclaration) node;
- List modifiers = enumDeclaration.modifiers();
- assertEquals("Wrong size", 2, modifiers.size());
- IExtendedModifier modifier = (IExtendedModifier) modifiers.get(0);
- assertTrue("Wrong type", modifier instanceof MarkerAnnotation);
- MarkerAnnotation markerAnnotation = (MarkerAnnotation) modifier;
- ITypeBinding typeBinding = markerAnnotation.resolveTypeBinding();
- assertTrue("Not an annotation", typeBinding.isAnnotation());
- assertTrue("Not a top level type", typeBinding.isTopLevel());
-
- sourceUnit = getCompilationUnit("Converter15" , "src", "test0140", "Annot.js"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- result = runJLS3Conversion(sourceUnit, true, false);
- assertNotNull(result);
- assertTrue("Not a compilation unit", result.getNodeType() == ASTNode.JAVASCRIPT_UNIT);
- compilationUnit = (JavaScriptUnit) result;
- assertProblemsSize(compilationUnit, 0);
- node = getASTNode(compilationUnit, 0);
- assertNotNull("No node", node);
- assertEquals("Not an annotation declaration", ASTNode.ANNOTATION_TYPE_DECLARATION, node.getNodeType());
- AnnotationTypeDeclaration annotationTypeDeclaration = (AnnotationTypeDeclaration) node;
- modifiers = annotationTypeDeclaration.modifiers();
- assertEquals("Wrong size", 1, modifiers.size());
- typeBinding = annotationTypeDeclaration.resolveBinding();
- int modifierValue = typeBinding.getModifiers();
- assertEquals("Type is not public", Modifier.PUBLIC, modifierValue);
- }
-
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=83100
public void test0141() throws CoreException {
this.workingCopy = getWorkingCopy("/Converter15/src/X.js", true/*resolve*/);
@@ -4486,213 +3582,8 @@
assertProblemsSize(compilationUnit, 0);
}
- // https://bugs.eclipse.org/bugs/show_bug.cgi?id=87350
- public void test0148() throws CoreException {
- this.workingCopy = getWorkingCopy("/Converter15/src/X.js", true/*resolve*/);
- String contents =
- "public enum X {\n" +
- " RED, GREEN(), BLUE(17), PINK(1) {/*anon*};\n" +
- " Color() {}\n" +
- " Color(int i) {}\n";
- ASTNode node = buildAST(
- contents,
- this.workingCopy,
- false);
- assertNotNull("No node", node);
- assertEquals("Not a compilation unit", ASTNode.JAVASCRIPT_UNIT, node.getNodeType());
- JavaScriptUnit compilationUnit = (JavaScriptUnit) node;
- String expectedErrors = "The constructor X(int) is undefined\n" +
- "The constructor X(int) is undefined\n" +
- "Unexpected end of comment";
- assertProblemsSize(compilationUnit, 3, expectedErrors);
- }
+
- // https://bugs.eclipse.org/bugs/show_bug.cgi?id=88252
- public void test0149() throws CoreException {
- this.workingCopy = getWorkingCopy("/Converter15/src/X.js", true/*resolve*/);
- String contents =
- " interface Jpf {\n" +
- " @interface Action {\n" +
- " ValidatableProperty[] validatableProperties();\n" +
- " }\n" +
- " \n" +
- " @interface ValidatableProperty {\n" +
- " String propertyName();\n" +
- " ValidationLocaleRules[] localeRules();\n" +
- " }\n" +
- " \n" +
- " @interface ValidationLocaleRules {\n" +
- " ValidateMinLength validateMinLength();\n" +
- " }\n" +
- " \n" +
- " @interface ValidateMinLength {\n" +
- " String chars();\n" +
- " }\n" +
- "}\n" +
- " \n" +
- " public class X {\n" +
- " \n" +
- " @Jpf.Action(\n" +
- " validatableProperties={@Jpf.ValidatableProperty(propertyName=\"fooField\",\n" +
- " localeRules={@Jpf.ValidationLocaleRules(\n" +
- " validateMinLength=@Jpf.ValidateMinLength(chars=\"12\")\n" +
- " )}\n" +
- " )}\n" +
- " )\n" +
- " public String actionForValidationRuleTest() {\n" +
- " return null;\n" +
- " }\n" +
- "}";
- ASTNode node = buildAST(
- contents,
- this.workingCopy);
- assertNotNull("No node", node);
- assertEquals("Not a compilation unit", ASTNode.JAVASCRIPT_UNIT, node.getNodeType());
- JavaScriptUnit compilationUnit = (JavaScriptUnit) node;
- assertProblemsSize(compilationUnit, 0);
- node = getASTNode(compilationUnit, 1, 0);
- assertEquals("Not a method declaration", ASTNode.FUNCTION_DECLARATION, node.getNodeType());
- FunctionDeclaration methodDeclaration = (FunctionDeclaration) node;
- List modifiers = methodDeclaration.modifiers();
- assertEquals("Wrong size", 2, modifiers.size());
- IExtendedModifier modifier = (IExtendedModifier) modifiers.get(0);
- assertTrue("Not a normal annotation", modifier instanceof NormalAnnotation);
- NormalAnnotation annotation = (NormalAnnotation) modifier;
- List values = annotation.values();
- assertEquals("wrong size", 1, values.size());
- MemberValuePair memberValuePair = (MemberValuePair) values.get(0);
- Expression expression = memberValuePair.getValue();
- assertEquals("Not an array initializer", ASTNode.ARRAY_INITIALIZER, expression.getNodeType());
- ArrayInitializer arrayInitializer = (ArrayInitializer) expression;
- List expressions = arrayInitializer.expressions();
- assertEquals("wrong size", 1, expressions.size());
- Expression expression2 = (Expression) expressions.get(0);
- assertEquals("Not a normal annotation", ASTNode.NORMAL_ANNOTATION, expression2.getNodeType());
- NormalAnnotation annotation2 = (NormalAnnotation) expression2;
- values = annotation2.values();
- assertEquals("wrong size", 2, values.size());
- MemberValuePair memberValuePair2 = (MemberValuePair) values.get(1);
- Expression expression3 = memberValuePair2.getValue();
- assertEquals("Not an array initializer", ASTNode.ARRAY_INITIALIZER, expression3.getNodeType());
- arrayInitializer = (ArrayInitializer) expression3;
- expressions = arrayInitializer.expressions();
- assertEquals("wrong size", 1, expressions.size());
- Expression expression4 = (Expression) expressions.get(0);
- assertEquals("Not a normal annotation", ASTNode.NORMAL_ANNOTATION, expression4.getNodeType());
- NormalAnnotation annotation3 = (NormalAnnotation) expression4;
- values = annotation3.values();
- assertEquals("wrong size", 1, values.size());
- MemberValuePair memberValuePair3 = (MemberValuePair) values.get(0);
- Expression expression5 = memberValuePair3.getValue();
- assertEquals("Not a normal annotation", ASTNode.NORMAL_ANNOTATION, expression5.getNodeType());
- NormalAnnotation annotation4 = (NormalAnnotation) expression5;
- checkSourceRange(annotation4, "@Jpf.ValidateMinLength(chars=\"12\")", contents);
- checkSourceRange(memberValuePair3, "validateMinLength=@Jpf.ValidateMinLength(chars=\"12\")", contents);
- }
-
- // https://bugs.eclipse.org/bugs/show_bug.cgi?id=88224
- public void test0150() throws CoreException {
- this.workingCopy = getWorkingCopy("/Converter15/src/X.js", true/*resolve*/);
- String contents =
- "public class X {\n" +
- " void foo() {\n" +
- " class Local {\n" +
- " static enum E {\n" +
- " C, B;\n" +
- " }\n" +
- " }\n" +
- " }\n" +
- " void bar() {\n" +
- " }\n" +
- "}";
- ASTNode node = buildAST(
- contents,
- this.workingCopy,
- false);
- assertNotNull("No node", node);
- assertEquals("Not a compilation unit", ASTNode.JAVASCRIPT_UNIT, node.getNodeType());
- JavaScriptUnit compilationUnit = (JavaScriptUnit) node;
- final String expectedErrors = "The member enum E cannot be local";
- assertProblemsSize(compilationUnit, 1, expectedErrors);
- node = getASTNode(compilationUnit, 0, 0, 0);
- assertEquals("Not a type declaration statement", ASTNode.TYPE_DECLARATION_STATEMENT, node.getNodeType());
- TypeDeclarationStatement typeDeclarationStatement = (TypeDeclarationStatement) node;
- AbstractTypeDeclaration typeDeclaration = typeDeclarationStatement.getDeclaration();
- List bodyDeclarations = typeDeclaration.bodyDeclarations();
- assertEquals("Wrong size", 1, bodyDeclarations.size());
- BodyDeclaration bodyDeclaration = (BodyDeclaration) bodyDeclarations.get(0);
- assertEquals("Not an enum declaration", ASTNode.ENUM_DECLARATION, bodyDeclaration.getNodeType());
- EnumDeclaration enumDeclaration = (EnumDeclaration) bodyDeclaration;
- List enumConstants = enumDeclaration.enumConstants();
- assertEquals("Wrong size", 2, enumConstants.size());
- EnumConstantDeclaration enumConstantDeclaration = (EnumConstantDeclaration) enumConstants.get(0);
- checkSourceRange(enumConstantDeclaration, "C", contents);
- enumConstantDeclaration = (EnumConstantDeclaration) enumConstants.get(1);
- checkSourceRange(enumConstantDeclaration, "B", contents);
- }
-
- // https://bugs.eclipse.org/bugs/show_bug.cgi?id=88548
- public void test0151() throws CoreException {
- this.workingCopy = getWorkingCopy("/Converter15/src/X.js", true/*resolve*/);
- String contents =
- "public enum X {\n" +
- " RED, GREEN(), BLUE(17);\n" +
- " X() {}\n" +
- " X(int i) {}\n" +
- " public static void main(String[] args) {\n" +
- " for (X x : X.values()) {\n" +
- " switch(x) {\n" +
- " case RED :\n" +
- " System.out.println(\"ROUGE\");\n" +
- " break;\n" +
- " case GREEN :\n" +
- " System.out.println(\"VERT\");\n" +
- " break;\n" +
- " case BLUE :\n" +
- " System.out.println(\"BLEU\");\n" +
- " break;\n" +
- " }\n" +
- " }\n" +
- " }\n" +
- "}";
- ASTNode node = buildAST(
- contents,
- this.workingCopy);
- assertNotNull("No node", node);
- assertEquals("Not a compilation unit", ASTNode.JAVASCRIPT_UNIT, node.getNodeType());
- JavaScriptUnit compilationUnit = (JavaScriptUnit) node;
- assertProblemsSize(compilationUnit, 0);
- node = getASTNode(compilationUnit, 0);
- assertEquals("Not an enum declaration", ASTNode.ENUM_DECLARATION, node.getNodeType());
- EnumDeclaration enumDeclaration = (EnumDeclaration) node;
- List bodyDeclarations = enumDeclaration.bodyDeclarations();
- assertEquals("Wrong size", 3, bodyDeclarations.size());
- BodyDeclaration bodyDeclaration = (BodyDeclaration) bodyDeclarations.get(2);
- assertEquals("Not a method declaration", ASTNode.FUNCTION_DECLARATION, bodyDeclaration.getNodeType());
- FunctionDeclaration methodDeclaration = (FunctionDeclaration) bodyDeclaration;
- Block block = methodDeclaration.getBody();
- assertNotNull("No body", block);
- List statements = block.statements();
- assertEquals("Wrong size", 1, statements.size());
- Statement statement = (Statement) statements.get(0);
- assertEquals("Not an enhanced for statement", ASTNode.ENHANCED_FOR_STATEMENT, statement.getNodeType());
- EnhancedForStatement forStatement = (EnhancedForStatement) statement;
- Statement statement2 = forStatement.getBody();
- assertEquals("Not a block", ASTNode.BLOCK, statement2.getNodeType());
- Block block2 = (Block) statement2;
- statements = block2.statements();
- assertEquals("Wrong size", 1, statements.size());
- statement = (Statement) statements.get(0);
- assertEquals("Not a switch statement", ASTNode.SWITCH_STATEMENT, statement.getNodeType());
- SwitchStatement switchStatement = (SwitchStatement) statement;
- statements = switchStatement.statements();
- assertEquals("Wrong size", 9, statements.size());
- statement = (Statement) statements.get(0);
- assertEquals("Not a switch case statement", ASTNode.SWITCH_CASE, statement.getNodeType());
- SwitchCase switchCase = (SwitchCase) statement;
- Expression expression = switchCase.getExpression();
- assertNull("Got a constant", expression.resolveConstantExpressionValue());
- }
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=88548
public void test0152() throws CoreException {
@@ -5459,27 +4350,6 @@
checkSourceRange(wildcardType, "? super java.lang.Number", contents);
}
- /*
- * https://bugs.eclipse.org/bugs/show_bug.cgi?id=93075
- */
- public void test0179() throws CoreException {
- this.workingCopy = getWorkingCopy("/Converter15/src/X.js", true/*resolve*/);
- String contents =
- "@interface Test {}\n" +
- "public enum X\n" +
- "{\n" +
- " /*start*/@Test HISTORY/*end*/\n" +
- "}";
- ASTNode node = buildAST(
- contents,
- this.workingCopy);
- assertEquals("Not an enum constant declaration", ASTNode.ENUM_CONSTANT_DECLARATION, node.getNodeType());
- EnumConstantDeclaration constantDeclaration = (EnumConstantDeclaration) node;
- List modifiers = constantDeclaration.modifiers();
- assertEquals("Wrong size", 1, modifiers.size());
- IExtendedModifier modifier = (IExtendedModifier) modifiers.get(0);
- assertTrue("Not a marker annotation", modifier instanceof MarkerAnnotation);
- }
/*
* https://bugs.eclipse.org/bugs/show_bug.cgi?id=92360
@@ -6136,46 +5006,7 @@
assertTrue("not a primitive type", type.isPrimitiveType());
}
- /*
- * https://bugs.eclipse.org/bugs/show_bug.cgi?id=110657
- */
- public void test0202() throws CoreException {
- this.workingCopy = getWorkingCopy("/Converter15/src/X.js", true/*resolve*/);
- final String source = "public class X {\n" +
- " public static void main(String[] args) {\n" +
- " byte[] b1 = new byte[0];\n" +
- " byte[] b2 = new byte[0];\n" +
- " for (@Ann final byte bs[] : new byte[][] { b1, b2 }) {\n" +
- " System.out.println(bs);\n" +
- " }\n" +
- " }\n" +
- "}\n" +
- "@interface Ann {}";
- ASTNode node = buildAST(
- source,
- this.workingCopy,
- false);
- assertEquals("Not a compilation unit", ASTNode.JAVASCRIPT_UNIT, node.getNodeType());
- JavaScriptUnit compilationUnit = (JavaScriptUnit) node;
- assertProblemsSize(compilationUnit, 0);
- node = getASTNode(compilationUnit, 0, 0, 2);
- assertEquals("Not an enhanced for statement", ASTNode.ENHANCED_FOR_STATEMENT, node.getNodeType());
- EnhancedForStatement forStatement = (EnhancedForStatement) node;
- final SingleVariableDeclaration parameter = forStatement.getParameter();
- final Type type = parameter.getType();
- assertEquals("Wrong extended dimension", 1, parameter.getExtraDimensions());
- checkSourceRange(type, "byte", source);
- checkSourceRange(parameter, "@Ann final byte bs[]", source);
- assertTrue("not a primitive type", type.isPrimitiveType());
- List modifiers = parameter.modifiers();
- assertEquals("Wrong size", 2, modifiers.size());
- final ASTNode modifier1 = ((ASTNode) modifiers.get(0));
- assertEquals("Not an annotation", ASTNode.MARKER_ANNOTATION, modifier1.getNodeType());
- final ASTNode modifier2 = ((ASTNode) modifiers.get(1));
- assertEquals("Not a modifier", ASTNode.MODIFIER, modifier2.getNodeType());
- checkSourceRange(modifier1, "@Ann", source);
- checkSourceRange(modifier2, "final", source);
- }
+
/*
* https://bugs.eclipse.org/bugs/show_bug.cgi?id=80472
*/
@@ -6249,44 +5080,6 @@
assertFalse("Declaration and reference keys should not be the same", bindings[0].getKey().equals(bindings[1].getKey()));
}
- /*
- * https://bugs.eclipse.org/bugs/show_bug.cgi?id=120263
- */
- public void test0206() throws JavaScriptModelException {
- this.workingCopy = getWorkingCopy("/Converter15/src/X.js", true/*resolve*/);
- String contents =
- "public class X {\n" +
- " public @interface Annot {\n" +
- " }\n" +
- " @Annot(newAttrib= {1, 2})\n" +
- " public void foo() {\n" +
- " }\n" +
- "}";
- ASTNode node = buildAST(
- contents,
- this.workingCopy,
- false);
- assertNotNull("No node", node);
- assertEquals("Not a compilation unit", ASTNode.JAVASCRIPT_UNIT, node.getNodeType());
- JavaScriptUnit compilationUnit = (JavaScriptUnit) node;
- assertProblemsSize(compilationUnit, 1, "The attribute newAttrib is undefined for the annotation type X.Annot");
- node = getASTNode(compilationUnit, 0, 1);
- assertEquals("Not a method declaration", ASTNode.FUNCTION_DECLARATION, node.getNodeType());
- FunctionDeclaration methodDeclaration = (FunctionDeclaration) node;
- List modifiers = methodDeclaration.modifiers();
- assertEquals("Wrong size", 2, modifiers.size());
- IExtendedModifier extendedModifier = (IExtendedModifier) modifiers.get(0);
- assertTrue("Not a normal annotation", extendedModifier instanceof NormalAnnotation);
- NormalAnnotation annotation = (NormalAnnotation) extendedModifier;
- List values = annotation.values();
- assertEquals("Wrong size", 1, values.size());
- MemberValuePair memberValuePair = (MemberValuePair) values.get(0);
- Expression value = memberValuePair.getValue();
- assertEquals("Not an array initializer", ASTNode.ARRAY_INITIALIZER, value.getNodeType());
- ArrayInitializer arrayInitializer = (ArrayInitializer) value;
- ITypeBinding typeBinding = arrayInitializer.resolveTypeBinding();
- assertNotNull("No binding", typeBinding);
- }
/*
* https://bugs.eclipse.org/bugs/show_bug.cgi?id=124716
@@ -6313,88 +5106,9 @@
ClassInstanceCreation classInstanceCreation = (ClassInstanceCreation) expression;
IFunctionBinding binding = classInstanceCreation.resolveConstructorBinding();
assertNotNull("Should not be null", binding);
- IAnnotationBinding[] annotations = binding.getAnnotations();
- assertNotNull("Should not be null", annotations);
- assertEquals("Should be empty", 0, annotations.length);
}
- /*
- * https://bugs.eclipse.org/bugs/show_bug.cgi?id=125807
- */
- public void test0208() throws JavaScriptModelException {
- this.workingCopy = getWorkingCopy("/Converter15/src/X.js", true/*resolve*/);
- String contents =
- "@Override(x= 1)\n" +
- "public class X { }";
- ASTNode node = buildAST(
- contents,
- this.workingCopy,
- false);
- assertNotNull("No node", node);
- assertEquals("Not a compilation unit", ASTNode.JAVASCRIPT_UNIT, node.getNodeType());
- JavaScriptUnit compilationUnit = (JavaScriptUnit) node;
- String problems =
- "The annotation @Override is disallowed for this location\n" +
- "The attribute x is undefined for the annotation type Override";
- assertProblemsSize(compilationUnit, 2, problems);
- node = getASTNode(compilationUnit, 0);
- assertEquals("Not a type declaration", ASTNode.TYPE_DECLARATION, node.getNodeType());
- TypeDeclaration typeDeclaration = (TypeDeclaration) node;
- List modifiers = typeDeclaration.modifiers();
- assertEquals("Wrong size", 2, modifiers.size());
- assertTrue("Wrong type", modifiers.get(0) instanceof NormalAnnotation);
- NormalAnnotation normalAnnotation = (NormalAnnotation) modifiers.get(0);
- IAnnotationBinding annotationBinding = normalAnnotation.resolveAnnotationBinding();
- IMemberValuePairBinding[] pairs = annotationBinding.getDeclaredMemberValuePairs();
- assertEquals("Wrong size", 1, pairs.length);
- assertNotNull("Should not be null", pairs[0].getValue());
- }
- public void test0209() throws JavaScriptModelException {
- this.workingCopy = getWorkingCopy("/Converter15/src/test/V.js", true/*resolve*/);
- String contents =
- "package test;\n" +
- "import pack.*;\n" +
- "public class V {\n" +
- " void bar() {\n" +
- " }\n" +
- " void foo() {\n" +
- " @A3(\n" +
- " annot = @A2(\n" +
- " annot = @A1(value = E.CV, list = new E[] { E.CAV, E.CAV}, clazz = E.class),\n" +
- " value = E.CV,\n" +
- " list = new E[] { E.CAV, E.CAV},\n" +
- " clazz = E.class),\n" +
- " value = E.CV,\n" +
- " list = new E[] { E.CAV, E.CAV},\n" +
- " clazz = E.class)\n" +
- " int x = 0;\n" +
- " System.out.println(x);\n" +
- " System.out.println(x + 1);\n" +
- " }\n" +
- "}";
- ASTNode node = buildAST(
- contents,
- this.workingCopy,
- false);
- assertNotNull("No node", node);
- assertEquals("Not a compilation unit", ASTNode.JAVASCRIPT_UNIT, node.getNodeType());
- JavaScriptUnit compilationUnit = (JavaScriptUnit) node;
- String problems =
- "The value for annotation attribute A1.list must be an array initializer\n" +
- "The value for annotation attribute A2.list must be an array initializer\n" +
- "The value for annotation attribute A3.list must be an array initializer";
- assertProblemsSize(compilationUnit, 3, problems);
- List imports = compilationUnit.imports();
- assertEquals("wrong size", 1, imports.size());
- ImportDeclaration importDeclaration = (ImportDeclaration) imports.get(0);
- Name name = importDeclaration.getName();
- assertEquals("Not a simple name", ASTNode.SIMPLE_NAME, name.getNodeType());
- SimpleName simpleName = (SimpleName) name;
- IBinding binding = simpleName.resolveBinding();
- assertNotNull("No binding", binding);
- assertEquals("Wrong type", IBinding.PACKAGE, binding.getKind());
- }
public void test0210() throws JavaScriptModelException {
this.workingCopy = getWorkingCopy("/Converter15/src/X.js", false);
String contents =
@@ -6511,8 +5225,6 @@
checkSourceRange(simpleName, "length", contents);
IBinding binding = simpleName.resolveBinding();
assertEquals("Not a field", IBinding.VARIABLE, binding.getKind());
- IVariableBinding variableBinding = (IVariableBinding) binding;
- assertEquals("No annotations", 0, variableBinding.getAnnotations().length);
}
/*
@@ -6877,81 +5589,6 @@
assertEquals("Wrong size", 0, typeArguments.length);
}
- /*
- * https://bugs.eclipse.org/bugs/show_bug.cgi?id=140318
- */
- public void test0218() throws JavaScriptModelException {
- this.workingCopy = getWorkingCopy("/Converter15/src/X.js", true/*resolve*/);
- String contents =
- "import java.util.List;\n" +
- "\n" +
- "public class X {\n" +
- " /**\n" +
- " * @category fo\n" +
- " */\n" +
- " @Test private int fXoo;\n" +
- "}";
- ASTNode node = buildAST(
- contents,
- this.workingCopy,
- false);
- assertEquals("Not a compilation unit", ASTNode.JAVASCRIPT_UNIT, node.getNodeType());
- JavaScriptUnit unit = (JavaScriptUnit) node;
- assertProblemsSize(unit, 1, "Test cannot be resolved to a type");
- node = getASTNode(unit, 0, 0);
- assertEquals("Not a field declaration", ASTNode.FIELD_DECLARATION, node.getNodeType());
- FieldDeclaration declaration = (FieldDeclaration) node;
- List modifiers = declaration.modifiers();
- assertEquals("wrong size", 2, modifiers.size());
- assertEquals("Not a marker annotation", ASTNode.MARKER_ANNOTATION, ((ASTNode) modifiers.get(0)).getNodeType());
- MarkerAnnotation annotation = (MarkerAnnotation) modifiers.get(0);
- Name name = annotation.getTypeName();
- assertEquals("Not a simple name", ASTNode.SIMPLE_NAME, name.getNodeType());
- ITypeBinding binding = name.resolveTypeBinding();
- assertNull("Got a binding", binding);
- IBinding binding2 = name.resolveBinding();
- assertNull("Got a binding", binding2);
- IAnnotationBinding annotationBinding = annotation.resolveAnnotationBinding();
- assertNull("Got a binding", annotationBinding);
- }
- /*
- * https://bugs.eclipse.org/bugs/show_bug.cgi?id=140318
- */
- public void test0219() throws JavaScriptModelException {
- this.workingCopy = getWorkingCopy("/Converter15/src/X.js", true/*resolve*/);
- String contents =
- "import java.util.List;\n" +
- "\n" +
- "public class X {\n" +
- " /**\n" +
- " * @category fo\n" +
- " */\n" +
- " @Test private int fXoo;\n" +
- "}\n" +
- "class Test {}";
- ASTNode node = buildAST(
- contents,
- this.workingCopy,
- false);
- assertEquals("Not a compilation unit", ASTNode.JAVASCRIPT_UNIT, node.getNodeType());
- JavaScriptUnit unit = (JavaScriptUnit) node;
- assertProblemsSize(unit, 1, "Type mismatch: cannot convert from Test to Annotation");
- node = getASTNode(unit, 0, 0);
- assertEquals("Not a field declaration", ASTNode.FIELD_DECLARATION, node.getNodeType());
- FieldDeclaration declaration = (FieldDeclaration) node;
- List modifiers = declaration.modifiers();
- assertEquals("wrong size", 2, modifiers.size());
- assertEquals("Not a marker annotation", ASTNode.MARKER_ANNOTATION, ((ASTNode) modifiers.get(0)).getNodeType());
- MarkerAnnotation annotation = (MarkerAnnotation) modifiers.get(0);
- Name name = annotation.getTypeName();
- assertEquals("Not a simple name", ASTNode.SIMPLE_NAME, name.getNodeType());
- ITypeBinding binding = name.resolveTypeBinding();
- assertNotNull("No binding", binding);
- IBinding binding2 = name.resolveBinding();
- assertNotNull("No binding", binding2);
- IAnnotationBinding annotationBinding = annotation.resolveAnnotationBinding();
- assertNull("Got a binding", annotationBinding);
- }
/*
* https://bugs.eclipse.org/bugs/show_bug.cgi?id=142793
@@ -7063,321 +5700,7 @@
assertNotNull("No expression", expression);
assertEquals("Not a method invocation", ASTNode.FUNCTION_INVOCATION, expression.getNodeType());
}
- /*
- * https://bugs.eclipse.org/bugs/show_bug.cgi?id=153303
- */
- public void test0223() throws JavaScriptModelException {
- this.workingCopy = getWorkingCopy("/Converter15/src/X.js", true/*resolve*/);
- String contents =
- "public class X {\n" +
- " @Zork\n" +
- " public void foo( ) {\n" +
- " }\n" +
- "}";
- ASTNode node = buildAST(
- contents,
- this.workingCopy,
- false);
- assertEquals("Not a compilation unit", ASTNode.JAVASCRIPT_UNIT, node.getNodeType());
- JavaScriptUnit unit = (JavaScriptUnit) node;
- assertProblemsSize(unit, 1, "Zork cannot be resolved to a type");
- node = getASTNode(unit, 0, 0);
- assertEquals("Not a method declaration", ASTNode.FUNCTION_DECLARATION, node.getNodeType());
- FunctionDeclaration methodDeclaration = (FunctionDeclaration) node;
- IFunctionBinding methodBinding = methodDeclaration.resolveBinding();
- IAnnotationBinding[] annotations = methodBinding.getAnnotations();
- assertEquals("Wrong size", 0, annotations.length);
- }
- /*
- * https://bugs.eclipse.org/bugs/show_bug.cgi?id=153303
- */
- public void test0224() throws JavaScriptModelException {
- this.workingCopy = getWorkingCopy("/Converter15/src/X.js", true/*resolve*/);
- String contents =
- "@Zork\n" +
- "public class X {\n" +
- "}";
- ASTNode node = buildAST(
- contents,
- this.workingCopy,
- false);
- assertEquals("Not a compilation unit", ASTNode.JAVASCRIPT_UNIT, node.getNodeType());
- JavaScriptUnit unit = (JavaScriptUnit) node;
- assertProblemsSize(unit, 1, "Zork cannot be resolved to a type");
- node = getASTNode(unit, 0);
- assertEquals("Not a type declaration", ASTNode.TYPE_DECLARATION, node.getNodeType());
- TypeDeclaration typeDeclaration = (TypeDeclaration) node;
- ITypeBinding typeBinding = typeDeclaration.resolveBinding();
- IAnnotationBinding[] annotations = typeBinding.getAnnotations();
- assertEquals("Wrong size", 0, annotations.length);
- }
- /*
- * https://bugs.eclipse.org/bugs/show_bug.cgi?id=153303
- */
- public void test0225() throws JavaScriptModelException {
- this.workingCopy = getWorkingCopy("/Converter15/src/X.js", true/*resolve*/);
- String contents =
- "public class X {\n" +
- " public void foo(@Zork String s) {\n" +
- " }\n" +
- "}";
- ASTNode node = buildAST(
- contents,
- this.workingCopy,
- false);
- assertEquals("Not a compilation unit", ASTNode.JAVASCRIPT_UNIT, node.getNodeType());
- JavaScriptUnit unit = (JavaScriptUnit) node;
- assertProblemsSize(unit, 1, "Zork cannot be resolved to a type");
- node = getASTNode(unit, 0, 0);
- assertEquals("Not a method declaration", ASTNode.FUNCTION_DECLARATION, node.getNodeType());
- FunctionDeclaration methodDeclaration = (FunctionDeclaration) node;
- List parameters = methodDeclaration.parameters();
- assertEquals("wrong size", 1, parameters.size());
- SingleVariableDeclaration singleVariableDeclaration = (SingleVariableDeclaration) parameters.get(0);
- IVariableBinding variableBinding = singleVariableDeclaration.resolveBinding();
- IAnnotationBinding[] bindings = variableBinding.getAnnotations();
- assertEquals("Wrong size", 0, bindings.length);
- }
- /*
- * https://bugs.eclipse.org/bugs/show_bug.cgi?id=153303
- */
- public void test0226() throws JavaScriptModelException {
- this.workingCopy = getWorkingCopy("/Converter15/src/p/package-info.js", true/*resolve*/);
- String contents =
- "@Zork package p;";
- ASTNode node = buildAST(
- contents,
- this.workingCopy,
- false);
- assertEquals("Not a compilation unit", ASTNode.JAVASCRIPT_UNIT, node.getNodeType());
- JavaScriptUnit unit = (JavaScriptUnit) node;
- assertProblemsSize(unit, 1, "Zork cannot be resolved to a type");
- PackageDeclaration packageDeclaration = unit.getPackage();
- IPackageBinding packageBinding = packageDeclaration.resolveBinding();
- IAnnotationBinding[] annotations = packageBinding.getAnnotations();
- assertEquals("Wrong size", 0, annotations.length);
- }
- // https://bugs.eclipse.org/bugs/show_bug.cgi?id=155115
- public void test0227() throws JavaScriptModelException {
- this.workingCopy = getWorkingCopy("/Converter15/src/X.js", true/*resolve*/);
- String contents =
- "import anno.Anno;\n" +
- "import binary.B;\n" +
- "import intf.IFoo;\n" +
- "\n" +
- "public class X extends B {\n" +
- " @Anno(clz=IFoo.IBar.class)\n" +
- // the annotation we chase up is not this one, but the one
- // carried by B#f
- " public void f() {}\n" +
- " IFoo.IBar m;\n" +
- "}";
- class TestASTRequestor extends ASTRequestor {
- public ArrayList asts = new ArrayList();
- public void acceptAST(IJavaScriptUnit source, JavaScriptUnit compilationUnit) {
- this.asts.add(compilationUnit);
- }
- public void acceptBinding(String bindingKey, IBinding binding) {
- }
- }
- this.workingCopy.getBuffer().setContents(contents);
- this.workingCopy.save(null, true);
- TestASTRequestor requestor = new TestASTRequestor();
- resolveASTs(new IJavaScriptUnit[] { this.workingCopy } , new String[0], requestor, this.getJavaProject("Converter15"), null);
- ArrayList asts = requestor.asts;
- assertEquals("Wrong size", 1, asts.size());
- JavaScriptUnit compilationUnit = (JavaScriptUnit) asts.get(0);
- assertNotNull("No compilation unit", compilationUnit);
- List types = compilationUnit.types();
- assertEquals("Wrong size", 1, types.size());
- AbstractTypeDeclaration abstractTypeDeclaration = (AbstractTypeDeclaration) types.get(0);
- assertEquals("Wrong type", ASTNode.TYPE_DECLARATION, abstractTypeDeclaration.getNodeType());
- TypeDeclaration declaration = (TypeDeclaration) abstractTypeDeclaration;
- Type superclass = declaration.getSuperclassType();
- assertNotNull("No superclass", superclass);
- ITypeBinding typeBinding = superclass.resolveBinding();
- assertNotNull("No binding", typeBinding);
- IFunctionBinding[] methods = typeBinding.getDeclaredMethods();
- assertNotNull("No methods", methods);
- assertEquals("Wrong size", 2, methods.length);
- IFunctionBinding methodBinding = null;
- for(int i = 0; i < 2; i++) {
- methodBinding = methods[i];
- if (methodBinding.getName().equals("f")) {
- break;
- }
- }
- assertEquals("Wrong name", "f", methodBinding.getName());
- IAnnotationBinding[] annotationBindings = methodBinding.getAnnotations();
- assertNotNull("No annotations", annotationBindings);
- assertEquals("Wrong size", 1, annotationBindings.length);
- IAnnotationBinding annotationBinding = annotationBindings[0];
- IMemberValuePairBinding[] pairs = annotationBinding.getAllMemberValuePairs();
- assertNotNull("no pairs", pairs);
- assertEquals("Wrong size", 1, pairs.length);
- IMemberValuePairBinding memberValuePairBinding = pairs[0];
- assertEquals("Wrong kind", IBinding.MEMBER_VALUE_PAIR, memberValuePairBinding.getKind());
- Object value = memberValuePairBinding.getValue();
- assertNotNull("No value", value);
- assertTrue("Not a type binding", value instanceof ITypeBinding);
- assertEquals("Wrong qualified name", "intf.IFoo.IBar",
- ((ITypeBinding) value).getQualifiedName());
- IVariableBinding[] fields =
- declaration.resolveBinding().getDeclaredFields();
- assertTrue("Bad field definition", fields != null && fields.length == 1);
- assertEquals("Type binding mismatch", value, fields[0].getType());
- }
- /*
- * https://bugs.eclipse.org/bugs/show_bug.cgi?id=157403
- */
- public void test0228() throws JavaScriptModelException {
- this.workingCopy = getWorkingCopy("/Converter15/src/X.js", true/*resolve*/);
- String contents =
- "@interface Ann {\n" +
- " int foo();\n" +
- "}\n" +
- "@Ann(foo = bar())\n" +
- "public class X {\n" +
- " public static int bar() {\n" +
- " return 0;\n" +
- " }\n" +
- "}";
- ASTNode node = buildAST(
- contents,
- this.workingCopy,
- false);
- assertEquals("Not a compilation unit", ASTNode.JAVASCRIPT_UNIT, node.getNodeType());
- JavaScriptUnit unit = (JavaScriptUnit) node;
- assertProblemsSize(unit, 1, "The method bar() is undefined for the type X");
- List types = unit.types();
- assertEquals("wrong size", 2, types.size());
- AbstractTypeDeclaration typeDeclaration = (AbstractTypeDeclaration) types.get(1);
- assertEquals("Not a type declaration", ASTNode.TYPE_DECLARATION, typeDeclaration.getNodeType());
- TypeDeclaration declaration = (TypeDeclaration) typeDeclaration;
- List modifiers = declaration.modifiers();
- assertEquals("wrong size", 2, modifiers.size());
- IExtendedModifier modifier = (IExtendedModifier) modifiers.get(0);
- assertTrue("not an annotation", modifier.isAnnotation());
- Annotation annotation = (Annotation) modifier;
- assertEquals("Not a normal annotation", ASTNode.NORMAL_ANNOTATION, annotation.getNodeType());
- NormalAnnotation normalAnnotation = (NormalAnnotation) annotation;
- List values = normalAnnotation.values();
- assertEquals("wrong size", 1, values.size());
- MemberValuePair pair = (MemberValuePair) values.get(0);
- IBinding binding = pair.getName().resolveBinding();
- assertNotNull("No binding", binding);
- binding = pair.getValue().resolveTypeBinding();
- assertNull("Got a binding", binding);
- binding = pair.resolveMemberValuePairBinding();
- assertNotNull("No binding", binding);
- }
-
- /*
- * https://bugs.eclipse.org/bugs/show_bug.cgi?id=160089
- */
- public void test0229() throws JavaScriptModelException {
- this.workingCopy = getWorkingCopy("/Converter15/src/X.js", true/*resolve*/);
- String contents =
- "import java.util.List;\n" +
- "import java.util.Collection;\n" +
- "public class X {\n" +
- " public static List<String> bar;\n" +
- " @SuppressWarnings(\"unchecked\")\n" +
- " public static Collection bar2;\n" +
- "}";
- this.workingCopy.getBuffer().setContents(contents);
- this.workingCopy.save(null, true);
- final ASTNode[] asts = new ASTNode[1];
- final IBinding[] bindings = new IBinding[1];
- final String key = BindingKey.createParameterizedTypeBindingKey(
- "Ljava/util/Collection<TE;>;", new String[] {});
- resolveASTs(
- new IJavaScriptUnit[] {
- this.workingCopy
- },
- new String[] {
- key
- },
- new ASTRequestor() {
- public void acceptAST(IJavaScriptUnit source, JavaScriptUnit localAst) {
- asts[0] = localAst;
- }
- public void acceptBinding(String bindingKey, IBinding binding) {
- if (key.equals(bindingKey)) {
- bindings[0] = binding;
- }
- }
- },
- getJavaProject("Converter15"),
- null);
- ASTNode node = asts[0];
- assertNotNull("Should not be null", node);
- assertNotNull("Should not be null", bindings[0]);
- assertEquals("Not a compilation unit", ASTNode.JAVASCRIPT_UNIT, node.getNodeType());
- JavaScriptUnit unit = (JavaScriptUnit) node;
- assertProblemsSize(unit, 0);
- node = getASTNode(unit, 0, 0);
- assertEquals("Not a compilation unit", ASTNode.FIELD_DECLARATION, node.getNodeType());
- FieldDeclaration fieldDeclaration = (FieldDeclaration) node;
- Type type = fieldDeclaration.getType();
- ITypeBinding typeBinding = type.resolveBinding();
- node = getASTNode(unit, 0, 1);
- assertEquals("Not a compilation unit", ASTNode.FIELD_DECLARATION, node.getNodeType());
- fieldDeclaration = (FieldDeclaration) node;
- type = fieldDeclaration.getType();
- ITypeBinding typeBinding2 = type.resolveBinding();
- final ITypeBinding collectionTypeBinding = (ITypeBinding) bindings[0];
- assertTrue("Not a raw type", collectionTypeBinding.isRawType());
- assertTrue("Not assignement compatible", typeBinding.isAssignmentCompatible(typeBinding2));
- assertTrue("Not assignement compatible", typeBinding.isAssignmentCompatible(collectionTypeBinding));
- }
-
- /*
- * https://bugs.eclipse.org/bugs/show_bug.cgi?id=156352
- */
- public void test0230() throws JavaScriptModelException {
- IJavaScriptUnit sourceUnit = getCompilationUnit("Converter15" , "src", "test0230", "Test3.js"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- IType type = sourceUnit.getType("Test3");//$NON-NLS-1$
-
- assertNotNull("Should not be null", type);
- ASTParser parser= ASTParser.newParser(AST.JLS3);
- parser.setProject(type.getJavaScriptProject());
- IBinding[] bindings= parser.createBindings(new IJavaScriptElement[] { type }, null);
- if (bindings.length == 1 && bindings[0] instanceof ITypeBinding) {
- ITypeBinding typeBinding= (ITypeBinding) bindings[0];
- StringBuffer buffer = new StringBuffer();
- while (typeBinding != null) {
- buffer.append(typeBinding.getAnnotations().length);
- typeBinding= typeBinding.getSuperclass();
- }
- assertEquals("Wrong number of annotations", "000", String.valueOf(buffer));
- }
- }
-
- /*
- * https://bugs.eclipse.org/bugs/show_bug.cgi?id=156352
- */
- public void test0231() throws JavaScriptModelException {
- IJavaScriptUnit sourceUnit = getCompilationUnit("Converter15" , "src", "test0231", "Test3.js"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- IType type = sourceUnit.getType("Test3");//$NON-NLS-1$
-
- assertNotNull("Should not be null", type);
- ASTParser parser= ASTParser.newParser(AST.JLS3);
- parser.setSource(sourceUnit);
- parser.setKind(ASTParser.K_COMPILATION_UNIT);
- parser.setResolveBindings(true);
- JavaScriptUnit unit = (JavaScriptUnit) parser.createAST(null);
- List types = unit.types();
- TypeDeclaration typeDeclaration = (TypeDeclaration) types.get(0);
- ITypeBinding typeBinding = typeDeclaration.resolveBinding();
- StringBuffer buffer = new StringBuffer();
- while (typeBinding != null) {
- buffer.append(typeBinding.getAnnotations().length);
- typeBinding= typeBinding.getSuperclass();
- }
- assertEquals("Wrong number of annotations", "020", String.valueOf(buffer));
- }
/*
* https://bugs.eclipse.org/bugs/show_bug.cgi?id=167958
@@ -7420,13 +5743,6 @@
Type type = declaration.getReturnType2();
ITypeBinding typeBinding = type.resolveBinding();
assertTrue("Not a binary type binding", !typeBinding.isFromSource());
- IAnnotationBinding[] annotations = typeBinding.getAnnotations();
- assertNotNull("No annotations", annotations);
- assertEquals("Wrong size", 1, annotations.length);
- IAnnotationBinding annotationBinding = annotations[0];
- assertEquals("Wrong name", "Annot", annotationBinding.getName());
- ITypeBinding binding = annotationBinding.getAnnotationType();
- assertEquals("Wrong name", "test0232.Annot", binding.getQualifiedName());
}
/*
@@ -7475,17 +5791,6 @@
Type type = declaration.getReturnType2();
ITypeBinding typeBinding = type.resolveBinding();
assertTrue("Not a binary type binding", !typeBinding.isFromSource());
- IAnnotationBinding[] annotations = typeBinding.getAnnotations();
- assertNotNull("No annotations", annotations);
- assertEquals("Wrong size", 1, annotations.length);
- IAnnotationBinding annotationBinding = annotations[0];
- assertEquals("Wrong name", "Annot", annotationBinding.getName());
- ITypeBinding binding = annotationBinding.getAnnotationType();
- assertEquals("Wrong name", "test0233.Annot", binding.getQualifiedName());
- IMemberValuePairBinding[] pairs = annotationBinding.getAllMemberValuePairs();
- assertEquals("Wrong number", 1, pairs.length);
- assertEquals("Wrong key", "message", pairs[0].getName());
- assertEquals("Wrong value", "Hello, World!", pairs[0].getValue());
}
/*
diff --git a/tests/org.eclipse.wst.jsdt.core.tests.model/src/org/eclipse/wst/jsdt/core/tests/dom/ASTConverterBindingsTest.java b/tests/org.eclipse.wst.jsdt.core.tests.model/src/org/eclipse/wst/jsdt/core/tests/dom/ASTConverterBindingsTest.java
index bf4b483..82a4290 100644
--- a/tests/org.eclipse.wst.jsdt.core.tests.model/src/org/eclipse/wst/jsdt/core/tests/dom/ASTConverterBindingsTest.java
+++ b/tests/org.eclipse.wst.jsdt.core.tests.model/src/org/eclipse/wst/jsdt/core/tests/dom/ASTConverterBindingsTest.java
@@ -15,16 +15,14 @@
import junit.framework.Test;
-import org.eclipse.wst.jsdt.core.IJavaScriptUnit;
import org.eclipse.wst.jsdt.core.IJavaScriptProject;
+import org.eclipse.wst.jsdt.core.IJavaScriptUnit;
import org.eclipse.wst.jsdt.core.IPackageFragment;
import org.eclipse.wst.jsdt.core.JavaScriptModelException;
import org.eclipse.wst.jsdt.core.dom.AST;
import org.eclipse.wst.jsdt.core.dom.ASTNode;
import org.eclipse.wst.jsdt.core.dom.ASTVisitor;
import org.eclipse.wst.jsdt.core.dom.AbstractTypeDeclaration;
-import org.eclipse.wst.jsdt.core.dom.AnnotationTypeDeclaration;
-import org.eclipse.wst.jsdt.core.dom.AnnotationTypeMemberDeclaration;
import org.eclipse.wst.jsdt.core.dom.AnonymousClassDeclaration;
import org.eclipse.wst.jsdt.core.dom.ArrayAccess;
import org.eclipse.wst.jsdt.core.dom.ArrayCreation;
@@ -35,12 +33,12 @@
import org.eclipse.wst.jsdt.core.dom.CastExpression;
import org.eclipse.wst.jsdt.core.dom.CharacterLiteral;
import org.eclipse.wst.jsdt.core.dom.ClassInstanceCreation;
-import org.eclipse.wst.jsdt.core.dom.JavaScriptUnit;
import org.eclipse.wst.jsdt.core.dom.ConditionalExpression;
import org.eclipse.wst.jsdt.core.dom.ConstructorInvocation;
-import org.eclipse.wst.jsdt.core.dom.EnumConstantDeclaration;
-import org.eclipse.wst.jsdt.core.dom.EnumDeclaration;
import org.eclipse.wst.jsdt.core.dom.FieldAccess;
+import org.eclipse.wst.jsdt.core.dom.FunctionDeclaration;
+import org.eclipse.wst.jsdt.core.dom.FunctionInvocation;
+import org.eclipse.wst.jsdt.core.dom.FunctionRef;
import org.eclipse.wst.jsdt.core.dom.IBinding;
import org.eclipse.wst.jsdt.core.dom.IFunctionBinding;
import org.eclipse.wst.jsdt.core.dom.IPackageBinding;
@@ -49,11 +47,9 @@
import org.eclipse.wst.jsdt.core.dom.ImportDeclaration;
import org.eclipse.wst.jsdt.core.dom.InfixExpression;
import org.eclipse.wst.jsdt.core.dom.InstanceofExpression;
+import org.eclipse.wst.jsdt.core.dom.JavaScriptUnit;
import org.eclipse.wst.jsdt.core.dom.ListExpression;
import org.eclipse.wst.jsdt.core.dom.MemberRef;
-import org.eclipse.wst.jsdt.core.dom.FunctionDeclaration;
-import org.eclipse.wst.jsdt.core.dom.FunctionInvocation;
-import org.eclipse.wst.jsdt.core.dom.FunctionRef;
import org.eclipse.wst.jsdt.core.dom.NullLiteral;
import org.eclipse.wst.jsdt.core.dom.NumberLiteral;
import org.eclipse.wst.jsdt.core.dom.PackageDeclaration;
@@ -98,23 +94,6 @@
}
}
- /**
- * @see org.eclipse.wst.jsdt.core.dom.ASTVisitor#endVisit(AnnotationTypeDeclaration)
- * @since 3.0
- */
- public void endVisit(AnnotationTypeDeclaration node) {
- ITypeBinding typeBinding = node.resolveBinding();
- collectBindings(node, typeBinding);
- }
-
- /**
- * @see org.eclipse.wst.jsdt.core.dom.ASTVisitor#endVisit(AnnotationTypeMemberDeclaration)
- * @since 3.0
- */
- public void endVisit(AnnotationTypeMemberDeclaration node) {
- IFunctionBinding binding = node.resolveBinding();
- collectBindings(node, binding);
- }
/**
* @see org.eclipse.wst.jsdt.core.dom.ASTVisitor#endVisit(AnonymousClassDeclaration)
@@ -213,24 +192,6 @@
}
/**
- * @see org.eclipse.wst.jsdt.core.dom.ASTVisitor#endVisit(EnumConstantDeclaration)
- * @since 3.0
- */
- public void endVisit(EnumConstantDeclaration node) {
- IVariableBinding binding = node.resolveVariable();
- collectBindings(node, binding);
- }
-
- /**
- * @see org.eclipse.wst.jsdt.core.dom.ASTVisitor#endVisit(EnumDeclaration)
- * @since 3.0
- */
- public void endVisit(EnumDeclaration node) {
- ITypeBinding typeBinding = node.resolveBinding();
- collectBindings(node, typeBinding);
- }
-
- /**
* @see org.eclipse.wst.jsdt.core.dom.ASTVisitor#endVisit(FieldAccess)
*/
public void endVisit(FieldAccess node) {
diff --git a/tests/org.eclipse.wst.jsdt.core.tests.model/src/org/eclipse/wst/jsdt/core/tests/dom/ASTConverterJavadocTest.java b/tests/org.eclipse.wst.jsdt.core.tests.model/src/org/eclipse/wst/jsdt/core/tests/dom/ASTConverterJavadocTest.java
index 53d8fa7..b08d9b6 100644
--- a/tests/org.eclipse.wst.jsdt.core.tests.model/src/org/eclipse/wst/jsdt/core/tests/dom/ASTConverterJavadocTest.java
+++ b/tests/org.eclipse.wst.jsdt.core.tests.model/src/org/eclipse/wst/jsdt/core/tests/dom/ASTConverterJavadocTest.java
@@ -10,7 +10,8 @@
*******************************************************************************/
package org.eclipse.wst.jsdt.core.tests.dom;
-import java.io.*;
+import java.io.File;
+import java.io.IOException;
import java.lang.reflect.Method;
import java.text.NumberFormat;
import java.util.ArrayList;
@@ -22,12 +23,45 @@
import junit.framework.TestSuite;
import org.eclipse.core.runtime.CoreException;
-import org.eclipse.wst.jsdt.core.IJavaScriptUnit;
import org.eclipse.wst.jsdt.core.IJavaScriptProject;
+import org.eclipse.wst.jsdt.core.IJavaScriptUnit;
import org.eclipse.wst.jsdt.core.JavaScriptCore;
import org.eclipse.wst.jsdt.core.JavaScriptModelException;
import org.eclipse.wst.jsdt.core.compiler.IProblem;
-import org.eclipse.wst.jsdt.core.dom.*;
+import org.eclipse.wst.jsdt.core.dom.AST;
+import org.eclipse.wst.jsdt.core.dom.ASTNode;
+import org.eclipse.wst.jsdt.core.dom.ASTParser;
+import org.eclipse.wst.jsdt.core.dom.ArrayType;
+import org.eclipse.wst.jsdt.core.dom.Block;
+import org.eclipse.wst.jsdt.core.dom.Comment;
+import org.eclipse.wst.jsdt.core.dom.Expression;
+import org.eclipse.wst.jsdt.core.dom.ExpressionStatement;
+import org.eclipse.wst.jsdt.core.dom.FieldDeclaration;
+import org.eclipse.wst.jsdt.core.dom.FunctionDeclaration;
+import org.eclipse.wst.jsdt.core.dom.FunctionInvocation;
+import org.eclipse.wst.jsdt.core.dom.FunctionRef;
+import org.eclipse.wst.jsdt.core.dom.FunctionRefParameter;
+import org.eclipse.wst.jsdt.core.dom.IBinding;
+import org.eclipse.wst.jsdt.core.dom.ITypeBinding;
+import org.eclipse.wst.jsdt.core.dom.IfStatement;
+import org.eclipse.wst.jsdt.core.dom.JSdoc;
+import org.eclipse.wst.jsdt.core.dom.JavaScriptUnit;
+import org.eclipse.wst.jsdt.core.dom.MemberRef;
+import org.eclipse.wst.jsdt.core.dom.Name;
+import org.eclipse.wst.jsdt.core.dom.PackageDeclaration;
+import org.eclipse.wst.jsdt.core.dom.PrimitiveType;
+import org.eclipse.wst.jsdt.core.dom.QualifiedName;
+import org.eclipse.wst.jsdt.core.dom.ReturnStatement;
+import org.eclipse.wst.jsdt.core.dom.SimpleName;
+import org.eclipse.wst.jsdt.core.dom.SimpleType;
+import org.eclipse.wst.jsdt.core.dom.Statement;
+import org.eclipse.wst.jsdt.core.dom.TagElement;
+import org.eclipse.wst.jsdt.core.dom.TextElement;
+import org.eclipse.wst.jsdt.core.dom.Type;
+import org.eclipse.wst.jsdt.core.dom.TypeDeclaration;
+import org.eclipse.wst.jsdt.core.dom.TypeDeclarationStatement;
+import org.eclipse.wst.jsdt.core.dom.VariableDeclarationFragment;
+import org.eclipse.wst.jsdt.core.dom.VariableDeclarationStatement;
import org.eclipse.wst.jsdt.internal.compiler.parser.ScannerHelper;
public class ASTConverterJavadocTest extends ConverterTestSetup {
@@ -2788,46 +2822,6 @@
}
}
- /**
- * Bug 94150: [javadoc][dom] Extended ranges wrong for method name without return type
- * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=94150"
- */
- public void testBug94150() throws JavaScriptModelException {
- workingCopies = new IJavaScriptUnit[1];
- astLevel = AST.JLS3;
- workingCopies[0] = getWorkingCopy("/Converter15/src/javadoc/b94150/Category.js",
- "package javadoc.b94150;\n" +
- "public enum Category {\n" +
- " /**\n" +
- " * history style\n" +
- " * @see Object\n" +
- " */ \n" +
- " HISTORY,\n" +
- "\n" +
- " /**\n" +
- " * war style\n" +
- " */ \n" +
- " WAR;\n" +
- "}\n"
- );
- JavaScriptUnit compilUnit = verifyComments(workingCopies[0]);
- if (docCommentSupport.equals(JavaScriptCore.ENABLED)) {
- // Get enum declaration
- ASTNode node = getASTNode(compilUnit, 0);
- assertEquals("Expected enum declaration.", ASTNode.ENUM_DECLARATION, node.getNodeType());
- EnumDeclaration enumDeclaration = (EnumDeclaration) node;
-
- // Verify each enum constant javadoc
- List constants = enumDeclaration.enumConstants();
- int size = constants.size();
- assertEquals("Wrong number of constants", 2, size);
- for (int i=0; i<size; i++) {
- EnumConstantDeclaration constant = (EnumConstantDeclaration) constants.get(i);
- JSdoc docComment = (JSdoc) compilUnit.getCommentList().get(i); // Do not need to verify following statement as we know it's ok as verifyComments did not fail
- assertTrue("Javadoc should be set on first enum constant", docComment == constant.getJavadoc());
- }
- }
- }
/**
* Bug 99507: [javadoc] Infinit loop in DocCommentParser
@@ -3416,60 +3410,4 @@
}
}
- /**
- * @bug 165525: [comments] ASTParser excludes trailing line comments from extended range of fields in enums
- * @test Ensure that extended ranges are correct for enum constants and last comments of enum declaration
- * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=165525"
- */
- public void testBug165525() throws JavaScriptModelException {
- workingCopies = new IJavaScriptUnit[1];
- workingCopies[0] = getWorkingCopy("/Converter15/src/javadoc/b165525/Test.js",
- "package javadoc.b165525;\n" +
- "public enum Test {\n" +
- " ENUM_CONST_1(\"String constant 1\") //$NON-NLS-1$\n" +
- " , ENUM_CONST_2(\"String constant 2\") //$NON-NLS-1$\n" +
- " ;\n" +
- " Test(String x) {\n" +
- " }\n" +
- " String a = \"a\"; //$NON-NLS-1$\n" +
- " String b = \"b\"; //$NON-NLS-1$\n" +
- "}\n"
- );
- JavaScriptUnit compilUnit = (JavaScriptUnit) runConversion(AST.JLS3, workingCopies[0], true);
- verifyWorkingCopiesComments();
- if (docCommentSupport.equals(JavaScriptCore.ENABLED)) {
- // Verify comment type
- List unitComments = compilUnit.getCommentList();
- assertEquals("Wrong number of comments", 4, unitComments.size());
-
- // Verify extension of first enum declaration constant
- Comment comment = (Comment) unitComments.get(0);
- EnumDeclaration enumDeclaration = (EnumDeclaration) compilUnit.types().get(0);
- EnumConstantDeclaration constantDeclaration = (EnumConstantDeclaration) enumDeclaration.enumConstants().get(0);
- int declarationEnd = constantDeclaration.getStartPosition() + compilUnit.getExtendedLength(constantDeclaration) - 1;
- int commentEnd = comment.getStartPosition() + comment.getLength() - 1;
- assumeEquals("Enum constant declaration "+constantDeclaration+" does not have the correct length", commentEnd, declarationEnd);
-
- // Verify extension of second enum declaration constant
- comment = (Comment) unitComments.get(1);
- constantDeclaration = (EnumConstantDeclaration) enumDeclaration.enumConstants().get(1);
- declarationEnd = constantDeclaration.getStartPosition() + compilUnit.getExtendedLength(constantDeclaration) - 1;
- commentEnd = comment.getStartPosition() + comment.getLength() - 1;
- assumeEquals("Enum constant declaration "+constantDeclaration+" does not have the correct length", commentEnd, declarationEnd);
-
- // Verify extension of first field declaration
- comment = (Comment) unitComments.get(2);
- FieldDeclaration fieldDeclaration = (FieldDeclaration) enumDeclaration.bodyDeclarations().get(1);
- declarationEnd = fieldDeclaration.getStartPosition() + compilUnit.getExtendedLength(fieldDeclaration) - 1;
- commentEnd = comment.getStartPosition() + comment.getLength() - 1;
- assumeEquals("Enum constant declaration "+constantDeclaration+" does not have the correct length", commentEnd, declarationEnd);
-
- // Verify extension of second field declaration
- comment = (Comment) unitComments.get(3);
- fieldDeclaration = (FieldDeclaration) enumDeclaration.bodyDeclarations().get(2);
- declarationEnd = fieldDeclaration.getStartPosition() + compilUnit.getExtendedLength(fieldDeclaration) - 1;
- commentEnd = comment.getStartPosition() + comment.getLength() - 1;
- assumeEquals("Enum constant declaration "+constantDeclaration+" does not have the correct length", commentEnd, declarationEnd);
- }
- }
}
diff --git a/tests/org.eclipse.wst.jsdt.core.tests.model/src/org/eclipse/wst/jsdt/core/tests/dom/ASTMatcherTest.java b/tests/org.eclipse.wst.jsdt.core.tests.model/src/org/eclipse/wst/jsdt/core/tests/dom/ASTMatcherTest.java
index db6bf21..245e4ad 100644
--- a/tests/org.eclipse.wst.jsdt.core.tests.model/src/org/eclipse/wst/jsdt/core/tests/dom/ASTMatcherTest.java
+++ b/tests/org.eclipse.wst.jsdt.core.tests.model/src/org/eclipse/wst/jsdt/core/tests/dom/ASTMatcherTest.java
@@ -14,8 +14,88 @@
import java.lang.reflect.Method;
import junit.framework.Test;
-import org.eclipse.wst.jsdt.core.dom.*;
+
+import org.eclipse.wst.jsdt.core.dom.AST;
+import org.eclipse.wst.jsdt.core.dom.ASTMatcher;
import org.eclipse.wst.jsdt.core.dom.ASTNode;
+import org.eclipse.wst.jsdt.core.dom.ASTVisitor;
+import org.eclipse.wst.jsdt.core.dom.AnonymousClassDeclaration;
+import org.eclipse.wst.jsdt.core.dom.ArrayAccess;
+import org.eclipse.wst.jsdt.core.dom.ArrayCreation;
+import org.eclipse.wst.jsdt.core.dom.ArrayInitializer;
+import org.eclipse.wst.jsdt.core.dom.ArrayType;
+import org.eclipse.wst.jsdt.core.dom.AssertStatement;
+import org.eclipse.wst.jsdt.core.dom.Assignment;
+import org.eclipse.wst.jsdt.core.dom.Block;
+import org.eclipse.wst.jsdt.core.dom.BlockComment;
+import org.eclipse.wst.jsdt.core.dom.BooleanLiteral;
+import org.eclipse.wst.jsdt.core.dom.BreakStatement;
+import org.eclipse.wst.jsdt.core.dom.CastExpression;
+import org.eclipse.wst.jsdt.core.dom.CatchClause;
+import org.eclipse.wst.jsdt.core.dom.CharacterLiteral;
+import org.eclipse.wst.jsdt.core.dom.ClassInstanceCreation;
+import org.eclipse.wst.jsdt.core.dom.ConditionalExpression;
+import org.eclipse.wst.jsdt.core.dom.ConstructorInvocation;
+import org.eclipse.wst.jsdt.core.dom.ContinueStatement;
+import org.eclipse.wst.jsdt.core.dom.DoStatement;
+import org.eclipse.wst.jsdt.core.dom.EmptyStatement;
+import org.eclipse.wst.jsdt.core.dom.EnhancedForStatement;
+import org.eclipse.wst.jsdt.core.dom.Expression;
+import org.eclipse.wst.jsdt.core.dom.ExpressionStatement;
+import org.eclipse.wst.jsdt.core.dom.FieldAccess;
+import org.eclipse.wst.jsdt.core.dom.FieldDeclaration;
+import org.eclipse.wst.jsdt.core.dom.ForStatement;
+import org.eclipse.wst.jsdt.core.dom.FunctionDeclaration;
+import org.eclipse.wst.jsdt.core.dom.FunctionInvocation;
+import org.eclipse.wst.jsdt.core.dom.FunctionRef;
+import org.eclipse.wst.jsdt.core.dom.FunctionRefParameter;
+import org.eclipse.wst.jsdt.core.dom.IfStatement;
+import org.eclipse.wst.jsdt.core.dom.ImportDeclaration;
+import org.eclipse.wst.jsdt.core.dom.InfixExpression;
+import org.eclipse.wst.jsdt.core.dom.Initializer;
+import org.eclipse.wst.jsdt.core.dom.JSdoc;
+import org.eclipse.wst.jsdt.core.dom.JavaScriptUnit;
+import org.eclipse.wst.jsdt.core.dom.LabeledStatement;
+import org.eclipse.wst.jsdt.core.dom.LineComment;
+import org.eclipse.wst.jsdt.core.dom.MemberRef;
+import org.eclipse.wst.jsdt.core.dom.Modifier;
+import org.eclipse.wst.jsdt.core.dom.Name;
+import org.eclipse.wst.jsdt.core.dom.NullLiteral;
+import org.eclipse.wst.jsdt.core.dom.NumberLiteral;
+import org.eclipse.wst.jsdt.core.dom.PackageDeclaration;
+import org.eclipse.wst.jsdt.core.dom.ParameterizedType;
+import org.eclipse.wst.jsdt.core.dom.ParenthesizedExpression;
+import org.eclipse.wst.jsdt.core.dom.PostfixExpression;
+import org.eclipse.wst.jsdt.core.dom.PrefixExpression;
+import org.eclipse.wst.jsdt.core.dom.PrimitiveType;
+import org.eclipse.wst.jsdt.core.dom.QualifiedName;
+import org.eclipse.wst.jsdt.core.dom.QualifiedType;
+import org.eclipse.wst.jsdt.core.dom.ReturnStatement;
+import org.eclipse.wst.jsdt.core.dom.SimpleName;
+import org.eclipse.wst.jsdt.core.dom.SimpleType;
+import org.eclipse.wst.jsdt.core.dom.SingleVariableDeclaration;
+import org.eclipse.wst.jsdt.core.dom.Statement;
+import org.eclipse.wst.jsdt.core.dom.StringLiteral;
+import org.eclipse.wst.jsdt.core.dom.SuperConstructorInvocation;
+import org.eclipse.wst.jsdt.core.dom.SuperFieldAccess;
+import org.eclipse.wst.jsdt.core.dom.SuperMethodInvocation;
+import org.eclipse.wst.jsdt.core.dom.SwitchCase;
+import org.eclipse.wst.jsdt.core.dom.SwitchStatement;
+import org.eclipse.wst.jsdt.core.dom.TagElement;
+import org.eclipse.wst.jsdt.core.dom.TextElement;
+import org.eclipse.wst.jsdt.core.dom.ThisExpression;
+import org.eclipse.wst.jsdt.core.dom.ThrowStatement;
+import org.eclipse.wst.jsdt.core.dom.TryStatement;
+import org.eclipse.wst.jsdt.core.dom.Type;
+import org.eclipse.wst.jsdt.core.dom.TypeDeclaration;
+import org.eclipse.wst.jsdt.core.dom.TypeDeclarationStatement;
+import org.eclipse.wst.jsdt.core.dom.TypeLiteral;
+import org.eclipse.wst.jsdt.core.dom.TypeParameter;
+import org.eclipse.wst.jsdt.core.dom.VariableDeclarationExpression;
+import org.eclipse.wst.jsdt.core.dom.VariableDeclarationFragment;
+import org.eclipse.wst.jsdt.core.dom.VariableDeclarationStatement;
+import org.eclipse.wst.jsdt.core.dom.WhileStatement;
+import org.eclipse.wst.jsdt.core.dom.WildcardType;
/**
* Test suite for <code>ASTMatcher</code> and <code>ASTNode.subtreeMatch</code>.
@@ -81,14 +161,8 @@
FunctionRefParameter MPARM1;
LineComment LC1;
BlockComment BC1;
- MemberValuePair MVP1;
- MemberValuePair MVP2;
- MarkerAnnotation ANO1;
- SingleMemberAnnotation ANO2;
Modifier MOD1;
Modifier MOD2;
- EnumConstantDeclaration EC1;
- EnumConstantDeclaration EC2;
final StringBuffer b = new StringBuffer();
@@ -196,28 +270,10 @@
TP2S = "[(tTP[(nSyynS)]tTP)]"; //$NON-NLS-1$
LC1 = ast.newLineComment();
- MVP1 = ast.newMemberValuePair();
- MVP1.setName(ast.newSimpleName("x")); //$NON-NLS-1$
- MVP1.setValue(ast.newSimpleName("y")); //$NON-NLS-1$
-
- MVP2 = ast.newMemberValuePair();
- MVP2.setName(ast.newSimpleName("a")); //$NON-NLS-1$
- MVP2.setValue(ast.newSimpleName("b")); //$NON-NLS-1$
-
- ANO1 = ast.newMarkerAnnotation();
- ANO1.setTypeName(ast.newSimpleName("p")); //$NON-NLS-1$
-
- ANO2 = ast.newSingleMemberAnnotation();
- ANO2.setTypeName(ast.newSimpleName("q")); //$NON-NLS-1$
- ANO2.setValue(ast.newSimpleName("v")); //$NON-NLS-1$
MOD1 = ast.newModifier(Modifier.ModifierKeyword.PUBLIC_KEYWORD);
MOD2 = ast.newModifier(Modifier.ModifierKeyword.FINAL_KEYWORD);
- EC1 = ast.newEnumConstantDeclaration();
- EC1.setName(ast.newSimpleName("F")); //$NON-NLS-1$
- EC2 = ast.newEnumConstantDeclaration();
- EC2.setName(ast.newSimpleName("G")); //$NON-NLS-1$
}
}
@@ -274,12 +330,6 @@
return this.result;
}
- public boolean match(AnnotationTypeDeclaration node, Object other) {
- return standardBody(node, other, superMatch ? super.match(node, other) : false);
- }
- public boolean match(AnnotationTypeMemberDeclaration node, Object other) {
- return standardBody(node, other, superMatch ? super.match(node, other) : false);
- }
public boolean match(AnonymousClassDeclaration node, Object other) {
return standardBody(node, other, superMatch ? super.match(node, other) : false);
}
@@ -346,12 +396,6 @@
public boolean match(EnhancedForStatement node, Object other) {
return standardBody(node, other, superMatch ? super.match(node, other) : false);
}
- public boolean match(EnumConstantDeclaration node, Object other) {
- return standardBody(node, other, superMatch ? super.match(node, other) : false);
- }
- public boolean match(EnumDeclaration node, Object other) {
- return standardBody(node, other, superMatch ? super.match(node, other) : false);
- }
public boolean match(ExpressionStatement node, Object other) {
return standardBody(node, other, superMatch ? super.match(node, other) : false);
}
@@ -385,15 +429,9 @@
public boolean match(LineComment node, Object other) {
return standardBody(node, other, superMatch ? super.match(node, other) : false);
}
- public boolean match(MarkerAnnotation node, Object other) {
- return standardBody(node, other, superMatch ? super.match(node, other) : false);
- }
public boolean match(MemberRef node, Object other) {
return standardBody(node, other, superMatch ? super.match(node, other) : false);
}
- public boolean match(MemberValuePair node, Object other) {
- return standardBody(node, other, superMatch ? super.match(node, other) : false);
- }
public boolean match(FunctionDeclaration node, Object other) {
return standardBody(node, other, superMatch ? super.match(node, other) : false);
}
@@ -409,9 +447,6 @@
public boolean match(Modifier node, Object other) {
return standardBody(node, other, superMatch ? super.match(node, other) : false);
}
- public boolean match(NormalAnnotation node, Object other) {
- return standardBody(node, other, superMatch ? super.match(node, other) : false);
- }
public boolean match(NullLiteral node, Object other) {
return standardBody(node, other, superMatch ? super.match(node, other) : false);
}
@@ -451,9 +486,6 @@
public boolean match(SimpleType node, Object other) {
return standardBody(node, other, superMatch ? super.match(node, other) : false);
}
- public boolean match(SingleMemberAnnotation node, Object other) {
- return standardBody(node, other, superMatch ? super.match(node, other) : false);
- }
public boolean match(SingleVariableDeclaration node, Object other) {
return standardBody(node, other, superMatch ? super.match(node, other) : false);
}
@@ -824,40 +856,6 @@
x1.setBody(S1);
basicMatch(x1);
}
- /** @deprecated Only to suppress warnings for refs to bodyDeclarations. */
- // TODO (jeem) - remove deprecation after 3.1 M4
- public void testEnumConstantDeclaration() {
- if (ast.apiLevel() == AST.JLS2) {
- return;
- }
- EnumConstantDeclaration x1 = ast.newEnumConstantDeclaration();
- x1.setJavadoc(JD1);
- x1.modifiers().add(MOD1);
- x1.modifiers().add(MOD2);
- x1.setName(N1);
- x1.arguments().add(E1);
- x1.arguments().add(E2);
- x1.setAnonymousClassDeclaration(ACD1);
- basicMatch(x1);
- }
- /** @deprecated using deprecated code */
- public void testEnumDeclaration() {
- if (ast.apiLevel() == AST.JLS2) {
- return;
- }
- EnumDeclaration x1 = ast.newEnumDeclaration();
- x1.setJavadoc(JD1);
- x1.modifiers().add(MOD1);
- x1.modifiers().add(MOD2);
- x1.setName(N1);
- x1.superInterfaceTypes().add(T1);
- x1.superInterfaceTypes().add(T2);
- x1.enumConstants().add(EC1);
- x1.enumConstants().add(EC2);
- x1.bodyDeclarations().add(FD1);
- x1.bodyDeclarations().add(FD2);
- basicMatch(x1);
- }
public void testExpressionStatement() {
ExpressionStatement x1 = ast.newExpressionStatement(E1);
basicMatch(x1);
@@ -1009,15 +1007,6 @@
NumberLiteral x1 = ast.newNumberLiteral("1.0"); //$NON-NLS-1$
basicMatch(x1);
}
- public void testPackageDeclaration() {
- PackageDeclaration x1 = ast.newPackageDeclaration();
- if (ast.apiLevel() >= AST.JLS3) {
- x1.setJavadoc(JD1);
- x1.annotations().add(ANO1);
- x1.annotations().add(ANO2);
- }
- basicMatch(x1);
- }
public void testParenthesizedExpression() {
ParenthesizedExpression x1 = ast.newParenthesizedExpression();
basicMatch(x1);
@@ -1209,68 +1198,5 @@
basicMatch(x1);
}
- // annotation-related
- /** @deprecated using deprecated code */
- public void testAnnotationTypeDeclaration() {
- if (ast.apiLevel() == AST.JLS2) {
- return;
- }
- AnnotationTypeDeclaration x1 = ast.newAnnotationTypeDeclaration();
- x1.setJavadoc(JD1);
- x1.modifiers().add(MOD1);
- x1.modifiers().add(MOD2);
- x1.setName(N1);
- x1.bodyDeclarations().add(FD1);
- x1.bodyDeclarations().add(FD2);
- basicMatch(x1);
- }
-
- /** @deprecated using deprecated code */
- public void testAnnotationTypeMemberDeclaration() {
- if (ast.apiLevel() == AST.JLS2) {
- return;
- }
- AnnotationTypeMemberDeclaration x1 = ast.newAnnotationTypeMemberDeclaration();
- x1.setJavadoc(JD1);
- x1.modifiers().add(MOD1);
- x1.modifiers().add(MOD2);
- x1.setType(T1);
- x1.setName(N1);
- x1.setDefault(E1);
- basicMatch(x1);
- }
-
- /** @deprecated using deprecated code */
- public void testNormalAnnotation() {
- if (ast.apiLevel() == AST.JLS2) {
- return;
- }
- NormalAnnotation x1 = ast.newNormalAnnotation();
- x1.setTypeName(N1);
- x1.values().add(MVP1);
- x1.values().add(MVP2);
- basicMatch(x1);
- }
-
- /** @deprecated using deprecated code */
- public void testMarkerAnnotation() {
- if (ast.apiLevel() == AST.JLS2) {
- return;
- }
- MarkerAnnotation x1 = ast.newMarkerAnnotation();
- x1.setTypeName(N1);
- basicMatch(x1);
- }
-
- /** @deprecated using deprecated code */
- public void testSingleMemberAnnotation() {
- if (ast.apiLevel() == AST.JLS2) {
- return;
- }
- SingleMemberAnnotation x1 = ast.newSingleMemberAnnotation();
- x1.setTypeName(N1);
- x1.setValue(E1);
- basicMatch(x1);
- }
}
diff --git a/tests/org.eclipse.wst.jsdt.core.tests.model/src/org/eclipse/wst/jsdt/core/tests/dom/ASTNodesCollectorVisitor.java b/tests/org.eclipse.wst.jsdt.core.tests.model/src/org/eclipse/wst/jsdt/core/tests/dom/ASTNodesCollectorVisitor.java
index 9247e8e..2b9ec0e 100644
--- a/tests/org.eclipse.wst.jsdt.core.tests.model/src/org/eclipse/wst/jsdt/core/tests/dom/ASTNodesCollectorVisitor.java
+++ b/tests/org.eclipse.wst.jsdt.core.tests.model/src/org/eclipse/wst/jsdt/core/tests/dom/ASTNodesCollectorVisitor.java
@@ -14,8 +14,31 @@
import java.util.List;
import java.util.Set;
-import org.eclipse.wst.jsdt.core.dom.*;
+import org.eclipse.wst.jsdt.core.dom.AST;
+import org.eclipse.wst.jsdt.core.dom.ASTNode;
import org.eclipse.wst.jsdt.core.dom.ASTVisitor;
+import org.eclipse.wst.jsdt.core.dom.AnonymousClassDeclaration;
+import org.eclipse.wst.jsdt.core.dom.ClassInstanceCreation;
+import org.eclipse.wst.jsdt.core.dom.FieldAccess;
+import org.eclipse.wst.jsdt.core.dom.FieldDeclaration;
+import org.eclipse.wst.jsdt.core.dom.FunctionDeclaration;
+import org.eclipse.wst.jsdt.core.dom.FunctionInvocation;
+import org.eclipse.wst.jsdt.core.dom.FunctionRef;
+import org.eclipse.wst.jsdt.core.dom.ImportDeclaration;
+import org.eclipse.wst.jsdt.core.dom.JavaScriptUnit;
+import org.eclipse.wst.jsdt.core.dom.MemberRef;
+import org.eclipse.wst.jsdt.core.dom.PackageDeclaration;
+import org.eclipse.wst.jsdt.core.dom.QualifiedName;
+import org.eclipse.wst.jsdt.core.dom.SimpleName;
+import org.eclipse.wst.jsdt.core.dom.SimpleType;
+import org.eclipse.wst.jsdt.core.dom.SingleVariableDeclaration;
+import org.eclipse.wst.jsdt.core.dom.SuperFieldAccess;
+import org.eclipse.wst.jsdt.core.dom.SuperMethodInvocation;
+import org.eclipse.wst.jsdt.core.dom.ThisExpression;
+import org.eclipse.wst.jsdt.core.dom.TypeDeclaration;
+import org.eclipse.wst.jsdt.core.dom.VariableDeclarationExpression;
+import org.eclipse.wst.jsdt.core.dom.VariableDeclarationFragment;
+import org.eclipse.wst.jsdt.core.dom.VariableDeclarationStatement;
class ASTNodesCollectorVisitor extends ASTVisitor {
@@ -34,24 +57,6 @@
private void add(ASTNode node) {
this.detachedAstNodes.add(node);
}
-
- /**
- * @see org.eclipse.wst.jsdt.core.dom.ASTVisitor#endVisit(AnnotationTypeDeclaration)
- * @since 3.0
- */
- public void endVisit(AnnotationTypeDeclaration node) {
- add(node);
- node.setName(node.getAST().newSimpleName("XXX")); //$NON-NLS-1$
- detachedListElement(node.bodyDeclarations());
- }
-
- /**
- * @see org.eclipse.wst.jsdt.core.dom.ASTVisitor#endVisit(AnnotationTypeMemberDeclaration)
- * @since 3.0
- */
- public void endVisit(AnnotationTypeMemberDeclaration node) {
- node.setName(node.getAST().newSimpleName("XXX")); //$NON-NLS-1$
- }
/**
* @see org.eclipse.wst.jsdt.core.dom.ASTVisitor#endVisit(org.eclipse.wst.jsdt.core.dom.AnonymousClassDeclaration)
@@ -86,25 +91,6 @@
node.setPackage(node.getAST().newPackageDeclaration());
}
- /**
- * @see org.eclipse.wst.jsdt.core.dom.ASTVisitor#endVisit(EnumConstantDeclaration)
- * @since 3.0
- */
- public void endVisit(EnumConstantDeclaration node) {
- add(node);
- node.setName(node.getAST().newSimpleName("XXX")); //$NON-NLS-1$
- detachedListElement(node.getAnonymousClassDeclaration().bodyDeclarations());
- }
-
- /**
- * @see org.eclipse.wst.jsdt.core.dom.ASTVisitor#endVisit(EnumDeclaration)
- * @since 3.0
- */
- public void endVisit(EnumDeclaration node) {
- add(node);
- node.setName(node.getAST().newSimpleName("XXX")); //$NON-NLS-1$
- detachedListElement(node.bodyDeclarations());
- }
/**
* @see org.eclipse.wst.jsdt.core.dom.ASTVisitor#endVisit(org.eclipse.wst.jsdt.core.dom.FieldAccess)
diff --git a/tests/org.eclipse.wst.jsdt.core.tests.model/src/org/eclipse/wst/jsdt/core/tests/dom/ASTTest.java b/tests/org.eclipse.wst.jsdt.core.tests.model/src/org/eclipse/wst/jsdt/core/tests/dom/ASTTest.java
index 6fce504..675a381 100644
--- a/tests/org.eclipse.wst.jsdt.core.tests.model/src/org/eclipse/wst/jsdt/core/tests/dom/ASTTest.java
+++ b/tests/org.eclipse.wst.jsdt.core.tests.model/src/org/eclipse/wst/jsdt/core/tests/dom/ASTTest.java
@@ -17,12 +17,96 @@
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
+import java.util.Map;
import java.util.Set;
-import java.util.Map;
-
import junit.framework.Test;
-import org.eclipse.wst.jsdt.core.dom.*;
+
+import org.eclipse.wst.jsdt.core.dom.AST;
+import org.eclipse.wst.jsdt.core.dom.ASTMatcher;
+import org.eclipse.wst.jsdt.core.dom.ASTNode;
+import org.eclipse.wst.jsdt.core.dom.ASTVisitor;
+import org.eclipse.wst.jsdt.core.dom.AbstractTypeDeclaration;
+import org.eclipse.wst.jsdt.core.dom.AnonymousClassDeclaration;
+import org.eclipse.wst.jsdt.core.dom.ArrayAccess;
+import org.eclipse.wst.jsdt.core.dom.ArrayCreation;
+import org.eclipse.wst.jsdt.core.dom.ArrayInitializer;
+import org.eclipse.wst.jsdt.core.dom.ArrayType;
+import org.eclipse.wst.jsdt.core.dom.AssertStatement;
+import org.eclipse.wst.jsdt.core.dom.Assignment;
+import org.eclipse.wst.jsdt.core.dom.Block;
+import org.eclipse.wst.jsdt.core.dom.BlockComment;
+import org.eclipse.wst.jsdt.core.dom.BodyDeclaration;
+import org.eclipse.wst.jsdt.core.dom.BooleanLiteral;
+import org.eclipse.wst.jsdt.core.dom.BreakStatement;
+import org.eclipse.wst.jsdt.core.dom.CastExpression;
+import org.eclipse.wst.jsdt.core.dom.CatchClause;
+import org.eclipse.wst.jsdt.core.dom.CharacterLiteral;
+import org.eclipse.wst.jsdt.core.dom.ClassInstanceCreation;
+import org.eclipse.wst.jsdt.core.dom.Comment;
+import org.eclipse.wst.jsdt.core.dom.ConditionalExpression;
+import org.eclipse.wst.jsdt.core.dom.ConstructorInvocation;
+import org.eclipse.wst.jsdt.core.dom.ContinueStatement;
+import org.eclipse.wst.jsdt.core.dom.DoStatement;
+import org.eclipse.wst.jsdt.core.dom.EmptyStatement;
+import org.eclipse.wst.jsdt.core.dom.EnhancedForStatement;
+import org.eclipse.wst.jsdt.core.dom.Expression;
+import org.eclipse.wst.jsdt.core.dom.ExpressionStatement;
+import org.eclipse.wst.jsdt.core.dom.FieldAccess;
+import org.eclipse.wst.jsdt.core.dom.FieldDeclaration;
+import org.eclipse.wst.jsdt.core.dom.ForStatement;
+import org.eclipse.wst.jsdt.core.dom.FunctionDeclaration;
+import org.eclipse.wst.jsdt.core.dom.FunctionInvocation;
+import org.eclipse.wst.jsdt.core.dom.FunctionRef;
+import org.eclipse.wst.jsdt.core.dom.FunctionRefParameter;
+import org.eclipse.wst.jsdt.core.dom.IfStatement;
+import org.eclipse.wst.jsdt.core.dom.ImportDeclaration;
+import org.eclipse.wst.jsdt.core.dom.InfixExpression;
+import org.eclipse.wst.jsdt.core.dom.Initializer;
+import org.eclipse.wst.jsdt.core.dom.InstanceofExpression;
+import org.eclipse.wst.jsdt.core.dom.JSdoc;
+import org.eclipse.wst.jsdt.core.dom.JavaScriptUnit;
+import org.eclipse.wst.jsdt.core.dom.LabeledStatement;
+import org.eclipse.wst.jsdt.core.dom.LineComment;
+import org.eclipse.wst.jsdt.core.dom.MemberRef;
+import org.eclipse.wst.jsdt.core.dom.Modifier;
+import org.eclipse.wst.jsdt.core.dom.Name;
+import org.eclipse.wst.jsdt.core.dom.NullLiteral;
+import org.eclipse.wst.jsdt.core.dom.NumberLiteral;
+import org.eclipse.wst.jsdt.core.dom.PackageDeclaration;
+import org.eclipse.wst.jsdt.core.dom.ParameterizedType;
+import org.eclipse.wst.jsdt.core.dom.ParenthesizedExpression;
+import org.eclipse.wst.jsdt.core.dom.PostfixExpression;
+import org.eclipse.wst.jsdt.core.dom.PrefixExpression;
+import org.eclipse.wst.jsdt.core.dom.PrimitiveType;
+import org.eclipse.wst.jsdt.core.dom.QualifiedName;
+import org.eclipse.wst.jsdt.core.dom.QualifiedType;
+import org.eclipse.wst.jsdt.core.dom.ReturnStatement;
+import org.eclipse.wst.jsdt.core.dom.SimpleName;
+import org.eclipse.wst.jsdt.core.dom.SimpleType;
+import org.eclipse.wst.jsdt.core.dom.SingleVariableDeclaration;
+import org.eclipse.wst.jsdt.core.dom.Statement;
+import org.eclipse.wst.jsdt.core.dom.StringLiteral;
+import org.eclipse.wst.jsdt.core.dom.SuperConstructorInvocation;
+import org.eclipse.wst.jsdt.core.dom.SuperFieldAccess;
+import org.eclipse.wst.jsdt.core.dom.SuperMethodInvocation;
+import org.eclipse.wst.jsdt.core.dom.SwitchCase;
+import org.eclipse.wst.jsdt.core.dom.SwitchStatement;
+import org.eclipse.wst.jsdt.core.dom.TagElement;
+import org.eclipse.wst.jsdt.core.dom.TextElement;
+import org.eclipse.wst.jsdt.core.dom.ThisExpression;
+import org.eclipse.wst.jsdt.core.dom.ThrowStatement;
+import org.eclipse.wst.jsdt.core.dom.TryStatement;
+import org.eclipse.wst.jsdt.core.dom.Type;
+import org.eclipse.wst.jsdt.core.dom.TypeDeclaration;
+import org.eclipse.wst.jsdt.core.dom.TypeDeclarationStatement;
+import org.eclipse.wst.jsdt.core.dom.TypeLiteral;
+import org.eclipse.wst.jsdt.core.dom.TypeParameter;
+import org.eclipse.wst.jsdt.core.dom.VariableDeclarationExpression;
+import org.eclipse.wst.jsdt.core.dom.VariableDeclarationFragment;
+import org.eclipse.wst.jsdt.core.dom.VariableDeclarationStatement;
+import org.eclipse.wst.jsdt.core.dom.WhileStatement;
+import org.eclipse.wst.jsdt.core.dom.WildcardType;
// testing
@@ -48,23 +132,6 @@
}
}
- /**
- * @see org.eclipse.wst.jsdt.core.dom.ASTMatcher#match(AnnotationTypeDeclaration, Object)
- * @since 3.0
- */
- public boolean match(AnnotationTypeDeclaration node, Object other) {
- checkPositions(node, other);
- return super.match(node, other);
- }
-
- /**
- * @see org.eclipse.wst.jsdt.core.dom.ASTMatcher#match(AnnotationTypeMemberDeclaration, Object)
- * @since 3.0
- */
- public boolean match(AnnotationTypeMemberDeclaration node, Object other) {
- checkPositions(node, other);
- return super.match(node, other);
- }
/**
* @see org.eclipse.wst.jsdt.core.dom.ASTMatcher#match(AnonymousClassDeclaration, Object)
@@ -243,16 +310,7 @@
checkPositions(node, other);
return super.match(node, other);
}
-
- /**
- * @see org.eclipse.wst.jsdt.core.dom.ASTMatcher#match(EnumConstantDeclaration, Object)
- * @since 3.0
- */
- public boolean match(EnumConstantDeclaration node, Object other) {
- checkPositions(node, other);
- return super.match(node, other);
- }
-
+
/**
* @see org.eclipse.wst.jsdt.core.dom.ASTMatcher#match(ExpressionStatement, Object)
*/
@@ -349,15 +407,7 @@
checkPositions(node, other);
return super.match(node, other);
}
-
- /**
- * @see org.eclipse.wst.jsdt.core.dom.ASTMatcher#match(MarkerAnnotation, Object)
- * @since 3.0
- */
- public boolean match(MarkerAnnotation node, Object other) {
- checkPositions(node, other);
- return super.match(node, other);
- }
+
/**
* @see org.eclipse.wst.jsdt.core.dom.ASTMatcher#match(MemberRef, Object)
@@ -368,14 +418,7 @@
return super.match(node, other);
}
- /**
- * @see org.eclipse.wst.jsdt.core.dom.ASTMatcher#match(MemberValuePair, Object)
- * @since 3.0
- */
- public boolean match(MemberValuePair node, Object other) {
- checkPositions(node, other);
- return super.match(node, other);
- }
+
/**
* @see org.eclipse.wst.jsdt.core.dom.ASTMatcher#match(FunctionDeclaration, Object)
@@ -420,14 +463,6 @@
return super.match(node, other);
}
- /**
- * @see org.eclipse.wst.jsdt.core.dom.ASTMatcher#match(NormalAnnotation, Object)
- * @since 3.0
- */
- public boolean match(NormalAnnotation node, Object other) {
- checkPositions(node, other);
- return super.match(node, other);
- }
/**
* @see org.eclipse.wst.jsdt.core.dom.ASTMatcher#match(NullLiteral, Object)
@@ -536,15 +571,6 @@
}
/**
- * @see org.eclipse.wst.jsdt.core.dom.ASTMatcher#match(SingleMemberAnnotation, Object)
- * @since 3.0
- */
- public boolean match(SingleMemberAnnotation node, Object other) {
- checkPositions(node, other);
- return super.match(node, other);
- }
-
- /**
* @see org.eclipse.wst.jsdt.core.dom.ASTMatcher#match(SingleVariableDeclaration, Object)
*/
public boolean match(SingleVariableDeclaration node, Object other) {
@@ -1477,22 +1503,7 @@
fd.setName(ast.newSimpleName("b")); //$NON-NLS-1$
assertTrue(x.isDeclaration() == false);
- if (ast.apiLevel() >= AST.JLS3) {
- AnnotationTypeDeclaration atd = ast.newAnnotationTypeDeclaration();
- atd.setName(x);
- assertTrue(x.isDeclaration() == true);
- atd.setName(ast.newSimpleName("b")); //$NON-NLS-1$
- assertTrue(x.isDeclaration() == false);
- }
-
- if (ast.apiLevel() >= AST.JLS3) {
- AnnotationTypeMemberDeclaration atmd = ast.newAnnotationTypeMemberDeclaration();
- atmd.setName(x);
- assertTrue(x.isDeclaration() == true);
- atmd.setName(ast.newSimpleName("b")); //$NON-NLS-1$
- assertTrue(x.isDeclaration() == false);
- }
-
+
}
public void testQualifiedName() {
@@ -2324,16 +2335,7 @@
}
});
- genericPropertyListTest(x, x.annotations(), new Property("Annotations", true, Annotation.class) { //$NON-NLS-1$
- public ASTNode sample(AST targetAst, boolean parented) {
- MarkerAnnotation result = targetAst.newMarkerAnnotation();
- if (parented) {
- PackageDeclaration pd = targetAst.newPackageDeclaration();
- pd.annotations().add(result);
- }
- return result;
- }
- });
+
}
genericPropertyTest(x, new Property("Name", true, Name.class) { //$NON-NLS-1$
@@ -2573,7 +2575,6 @@
}
tJavadocComment(x);
- tModifiers(x);
genericPropertyTest(x, new Property("Name", true, SimpleName.class) { //$NON-NLS-1$
public ASTNode sample(AST targetAst, boolean parented) {
@@ -2697,14 +2698,6 @@
TypeDeclaration t1 = ast.newTypeDeclaration();
TypeDeclaration t2 = ast.newTypeDeclaration();
- EnumConstantDeclaration c1 = null;
- EnumConstantDeclaration c2 = null;
- if (ast.apiLevel() >= AST.JLS3) {
- c1 = ast.newEnumConstantDeclaration();
- c2 = ast.newEnumConstantDeclaration();
- x.bodyDeclarations().add(c1);
- x.bodyDeclarations().add(c2);
- }
x.bodyDeclarations().add(ast.newInitializer());
x.bodyDeclarations().add(f1);
@@ -2742,250 +2735,6 @@
}
- /** @deprecated using deprecated code */
- public void testEnumDeclaration() {
- if (ast.apiLevel() == AST.JLS2) {
- // node type introduced in 3.0 API
- try {
- ast.newEnumDeclaration();
- assertTrue(false);
- } catch (UnsupportedOperationException e) {
- // pass
- }
- return;
- }
- long previousCount = ast.modificationCount();
- final EnumDeclaration x = ast.newEnumDeclaration();
- assertTrue(ast.modificationCount() > previousCount);
- previousCount = ast.modificationCount();
- assertTrue(x.getAST() == ast);
- assertTrue(x.getParent() == null);
- assertTrue(x.modifiers().size() == 0);
- assertTrue(x.getName().getParent() == x);
- assertTrue(x.getName().isDeclaration() == true);
- assertTrue(x.getJavadoc() == null);
- assertTrue(x.superInterfaceTypes().size() == 0);
- assertTrue(x.enumConstants().size()== 0);
- assertTrue(x.bodyDeclarations().size()== 0);
- assertTrue(x.getNodeType() == ASTNode.ENUM_DECLARATION);
- assertTrue(x.structuralPropertiesForType() == EnumDeclaration.propertyDescriptors(ast.apiLevel()));
- // make sure that reading did not change modification count
- assertTrue(ast.modificationCount() == previousCount);
-
- previousCount = ast.modificationCount();
-
- tJavadocComment(x);
- tModifiers(x);
-
- genericPropertyTest(x, new Property("Name", true, SimpleName.class) { //$NON-NLS-1$
- public ASTNode sample(AST targetAst, boolean parented) {
- SimpleName result = targetAst.newSimpleName("foo"); //$NON-NLS-1$
- if (parented) {
- targetAst.newExpressionStatement(result);
- }
- return result;
- }
- public ASTNode get() {
- return x.getName();
- }
- public void set(ASTNode value) {
- x.setName((SimpleName) value);
- }
- });
-
- genericPropertyListTest(x, x.superInterfaceTypes(),
- new Property("SuperInterfaceTypes", true, Type.class) { //$NON-NLS-1$
- public ASTNode sample(AST targetAst, boolean parented) {
- SimpleType result = targetAst.newSimpleType(targetAst.newSimpleName("foo")); //$NON-NLS-1$
- if (parented) {
- targetAst.newArrayType(result);
- }
- return result;
- }
- });
-
- genericPropertyListTest(x, x.enumConstants(),
- new Property("EnumConstants", true, EnumConstantDeclaration.class) { //$NON-NLS-1$
- public ASTNode sample(AST targetAst, boolean parented) {
- EnumConstantDeclaration result = targetAst.newEnumConstantDeclaration();
- if (parented) {
- // use fact that EnumConstantDeclaration is also a BodyDeclaration
- TypeDeclaration d = targetAst.newTypeDeclaration();
- d.bodyDeclarations().add(result);
- }
- return result;
- }
- public ASTNode wrap() {
- EnumConstantDeclaration s1 = x.getAST().newEnumConstantDeclaration();
- AnonymousClassDeclaration anonymousClassDeclaration = x.getAST().newAnonymousClassDeclaration();
- s1.setAnonymousClassDeclaration(anonymousClassDeclaration);
- anonymousClassDeclaration.bodyDeclarations().add(x);
- return s1;
- }
- public void unwrap() {
- AnonymousClassDeclaration anonymousClassDeclaration = (AnonymousClassDeclaration) x.getParent();
- if (anonymousClassDeclaration != null) {
- anonymousClassDeclaration.bodyDeclarations().remove(x);
- }
- }
- });
-
- genericPropertyListTest(x, x.bodyDeclarations(),
- new Property("BodyDeclarations", true, BodyDeclaration.class) { //$NON-NLS-1$
- public ASTNode sample(AST targetAst, boolean parented) {
- TypeDeclaration result = targetAst.newTypeDeclaration();
- if (parented) {
- JavaScriptUnit cu = targetAst.newJavaScriptUnit();
- cu.types().add(result);
- }
- return result;
- }
- public ASTNode wrap() {
- TypeDeclaration s1 = x.getAST().newTypeDeclaration();
- s1.bodyDeclarations().add(x);
- return s1;
- }
- public void unwrap() {
- TypeDeclaration s1 = (TypeDeclaration) x.getParent();
- s1.bodyDeclarations().remove(x);
- }
- });
-
- // check special bodyDeclaration methods
- x.bodyDeclarations().clear();
- EnumConstantDeclaration c1 = ast.newEnumConstantDeclaration();
- EnumConstantDeclaration c2 = ast.newEnumConstantDeclaration();
- FieldDeclaration f1 = ast.newFieldDeclaration(ast.newVariableDeclarationFragment());
- FieldDeclaration f2 = ast.newFieldDeclaration(ast.newVariableDeclarationFragment());
- FunctionDeclaration m1 = ast.newFunctionDeclaration();
- FunctionDeclaration m2 = ast.newFunctionDeclaration();
- TypeDeclaration t1 = ast.newTypeDeclaration();
- TypeDeclaration t2 = ast.newTypeDeclaration();
-
- x.enumConstants().add(c1);
- x.enumConstants().add(c2);
- x.bodyDeclarations().add(f1);
- x.bodyDeclarations().add(f2);
- x.bodyDeclarations().add(m1);
- x.bodyDeclarations().add(m2);
- x.bodyDeclarations().add(t1);
- x.bodyDeclarations().add(t2);
-
- // check that TypeDeclarations in body are classified correctly
- assertTrue(t1.isLocalTypeDeclaration() == false);
- assertTrue(t1.isMemberTypeDeclaration() == true);
- assertTrue(t1.isPackageMemberTypeDeclaration() == false);
-
- }
-
- /** @deprecated using deprecated code */
- public void testEnumConstantDeclaration() {
- if (ast.apiLevel() == AST.JLS2) {
- // node type introduced in 3.0 API
- try {
- ast.newEnumConstantDeclaration();
- assertTrue(false);
- } catch (UnsupportedOperationException e) {
- // pass
- }
- return;
- }
- long previousCount = ast.modificationCount();
- final EnumConstantDeclaration x = ast.newEnumConstantDeclaration();
- assertTrue(ast.modificationCount() > previousCount);
- previousCount = ast.modificationCount();
- assertTrue(x.getAST() == ast);
- assertTrue(x.getParent() == null);
- assertTrue(x.getName().getParent() == x);
- assertTrue(x.getName().isDeclaration() == true);
- assertTrue(x.getJavadoc() == null);
- assertTrue(x.arguments().size()== 0);
- assertTrue(x.getAnonymousClassDeclaration() == null);
- assertTrue(x.modifiers().size() == 0);
- assertTrue(x.getNodeType() == ASTNode.ENUM_CONSTANT_DECLARATION);
- assertTrue(x.structuralPropertiesForType() == EnumConstantDeclaration.propertyDescriptors(ast.apiLevel()));
- // make sure that reading did not change modification count
- assertTrue(ast.modificationCount() == previousCount);
-
- tJavadocComment(x);
- tModifiers(x);
-
- genericPropertyTest(x, new Property("Name", true, SimpleName.class) { //$NON-NLS-1$
- public ASTNode sample(AST targetAst, boolean parented) {
- SimpleName result = targetAst.newSimpleName("foo"); //$NON-NLS-1$
- if (parented) {
- targetAst.newExpressionStatement(result);
- }
- return result;
- }
- public ASTNode get() {
- return x.getName();
- }
- public void set(ASTNode value) {
- x.setName((SimpleName) value);
- }
- });
-
- genericPropertyListTest(x, x.arguments(),
- new Property("Arguments", true, Expression.class) { //$NON-NLS-1$
- public ASTNode sample(AST targetAst, boolean parented) {
- SimpleName result = targetAst.newSimpleName("foo"); //$NON-NLS-1$
- if (parented) {
- targetAst.newExpressionStatement(result);
- }
- return result;
- }
- public ASTNode wrap() {
- AnonymousClassDeclaration s1 = x.getAST().newAnonymousClassDeclaration();
- s1.bodyDeclarations().add(x);
- return s1;
- }
- public void unwrap() {
- AnonymousClassDeclaration s1 = (AnonymousClassDeclaration) x.getParent();
- s1.bodyDeclarations().remove(x);
- }
- });
-
- genericPropertyTest(x, new Property("AnonymousClassDeclaration", false, AnonymousClassDeclaration.class) { //$NON-NLS-1$
- public ASTNode sample(AST targetAst, boolean parented) {
- AnonymousClassDeclaration result = targetAst.newAnonymousClassDeclaration();
- if (parented) {
- targetAst.newClassInstanceCreation().setAnonymousClassDeclaration(result);
- }
- return result;
- }
- public ASTNode wrap() {
- // return AnonymousClassDeclaration that embeds x
- AnonymousClassDeclaration s0 = x.getAST().newAnonymousClassDeclaration();
- EnumDeclaration s1 = x.getAST().newEnumDeclaration();
- s0.bodyDeclarations().add(s1);
- s1.bodyDeclarations().add(x);
- return s0;
- }
- public void unwrap() {
- EnumDeclaration s1 = (EnumDeclaration) x.getParent();
- s1.bodyDeclarations().remove(x);
- }
- public ASTNode get() {
- return x.getAnonymousClassDeclaration();
- }
- public void set(ASTNode value) {
- x.setAnonymousClassDeclaration((AnonymousClassDeclaration) value);
- }
- });
-
- // check that TypeDeclarations in body are classified correctly
- x.setAnonymousClassDeclaration(null);
- AnonymousClassDeclaration w0 = ast.newAnonymousClassDeclaration();
- x.setAnonymousClassDeclaration(w0);
- TypeDeclaration w1 = ast.newTypeDeclaration();
- w0.bodyDeclarations().add(w1);
-
- assertTrue(w1.isLocalTypeDeclaration() == false);
- assertTrue(w1.isMemberTypeDeclaration() == true);
- assertTrue(w1.isPackageMemberTypeDeclaration() == false);
-
- }
/** @deprecated using deprecated code */
public void testTypeParameter() {
@@ -3100,55 +2849,6 @@
assertTrue(x.isVarargs() == false);
}
- if (ast.apiLevel() >= AST.JLS3) {
- genericPropertyListTest(x, x.modifiers(), new Property("Modifiers", true, IExtendedModifier.class) { //$NON-NLS-1$
- public ASTNode sample(AST targetAst, boolean parented) {
- Modifier result = targetAst.newModifier(Modifier.ModifierKeyword.PUBLIC_KEYWORD);
- if (parented) {
- TypeDeclaration pd = targetAst.newTypeDeclaration();
- pd.modifiers().add(result);
- }
- return result;
- }
- public ASTNode wrap() {
- SingleMemberAnnotation s1 = x.getAST().newSingleMemberAnnotation();
- ClassInstanceCreation s2 = x.getAST().newClassInstanceCreation();
- AnonymousClassDeclaration s3 = x.getAST().newAnonymousClassDeclaration();
- FunctionDeclaration s4 = x.getAST().newFunctionDeclaration();
- SingleVariableDeclaration s5 = x.getAST().newSingleVariableDeclaration();
- s1.setValue(s2);
- s2.setAnonymousClassDeclaration(s3);
- s3.bodyDeclarations().add(s4);
- s4.parameters().add(s5);
- s5.modifiers().add(x);
- return s1;
- }
- public void unwrap() {
- SingleVariableDeclaration s5 = (SingleVariableDeclaration) x.getParent();
- s5.modifiers().remove(x);
- }
- });
-
- // check that getModifiers() tracks changes to modifiers()
- x.modifiers().clear();
- assertTrue(x.getModifiers() == Modifier.NONE);
- Modifier[] allMods = allModifiers();
- // one at a time
- for (int i = 0 ; i < allMods.length; i++) {
- x.modifiers().add(allMods[i]);
- assertTrue(x.getModifiers() == allMods[i].getKeyword().toFlagValue());
- x.modifiers().remove(allMods[i]);
- assertTrue(x.getModifiers() == Modifier.NONE);
- }
- // all at same time
- for (int i = 0 ; i < allMods.length; i++) {
- x.modifiers().add(allMods[i]);
- }
- int flags = x.getModifiers();
- for (int i = 0 ; i < allMods.length; i++) {
- assertTrue((flags & allMods[i].getKeyword().toFlagValue()) != 0);
- }
- }
genericPropertyTest(x, new Property("Name", true, SimpleName.class) { //$NON-NLS-1$
public ASTNode sample(AST targetAst, boolean parented) {
@@ -3361,7 +3061,6 @@
assertTrue(x.getExtraDimensions() == 0);
tJavadocComment(x);
- tModifiers(x);
if (ast.apiLevel() >= AST.JLS3) {
genericPropertyListTest(x, x.typeParameters(),
@@ -3534,7 +3233,6 @@
assertTrue(ast.modificationCount() == previousCount);
tJavadocComment(x);
- tModifiers(x);
if (ast.apiLevel() == AST.JLS2) {
int legal = Modifier.STATIC;
@@ -4282,58 +3980,6 @@
assertTrue(x.getModifiers() == Modifier.NONE);
}
- if (ast.apiLevel() >= AST.JLS3) {
- genericPropertyListTest(x, x.modifiers(), new Property("Modifiers", true, IExtendedModifier.class) { //$NON-NLS-1$
- public ASTNode sample(AST targetAst, boolean parented) {
- Modifier result = targetAst.newModifier(Modifier.ModifierKeyword.PUBLIC_KEYWORD);
- if (parented) {
- TypeDeclaration pd = targetAst.newTypeDeclaration();
- pd.modifiers().add(result);
- }
- return result;
- }
- public ASTNode wrap() {
- SingleMemberAnnotation s1 = x.getAST().newSingleMemberAnnotation();
- ClassInstanceCreation s2 = x.getAST().newClassInstanceCreation();
- AnonymousClassDeclaration s3 = x.getAST().newAnonymousClassDeclaration();
- FunctionDeclaration s4 = x.getAST().newFunctionDeclaration();
- Block s5 = x.getAST().newBlock();
- VariableDeclarationFragment s6 = x.getAST().newVariableDeclarationFragment();
- VariableDeclarationStatement s7 = x.getAST().newVariableDeclarationStatement(s6);
- s1.setValue(s2);
- s2.setAnonymousClassDeclaration(s3);
- s3.bodyDeclarations().add(s4);
- s4.setBody(s5);
- s5.statements().add(s7);
- s7.modifiers().add(x);
- return s1;
- }
- public void unwrap() {
- VariableDeclarationStatement s7 = (VariableDeclarationStatement) x.getParent();
- s7.modifiers().remove(x);
- }
- });
-
- // check that getModifiers() tracks changes to modifiers()
- x.modifiers().clear();
- assertTrue(x.getModifiers() == Modifier.NONE);
- Modifier[] allMods = allModifiers();
- // one at a time
- for (int i = 0 ; i < allMods.length; i++) {
- x.modifiers().add(allMods[i]);
- assertTrue(x.getModifiers() == allMods[i].getKeyword().toFlagValue());
- x.modifiers().remove(allMods[i]);
- assertTrue(x.getModifiers() == Modifier.NONE);
- }
- // all at same time
- for (int i = 0 ; i < allMods.length; i++) {
- x.modifiers().add(allMods[i]);
- }
- int flags = x.getModifiers();
- for (int i = 0 ; i < allMods.length; i++) {
- assertTrue((flags & allMods[i].getKeyword().toFlagValue()) != 0);
- }
- }
genericPropertyTest(x, new Property("Type", true, Type.class) { //$NON-NLS-1$
public ASTNode sample(AST targetAst, boolean parented) {
@@ -4513,47 +4159,6 @@
assertTrue(x.getModifiers() == Modifier.NONE);
}
- if (ast.apiLevel() >= AST.JLS3) {
- genericPropertyListTest(x, x.modifiers(), new Property("Modifiers", true, IExtendedModifier.class) { //$NON-NLS-1$
- public ASTNode sample(AST targetAst, boolean parented) {
- Modifier result = targetAst.newModifier(Modifier.ModifierKeyword.PUBLIC_KEYWORD);
- if (parented) {
- TypeDeclaration pd = targetAst.newTypeDeclaration();
- pd.modifiers().add(result);
- }
- return result;
- }
- public ASTNode wrap() {
- SingleMemberAnnotation s1 = x.getAST().newSingleMemberAnnotation();
- s1.setValue(x);
- return s1;
- }
- public void unwrap() {
- SingleMemberAnnotation s1 = (SingleMemberAnnotation) x.getParent();
- s1.setValue(x.getAST().newNullLiteral());
- }
- });
-
- // check that getModifiers() tracks changes to modifiers()
- x.modifiers().clear();
- assertTrue(x.getModifiers() == Modifier.NONE);
- Modifier[] allMods = allModifiers();
- // one at a time
- for (int i = 0 ; i < allMods.length; i++) {
- x.modifiers().add(allMods[i]);
- assertTrue(x.getModifiers() == allMods[i].getKeyword().toFlagValue());
- x.modifiers().remove(allMods[i]);
- assertTrue(x.getModifiers() == Modifier.NONE);
- }
- // all at same time
- for (int i = 0 ; i < allMods.length; i++) {
- x.modifiers().add(allMods[i]);
- }
- int flags = x.getModifiers();
- for (int i = 0 ; i < allMods.length; i++) {
- assertTrue((flags & allMods[i].getKeyword().toFlagValue()) != 0);
- }
- }
genericPropertyTest(x, new Property("Type", true, Type.class) { //$NON-NLS-1$
public ASTNode sample(AST targetAst, boolean parented) {
@@ -4644,7 +4249,6 @@
}
tJavadocComment(x);
- tModifiers(x);
genericPropertyTest(x, new Property("Type", true, Type.class) { //$NON-NLS-1$
public ASTNode sample(AST targetAst, boolean parented) {
@@ -5472,62 +5076,6 @@
return allMods;
}
- /**
- * Exercise the modifiers property.
- *
- * @param x the body declaration to test
- * @deprecated using deprecated code
- */
- void tModifiers(final BodyDeclaration x) {
- if (ast.apiLevel() == AST.JLS2) {
- return;
- }
- genericPropertyListTest(x, x.modifiers(), new Property("Modifiers", true, IExtendedModifier.class) { //$NON-NLS-1$
- public ASTNode sample(AST targetAst, boolean parented) {
- Modifier result = targetAst.newModifier(Modifier.ModifierKeyword.PUBLIC_KEYWORD);
- if (parented) {
- TypeDeclaration pd = targetAst.newTypeDeclaration();
- pd.modifiers().add(result);
- }
- return result;
- }
- public ASTNode wrap() {
- SingleMemberAnnotation s1 = x.getAST().newSingleMemberAnnotation();
- ClassInstanceCreation s2 = x.getAST().newClassInstanceCreation();
- AnonymousClassDeclaration s3 = x.getAST().newAnonymousClassDeclaration();
- FunctionDeclaration s4 = x.getAST().newFunctionDeclaration();
- s1.setValue(s2);
- s2.setAnonymousClassDeclaration(s3);
- s3.bodyDeclarations().add(s4);
- s4.modifiers().add(x);
- return s1;
- }
- public void unwrap() {
- FunctionDeclaration s4 = (FunctionDeclaration) x.getParent();
- s4.modifiers().remove(x);
- }
- });
-
- // check that getModifiers() tracks changes to modifiers()
- x.modifiers().clear();
- assertTrue(x.getModifiers() == Modifier.NONE);
- Modifier[] allMods = allModifiers();
- // one at a time
- for (int i = 0 ; i < allMods.length; i++) {
- x.modifiers().add(allMods[i]);
- assertTrue(x.getModifiers() == allMods[i].getKeyword().toFlagValue());
- x.modifiers().remove(allMods[i]);
- assertTrue(x.getModifiers() == Modifier.NONE);
- }
- // all at same time
- for (int i = 0 ; i < allMods.length; i++) {
- x.modifiers().add(allMods[i]);
- }
- int flags = x.getModifiers();
- for (int i = 0 ; i < allMods.length; i++) {
- assertTrue((flags & allMods[i].getKeyword().toFlagValue()) != 0);
- }
- }
/**
* Exercise the alternateRoot property of a Comment.
@@ -6154,10 +5702,6 @@
assertTrue(node.resolveBinding() == null);
return true;
}
- public boolean visit(EnumConstantDeclaration node) {
- assertTrue(node.resolveVariable() == null);
- return true;
- }
};
x.accept(v);
@@ -7764,451 +7308,6 @@
});
}
- /** @deprecated using deprecated code */
- public void testAnnotationTypeDeclaration() {
- if (ast.apiLevel() == AST.JLS2) {
- // node type introduced in 3.0 API
- try {
- ast.newAnnotationTypeDeclaration();
- assertTrue(false);
- } catch (UnsupportedOperationException e) {
- // pass
- }
- return;
- }
- long previousCount = ast.modificationCount();
- final AnnotationTypeDeclaration x = ast.newAnnotationTypeDeclaration();
- assertTrue(ast.modificationCount() > previousCount);
- previousCount = ast.modificationCount();
- assertTrue(x.getAST() == ast);
- assertTrue(x.getParent() == null);
- assertTrue(x.modifiers().size() == 0);
- assertTrue(x.getJavadoc() == null);
- assertTrue(x.getName().getParent() == x);
- assertTrue(x.getName().isDeclaration() == true);
- assertTrue(x.bodyDeclarations().size()== 0);
- assertTrue(x.getNodeType() == ASTNode.ANNOTATION_TYPE_DECLARATION);
- assertTrue(x.structuralPropertiesForType() ==
- AnnotationTypeDeclaration.propertyDescriptors(ast.apiLevel()));
- // make sure that reading did not change modification count
- assertTrue(ast.modificationCount() == previousCount);
-
- previousCount = ast.modificationCount();
-
- tJavadocComment(x);
- tModifiers(x);
-
- genericPropertyTest(x, new Property("Name", true, SimpleName.class) { //$NON-NLS-1$
- public ASTNode sample(AST targetAst, boolean parented) {
- SimpleName result = targetAst.newSimpleName("foo"); //$NON-NLS-1$
- if (parented) {
- targetAst.newExpressionStatement(result);
- }
- return result;
- }
- public ASTNode get() {
- return x.getName();
- }
- public void set(ASTNode value) {
- x.setName((SimpleName) value);
- }
- });
-
- genericPropertyListTest(x, x.bodyDeclarations(),
- new Property("BodyDeclarations", true, BodyDeclaration.class) { //$NON-NLS-1$
- public ASTNode sample(AST targetAst, boolean parented) {
- AnnotationTypeMemberDeclaration result = targetAst.newAnnotationTypeMemberDeclaration();
- if (parented) {
- AnnotationTypeDeclaration atd = targetAst.newAnnotationTypeDeclaration();
- atd.bodyDeclarations().add(result);
- }
- return result;
- }
- public ASTNode wrap() {
- // return AnnotationTypeMemberDeclaration that embeds x
- AnnotationTypeMemberDeclaration s1 = x.getAST().newAnnotationTypeMemberDeclaration();
- ClassInstanceCreation s2 = x.getAST().newClassInstanceCreation();
- AnonymousClassDeclaration s3 = x.getAST().newAnonymousClassDeclaration();
- s1.setDefault(s2);
- s2.setAnonymousClassDeclaration(s3);
- s3.bodyDeclarations().add(x);
- return s1;
- }
- public void unwrap() {
- AnonymousClassDeclaration s3 = (AnonymousClassDeclaration) x.getParent();
- s3.bodyDeclarations().remove(x);
- }
- });
-
- // check that TypeDeclarations in body are classified correctly
- assertTrue(x.isLocalTypeDeclaration() == false);
- assertTrue(x.isMemberTypeDeclaration() == false);
- assertTrue(x.isPackageMemberTypeDeclaration() == false);
-
- // check special bodyDeclaration methods
- TypeDeclaration t0 = ast.newTypeDeclaration();
- AnnotationTypeDeclaration t1 = ast.newAnnotationTypeDeclaration();
- t0.bodyDeclarations().add(t1);
- assertTrue(t1.isLocalTypeDeclaration() == false);
- assertTrue(t1.isMemberTypeDeclaration() == true);
- assertTrue(t1.isPackageMemberTypeDeclaration() == false);
-
- JavaScriptUnit t2 = ast.newJavaScriptUnit();
- AnnotationTypeDeclaration t3 = ast.newAnnotationTypeDeclaration();
- t2.types().add(t3);
- assertTrue(t3.isLocalTypeDeclaration() == false);
- assertTrue(t3.isMemberTypeDeclaration() == false);
- assertTrue(t3.isPackageMemberTypeDeclaration() == true);
- }
-
- /** @deprecated using deprecated code */
- public void testAnnotationTypeMemberDeclaration() {
- if (ast.apiLevel() == AST.JLS2) {
- // node type introduced in 3.0 API
- try {
- ast.newAnnotationTypeMemberDeclaration();
- assertTrue(false);
- } catch (UnsupportedOperationException e) {
- // pass
- }
- return;
- }
- long previousCount = ast.modificationCount();
- final AnnotationTypeMemberDeclaration x = ast.newAnnotationTypeMemberDeclaration();
- assertTrue(ast.modificationCount() > previousCount);
- previousCount = ast.modificationCount();
- assertTrue(x.getAST() == ast);
- assertTrue(x.getParent() == null);
- assertTrue(x.modifiers().size() == 0);
- assertTrue(x.getName().getParent() == x);
- assertTrue(x.getName().isDeclaration() == true);
- assertTrue(x.getType().getParent() == x);
- assertTrue(x.getJavadoc() == null);
- assertTrue(x.getDefault() == null);
- assertTrue(x.getNodeType() == ASTNode.ANNOTATION_TYPE_MEMBER_DECLARATION);
- assertTrue(x.structuralPropertiesForType() ==
- AnnotationTypeMemberDeclaration.propertyDescriptors(ast.apiLevel()));
- // make sure that reading did not change modification count
- assertTrue(ast.modificationCount() == previousCount);
-
- tJavadocComment(x);
- tModifiers(x);
-
- genericPropertyTest(x, new Property("Name", true, SimpleName.class) { //$NON-NLS-1$
- public ASTNode sample(AST targetAst, boolean parented) {
- SimpleName result = targetAst.newSimpleName("foo"); //$NON-NLS-1$
- if (parented) {
- targetAst.newExpressionStatement(result);
- }
- return result;
- }
- public ASTNode get() {
- return x.getName();
- }
- public void set(ASTNode value) {
- x.setName((SimpleName) value);
- }
- });
-
- genericPropertyTest(x, new Property("Type", true, Type.class) { //$NON-NLS-1$
- public ASTNode sample(AST targetAst, boolean parented) {
- SimpleType result = targetAst.newSimpleType(
- targetAst.newSimpleName("foo")); //$NON-NLS-1$
- if (parented) {
- targetAst.newArrayType(result);
- }
- return result;
- }
- public ASTNode get() {
- return x.getType();
- }
- public void set(ASTNode value) {
- x.setType((Type) value);
- }
- });
-
- genericPropertyTest(x, new Property("Default", false, Expression.class) { //$NON-NLS-1$
- public ASTNode sample(AST localAst, boolean parented) {
- Expression result = localAst.newSimpleName("foo"); //$NON-NLS-1$
- if (parented) {
- localAst.newExpressionStatement(result);
- }
- return result;
- }
- public ASTNode wrap() {
- // return Expression that embeds x
- ClassInstanceCreation s1 = x.getAST().newClassInstanceCreation();
- AnonymousClassDeclaration s2 = x.getAST().newAnonymousClassDeclaration();
- s1.setAnonymousClassDeclaration(s2);
- s2.bodyDeclarations().add(x);
- return s1;
- }
- public void unwrap() {
- AnonymousClassDeclaration s2 = (AnonymousClassDeclaration) x.getParent();
- s2.bodyDeclarations().remove(x);
- }
- public ASTNode get() {
- return x.getDefault();
- }
- public void set(ASTNode value) {
- x.setDefault((Expression) value);
- }
- });
- }
-
- /** @deprecated using deprecated code */
- public void testNormalAnnotation() {
- if (ast.apiLevel() == AST.JLS2) {
- // node type introduced in 3.0 API
- try {
- ast.newNormalAnnotation();
- assertTrue(false);
- } catch (UnsupportedOperationException e) {
- // pass
- }
- return;
- }
- long previousCount = ast.modificationCount();
- final NormalAnnotation x = ast.newNormalAnnotation(); //$NON-NLS-1$
- assertTrue(ast.modificationCount() > previousCount);
- previousCount = ast.modificationCount();
- assertTrue(x.getAST() == ast);
- assertTrue(x.getParent() == null);
- assertTrue(x.getTypeName().getParent() == x);
- assertTrue(x.values().size() == 0);
- assertTrue(x.isAnnotation());
- assertTrue(!x.isModifier());
- assertTrue(!x.isMarkerAnnotation());
- assertTrue(x.isNormalAnnotation());
- assertTrue(!x.isSingleMemberAnnotation());
- assertTrue(x.getNodeType() == ASTNode.NORMAL_ANNOTATION);
- assertTrue(x.structuralPropertiesForType() ==
- NormalAnnotation.propertyDescriptors(ast.apiLevel()));
- // make sure that reading did not change modification count
- assertTrue(ast.modificationCount() == previousCount);
-
- tAnnotationName(x);
-
- genericPropertyListTest(x, x.values(), new Property("Values", true, MemberValuePair.class) { //$NON-NLS-1$
- public ASTNode sample(AST targetAst, boolean parented) {
- MemberValuePair result = targetAst.newMemberValuePair();
- if (parented) {
- NormalAnnotation ann = targetAst.newNormalAnnotation();
- ann.values().add(result);
- }
- return result;
- }
- public ASTNode wrap() {
- // return MemberValuePair that embeds x
- MemberValuePair s1 = x.getAST().newMemberValuePair();
- ClassInstanceCreation s2 = x.getAST().newClassInstanceCreation();
- AnonymousClassDeclaration s3 = x.getAST().newAnonymousClassDeclaration();
- FunctionDeclaration s4 = x.getAST().newFunctionDeclaration();
- s1.setValue(s2);
- s2.setAnonymousClassDeclaration(s3);
- s3.bodyDeclarations().add(s4);
- s4.modifiers().add(x);
- return s1;
- }
- public void unwrap() {
- FunctionDeclaration s4 = (FunctionDeclaration) x.getParent();
- s4.modifiers().remove(x);
- }
- });
- }
-
- /** @deprecated using deprecated code */
- public void testMarkerAnnotation() {
- if (ast.apiLevel() == AST.JLS2) {
- // node type introduced in 3.0 API
- try {
- ast.newMarkerAnnotation();
- assertTrue(false);
- } catch (UnsupportedOperationException e) {
- // pass
- }
- return;
- }
- long previousCount = ast.modificationCount();
- final MarkerAnnotation x = ast.newMarkerAnnotation(); //$NON-NLS-1$
- assertTrue(ast.modificationCount() > previousCount);
- previousCount = ast.modificationCount();
- assertTrue(x.getAST() == ast);
- assertTrue(x.getParent() == null);
- assertTrue(x.getTypeName().getParent() == x);
- assertTrue(x.isAnnotation());
- assertTrue(!x.isModifier());
- assertTrue(x.isMarkerAnnotation());
- assertTrue(!x.isNormalAnnotation());
- assertTrue(!x.isSingleMemberAnnotation());
- assertTrue(x.getNodeType() == ASTNode.MARKER_ANNOTATION);
- assertTrue(x.structuralPropertiesForType() ==
- MarkerAnnotation.propertyDescriptors(ast.apiLevel()));
- // make sure that reading did not change modification count
- assertTrue(ast.modificationCount() == previousCount);
-
- tAnnotationName(x);
- }
-
- /** @deprecated using deprecated code */
- public void testSingleMemberAnnotation() {
- if (ast.apiLevel() == AST.JLS2) {
- // node type introduced in 3.0 API
- try {
- ast.newSingleMemberAnnotation();
- assertTrue(false);
- } catch (UnsupportedOperationException e) {
- // pass
- }
- return;
- }
- long previousCount = ast.modificationCount();
- final SingleMemberAnnotation x = ast.newSingleMemberAnnotation(); //$NON-NLS-1$
- assertTrue(ast.modificationCount() > previousCount);
- previousCount = ast.modificationCount();
- assertTrue(x.getAST() == ast);
- assertTrue(x.getParent() == null);
- assertTrue(x.getTypeName().getParent() == x);
- assertTrue(x.isAnnotation());
- assertTrue(!x.isModifier());
- assertTrue(!x.isMarkerAnnotation());
- assertTrue(!x.isNormalAnnotation());
- assertTrue(x.isSingleMemberAnnotation());
- assertTrue(x.getNodeType() == ASTNode.SINGLE_MEMBER_ANNOTATION);
- // make sure that reading did not change modification count
- assertTrue(ast.modificationCount() == previousCount);
-
- tAnnotationName(x);
-
- genericPropertyTest(x, new Property("Value", true, Expression.class) { //$NON-NLS-1$
- public ASTNode sample(AST localAst, boolean parented) {
- Expression result = localAst.newSimpleName("foo"); //$NON-NLS-1$
- if (parented) {
- localAst.newExpressionStatement(result);
- }
- return result;
- }
- public ASTNode wrap() {
- // return Expression that embeds x
- ClassInstanceCreation s1 = x.getAST().newClassInstanceCreation();
- AnonymousClassDeclaration s2 = x.getAST().newAnonymousClassDeclaration();
- FunctionDeclaration s3 = x.getAST().newFunctionDeclaration();
- s1.setAnonymousClassDeclaration(s2);
- s2.bodyDeclarations().add(s3);
- s3.modifiers().add(x);
- return s1;
- }
- public void unwrap() {
- FunctionDeclaration s3 = (FunctionDeclaration) x.getParent();
- s3.modifiers().remove(x);
- }
- public ASTNode get() {
- return x.getValue();
- }
- public void set(ASTNode value) {
- x.setValue((Expression) value);
- }
- });
- }
-
- /** @deprecated using deprecated code */
- public void testMemberValuePair() {
- if (ast.apiLevel() == AST.JLS2) {
- // node type introduced in 3.0 API
- try {
- ast.newMemberValuePair();
- assertTrue(false);
- } catch (UnsupportedOperationException e) {
- // pass
- }
- return;
- }
- long previousCount = ast.modificationCount();
- final MemberValuePair x = ast.newMemberValuePair(); //$NON-NLS-1$
- assertTrue(ast.modificationCount() > previousCount);
- previousCount = ast.modificationCount();
- assertTrue(x.getAST() == ast);
- assertTrue(x.getParent() == null);
- assertTrue(x.getName().getParent() == x);
- assertTrue(x.getName().isDeclaration() == false);
- assertTrue(x.getNodeType() == ASTNode.MEMBER_VALUE_PAIR);
- assertTrue(x.structuralPropertiesForType() ==
- MemberValuePair.propertyDescriptors(ast.apiLevel()));
- // make sure that reading did not change modification count
- assertTrue(ast.modificationCount() == previousCount);
-
- genericPropertyTest(x, new Property("Name", true, SimpleName.class) { //$NON-NLS-1$
- public ASTNode sample(AST targetAst, boolean parented) {
- SimpleName result = targetAst.newSimpleName("a"); //$NON-NLS-1$
- if (parented) {
- targetAst.newExpressionStatement(result);
- }
- return result;
- }
- public ASTNode get() {
- return x.getName();
- }
- public void set(ASTNode value) {
- x.setName((SimpleName) value);
- }
- });
-
- genericPropertyTest(x, new Property("Value", true, Expression.class) { //$NON-NLS-1$
- public ASTNode sample(AST localAst, boolean parented) {
- Expression result = localAst.newSimpleName("foo"); //$NON-NLS-1$
- if (parented) {
- localAst.newExpressionStatement(result);
- }
- return result;
- }
- public ASTNode wrap() {
- // return Expression that embeds x
- ClassInstanceCreation s1 = x.getAST().newClassInstanceCreation();
- AnonymousClassDeclaration s2 = x.getAST().newAnonymousClassDeclaration();
- FunctionDeclaration s3 = x.getAST().newFunctionDeclaration();
- NormalAnnotation s4 = x.getAST().newNormalAnnotation();
- s1.setAnonymousClassDeclaration(s2);
- s2.bodyDeclarations().add(s3);
- s3.modifiers().add(s4);
- s4.values().add(x);
- return s1;
- }
- public void unwrap() {
- NormalAnnotation s4 = (NormalAnnotation) x.getParent();
- s4.values().remove(x);
- }
- public ASTNode get() {
- return x.getValue();
- }
- public void set(ASTNode value) {
- x.setValue((Expression) value);
- }
- });
- }
-
- /**
- * Exercise the typeName property of an Annotation.
- *
- * @param x the annotation to test
- * @since 3.0
- */
- public void tAnnotationName(final Annotation x) {
- genericPropertyTest(x, new Property("TypeName", true, Name.class) { //$NON-NLS-1$
- public ASTNode sample(AST targetAst, boolean parented) {
- SimpleName result = targetAst.newSimpleName("a"); //$NON-NLS-1$
- if (parented) {
- targetAst.newExpressionStatement(result);
- }
- return result;
- }
- public ASTNode get() {
- return x.getTypeName();
- }
- public void set(ASTNode value) {
- x.setTypeName((Name) value);
- }
- });
- }
/** @deprecated using deprecated code */
public void testModifiers() {
@@ -8483,25 +7582,15 @@
assertTrue(ASTNode.FUNCTION_REF == 68);
assertTrue(ASTNode.FUNCTION_REF_PARAMETER == 69);
assertTrue(ASTNode.ENHANCED_FOR_STATEMENT == 70);
- assertTrue(ASTNode.ENUM_DECLARATION == 71);
- assertTrue(ASTNode.ENUM_CONSTANT_DECLARATION == 72);
assertTrue(ASTNode.TYPE_PARAMETER == 73);
assertTrue(ASTNode.PARAMETERIZED_TYPE == 74);
assertTrue(ASTNode.QUALIFIED_TYPE == 75);
assertTrue(ASTNode.WILDCARD_TYPE == 76);
- assertTrue(ASTNode.NORMAL_ANNOTATION == 77);
- assertTrue(ASTNode.MARKER_ANNOTATION == 78);
- assertTrue(ASTNode.SINGLE_MEMBER_ANNOTATION == 79);
- assertTrue(ASTNode.MEMBER_VALUE_PAIR == 80);
- assertTrue(ASTNode.ANNOTATION_TYPE_DECLARATION == 81);
- assertTrue(ASTNode.ANNOTATION_TYPE_MEMBER_DECLARATION == 82);
assertTrue(ASTNode.MODIFIER == 83);
// ensure that all constants are distinct, positive, and small
// (this may seem paranoid, but this test did uncover a stupid bug!)
int[] all= {
- ASTNode.ANNOTATION_TYPE_DECLARATION,
- ASTNode.ANNOTATION_TYPE_MEMBER_DECLARATION,
ASTNode.ANONYMOUS_CLASS_DECLARATION,
ASTNode.ARRAY_ACCESS,
ASTNode.ARRAY_CREATION,
@@ -8524,8 +7613,6 @@
ASTNode.DO_STATEMENT,
ASTNode.EMPTY_STATEMENT,
ASTNode.ENHANCED_FOR_STATEMENT,
- ASTNode.ENUM_CONSTANT_DECLARATION,
- ASTNode.ENUM_DECLARATION,
ASTNode.EXPRESSION_STATEMENT,
ASTNode.FIELD_ACCESS,
ASTNode.FIELD_DECLARATION,
@@ -8538,15 +7625,12 @@
ASTNode.JSDOC,
ASTNode.LABELED_STATEMENT,
ASTNode.LINE_COMMENT,
- ASTNode.MARKER_ANNOTATION,
ASTNode.MEMBER_REF,
- ASTNode.MEMBER_VALUE_PAIR,
ASTNode.FUNCTION_DECLARATION,
ASTNode.FUNCTION_INVOCATION,
ASTNode.FUNCTION_REF,
ASTNode.FUNCTION_REF_PARAMETER,
ASTNode.MODIFIER,
- ASTNode.NORMAL_ANNOTATION,
ASTNode.NULL_LITERAL,
ASTNode.NUMBER_LITERAL,
ASTNode.PACKAGE_DECLARATION,
@@ -8560,7 +7644,6 @@
ASTNode.RETURN_STATEMENT,
ASTNode.SIMPLE_NAME,
ASTNode.SIMPLE_TYPE,
- ASTNode.SINGLE_MEMBER_ANNOTATION,
ASTNode.SINGLE_VARIABLE_DECLARATION,
ASTNode.STRING_LITERAL,
ASTNode.SUPER_CONSTRUCTOR_INVOCATION,
diff --git a/tests/org.eclipse.wst.jsdt.core.tests.model/src/org/eclipse/wst/jsdt/core/tests/dom/ASTVisitorTest.java b/tests/org.eclipse.wst.jsdt.core.tests.model/src/org/eclipse/wst/jsdt/core/tests/dom/ASTVisitorTest.java
index 0937859..761d8b8 100644
--- a/tests/org.eclipse.wst.jsdt.core.tests.model/src/org/eclipse/wst/jsdt/core/tests/dom/ASTVisitorTest.java
+++ b/tests/org.eclipse.wst.jsdt.core.tests.model/src/org/eclipse/wst/jsdt/core/tests/dom/ASTVisitorTest.java
@@ -12,9 +12,90 @@
package org.eclipse.wst.jsdt.core.tests.dom;
import java.lang.reflect.Method;
+
import junit.framework.Test;
-import org.eclipse.wst.jsdt.core.dom.*;
+
+import org.eclipse.wst.jsdt.core.dom.AST;
import org.eclipse.wst.jsdt.core.dom.ASTNode;
+import org.eclipse.wst.jsdt.core.dom.ASTVisitor;
+import org.eclipse.wst.jsdt.core.dom.AnonymousClassDeclaration;
+import org.eclipse.wst.jsdt.core.dom.ArrayAccess;
+import org.eclipse.wst.jsdt.core.dom.ArrayCreation;
+import org.eclipse.wst.jsdt.core.dom.ArrayInitializer;
+import org.eclipse.wst.jsdt.core.dom.ArrayType;
+import org.eclipse.wst.jsdt.core.dom.AssertStatement;
+import org.eclipse.wst.jsdt.core.dom.Assignment;
+import org.eclipse.wst.jsdt.core.dom.Block;
+import org.eclipse.wst.jsdt.core.dom.BlockComment;
+import org.eclipse.wst.jsdt.core.dom.BooleanLiteral;
+import org.eclipse.wst.jsdt.core.dom.BreakStatement;
+import org.eclipse.wst.jsdt.core.dom.CastExpression;
+import org.eclipse.wst.jsdt.core.dom.CatchClause;
+import org.eclipse.wst.jsdt.core.dom.CharacterLiteral;
+import org.eclipse.wst.jsdt.core.dom.ClassInstanceCreation;
+import org.eclipse.wst.jsdt.core.dom.ConditionalExpression;
+import org.eclipse.wst.jsdt.core.dom.ConstructorInvocation;
+import org.eclipse.wst.jsdt.core.dom.ContinueStatement;
+import org.eclipse.wst.jsdt.core.dom.DoStatement;
+import org.eclipse.wst.jsdt.core.dom.EmptyStatement;
+import org.eclipse.wst.jsdt.core.dom.EnhancedForStatement;
+import org.eclipse.wst.jsdt.core.dom.Expression;
+import org.eclipse.wst.jsdt.core.dom.ExpressionStatement;
+import org.eclipse.wst.jsdt.core.dom.FieldAccess;
+import org.eclipse.wst.jsdt.core.dom.FieldDeclaration;
+import org.eclipse.wst.jsdt.core.dom.ForStatement;
+import org.eclipse.wst.jsdt.core.dom.FunctionDeclaration;
+import org.eclipse.wst.jsdt.core.dom.FunctionInvocation;
+import org.eclipse.wst.jsdt.core.dom.FunctionRef;
+import org.eclipse.wst.jsdt.core.dom.FunctionRefParameter;
+import org.eclipse.wst.jsdt.core.dom.IfStatement;
+import org.eclipse.wst.jsdt.core.dom.ImportDeclaration;
+import org.eclipse.wst.jsdt.core.dom.InfixExpression;
+import org.eclipse.wst.jsdt.core.dom.Initializer;
+import org.eclipse.wst.jsdt.core.dom.InstanceofExpression;
+import org.eclipse.wst.jsdt.core.dom.JSdoc;
+import org.eclipse.wst.jsdt.core.dom.JavaScriptUnit;
+import org.eclipse.wst.jsdt.core.dom.LabeledStatement;
+import org.eclipse.wst.jsdt.core.dom.LineComment;
+import org.eclipse.wst.jsdt.core.dom.MemberRef;
+import org.eclipse.wst.jsdt.core.dom.Modifier;
+import org.eclipse.wst.jsdt.core.dom.Name;
+import org.eclipse.wst.jsdt.core.dom.NullLiteral;
+import org.eclipse.wst.jsdt.core.dom.NumberLiteral;
+import org.eclipse.wst.jsdt.core.dom.PackageDeclaration;
+import org.eclipse.wst.jsdt.core.dom.ParameterizedType;
+import org.eclipse.wst.jsdt.core.dom.ParenthesizedExpression;
+import org.eclipse.wst.jsdt.core.dom.PostfixExpression;
+import org.eclipse.wst.jsdt.core.dom.PrefixExpression;
+import org.eclipse.wst.jsdt.core.dom.PrimitiveType;
+import org.eclipse.wst.jsdt.core.dom.QualifiedName;
+import org.eclipse.wst.jsdt.core.dom.QualifiedType;
+import org.eclipse.wst.jsdt.core.dom.ReturnStatement;
+import org.eclipse.wst.jsdt.core.dom.SimpleName;
+import org.eclipse.wst.jsdt.core.dom.SimpleType;
+import org.eclipse.wst.jsdt.core.dom.SingleVariableDeclaration;
+import org.eclipse.wst.jsdt.core.dom.Statement;
+import org.eclipse.wst.jsdt.core.dom.StringLiteral;
+import org.eclipse.wst.jsdt.core.dom.SuperConstructorInvocation;
+import org.eclipse.wst.jsdt.core.dom.SuperFieldAccess;
+import org.eclipse.wst.jsdt.core.dom.SuperMethodInvocation;
+import org.eclipse.wst.jsdt.core.dom.SwitchCase;
+import org.eclipse.wst.jsdt.core.dom.SwitchStatement;
+import org.eclipse.wst.jsdt.core.dom.TagElement;
+import org.eclipse.wst.jsdt.core.dom.TextElement;
+import org.eclipse.wst.jsdt.core.dom.ThisExpression;
+import org.eclipse.wst.jsdt.core.dom.ThrowStatement;
+import org.eclipse.wst.jsdt.core.dom.TryStatement;
+import org.eclipse.wst.jsdt.core.dom.Type;
+import org.eclipse.wst.jsdt.core.dom.TypeDeclaration;
+import org.eclipse.wst.jsdt.core.dom.TypeDeclarationStatement;
+import org.eclipse.wst.jsdt.core.dom.TypeLiteral;
+import org.eclipse.wst.jsdt.core.dom.TypeParameter;
+import org.eclipse.wst.jsdt.core.dom.VariableDeclarationExpression;
+import org.eclipse.wst.jsdt.core.dom.VariableDeclarationFragment;
+import org.eclipse.wst.jsdt.core.dom.VariableDeclarationStatement;
+import org.eclipse.wst.jsdt.core.dom.WhileStatement;
+import org.eclipse.wst.jsdt.core.dom.WildcardType;
public class ASTVisitorTest extends org.eclipse.wst.jsdt.core.tests.junit.extension.TestCase {
@@ -103,21 +184,15 @@
String TP1S;
TypeParameter TP2;
String TP2S;
- MemberValuePair MVP1;
String MVP1S;
- MemberValuePair MVP2;
String MVP2S;
Modifier MOD1;
String MOD1S;
Modifier MOD2;
String MOD2S;
- Annotation ANO1;
String ANO1S;
- Annotation ANO2;
String ANO2S;
- EnumConstantDeclaration EC1;
String EC1S;
- EnumConstantDeclaration EC2;
String EC2S;
final StringBuffer b = new StringBuffer();
@@ -248,36 +323,12 @@
TP2.setName(ast.newSimpleName("y")); //$NON-NLS-1$
TP2S = "[(tTP[(nSyynS)]tTP)]"; //$NON-NLS-1$
- MVP1 = ast.newMemberValuePair();
- MVP1.setName(ast.newSimpleName("x")); //$NON-NLS-1$
- MVP1.setValue(ast.newSimpleName("y")); //$NON-NLS-1$
- MVP1S = "[(@MVP[(nSxxnS)][(nSyynS)]@MVP)]"; //$NON-NLS-1$
-
- MVP2 = ast.newMemberValuePair();
- MVP2.setName(ast.newSimpleName("a")); //$NON-NLS-1$
- MVP2.setValue(ast.newSimpleName("b")); //$NON-NLS-1$
- MVP2S = "[(@MVP[(nSaanS)][(nSbbnS)]@MVP)]"; //$NON-NLS-1$
MOD1 = ast.newModifier(Modifier.ModifierKeyword.PUBLIC_KEYWORD);
MOD1S = "[(MODpublicpublicMOD)]"; //$NON-NLS-1$
MOD2 = ast.newModifier(Modifier.ModifierKeyword.FINAL_KEYWORD);
MOD2S = "[(MODfinalfinalMOD)]"; //$NON-NLS-1$
- ANO1 = ast.newMarkerAnnotation();
- ANO1.setTypeName(ast.newSimpleName("a")); //$NON-NLS-1$
- ANO1S = "[(@MAN[(nSaanS)]@MAN)]"; //$NON-NLS-1$
-
- ANO2 = ast.newNormalAnnotation();
- ANO2.setTypeName(ast.newSimpleName("b")); //$NON-NLS-1$
- ANO2S = "[(@NAN[(nSbbnS)]@NAN)]"; //$NON-NLS-1$
-
- EC1 = ast.newEnumConstantDeclaration();
- EC1.setName(ast.newSimpleName("c")); //$NON-NLS-1$
- EC1S = "[(ECD[(nSccnS)]ECD)]"; //$NON-NLS-1$
-
- EC2 = ast.newEnumConstantDeclaration();
- EC2.setName(ast.newSimpleName("d")); //$NON-NLS-1$
- EC2S = "[(ECD[(nSddnS)]ECD)]"; //$NON-NLS-1$
}
}
@@ -559,22 +610,6 @@
b.append("sEFR)"); //$NON-NLS-1$
}
- public boolean visit(EnumConstantDeclaration node) {
- b.append("(ECD"); //$NON-NLS-1$
- return isVisitingChildren();
- }
- public void endVisit(EnumConstantDeclaration node) {
- b.append("ECD)"); //$NON-NLS-1$
- }
-
- public boolean visit(EnumDeclaration node) {
- b.append("(ED"); //$NON-NLS-1$
- return isVisitingChildren();
- }
- public void endVisit(EnumDeclaration node) {
- b.append("ED)"); //$NON-NLS-1$
- }
-
public boolean visit(ExpressionStatement node) {
b.append("(sEX"); //$NON-NLS-1$
return isVisitingChildren();
@@ -967,53 +1002,6 @@
b.append("sWH)"); //$NON-NLS-1$
}
- public boolean visit(AnnotationTypeDeclaration node) {
- b.append("(@TD"); //$NON-NLS-1$
- return isVisitingChildren();
- }
- public void endVisit(AnnotationTypeDeclaration node) {
- b.append("@TD)"); //$NON-NLS-1$
- }
-
- public boolean visit(AnnotationTypeMemberDeclaration node) {
- b.append("(@MD"); //$NON-NLS-1$
- return isVisitingChildren();
- }
- public void endVisit(AnnotationTypeMemberDeclaration node) {
- b.append("@MD)"); //$NON-NLS-1$
- }
-
- public boolean visit(NormalAnnotation node) {
- b.append("(@NAN"); //$NON-NLS-1$
- return isVisitingChildren();
- }
- public void endVisit(NormalAnnotation node) {
- b.append("@NAN)"); //$NON-NLS-1$
- }
-
- public boolean visit(MarkerAnnotation node) {
- b.append("(@MAN"); //$NON-NLS-1$
- return isVisitingChildren();
- }
- public void endVisit(MarkerAnnotation node) {
- b.append("@MAN)"); //$NON-NLS-1$
- }
-
- public boolean visit(SingleMemberAnnotation node) {
- b.append("(@SMAN"); //$NON-NLS-1$
- return isVisitingChildren();
- }
- public void endVisit(SingleMemberAnnotation node) {
- b.append("@SMAN)"); //$NON-NLS-1$
- }
-
- public boolean visit(MemberValuePair node) {
- b.append("(@MVP"); //$NON-NLS-1$
- return isVisitingChildren();
- }
- public void endVisit(MemberValuePair node) {
- b.append("@MVP)"); //$NON-NLS-1$
- }
public boolean visit(Modifier node) {
b.append("(MOD"); //$NON-NLS-1$
@@ -1360,48 +1348,6 @@
String result = b.toString();
assertTrue(result.equals("[(sEMsEM)]")); //$NON-NLS-1$
}
- /** @deprecated Only to suppress warnings for refs to bodyDeclarations. */
- // TODO (jeem) - remove deprecation after 3.1 M4
- public void testEnumConstantDeclaration() {
- if (ast.apiLevel() == AST.JLS2) {
- return;
- }
- EnumConstantDeclaration x1 = ast.newEnumConstantDeclaration();
- x1.setJavadoc(JD1);
- x1.modifiers().add(MOD1);
- x1.modifiers().add(MOD2);
- x1.setName(N1);
- x1.arguments().add(E1);
- x1.arguments().add(E2);
- x1.setAnonymousClassDeclaration(ACD1);
- TestVisitor v1 = new TestVisitor();
- b.setLength(0);
- x1.accept(v1);
- String result = b.toString();
- assertTrue(result.equals("[(ECD"+JD1S+MOD1S+MOD2S+N1S+E1S+E2S+ACD1S+"ECD)]")); //$NON-NLS-1$ //$NON-NLS-2$
- }
- /** @deprecated using deprecated code */
- public void testEnumDeclaration() {
- if (ast.apiLevel() == AST.JLS2) {
- return;
- }
- EnumDeclaration x1 = ast.newEnumDeclaration();
- x1.setJavadoc(JD1);
- x1.modifiers().add(MOD1);
- x1.modifiers().add(MOD2);
- x1.setName(N1);
- x1.superInterfaceTypes().add(T1);
- x1.superInterfaceTypes().add(T2);
- x1.enumConstants().add(EC1);
- x1.enumConstants().add(EC2);
- x1.bodyDeclarations().add(FD1);
- x1.bodyDeclarations().add(FD2);
- TestVisitor v1 = new TestVisitor();
- b.setLength(0);
- x1.accept(v1);
- String result = b.toString();
- assertTrue(result.equals("[(ED"+JD1S+MOD1S+MOD2S+N1S+T1S+T2S+EC1S+EC2S+FD1S+FD2S+"ED)]")); //$NON-NLS-1$ //$NON-NLS-2$
- }
public void testExpressionStatement() {
ExpressionStatement x1 = ast.newExpressionStatement(E1);
TestVisitor v1 = new TestVisitor();
@@ -1685,104 +1631,6 @@
assertTrue(result.equals("[(MODprivateprivateMOD)]")); //$NON-NLS-1$ //$NON-NLS-2$
}
- /** @deprecated using deprecated code */
- public void testNormalAnnotation() {
- if (ast.apiLevel() == AST.JLS2) {
- return;
- }
- NormalAnnotation x1 = ast.newNormalAnnotation();
- x1.setTypeName(N1);
- x1.values().add(MVP1);
- x1.values().add(MVP2);
- TestVisitor v1 = new TestVisitor();
- b.setLength(0);
- x1.accept(v1);
- String result = b.toString();
- assertTrue(result.equals("[(@NAN"+N1S+MVP1S+MVP2S+"@NAN)]")); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- /** @deprecated using deprecated code */
- public void testMemberValuePair() {
- if (ast.apiLevel() == AST.JLS2) {
- return;
- }
- MemberValuePair x1 = ast.newMemberValuePair();
- x1.setName(N1);
- x1.setValue(E1);
- TestVisitor v1 = new TestVisitor();
- b.setLength(0);
- x1.accept(v1);
- String result = b.toString();
- assertTrue(result.equals("[(@MVP"+N1S+E1S+"@MVP)]")); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- /** @deprecated using deprecated code */
- public void testMarkerAnnotation() {
- if (ast.apiLevel() == AST.JLS2) {
- return;
- }
- MarkerAnnotation x1 = ast.newMarkerAnnotation();
- x1.setTypeName(N1);
- TestVisitor v1 = new TestVisitor();
- b.setLength(0);
- x1.accept(v1);
- String result = b.toString();
- assertTrue(result.equals("[(@MAN"+N1S+"@MAN)]")); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- /** @deprecated using deprecated code */
- public void testSingleMemberAnnotation() {
- if (ast.apiLevel() == AST.JLS2) {
- return;
- }
- SingleMemberAnnotation x1 = ast.newSingleMemberAnnotation();
- x1.setTypeName(N1);
- x1.setValue(E1);
- TestVisitor v1 = new TestVisitor();
- b.setLength(0);
- x1.accept(v1);
- String result = b.toString();
- assertTrue(result.equals("[(@SMAN"+N1S+E1S+"@SMAN)]")); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- /** @deprecated using deprecated code */
- public void testAnnotationTypeDeclaration() {
- if (ast.apiLevel() == AST.JLS2) {
- return;
- }
- AnnotationTypeDeclaration x1 = ast.newAnnotationTypeDeclaration();
- x1.setJavadoc(JD1);
- x1.modifiers().add(MOD1);
- x1.modifiers().add(MOD2);
- x1.setName(N1);
- x1.bodyDeclarations().add(FD1);
- x1.bodyDeclarations().add(FD2);
- TestVisitor v1 = new TestVisitor();
- b.setLength(0);
- x1.accept(v1);
- String result = b.toString();
- assertTrue(result.equals("[(@TD"+JD1S+MOD1S+MOD2S+N1S+FD1S+FD2S+"@TD)]")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
-
- /** @deprecated using deprecated code */
- public void testAnnotationTypeMemberDeclaration() {
- if (ast.apiLevel() == AST.JLS2) {
- return;
- }
- AnnotationTypeMemberDeclaration x1 = ast.newAnnotationTypeMemberDeclaration();
- x1.setJavadoc(JD1);
- x1.modifiers().add(MOD1);
- x1.modifiers().add(MOD2);
- x1.setType(T1);
- x1.setName(N1);
- x1.setDefault(E1);
- TestVisitor v1 = new TestVisitor();
- b.setLength(0);
- x1.accept(v1);
- String result = b.toString();
- assertTrue(result.equals("[(@MD"+JD1S+MOD1S+MOD2S+T1S+N1S+E1S+"@MD)]")); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
public void testNullLiteral() {
NullLiteral x1 = ast.newNullLiteral();
TestVisitor v1 = new TestVisitor();
@@ -1799,25 +1647,6 @@
String result = b.toString();
assertTrue(result.equals("[(eNU1.01.0eNU)]")); //$NON-NLS-1$
}
- /** @deprecated using deprecated code */
- public void testPackageDeclaration() {
- PackageDeclaration x1 = ast.newPackageDeclaration();
- if (ast.apiLevel() >= AST.JLS3) {
- x1.setJavadoc(JD1);
- x1.annotations().add(ANO1);
- x1.annotations().add(ANO2);
- }
- x1.setName(N1);
- TestVisitor v1 = new TestVisitor();
- b.setLength(0);
- x1.accept(v1);
- String result = b.toString();
- if (ast.apiLevel() == AST.JLS2) {
- assertTrue(result.equals("[(PD"+N1S+"PD)]")); //$NON-NLS-1$ //$NON-NLS-2$
- } else {
- assertTrue(result.equals("[(PD"+JD1S+ANO1S+ANO2S+N1S+"PD)]")); //$NON-NLS-1$ //$NON-NLS-2$
- }
- }
public void testParenthesizedExpression() {
ParenthesizedExpression x1 = ast.newParenthesizedExpression();
x1.setExpression(E1);
diff --git a/tests/org.eclipse.wst.jsdt.core.tests.model/src/org/eclipse/wst/jsdt/core/tests/dom/BindingsCollectorVisitor.java b/tests/org.eclipse.wst.jsdt.core.tests.model/src/org/eclipse/wst/jsdt/core/tests/dom/BindingsCollectorVisitor.java
index 40a9dd0..66e209f 100644
--- a/tests/org.eclipse.wst.jsdt.core.tests.model/src/org/eclipse/wst/jsdt/core/tests/dom/BindingsCollectorVisitor.java
+++ b/tests/org.eclipse.wst.jsdt.core.tests.model/src/org/eclipse/wst/jsdt/core/tests/dom/BindingsCollectorVisitor.java
@@ -13,7 +13,55 @@
import java.util.HashMap;
import java.util.HashSet;
-import org.eclipse.wst.jsdt.core.dom.*;
+import org.eclipse.wst.jsdt.core.dom.ASTNode;
+import org.eclipse.wst.jsdt.core.dom.ASTVisitor;
+import org.eclipse.wst.jsdt.core.dom.AnonymousClassDeclaration;
+import org.eclipse.wst.jsdt.core.dom.ArrayAccess;
+import org.eclipse.wst.jsdt.core.dom.ArrayCreation;
+import org.eclipse.wst.jsdt.core.dom.ArrayInitializer;
+import org.eclipse.wst.jsdt.core.dom.ArrayType;
+import org.eclipse.wst.jsdt.core.dom.Assignment;
+import org.eclipse.wst.jsdt.core.dom.BooleanLiteral;
+import org.eclipse.wst.jsdt.core.dom.CastExpression;
+import org.eclipse.wst.jsdt.core.dom.CharacterLiteral;
+import org.eclipse.wst.jsdt.core.dom.ClassInstanceCreation;
+import org.eclipse.wst.jsdt.core.dom.ConditionalExpression;
+import org.eclipse.wst.jsdt.core.dom.ConstructorInvocation;
+import org.eclipse.wst.jsdt.core.dom.FieldAccess;
+import org.eclipse.wst.jsdt.core.dom.FunctionDeclaration;
+import org.eclipse.wst.jsdt.core.dom.FunctionInvocation;
+import org.eclipse.wst.jsdt.core.dom.FunctionRef;
+import org.eclipse.wst.jsdt.core.dom.IBinding;
+import org.eclipse.wst.jsdt.core.dom.IFunctionBinding;
+import org.eclipse.wst.jsdt.core.dom.IPackageBinding;
+import org.eclipse.wst.jsdt.core.dom.ITypeBinding;
+import org.eclipse.wst.jsdt.core.dom.IVariableBinding;
+import org.eclipse.wst.jsdt.core.dom.ImportDeclaration;
+import org.eclipse.wst.jsdt.core.dom.InfixExpression;
+import org.eclipse.wst.jsdt.core.dom.InstanceofExpression;
+import org.eclipse.wst.jsdt.core.dom.ListExpression;
+import org.eclipse.wst.jsdt.core.dom.MemberRef;
+import org.eclipse.wst.jsdt.core.dom.NullLiteral;
+import org.eclipse.wst.jsdt.core.dom.NumberLiteral;
+import org.eclipse.wst.jsdt.core.dom.PackageDeclaration;
+import org.eclipse.wst.jsdt.core.dom.ParameterizedType;
+import org.eclipse.wst.jsdt.core.dom.ParenthesizedExpression;
+import org.eclipse.wst.jsdt.core.dom.PostfixExpression;
+import org.eclipse.wst.jsdt.core.dom.PrefixExpression;
+import org.eclipse.wst.jsdt.core.dom.PrimitiveType;
+import org.eclipse.wst.jsdt.core.dom.QualifiedName;
+import org.eclipse.wst.jsdt.core.dom.SimpleName;
+import org.eclipse.wst.jsdt.core.dom.SimpleType;
+import org.eclipse.wst.jsdt.core.dom.SingleVariableDeclaration;
+import org.eclipse.wst.jsdt.core.dom.StringLiteral;
+import org.eclipse.wst.jsdt.core.dom.SuperConstructorInvocation;
+import org.eclipse.wst.jsdt.core.dom.SuperFieldAccess;
+import org.eclipse.wst.jsdt.core.dom.SuperMethodInvocation;
+import org.eclipse.wst.jsdt.core.dom.ThisExpression;
+import org.eclipse.wst.jsdt.core.dom.TypeDeclaration;
+import org.eclipse.wst.jsdt.core.dom.TypeLiteral;
+import org.eclipse.wst.jsdt.core.dom.VariableDeclarationExpression;
+import org.eclipse.wst.jsdt.core.dom.VariableDeclarationFragment;
/**
* @author oliviert
*
@@ -43,24 +91,7 @@
set.add(node);
}
}
-
- /**
- * @see org.eclipse.wst.jsdt.core.dom.ASTVisitor#endVisit(AnnotationTypeDeclaration)
- * @since 3.0
- */
- public void endVisit(AnnotationTypeDeclaration node) {
- ITypeBinding typeBinding = node.resolveBinding();
- collectBindings(node, typeBinding);
- }
-
- /**
- * @see org.eclipse.wst.jsdt.core.dom.ASTVisitor#endVisit(AnnotationTypeMemberDeclaration)
- * @since 3.0
- */
- public void endVisit(AnnotationTypeMemberDeclaration node) {
- IFunctionBinding binding = node.resolveBinding();
- collectBindings(node, binding);
- }
+
/**
* @see org.eclipse.wst.jsdt.core.dom.ASTVisitor#endVisit(AnonymousClassDeclaration)
@@ -157,25 +188,7 @@
IFunctionBinding methodBinding = node.resolveConstructorBinding();
collectBindings(node, methodBinding);
}
-
- /**
- * @see org.eclipse.wst.jsdt.core.dom.ASTVisitor#endVisit(EnumConstantDeclaration)
- * @since 3.0
- */
- public void endVisit(EnumConstantDeclaration node) {
- IVariableBinding binding = node.resolveVariable();
- collectBindings(node, binding);
- }
-
- /**
- * @see org.eclipse.wst.jsdt.core.dom.ASTVisitor#endVisit(EnumDeclaration)
- * @since 3.0
- */
- public void endVisit(EnumDeclaration node) {
- ITypeBinding typeBinding = node.resolveBinding();
- collectBindings(node, typeBinding);
- }
-
+
/**
* @see org.eclipse.wst.jsdt.core.dom.ASTVisitor#endVisit(FieldAccess)
*/
diff --git a/tests/org.eclipse.wst.jsdt.core.tests.model/src/org/eclipse/wst/jsdt/core/tests/dom/ConverterTestSetup.java b/tests/org.eclipse.wst.jsdt.core.tests.model/src/org/eclipse/wst/jsdt/core/tests/dom/ConverterTestSetup.java
index 63e73b9..f6a1978 100644
--- a/tests/org.eclipse.wst.jsdt.core.tests.model/src/org/eclipse/wst/jsdt/core/tests/dom/ConverterTestSetup.java
+++ b/tests/org.eclipse.wst.jsdt.core.tests.model/src/org/eclipse/wst/jsdt/core/tests/dom/ConverterTestSetup.java
@@ -17,14 +17,64 @@
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
import org.eclipse.wst.jsdt.core.IClassFile;
-import org.eclipse.wst.jsdt.core.IJavaScriptUnit;
import org.eclipse.wst.jsdt.core.IJavaScriptProject;
+import org.eclipse.wst.jsdt.core.IJavaScriptUnit;
import org.eclipse.wst.jsdt.core.JavaScriptCore;
import org.eclipse.wst.jsdt.core.JavaScriptModelException;
import org.eclipse.wst.jsdt.core.compiler.IProblem;
-
import org.eclipse.wst.jsdt.core.compiler.libraries.SystemLibraryLocation;
-import org.eclipse.wst.jsdt.core.dom.*;
+import org.eclipse.wst.jsdt.core.dom.AST;
+import org.eclipse.wst.jsdt.core.dom.ASTNode;
+import org.eclipse.wst.jsdt.core.dom.ASTParser;
+import org.eclipse.wst.jsdt.core.dom.ASTVisitor;
+import org.eclipse.wst.jsdt.core.dom.AnonymousClassDeclaration;
+import org.eclipse.wst.jsdt.core.dom.ArrayAccess;
+import org.eclipse.wst.jsdt.core.dom.ArrayCreation;
+import org.eclipse.wst.jsdt.core.dom.ArrayInitializer;
+import org.eclipse.wst.jsdt.core.dom.ArrayType;
+import org.eclipse.wst.jsdt.core.dom.Assignment;
+import org.eclipse.wst.jsdt.core.dom.Block;
+import org.eclipse.wst.jsdt.core.dom.BodyDeclaration;
+import org.eclipse.wst.jsdt.core.dom.BooleanLiteral;
+import org.eclipse.wst.jsdt.core.dom.CastExpression;
+import org.eclipse.wst.jsdt.core.dom.CharacterLiteral;
+import org.eclipse.wst.jsdt.core.dom.ClassInstanceCreation;
+import org.eclipse.wst.jsdt.core.dom.ConditionalExpression;
+import org.eclipse.wst.jsdt.core.dom.ExpressionStatement;
+import org.eclipse.wst.jsdt.core.dom.FieldAccess;
+import org.eclipse.wst.jsdt.core.dom.FunctionDeclaration;
+import org.eclipse.wst.jsdt.core.dom.FunctionInvocation;
+import org.eclipse.wst.jsdt.core.dom.FunctionRef;
+import org.eclipse.wst.jsdt.core.dom.ImportDeclaration;
+import org.eclipse.wst.jsdt.core.dom.InfixExpression;
+import org.eclipse.wst.jsdt.core.dom.Initializer;
+import org.eclipse.wst.jsdt.core.dom.InstanceofExpression;
+import org.eclipse.wst.jsdt.core.dom.JavaScriptUnit;
+import org.eclipse.wst.jsdt.core.dom.MemberRef;
+import org.eclipse.wst.jsdt.core.dom.NullLiteral;
+import org.eclipse.wst.jsdt.core.dom.NumberLiteral;
+import org.eclipse.wst.jsdt.core.dom.PackageDeclaration;
+import org.eclipse.wst.jsdt.core.dom.ParameterizedType;
+import org.eclipse.wst.jsdt.core.dom.ParenthesizedExpression;
+import org.eclipse.wst.jsdt.core.dom.PostfixExpression;
+import org.eclipse.wst.jsdt.core.dom.PrefixExpression;
+import org.eclipse.wst.jsdt.core.dom.PrimitiveType;
+import org.eclipse.wst.jsdt.core.dom.QualifiedName;
+import org.eclipse.wst.jsdt.core.dom.QualifiedType;
+import org.eclipse.wst.jsdt.core.dom.SimpleName;
+import org.eclipse.wst.jsdt.core.dom.SimpleType;
+import org.eclipse.wst.jsdt.core.dom.SingleVariableDeclaration;
+import org.eclipse.wst.jsdt.core.dom.StringLiteral;
+import org.eclipse.wst.jsdt.core.dom.SuperFieldAccess;
+import org.eclipse.wst.jsdt.core.dom.SuperMethodInvocation;
+import org.eclipse.wst.jsdt.core.dom.ThisExpression;
+import org.eclipse.wst.jsdt.core.dom.TypeDeclaration;
+import org.eclipse.wst.jsdt.core.dom.TypeDeclarationStatement;
+import org.eclipse.wst.jsdt.core.dom.TypeLiteral;
+import org.eclipse.wst.jsdt.core.dom.TypeParameter;
+import org.eclipse.wst.jsdt.core.dom.VariableDeclarationExpression;
+import org.eclipse.wst.jsdt.core.dom.VariableDeclarationFragment;
+import org.eclipse.wst.jsdt.core.dom.WildcardType;
import org.eclipse.wst.jsdt.core.tests.util.Util;
public abstract class ConverterTestSetup extends AbstractASTTests {
@@ -208,21 +258,11 @@
super.endVisit(node);
}
- public void endVisit(MarkerAnnotation node) {
- assertNotNull(node+" should have a binding", node.resolveTypeBinding());
- super.endVisit(node);
- }
-
public void endVisit(FunctionInvocation node) {
assertNotNull(node+" should have a binding", node.resolveTypeBinding());
super.endVisit(node);
}
- public void endVisit(NormalAnnotation node) {
- assertNotNull(node+" should have a binding", node.resolveTypeBinding());
- super.endVisit(node);
- }
-
public void endVisit(NullLiteral node) {
assertNotNull(node+" should have a binding", node.resolveTypeBinding());
super.endVisit(node);
@@ -248,11 +288,6 @@
super.endVisit(node);
}
- public void endVisit(SingleMemberAnnotation node) {
- assertNotNull(node+" should have a binding", node.resolveTypeBinding());
- super.endVisit(node);
- }
-
public void endVisit(StringLiteral node) {
assertNotNull(node+" should have a binding", node.resolveTypeBinding());
super.endVisit(node);
@@ -283,16 +318,6 @@
super.endVisit(node);
}
- public void endVisit(AnnotationTypeDeclaration node) {
- assertNotNull(node+" should have a binding", node.resolveBinding());
- super.endVisit(node);
- }
-
- public void endVisit(AnnotationTypeMemberDeclaration node) {
- assertNotNull(node+" should have a binding", node.resolveBinding());
- super.endVisit(node);
- }
-
public void endVisit(AnonymousClassDeclaration node) {
assertNotNull(node+" should have a binding", node.resolveBinding());
super.endVisit(node);
@@ -303,11 +328,6 @@
super.endVisit(node);
}
- public void endVisit(EnumDeclaration node) {
- assertNotNull(node+" should have a binding", node.resolveBinding());
- super.endVisit(node);
- }
-
public void endVisit(ImportDeclaration node) {
assertNotNull(node+" should have a binding", node.resolveBinding());
super.endVisit(node);
diff --git a/tests/org.eclipse.wst.jsdt.core.tests.model/src/org/eclipse/wst/jsdt/core/tests/dom/SampleASTs.java b/tests/org.eclipse.wst.jsdt.core.tests.model/src/org/eclipse/wst/jsdt/core/tests/dom/SampleASTs.java
index ca5029f..a12e79c 100644
--- a/tests/org.eclipse.wst.jsdt.core.tests.model/src/org/eclipse/wst/jsdt/core/tests/dom/SampleASTs.java
+++ b/tests/org.eclipse.wst.jsdt.core.tests.model/src/org/eclipse/wst/jsdt/core/tests/dom/SampleASTs.java
@@ -15,7 +15,6 @@
import org.eclipse.wst.jsdt.core.dom.AST;
import org.eclipse.wst.jsdt.core.dom.ASTNode;
-import org.eclipse.wst.jsdt.core.dom.AnnotationTypeDeclaration;
import org.eclipse.wst.jsdt.core.dom.AnonymousClassDeclaration;
import org.eclipse.wst.jsdt.core.dom.ArrayAccess;
import org.eclipse.wst.jsdt.core.dom.ArrayCreation;
@@ -30,32 +29,28 @@
import org.eclipse.wst.jsdt.core.dom.CatchClause;
import org.eclipse.wst.jsdt.core.dom.CharacterLiteral;
import org.eclipse.wst.jsdt.core.dom.ClassInstanceCreation;
-import org.eclipse.wst.jsdt.core.dom.JavaScriptUnit;
import org.eclipse.wst.jsdt.core.dom.ConditionalExpression;
import org.eclipse.wst.jsdt.core.dom.ConstructorInvocation;
import org.eclipse.wst.jsdt.core.dom.ContinueStatement;
import org.eclipse.wst.jsdt.core.dom.DoStatement;
import org.eclipse.wst.jsdt.core.dom.EmptyStatement;
import org.eclipse.wst.jsdt.core.dom.EnhancedForStatement;
-import org.eclipse.wst.jsdt.core.dom.EnumConstantDeclaration;
-import org.eclipse.wst.jsdt.core.dom.EnumDeclaration;
import org.eclipse.wst.jsdt.core.dom.ExpressionStatement;
import org.eclipse.wst.jsdt.core.dom.FieldAccess;
import org.eclipse.wst.jsdt.core.dom.FieldDeclaration;
import org.eclipse.wst.jsdt.core.dom.ForStatement;
+import org.eclipse.wst.jsdt.core.dom.FunctionDeclaration;
+import org.eclipse.wst.jsdt.core.dom.FunctionInvocation;
+import org.eclipse.wst.jsdt.core.dom.FunctionRef;
import org.eclipse.wst.jsdt.core.dom.IfStatement;
import org.eclipse.wst.jsdt.core.dom.ImportDeclaration;
import org.eclipse.wst.jsdt.core.dom.InfixExpression;
import org.eclipse.wst.jsdt.core.dom.Initializer;
import org.eclipse.wst.jsdt.core.dom.InstanceofExpression;
import org.eclipse.wst.jsdt.core.dom.JSdoc;
+import org.eclipse.wst.jsdt.core.dom.JavaScriptUnit;
import org.eclipse.wst.jsdt.core.dom.LabeledStatement;
-import org.eclipse.wst.jsdt.core.dom.FunctionDeclaration;
-import org.eclipse.wst.jsdt.core.dom.FunctionInvocation;
-import org.eclipse.wst.jsdt.core.dom.FunctionRef;
-import org.eclipse.wst.jsdt.core.dom.Modifier;
import org.eclipse.wst.jsdt.core.dom.Name;
-import org.eclipse.wst.jsdt.core.dom.NormalAnnotation;
import org.eclipse.wst.jsdt.core.dom.NullLiteral;
import org.eclipse.wst.jsdt.core.dom.NumberLiteral;
import org.eclipse.wst.jsdt.core.dom.PackageDeclaration;
@@ -124,12 +119,6 @@
Initializer in = target.newInitializer();
td.bodyDeclarations().add(in);
- if (target.apiLevel() >= AST.JLS3) {
- EnumDeclaration ed = target.newEnumDeclaration();
- td.bodyDeclarations().add(ed);
- EnumConstantDeclaration ec = target.newEnumConstantDeclaration();
- ed.enumConstants().add(ec);
- }
FunctionDeclaration md = target.newFunctionDeclaration();
SingleVariableDeclaration singleVariableDeclaration = target.newSingleVariableDeclaration();
@@ -272,18 +261,7 @@
VariableDeclarationExpression variableDeclarationExpression = target.newVariableDeclarationExpression(variableDeclarationFragment3);
z.add(variableDeclarationExpression);
- // annotations
- if (target.apiLevel() >= AST.JLS3) {
- AnnotationTypeDeclaration atd = target.newAnnotationTypeDeclaration();
- cu.types().add(atd);
- atd.bodyDeclarations().add(target.newAnnotationTypeMemberDeclaration());
- td.modifiers().add(target.newMarkerAnnotation());
- td.modifiers().add(target.newSingleMemberAnnotation());
- NormalAnnotation an0 = target.newNormalAnnotation();
- td.modifiers().add(an0);
- an0.values().add(target.newMemberValuePair());
- td.modifiers().add(target.newModifier(Modifier.ModifierKeyword.PRIVATE_KEYWORD));
- }
+
return cu;
}
diff --git a/tests/org.eclipse.wst.jsdt.core.tests.model/src/org/eclipse/wst/jsdt/core/tests/model/DefaultJavaElementComparator.java b/tests/org.eclipse.wst.jsdt.core.tests.model/src/org/eclipse/wst/jsdt/core/tests/model/DefaultJavaElementComparator.java
index 45ad39d..385264b 100644
--- a/tests/org.eclipse.wst.jsdt.core.tests.model/src/org/eclipse/wst/jsdt/core/tests/model/DefaultJavaElementComparator.java
+++ b/tests/org.eclipse.wst.jsdt.core.tests.model/src/org/eclipse/wst/jsdt/core/tests/model/DefaultJavaElementComparator.java
@@ -16,13 +16,11 @@
import org.eclipse.wst.jsdt.core.Flags;
import org.eclipse.wst.jsdt.core.dom.ASTNode;
import org.eclipse.wst.jsdt.core.dom.AbstractTypeDeclaration;
-import org.eclipse.wst.jsdt.core.dom.AnnotationTypeMemberDeclaration;
import org.eclipse.wst.jsdt.core.dom.ArrayType;
import org.eclipse.wst.jsdt.core.dom.BodyDeclaration;
-import org.eclipse.wst.jsdt.core.dom.EnumConstantDeclaration;
import org.eclipse.wst.jsdt.core.dom.FieldDeclaration;
-import org.eclipse.wst.jsdt.core.dom.Initializer;
import org.eclipse.wst.jsdt.core.dom.FunctionDeclaration;
+import org.eclipse.wst.jsdt.core.dom.Initializer;
import org.eclipse.wst.jsdt.core.dom.Name;
import org.eclipse.wst.jsdt.core.dom.PrimitiveType;
import org.eclipse.wst.jsdt.core.dom.QualifiedName;
@@ -177,22 +175,13 @@
return this.categories[STATIC_METHOD_CATEGORY];
}
return this.categories[METHOD_CATEGORY];
- case ASTNode.ANNOTATION_TYPE_MEMBER_DECLARATION :
- if (Flags.isStatic(node.getModifiers())) {
- return this.categories[STATIC_METHOD_CATEGORY];
- }
- return this.categories[METHOD_CATEGORY];
case ASTNode.FIELD_DECLARATION :
FieldDeclaration fieldDeclaration = (FieldDeclaration) node;
if (Flags.isStatic(fieldDeclaration.getModifiers())) {
return this.categories[STATIC_FIELD_CATEGORY];
}
return this.categories[FIELD_CATEGORY];
- case ASTNode.ENUM_CONSTANT_DECLARATION :
- return this.categories[STATIC_FIELD_CATEGORY];
case ASTNode.TYPE_DECLARATION :
- case ASTNode.ENUM_DECLARATION :
- case ASTNode.ANNOTATION_TYPE_DECLARATION :
AbstractTypeDeclaration abstractTypeDeclaration = (AbstractTypeDeclaration) node;
if (Flags.isStatic(abstractTypeDeclaration.getModifiers())) {
return this.categories[STATIC_TYPE_CATEGORY];
@@ -263,20 +252,12 @@
buffer.append(buildSignature(type));
}
return String.valueOf(buffer);
- case ASTNode.ANNOTATION_TYPE_MEMBER_DECLARATION :
- AnnotationTypeMemberDeclaration annotationTypeMemberDeclaration = (AnnotationTypeMemberDeclaration) node;
- return annotationTypeMemberDeclaration.getName().getIdentifier();
case ASTNode.FIELD_DECLARATION :
FieldDeclaration fieldDeclaration = (FieldDeclaration) node;
return ((VariableDeclarationFragment) fieldDeclaration.fragments().get(0)).getName().getIdentifier();
- case ASTNode.ENUM_CONSTANT_DECLARATION :
- EnumConstantDeclaration enumConstantDeclaration = (EnumConstantDeclaration) node;
- return enumConstantDeclaration.getName().getIdentifier();
case ASTNode.INITIALIZER :
return ((Integer) node.getProperty(JavaScriptUnitSorter.RELATIVE_ORDER)).toString();
case ASTNode.TYPE_DECLARATION :
- case ASTNode.ENUM_DECLARATION :
- case ASTNode.ANNOTATION_TYPE_DECLARATION :
AbstractTypeDeclaration abstractTypeDeclaration = (AbstractTypeDeclaration) node;
return abstractTypeDeclaration.getName().getIdentifier();
}
diff --git a/tests/org.eclipse.wst.jsdt.core.tests.model/src/org/eclipse/wst/jsdt/core/tests/model/SortCompilationUnitElementsTests.java b/tests/org.eclipse.wst.jsdt.core.tests.model/src/org/eclipse/wst/jsdt/core/tests/model/SortCompilationUnitElementsTests.java
index d7d5f41..8532f86 100644
--- a/tests/org.eclipse.wst.jsdt.core.tests.model/src/org/eclipse/wst/jsdt/core/tests/model/SortCompilationUnitElementsTests.java
+++ b/tests/org.eclipse.wst.jsdt.core.tests.model/src/org/eclipse/wst/jsdt/core/tests/model/SortCompilationUnitElementsTests.java
@@ -24,10 +24,8 @@
import org.eclipse.wst.jsdt.core.IJavaScriptUnit;
import org.eclipse.wst.jsdt.core.JavaScriptModelException;
import org.eclipse.wst.jsdt.core.dom.AST;
-import org.eclipse.wst.jsdt.core.dom.ASTNode;
import org.eclipse.wst.jsdt.core.dom.ASTParser;
import org.eclipse.wst.jsdt.core.dom.BodyDeclaration;
-import org.eclipse.wst.jsdt.core.dom.EnumConstantDeclaration;
import org.eclipse.wst.jsdt.core.util.JavaScriptUnitSorter;
import org.eclipse.wst.jsdt.internal.compiler.impl.CompilerOptions;
@@ -2018,12 +2016,6 @@
Comparator comparator = new Comparator() {
public int compare(Object o1, Object o2) {
- switch(((ASTNode) o1).getNodeType()) {
- case ASTNode.ENUM_CONSTANT_DECLARATION :
- if (o2 instanceof EnumConstantDeclaration) {
- return ((EnumConstantDeclaration) o1).getName().getIdentifier().compareTo(((EnumConstantDeclaration) o2).getName().getIdentifier());
- }
- }
BodyDeclaration bodyDeclaration1 = (BodyDeclaration) o1;
BodyDeclaration bodyDeclaration2 = (BodyDeclaration) o2;
final int sourceStart1 = ((Integer) bodyDeclaration1.getProperty(JavaScriptUnitSorter.RELATIVE_ORDER)).intValue();
diff --git a/tests/org.eclipse.wst.jsdt.core.tests.model/src/org/eclipse/wst/jsdt/core/tests/rewrite/describing/ASTRewritingMethodDeclTest.java b/tests/org.eclipse.wst.jsdt.core.tests.model/src/org/eclipse/wst/jsdt/core/tests/rewrite/describing/ASTRewritingMethodDeclTest.java
index bd71571..40d577e 100644
--- a/tests/org.eclipse.wst.jsdt.core.tests.model/src/org/eclipse/wst/jsdt/core/tests/rewrite/describing/ASTRewritingMethodDeclTest.java
+++ b/tests/org.eclipse.wst.jsdt.core.tests.model/src/org/eclipse/wst/jsdt/core/tests/rewrite/describing/ASTRewritingMethodDeclTest.java
@@ -19,7 +19,29 @@
import org.eclipse.wst.jsdt.core.IJavaScriptUnit;
import org.eclipse.wst.jsdt.core.IPackageFragment;
-import org.eclipse.wst.jsdt.core.dom.*;
+import org.eclipse.wst.jsdt.core.dom.AST;
+import org.eclipse.wst.jsdt.core.dom.ASTNode;
+import org.eclipse.wst.jsdt.core.dom.Block;
+import org.eclipse.wst.jsdt.core.dom.ExpressionStatement;
+import org.eclipse.wst.jsdt.core.dom.FieldDeclaration;
+import org.eclipse.wst.jsdt.core.dom.FunctionDeclaration;
+import org.eclipse.wst.jsdt.core.dom.FunctionInvocation;
+import org.eclipse.wst.jsdt.core.dom.Initializer;
+import org.eclipse.wst.jsdt.core.dom.JSdoc;
+import org.eclipse.wst.jsdt.core.dom.JavaScriptUnit;
+import org.eclipse.wst.jsdt.core.dom.Modifier;
+import org.eclipse.wst.jsdt.core.dom.Name;
+import org.eclipse.wst.jsdt.core.dom.PrimitiveType;
+import org.eclipse.wst.jsdt.core.dom.SimpleName;
+import org.eclipse.wst.jsdt.core.dom.SingleVariableDeclaration;
+import org.eclipse.wst.jsdt.core.dom.TagElement;
+import org.eclipse.wst.jsdt.core.dom.TextElement;
+import org.eclipse.wst.jsdt.core.dom.TryStatement;
+import org.eclipse.wst.jsdt.core.dom.Type;
+import org.eclipse.wst.jsdt.core.dom.TypeDeclaration;
+import org.eclipse.wst.jsdt.core.dom.TypeParameter;
+import org.eclipse.wst.jsdt.core.dom.VariableDeclarationExpression;
+import org.eclipse.wst.jsdt.core.dom.VariableDeclarationFragment;
import org.eclipse.wst.jsdt.core.dom.rewrite.ASTRewrite;
import org.eclipse.wst.jsdt.core.dom.rewrite.ListRewrite;
@@ -1594,131 +1616,8 @@
assertEqualString(preview, buf.toString());
}
- public void testModifiersAST3WithAnnotations() throws Exception {
- IPackageFragment pack1= this.sourceFolder.createPackageFragment("test1", false, null);
- StringBuffer buf= new StringBuffer();
- buf.append("package test1;\n");
- buf.append("public abstract class E {\n");
- buf.append(" public Object foo1() { return null; }\n");
- buf.append(" /** javadoc comment */\n");
- buf.append(" @Deprecated\n");
- buf.append(" public Object foo2() { return null; }\n");
- buf.append(" @ToBeRemoved\n");
- buf.append(" public Object foo3() { return null; }\n");
- buf.append(" /** javadoc comment */\n");
- buf.append(" @ToBeRemoved\n");
- buf.append(" @Deprecated\n");
- buf.append(" public Object foo4() { return null; }\n");
- buf.append("}\n");
- IJavaScriptUnit cu= pack1.createCompilationUnit("E.js", buf.toString(), false, null);
-
- JavaScriptUnit astRoot= createAST3(cu);
- ASTRewrite rewrite= ASTRewrite.create(astRoot.getAST());
- AST ast= astRoot.getAST();
- TypeDeclaration type= findTypeDeclaration(astRoot, "E");
-
- { // insert annotation first before normal
- FunctionDeclaration methodDecl= findMethodDeclaration(type, "foo1");
- ListRewrite listRewrite= rewrite.getListRewrite(methodDecl, FunctionDeclaration.MODIFIERS2_PROPERTY);
- MarkerAnnotation annot= ast.newMarkerAnnotation();
- annot.setTypeName(ast.newSimpleName("Override"));
- listRewrite.insertFirst(annot, null);
- }
- { // insert annotation first before annotation
- FunctionDeclaration methodDecl= findMethodDeclaration(type, "foo2");
- ListRewrite listRewrite= rewrite.getListRewrite(methodDecl, FunctionDeclaration.MODIFIERS2_PROPERTY);
- MarkerAnnotation annot= ast.newMarkerAnnotation();
- annot.setTypeName(ast.newSimpleName("Override"));
- listRewrite.insertFirst(annot, null);
- }
- { // remove annotation before normal
- FunctionDeclaration methodDecl= findMethodDeclaration(type, "foo3");
- rewrite.remove((ASTNode) methodDecl.modifiers().get(0), null);
- }
- { // remove annotation before annotation
- FunctionDeclaration methodDecl= findMethodDeclaration(type, "foo4");
- rewrite.remove((ASTNode) methodDecl.modifiers().get(0), null);
- }
-
- String preview= evaluateRewrite(cu, rewrite);
-
- buf= new StringBuffer();
- buf.append("package test1;\n");
- buf.append("public abstract class E {\n");
- buf.append(" @Override\n");
- buf.append(" public Object foo1() { return null; }\n");
- buf.append(" /** javadoc comment */\n");
- buf.append(" @Override\n");
- buf.append(" @Deprecated\n");
- buf.append(" public Object foo2() { return null; }\n");
- buf.append(" public Object foo3() { return null; }\n");
- buf.append(" /** javadoc comment */\n");
- buf.append(" @Deprecated\n");
- buf.append(" public Object foo4() { return null; }\n");
- buf.append("}\n");
- assertEqualString(preview, buf.toString());
- }
-
- public void testModifiersAST3WithAnnotations2() throws Exception {
- IPackageFragment pack1= this.sourceFolder.createPackageFragment("test1", false, null);
- StringBuffer buf= new StringBuffer();
- buf.append("package test1;\n");
- buf.append("public abstract class E {\n");
- buf.append(" Object foo1() { return null; }\n");
- buf.append(" Object foo2() { return null; }\n");
- buf.append(" @Deprecated()Object foo3() { return null; }\n");
- buf.append(" @Deprecated()Object foo4() { return null; }\n");
- buf.append("}\n");
- IJavaScriptUnit cu= pack1.createCompilationUnit("E.js", buf.toString(), false, null);
-
- JavaScriptUnit astRoot= createAST3(cu);
- ASTRewrite rewrite= ASTRewrite.create(astRoot.getAST());
- AST ast= astRoot.getAST();
- TypeDeclaration type= findTypeDeclaration(astRoot, "E");
-
- { // insert annotation first
- FunctionDeclaration methodDecl= findMethodDeclaration(type, "foo1");
- ListRewrite listRewrite= rewrite.getListRewrite(methodDecl, FunctionDeclaration.MODIFIERS2_PROPERTY);
- MarkerAnnotation annot= ast.newMarkerAnnotation();
- annot.setTypeName(ast.newSimpleName("Override"));
- listRewrite.insertFirst(annot, null);
- }
- { // insert modifier first
- FunctionDeclaration methodDecl= findMethodDeclaration(type, "foo2");
- ListRewrite listRewrite= rewrite.getListRewrite(methodDecl, FunctionDeclaration.MODIFIERS2_PROPERTY);
- Modifier modifier= ast.newModifier(Modifier.ModifierKeyword.PUBLIC_KEYWORD);
- listRewrite.insertFirst(modifier, null);
- }
- { // insert modifier last
- FunctionDeclaration methodDecl= findMethodDeclaration(type, "foo3");
- ListRewrite listRewrite= rewrite.getListRewrite(methodDecl, FunctionDeclaration.MODIFIERS2_PROPERTY);
- Modifier modifier= ast.newModifier(Modifier.ModifierKeyword.PUBLIC_KEYWORD);
- listRewrite.insertLast(modifier, null);
- }
- { // insert modifier first
- FunctionDeclaration methodDecl= findMethodDeclaration(type, "foo4");
- ListRewrite listRewrite= rewrite.getListRewrite(methodDecl, FunctionDeclaration.MODIFIERS2_PROPERTY);
- Modifier modifier= ast.newModifier(Modifier.ModifierKeyword.PUBLIC_KEYWORD);
- listRewrite.insertFirst(modifier, null);
- }
-
- String preview= evaluateRewrite(cu, rewrite);
-
- buf= new StringBuffer();
- buf.append("package test1;\n");
- buf.append("public abstract class E {\n");
- buf.append(" @Override\n");
- buf.append(" Object foo1() { return null; }\n");
- buf.append(" public Object foo2() { return null; }\n");
- buf.append(" @Deprecated()\n");
- buf.append(" public Object foo3() { return null; }\n");
- buf.append(" public @Deprecated()Object foo4() { return null; }\n");
- buf.append("}\n");
- assertEqualString(preview, buf.toString());
- }
-
public void testFieldDeclaration() throws Exception {
IPackageFragment pack1= this.sourceFolder.createPackageFragment("test1", false, null);
StringBuffer buf= new StringBuffer();
@@ -2339,289 +2238,6 @@
assertEqualString(preview, buf.toString());
}
- public void testAnnotationTypeMember() throws Exception {
-
- IPackageFragment pack1= this.sourceFolder.createPackageFragment("test1", false, null);
- StringBuffer buf= new StringBuffer();
- buf.append("package test1;\n");
- buf.append("public @interface DD {\n");
- buf.append(" public String value1();\n");
- buf.append(" String value2() default 1;\n");
- buf.append(" String value3() default 2;\n");
- buf.append("}\n");
- IJavaScriptUnit cu= pack1.createCompilationUnit("DD.js", buf.toString(), false, null);
-
- JavaScriptUnit astRoot= createAST3(cu);
- AST ast= astRoot.getAST();
- ASTRewrite rewrite= ASTRewrite.create(astRoot.getAST());
- AnnotationTypeDeclaration type= (AnnotationTypeDeclaration) findAbstractTypeDeclaration(astRoot, "DD");
- {
- AnnotationTypeMemberDeclaration methodDecl= (AnnotationTypeMemberDeclaration) type.bodyDeclarations().get(0);
- rewrite.remove((ASTNode) methodDecl.modifiers().get(0), null);
- rewrite.set(methodDecl, AnnotationTypeMemberDeclaration.TYPE_PROPERTY, ast.newPrimitiveType(PrimitiveType.BOOLEAN), null);
- rewrite.set(methodDecl, AnnotationTypeMemberDeclaration.NAME_PROPERTY, ast.newSimpleName("test"), null);
-
- rewrite.set(methodDecl, AnnotationTypeMemberDeclaration.DEFAULT_PROPERTY, ast.newNumberLiteral("1"), null);
- }
- {
- AnnotationTypeMemberDeclaration methodDecl= (AnnotationTypeMemberDeclaration) type.bodyDeclarations().get(1);
- rewrite.getListRewrite(methodDecl, AnnotationTypeMemberDeclaration.MODIFIERS2_PROPERTY).insertFirst(ast.newModifier(Modifier.ModifierKeyword.PUBLIC_KEYWORD), null);
- rewrite.set(methodDecl, AnnotationTypeMemberDeclaration.DEFAULT_PROPERTY, ast.newNumberLiteral("2"), null);
- }
- {
- AnnotationTypeMemberDeclaration methodDecl= (AnnotationTypeMemberDeclaration) type.bodyDeclarations().get(2);
- rewrite.set(methodDecl, AnnotationTypeMemberDeclaration.DEFAULT_PROPERTY, null, null);
- }
-
- String preview= evaluateRewrite(cu, rewrite);
-
- buf= new StringBuffer();
- buf.append("package test1;\n");
- buf.append("public @interface DD {\n");
- buf.append(" boolean test() default 1;\n");
- buf.append(" public String value2() default 2;\n");
- buf.append(" String value3();\n");
- buf.append("}\n");
- assertEqualString(preview, buf.toString());
- }
-
- public void testEnumConstantDeclaration1() throws Exception {
-
- IPackageFragment pack1= this.sourceFolder.createPackageFragment("test1", false, null);
- StringBuffer buf= new StringBuffer();
- buf.append("package test1;\n");
- buf.append("public enum DD {\n");
- buf.append(" E1(1), E2, E3(), E4(1, 2)\n");
- buf.append("}\n");
- IJavaScriptUnit cu= pack1.createCompilationUnit("DD.js", buf.toString(), false, null);
-
- JavaScriptUnit astRoot= createAST3(cu);
- AST ast= astRoot.getAST();
- ASTRewrite rewrite= ASTRewrite.create(astRoot.getAST());
- EnumDeclaration type= (EnumDeclaration) findAbstractTypeDeclaration(astRoot, "DD");
- {
- EnumConstantDeclaration enumConst= (EnumConstantDeclaration) type.enumConstants().get(0);
- rewrite.set(enumConst, EnumConstantDeclaration.NAME_PROPERTY, ast.newSimpleName("X"), null);
- ListRewrite listRewrite= rewrite.getListRewrite(enumConst, EnumConstantDeclaration.ARGUMENTS_PROPERTY);
- listRewrite.remove((ASTNode) enumConst.arguments().get(0), null);
- }
- {
- EnumConstantDeclaration enumConst= (EnumConstantDeclaration) type.enumConstants().get(1);
- ListRewrite listRewrite= rewrite.getListRewrite(enumConst, EnumConstantDeclaration.ARGUMENTS_PROPERTY);
- listRewrite.insertFirst(ast.newNumberLiteral("1"), null);
- }
- {
- EnumConstantDeclaration enumConst= (EnumConstantDeclaration) type.enumConstants().get(2);
- ListRewrite listRewrite= rewrite.getListRewrite(enumConst, EnumConstantDeclaration.ARGUMENTS_PROPERTY);
- listRewrite.insertFirst(ast.newNumberLiteral("2"), null);
- }
- {
- EnumConstantDeclaration enumConst= (EnumConstantDeclaration) type.enumConstants().get(3);
- ListRewrite listRewrite= rewrite.getListRewrite(enumConst, EnumConstantDeclaration.ARGUMENTS_PROPERTY);
- listRewrite.remove((ASTNode) enumConst.arguments().get(0), null);
- }
-
- String preview= evaluateRewrite(cu, rewrite);
-
- buf= new StringBuffer();
- buf.append("package test1;\n");
- buf.append("public enum DD {\n");
- buf.append(" X, E2(1), E3(2), E4(2)\n");
- buf.append("}\n");
- assertEqualString(preview, buf.toString());
- }
-
- public void testEnumConstantDeclaration2() throws Exception {
- IPackageFragment pack1= this.sourceFolder.createPackageFragment("test1", false, null);
- StringBuffer buf= new StringBuffer();
- buf.append("package test1;\n");
- buf.append("public enum DD {\n");
- buf.append(" E1Add(1),\n");
- buf.append(" E2Add,\n");
- buf.append(" E3Add(1),\n");
- buf.append(" E4Add(1),\n");
- buf.append(" E5Add(1) {\n");
- buf.append(" public void foo() {\n");
- buf.append(" }\n");
- buf.append(" },\n");
- buf.append(" E1Remove(1) {\n");
- buf.append(" public void foo() {\n");
- buf.append(" }\n");
- buf.append(" },\n");
- buf.append(" E2Remove {\n");
- buf.append(" public void foo() {\n");
- buf.append(" }\n");
- buf.append(" },\n");
- buf.append(" E3Remove(1) {\n");
- buf.append(" public void foo() {\n");
- buf.append(" }\n");
- buf.append(" },\n");
- buf.append(" E4Remove(1) {\n");
- buf.append(" public void foo() {\n");
- buf.append(" }\n");
- buf.append(" }\n");
- buf.append("}\n");
- IJavaScriptUnit cu= pack1.createCompilationUnit("DD.js", buf.toString(), false, null);
-
- JavaScriptUnit astRoot= createAST3(cu);
- AST ast= astRoot.getAST();
- ASTRewrite rewrite= ASTRewrite.create(astRoot.getAST());
- EnumDeclaration type= (EnumDeclaration) findAbstractTypeDeclaration(astRoot, "DD");
- {
- EnumConstantDeclaration enumConst= (EnumConstantDeclaration) type.enumConstants().get(0);
- assertNull(enumConst.getAnonymousClassDeclaration());
-
- AnonymousClassDeclaration classDecl= ast.newAnonymousClassDeclaration();
- ListRewrite bodyRewrite= rewrite.getListRewrite(classDecl, AnonymousClassDeclaration.BODY_DECLARATIONS_PROPERTY);
- bodyRewrite.insertFirst(createNewMethod(ast, "test", false), null);
-
- rewrite.set(enumConst, EnumConstantDeclaration.ANONYMOUS_CLASS_DECLARATION_PROPERTY, classDecl, null);
- }
- {
- EnumConstantDeclaration enumConst= (EnumConstantDeclaration) type.enumConstants().get(1);
- assertNull(enumConst.getAnonymousClassDeclaration());
-
- ListRewrite argsRewrite= rewrite.getListRewrite(enumConst, EnumConstantDeclaration.ARGUMENTS_PROPERTY);
- argsRewrite.insertFirst(ast.newNumberLiteral("1"), null);
-
- AnonymousClassDeclaration classDecl= ast.newAnonymousClassDeclaration();
- ListRewrite bodyRewrite= rewrite.getListRewrite(classDecl, AnonymousClassDeclaration.BODY_DECLARATIONS_PROPERTY);
- bodyRewrite.insertFirst(createNewMethod(ast, "test", false), null);
-
- rewrite.set(enumConst, EnumConstantDeclaration.ANONYMOUS_CLASS_DECLARATION_PROPERTY, classDecl, null);
-
- }
- {
- EnumConstantDeclaration enumConst= (EnumConstantDeclaration) type.enumConstants().get(2);
- assertNull(enumConst.getAnonymousClassDeclaration());
-
- rewrite.remove((ASTNode) enumConst.arguments().get(0), null);
-
- AnonymousClassDeclaration classDecl= ast.newAnonymousClassDeclaration();
- ListRewrite bodyRewrite= rewrite.getListRewrite(classDecl, AnonymousClassDeclaration.BODY_DECLARATIONS_PROPERTY);
- bodyRewrite.insertFirst(createNewMethod(ast, "test", false), null);
-
- rewrite.set(enumConst, EnumConstantDeclaration.ANONYMOUS_CLASS_DECLARATION_PROPERTY, classDecl, null);
- }
- {
- EnumConstantDeclaration enumConst= (EnumConstantDeclaration) type.enumConstants().get(3);
- assertNull(enumConst.getAnonymousClassDeclaration());
-
- AnonymousClassDeclaration classDecl= ast.newAnonymousClassDeclaration();
- rewrite.set(enumConst, EnumConstantDeclaration.ANONYMOUS_CLASS_DECLARATION_PROPERTY, classDecl, null);
- }
- {
- EnumConstantDeclaration enumConst= (EnumConstantDeclaration) type.enumConstants().get(4);
-
- AnonymousClassDeclaration classDecl= enumConst.getAnonymousClassDeclaration();
- assertNotNull(classDecl);
-
- ListRewrite bodyRewrite= rewrite.getListRewrite(classDecl, AnonymousClassDeclaration.BODY_DECLARATIONS_PROPERTY);
- bodyRewrite.insertFirst(createNewMethod(ast, "test", false), null);
- }
- {
- EnumConstantDeclaration enumConst= (EnumConstantDeclaration) type.enumConstants().get(5);
-
- AnonymousClassDeclaration classDecl= enumConst.getAnonymousClassDeclaration();
- assertNotNull(classDecl);
-
- rewrite.remove(classDecl, null);
- }
- {
- EnumConstantDeclaration enumConst= (EnumConstantDeclaration) type.enumConstants().get(6);
-
- AnonymousClassDeclaration classDecl= enumConst.getAnonymousClassDeclaration();
- assertNotNull(classDecl);
-
- ListRewrite argsRewrite= rewrite.getListRewrite(enumConst, EnumConstantDeclaration.ARGUMENTS_PROPERTY);
- argsRewrite.insertFirst(ast.newNumberLiteral("1"), null);
-
- rewrite.remove(classDecl, null);
- }
- {
- EnumConstantDeclaration enumConst= (EnumConstantDeclaration) type.enumConstants().get(7);
-
- AnonymousClassDeclaration classDecl= enumConst.getAnonymousClassDeclaration();
- assertNotNull(classDecl);
-
- rewrite.remove((ASTNode) enumConst.arguments().get(0), null);
- rewrite.remove(classDecl, null);
- }
- {
- EnumConstantDeclaration enumConst= (EnumConstantDeclaration) type.enumConstants().get(8);
-
- AnonymousClassDeclaration classDecl= enumConst.getAnonymousClassDeclaration();
- assertNotNull(classDecl);
-
- rewrite.remove((ASTNode) classDecl.bodyDeclarations().get(0), null);
- }
-
-
- String preview= evaluateRewrite(cu, rewrite);
-
- buf= new StringBuffer();
- buf.append("package test1;\n");
- buf.append("public enum DD {\n");
- buf.append(" E1Add(1) {\n");
- buf.append(" private void test(String str) {\n");
- buf.append(" }\n");
- buf.append(" },\n");
- buf.append(" E2Add(1) {\n");
- buf.append(" private void test(String str) {\n");
- buf.append(" }\n");
- buf.append(" },\n");
- buf.append(" E3Add {\n");
- buf.append(" private void test(String str) {\n");
- buf.append(" }\n");
- buf.append(" },\n");
- buf.append(" E4Add(1) {\n");
- buf.append(" },\n");
- buf.append(" E5Add(1) {\n");
- buf.append(" private void test(String str) {\n");
- buf.append(" }\n");
- buf.append("\n");
- buf.append(" public void foo() {\n");
- buf.append(" }\n");
- buf.append(" },\n");
- buf.append(" E1Remove(1),\n");
- buf.append(" E2Remove(1),\n");
- buf.append(" E3Remove,\n");
- buf.append(" E4Remove(1) {\n");
- buf.append(" }\n");
- buf.append("}\n");
- assertEqualString(preview, buf.toString());
- }
-
- public void testEnumConstantDeclaration_bug114119() throws Exception {
- IPackageFragment pack1= this.sourceFolder.createPackageFragment("test1", false, null);
- StringBuffer buf= new StringBuffer();
- buf.append("package test1;\n");
- buf.append("public enum DD {\n");
- buf.append(" RED, BROWN(), GREEN(){};\n");
- buf.append("}\n");
- IJavaScriptUnit cu= pack1.createCompilationUnit("DD.js", buf.toString(), false, null);
-
- JavaScriptUnit astRoot= createAST3(cu);
- ASTRewrite rewrite= ASTRewrite.create(astRoot.getAST());
- EnumDeclaration type= (EnumDeclaration) findAbstractTypeDeclaration(astRoot, "DD");
- {
- EnumConstantDeclaration enumConst= (EnumConstantDeclaration) type.enumConstants().get(2);
- assertNotNull(enumConst.getAnonymousClassDeclaration());
-
- rewrite.remove(enumConst.getAnonymousClassDeclaration(), null);
- }
-
-
- String preview= evaluateRewrite(cu, rewrite);
-
- buf= new StringBuffer();
- buf.append("package test1;\n");
- buf.append("public enum DD {\n");
- buf.append(" RED, BROWN(), GREEN();\n");
- buf.append("}\n");
- assertEqualString(preview, buf.toString());
- }
-
public void testMethodDeclChangesBug77538() throws Exception {
IPackageFragment pack1= this.sourceFolder.createPackageFragment("test1", false, null);
@@ -2674,96 +2290,5 @@
assertFalse("Invalid extended length for "+body, astRoot.getExtendedLength(body)<0);
}
- public void testAnnotations() throws Exception {
- IPackageFragment pack1= this.sourceFolder.createPackageFragment("test1", false, null);
- StringBuffer buf= new StringBuffer();
- buf.append("package test1;\n");
- buf.append("@An\n");
- buf.append("@An()\n");
- buf.append("@An(val=1, val=2)\n");
- buf.append("@An(val=1, val=2)\n");
- buf.append("@An(1)\n");
- buf.append("class E {\n");
- buf.append("}\n");
- IJavaScriptUnit cu= pack1.createCompilationUnit("E.js", buf.toString(), false, null);
-
- JavaScriptUnit astRoot= createAST3(cu);
- ASTRewrite rewrite= ASTRewrite.create(astRoot.getAST());
- AST ast= astRoot.getAST();
- TypeDeclaration type= findTypeDeclaration(astRoot, "E");
- List modifiers= type.modifiers();
- assertEquals(5, modifiers.size());
- {
- MarkerAnnotation an= (MarkerAnnotation) modifiers.get(0);
- SimpleName newName= ast.newSimpleName("X");
- rewrite.set(an, MarkerAnnotation.TYPE_NAME_PROPERTY, newName, null);
- }
- {
- NormalAnnotation an= (NormalAnnotation) modifiers.get(1);
- SimpleName newName= ast.newSimpleName("X");
- rewrite.set(an, NormalAnnotation.TYPE_NAME_PROPERTY, newName, null);
-
- ListRewrite listRewrite= rewrite.getListRewrite(an, NormalAnnotation.VALUES_PROPERTY);
-
- MemberValuePair newPair= ast.newMemberValuePair();
- newPair.setName(ast.newSimpleName("foo"));
- newPair.setValue(ast.newNumberLiteral("0"));
-
- listRewrite.insertFirst(newPair, null);
- }
- {
- NormalAnnotation an= (NormalAnnotation) modifiers.get(2);
- SimpleName newName= ast.newSimpleName("X");
- rewrite.set(an, NormalAnnotation.TYPE_NAME_PROPERTY, newName, null);
-
- List values= an.values();
-
- ListRewrite listRewrite= rewrite.getListRewrite(an, NormalAnnotation.VALUES_PROPERTY);
- listRewrite.remove((ASTNode) values.get(0), null);
-
- MemberValuePair p= (MemberValuePair) values.get(1);
- SimpleName newMember= ast.newSimpleName("Y");
- SimpleName newValue= ast.newSimpleName("Z");
- rewrite.set(p, MemberValuePair.NAME_PROPERTY, newMember, null);
- rewrite.set(p, MemberValuePair.VALUE_PROPERTY, newValue, null);
-
- MemberValuePair newPair= ast.newMemberValuePair();
- newPair.setName(ast.newSimpleName("foo"));
- newPair.setValue(ast.newNumberLiteral("0"));
-
- listRewrite.insertLast(newPair, null);
- }
- {
- NormalAnnotation an= (NormalAnnotation) modifiers.get(3);
- SimpleName newName= ast.newSimpleName("X");
- rewrite.set(an, NormalAnnotation.TYPE_NAME_PROPERTY, newName, null);
-
- List values= an.values();
-
- ListRewrite listRewrite= rewrite.getListRewrite(an, NormalAnnotation.VALUES_PROPERTY);
- listRewrite.remove((ASTNode) values.get(0), null);
- listRewrite.remove((ASTNode) values.get(1), null);
- }
- {
- SingleMemberAnnotation an= (SingleMemberAnnotation) modifiers.get(4);
- SimpleName newName= ast.newSimpleName("X");
- rewrite.set(an, SingleMemberAnnotation.TYPE_NAME_PROPERTY, newName, null);
- rewrite.set(an, SingleMemberAnnotation.VALUE_PROPERTY, ast.newBooleanLiteral(true), null);
- }
-
-
- String preview= evaluateRewrite(cu, rewrite);
-
- buf= new StringBuffer();
- buf.append("package test1;\n");
- buf.append("@X\n");
- buf.append("@X(foo = 0)\n");
- buf.append("@X(Y=Z, foo = 0)\n");
- buf.append("@X()\n");
- buf.append("@X(true)\n");
- buf.append("class E {\n");
- buf.append("}\n");
- assertEqualString(preview, buf.toString());
- }
}
diff --git a/tests/org.eclipse.wst.jsdt.core.tests.model/src/org/eclipse/wst/jsdt/core/tests/rewrite/describing/ASTRewritingTypeDeclTest.java b/tests/org.eclipse.wst.jsdt.core.tests.model/src/org/eclipse/wst/jsdt/core/tests/rewrite/describing/ASTRewritingTypeDeclTest.java
index 4903582..e2eec7f 100644
--- a/tests/org.eclipse.wst.jsdt.core.tests.model/src/org/eclipse/wst/jsdt/core/tests/rewrite/describing/ASTRewritingTypeDeclTest.java
+++ b/tests/org.eclipse.wst.jsdt.core.tests.model/src/org/eclipse/wst/jsdt/core/tests/rewrite/describing/ASTRewritingTypeDeclTest.java
@@ -17,8 +17,31 @@
import org.eclipse.wst.jsdt.core.IJavaScriptUnit;
import org.eclipse.wst.jsdt.core.IPackageFragment;
-
-import org.eclipse.wst.jsdt.core.dom.*;
+import org.eclipse.wst.jsdt.core.dom.AST;
+import org.eclipse.wst.jsdt.core.dom.ASTNode;
+import org.eclipse.wst.jsdt.core.dom.AnonymousClassDeclaration;
+import org.eclipse.wst.jsdt.core.dom.ArrayType;
+import org.eclipse.wst.jsdt.core.dom.Block;
+import org.eclipse.wst.jsdt.core.dom.ClassInstanceCreation;
+import org.eclipse.wst.jsdt.core.dom.Expression;
+import org.eclipse.wst.jsdt.core.dom.ExpressionStatement;
+import org.eclipse.wst.jsdt.core.dom.FieldDeclaration;
+import org.eclipse.wst.jsdt.core.dom.FunctionDeclaration;
+import org.eclipse.wst.jsdt.core.dom.ImportDeclaration;
+import org.eclipse.wst.jsdt.core.dom.JavaScriptUnit;
+import org.eclipse.wst.jsdt.core.dom.Modifier;
+import org.eclipse.wst.jsdt.core.dom.Name;
+import org.eclipse.wst.jsdt.core.dom.PackageDeclaration;
+import org.eclipse.wst.jsdt.core.dom.ParameterizedType;
+import org.eclipse.wst.jsdt.core.dom.PrimitiveType;
+import org.eclipse.wst.jsdt.core.dom.SimpleName;
+import org.eclipse.wst.jsdt.core.dom.SingleVariableDeclaration;
+import org.eclipse.wst.jsdt.core.dom.Type;
+import org.eclipse.wst.jsdt.core.dom.TypeDeclaration;
+import org.eclipse.wst.jsdt.core.dom.TypeParameter;
+import org.eclipse.wst.jsdt.core.dom.VariableDeclarationFragment;
+import org.eclipse.wst.jsdt.core.dom.VariableDeclarationStatement;
+import org.eclipse.wst.jsdt.core.dom.WildcardType;
import org.eclipse.wst.jsdt.core.dom.rewrite.ASTRewrite;
import org.eclipse.wst.jsdt.core.dom.rewrite.ListRewrite;
@@ -1154,367 +1177,6 @@
}
- public void testEnumDeclaration() throws Exception {
- // test the creation of an enum declaration
-
- IPackageFragment pack1= this.sourceFolder.createPackageFragment("test1", false, null);
- StringBuffer buf= new StringBuffer();
- buf.append("package test1;\n");
- buf.append("public class E {\n");
- buf.append("}\n");
- IJavaScriptUnit cu= pack1.createCompilationUnit("E.js", buf.toString(), false, null);
-
- JavaScriptUnit astRoot= createAST3(cu);
- ASTRewrite rewrite= ASTRewrite.create(astRoot.getAST());
- AST ast= astRoot.getAST();
-
- TypeDeclaration type= findTypeDeclaration(astRoot, "E");
- List members= type.bodyDeclarations();
- assertTrue("Has declarations", members.isEmpty());
-
- ListRewrite declarations= rewrite.getListRewrite(type, TypeDeclaration.BODY_DECLARATIONS_PROPERTY);
- { // insert an enum inner class
- EnumDeclaration enumD= ast.newEnumDeclaration();
-
- // where fEnumName is a String
- SimpleName enumName= ast.newSimpleName("MyEnum");
- enumD.setName(enumName);
- List enumStatements= enumD.enumConstants();
-
- String[] names= { "a", "b", "c" };
-
- // where fFieldsToExtract is an array of SimpleNames
- for (int i= 0; i < names.length; i++) {
- String curr= names[i];
- EnumConstantDeclaration constDecl= ast.newEnumConstantDeclaration();
- constDecl.setName(ast.newSimpleName(curr));
- enumStatements.add(constDecl);
- }
-
- declarations.insertFirst(enumD, null);
- }
-
- String preview= evaluateRewrite(cu, rewrite);
-
- buf= new StringBuffer();
- buf.append("package test1;\n");
- buf.append("public class E {\n");
- buf.append("\n");
- buf.append(" enum MyEnum {\n");
- buf.append(" a, b, c\n");
- buf.append(" }\n");
- buf.append("}\n");
- assertEqualString(preview, buf.toString());
- }
-
-
- public void testEnumDeclaration1() throws Exception {
- // test the creation of an enum declaration
-
- IPackageFragment pack1= this.sourceFolder.createPackageFragment("test1", false, null);
- StringBuffer buf= new StringBuffer();
- buf.append("package test1;\n");
- buf.append("public enum E {\n");
- buf.append("}\n");
- IJavaScriptUnit cu= pack1.createCompilationUnit("E.js", buf.toString(), false, null);
-
- JavaScriptUnit astRoot= createAST3(cu);
- ASTRewrite rewrite= ASTRewrite.create(astRoot.getAST());
- AST ast= astRoot.getAST();
-
- EnumDeclaration declaration= (EnumDeclaration) findAbstractTypeDeclaration(astRoot, "E");
-
- List members= declaration.bodyDeclarations();
- assertTrue("Has declarations", members.isEmpty());
-
- ListRewrite declarations= rewrite.getListRewrite(declaration, EnumDeclaration.ENUM_CONSTANTS_PROPERTY);
- EnumConstantDeclaration constDecl= ast.newEnumConstantDeclaration();
- constDecl.setName(ast.newSimpleName("A"));
-
- declarations.insertFirst(constDecl, null);
-
-
- String preview= evaluateRewrite(cu, rewrite);
-
- buf= new StringBuffer();
- buf.append("package test1;\n");
- buf.append("public enum E {\n");
- buf.append(" A\n");
- buf.append("}\n");
- assertEqualString(preview, buf.toString());
- }
-
-
- public void testEnumDeclaration2() throws Exception {
-
- IPackageFragment pack1= this.sourceFolder.createPackageFragment("test1", false, null);
- StringBuffer buf= new StringBuffer();
- buf.append("package test1;\n");
- buf.append("public enum E {\n");
- buf.append(" A, B, C\n");
- buf.append("}\n");
- IJavaScriptUnit cu= pack1.createCompilationUnit("E.js", buf.toString(), false, null);
-
- JavaScriptUnit astRoot= createAST3(cu);
- ASTRewrite rewrite= ASTRewrite.create(astRoot.getAST());
- AST ast= astRoot.getAST();
-
- EnumDeclaration declaration= (EnumDeclaration) findAbstractTypeDeclaration(astRoot, "E");
-
- {
- // remove first, insert after 2nd
- rewrite.remove((ASTNode) declaration.enumConstants().get(0), null);
-
- ASTNode newNode= ast.newSimpleName("X");
-
- ListRewrite listRewrite= rewrite.getListRewrite(declaration, EnumDeclaration.ENUM_CONSTANTS_PROPERTY);
- listRewrite.insertAfter(newNode, (ASTNode) declaration.enumConstants().get(1), null);
-
- // add body declaration
-
- ListRewrite bodyListRewrite= rewrite.getListRewrite(declaration, EnumDeclaration.BODY_DECLARATIONS_PROPERTY);
- bodyListRewrite.insertFirst(createNewMethod(ast, "foo", false), null);
- }
-
- String preview= evaluateRewrite(cu, rewrite);
-
- buf= new StringBuffer();
- buf.append("package test1;\n");
- buf.append("public enum E {\n");
- buf.append(" B, X, C;\n");
- buf.append("\n");
- buf.append(" private void foo(String str) {\n");
- buf.append(" }\n");
- buf.append("}\n");
- assertEqualString(preview, buf.toString());
- }
-
- public void testEnumDeclaration3() throws Exception {
-
- IPackageFragment pack1= this.sourceFolder.createPackageFragment("test1", false, null);
- StringBuffer buf= new StringBuffer();
- buf.append("package test1;\n");
- buf.append("public enum E {\n");
- buf.append(" A, B, C;\n");
- buf.append("}\n");
- IJavaScriptUnit cu= pack1.createCompilationUnit("E.js", buf.toString(), false, null);
-
- JavaScriptUnit astRoot= createAST3(cu);
- ASTRewrite rewrite= ASTRewrite.create(astRoot.getAST());
- AST ast= astRoot.getAST();
-
- EnumDeclaration declaration= (EnumDeclaration) findAbstractTypeDeclaration(astRoot, "E");
-
- {
- // remove first, insert after 2nd
- rewrite.remove((ASTNode) declaration.enumConstants().get(0), null);
-
- ASTNode newNode= ast.newSimpleName("X");
-
- ListRewrite listRewrite= rewrite.getListRewrite(declaration, EnumDeclaration.ENUM_CONSTANTS_PROPERTY);
- listRewrite.insertAfter(newNode, (ASTNode) declaration.enumConstants().get(1), null);
-
- // add body declaration
-
- ListRewrite bodyListRewrite= rewrite.getListRewrite(declaration, EnumDeclaration.BODY_DECLARATIONS_PROPERTY);
- bodyListRewrite.insertFirst(createNewMethod(ast, "foo", false), null);
- }
-
- String preview= evaluateRewrite(cu, rewrite);
-
- buf= new StringBuffer();
- buf.append("package test1;\n");
- buf.append("public enum E {\n");
- buf.append(" B, X, C;\n");
- buf.append("\n");
- buf.append(" private void foo(String str) {\n");
- buf.append(" }\n");
- buf.append("}\n");
- assertEqualString(preview, buf.toString());
- }
-
- public void testEnumDeclaration4() throws Exception {
-
- IPackageFragment pack1= this.sourceFolder.createPackageFragment("test1", false, null);
- StringBuffer buf= new StringBuffer();
- buf.append("package test1;\n");
- buf.append("public enum E {\n");
- buf.append(" A, B, C;\n");
- buf.append(" private void foo(String str) {\n");
- buf.append(" }\n");
- buf.append("}\n");
- IJavaScriptUnit cu= pack1.createCompilationUnit("E.js", buf.toString(), false, null);
-
- JavaScriptUnit astRoot= createAST3(cu);
- ASTRewrite rewrite= ASTRewrite.create(astRoot.getAST());
-
- EnumDeclaration declaration= (EnumDeclaration) findAbstractTypeDeclaration(astRoot, "E");
- {
- rewrite.remove((ASTNode) declaration.enumConstants().get(2), null);
- rewrite.remove((ASTNode) declaration.bodyDeclarations().get(0), null);
- }
-
- String preview= evaluateRewrite(cu, rewrite);
-
- buf= new StringBuffer();
- buf.append("package test1;\n");
- buf.append("public enum E {\n");
- buf.append(" A, B\n");
- buf.append("}\n");
- assertEqualString(preview, buf.toString());
- }
-
- public void testEnumDeclaration5() throws Exception {
-
- IPackageFragment pack1= this.sourceFolder.createPackageFragment("test1", false, null);
- StringBuffer buf= new StringBuffer();
- buf.append("package test1;\n");
- buf.append("public enum E {\n");
- buf.append(" A, B, C;\n");
- buf.append("\n");
- buf.append(" private void foo(String str) {\n");
- buf.append(" }\n");
- buf.append(" private void foo2(String str) {\n");
- buf.append(" }\n");
- buf.append("}\n");
- IJavaScriptUnit cu= pack1.createCompilationUnit("E.js", buf.toString(), false, null);
-
- JavaScriptUnit astRoot= createAST3(cu);
- ASTRewrite rewrite= ASTRewrite.create(astRoot.getAST());
-
- EnumDeclaration declaration= (EnumDeclaration) findAbstractTypeDeclaration(astRoot, "E");
- {
-
- ASTNode newNode= astRoot.getAST().newSimpleName("X");
-
- ListRewrite listRewrite= rewrite.getListRewrite(declaration, EnumDeclaration.ENUM_CONSTANTS_PROPERTY);
- listRewrite.insertAfter(newNode, (ASTNode) declaration.enumConstants().get(2), null);
-
- rewrite.remove((ASTNode) declaration.bodyDeclarations().get(0), null);
- }
-
- String preview= evaluateRewrite(cu, rewrite);
-
- buf= new StringBuffer();
- buf.append("package test1;\n");
- buf.append("public enum E {\n");
- buf.append(" A, B, C, X;\n");
- buf.append("\n");
- buf.append(" private void foo2(String str) {\n");
- buf.append(" }\n");
- buf.append("}\n");
- assertEqualString(preview, buf.toString());
- }
-
- public void testEnumDeclaration6() throws Exception {
- // test the creation of an enum declaration
-
- IPackageFragment pack1= this.sourceFolder.createPackageFragment("test1", false, null);
- StringBuffer buf= new StringBuffer();
- buf.append("package test1;\n");
- buf.append("public enum E {\n");
- buf.append(" A\n");
- buf.append("}\n");
- IJavaScriptUnit cu= pack1.createCompilationUnit("E.js", buf.toString(), false, null);
-
- JavaScriptUnit astRoot= createAST3(cu);
- ASTRewrite rewrite= ASTRewrite.create(astRoot.getAST());
- EnumDeclaration declaration= (EnumDeclaration) findAbstractTypeDeclaration(astRoot, "E");
-
- List members= declaration.bodyDeclarations();
- assertTrue("Has declarations", members.isEmpty());
-
- rewrite.remove((ASTNode) declaration.enumConstants().get(0), null);
-
-
- String preview= evaluateRewrite(cu, rewrite);
-
- buf= new StringBuffer();
- buf.append("package test1;\n");
- buf.append("public enum E {\n");
- buf.append("}\n");
- assertEqualString(preview, buf.toString());
- }
-
- public void testEnumDeclaration7() throws Exception {
- IPackageFragment pack1= this.sourceFolder.createPackageFragment("test1", false, null);
- StringBuffer buf= new StringBuffer();
- buf.append("package test1;\n");
- buf.append("public enum E {\n");
- buf.append("}\n");
- IJavaScriptUnit cu= pack1.createCompilationUnit("E.js", buf.toString(), false, null);
-
- JavaScriptUnit astRoot= createAST3(cu);
- ASTRewrite rewrite= ASTRewrite.create(astRoot.getAST());
- EnumDeclaration declaration= (EnumDeclaration) findAbstractTypeDeclaration(astRoot, "E");
-
- ListRewrite bodyListRewrite= rewrite.getListRewrite(declaration, EnumDeclaration.BODY_DECLARATIONS_PROPERTY);
-
- AST ast= astRoot.getAST();
- bodyListRewrite.insertFirst(createNewMethod(ast, "foo", false), null);
-
- String preview= evaluateRewrite(cu, rewrite);
-
- buf= new StringBuffer();
- buf.append("package test1;\n");
- buf.append("public enum E {\n");
- buf.append(" ;\n");
- buf.append("\n");
- buf.append(" private void foo(String str) {\n");
- buf.append(" }\n");
- buf.append("}\n");
- assertEqualString(preview, buf.toString());
- }
-
-
- public void testAnnotationTypeDeclaration1() throws Exception {
- IPackageFragment pack1= this.sourceFolder.createPackageFragment("test1", false, null);
- StringBuffer buf= new StringBuffer();
- buf.append("package test1;\n");
- buf.append("/**\n");
- buf.append(" * test\n");
- buf.append(" */\n");
- buf.append("public @interface E {\n");
- buf.append("}\n");
- IJavaScriptUnit cu= pack1.createCompilationUnit("E.js", buf.toString(), false, null);
-
- JavaScriptUnit astRoot= createAST3(cu);
- ASTRewrite rewrite= ASTRewrite.create(astRoot.getAST());
- AST ast= astRoot.getAST();
-
- {
- AnnotationTypeDeclaration type= (AnnotationTypeDeclaration) findAbstractTypeDeclaration(astRoot, "E");
-
- ListRewrite listRewrite= rewrite.getListRewrite(type, AnnotationTypeDeclaration.MODIFIERS2_PROPERTY);
- listRewrite.insertFirst(ast.newModifier(Modifier.ModifierKeyword.FINAL_KEYWORD), null);
-
- SimpleName name= type.getName();
- SimpleName newName= ast.newSimpleName("X");
-
- rewrite.replace(name, newName, null);
-
- AnnotationTypeMemberDeclaration declaration= ast.newAnnotationTypeMemberDeclaration();
- declaration.setName(ast.newSimpleName("value"));
- declaration.setType(ast.newSimpleType(ast.newSimpleName("String")));
-
- ListRewrite bodyList= rewrite.getListRewrite(type, AnnotationTypeDeclaration.BODY_DECLARATIONS_PROPERTY);
- bodyList.insertFirst(declaration, null);
- }
-
- String preview= evaluateRewrite(cu, rewrite);
-
- buf= new StringBuffer();
- buf.append("package test1;\n");
- buf.append("/**\n");
- buf.append(" * test\n");
- buf.append(" */\n");
- buf.append("final public @interface X {\n");
- buf.append("\n");
- buf.append(" String value();\n");
- buf.append("}\n");
- assertEqualString(preview, buf.toString());
-
- }
public void testWildcardType() throws Exception {
IPackageFragment pack1= this.sourceFolder.createPackageFragment("test1", false, null);