Lines 46-52
Link Here
|
46 |
} |
46 |
} |
47 |
|
47 |
|
48 |
static { |
48 |
static { |
49 |
// TESTS_NUMBERS = new int[] { 272 }; |
49 |
TESTS_NUMBERS = new int[] { 276 }; |
50 |
// TESTS_RANGE = new int[] { 253, -1 }; |
50 |
// TESTS_RANGE = new int[] { 253, -1 }; |
51 |
// TESTS_NAMES = new String[] {"test0204"}; |
51 |
// TESTS_NAMES = new String[] {"test0204"}; |
52 |
} |
52 |
} |
Lines 9098-9101
Link Here
|
9098 |
CompilationUnit unit = (CompilationUnit) node; |
9098 |
CompilationUnit unit = (CompilationUnit) node; |
9099 |
assertProblemsSize(unit, 1, "The type A is not generic; it cannot be parameterized with arguments <?>"); |
9099 |
assertProblemsSize(unit, 1, "The type A is not generic; it cannot be parameterized with arguments <?>"); |
9100 |
} |
9100 |
} |
|
|
9101 |
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=191908 |
9102 |
public void test0274() throws JavaModelException { |
9103 |
this.workingCopy = getWorkingCopy("/Converter15/src/X.java", true/*resolve*/); |
9104 |
String contents = |
9105 |
"public class X {\n" + |
9106 |
" @Deprecated\n" + |
9107 |
" public static int x= 5, y= 10;\n" + |
9108 |
"}"; |
9109 |
ASTNode node = buildAST( |
9110 |
contents, |
9111 |
this.workingCopy, |
9112 |
true); |
9113 |
assertEquals("Not a compilation unit", ASTNode.COMPILATION_UNIT, node.getNodeType()); |
9114 |
CompilationUnit unit = (CompilationUnit) node; |
9115 |
assertProblemsSize(unit, 0); |
9116 |
node = getASTNode(unit, 0, 0); |
9117 |
assertEquals("Not a field declaration", ASTNode.FIELD_DECLARATION, node.getNodeType()); |
9118 |
FieldDeclaration fieldDeclaration = (FieldDeclaration) node; |
9119 |
List fragments = fieldDeclaration.fragments(); |
9120 |
assertEquals("Wrong size", 2, fragments.size()); |
9121 |
VariableDeclarationFragment fragment = (VariableDeclarationFragment) fragments.get(0); |
9122 |
IVariableBinding binding = fragment.resolveBinding(); |
9123 |
assertTrue("Not deprecated", binding.isDeprecated()); |
9124 |
fragment = (VariableDeclarationFragment) fragments.get(1); |
9125 |
binding = fragment.resolveBinding(); |
9126 |
assertTrue("Not deprecated", binding.isDeprecated()); |
9127 |
} |
9128 |
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=191908 |
9129 |
public void test0275() throws JavaModelException { |
9130 |
this.workingCopy = getWorkingCopy("/Converter15/src/X.java", true/*resolve*/); |
9131 |
String contents = |
9132 |
"public class X {\n" + |
9133 |
" public void foo() {\n" + |
9134 |
" @Deprecated\n" + |
9135 |
" int x= 5, y= 10;\n" + |
9136 |
" }\n" + |
9137 |
"}"; |
9138 |
ASTNode node = buildAST( |
9139 |
contents, |
9140 |
this.workingCopy, |
9141 |
true); |
9142 |
assertEquals("Not a compilation unit", ASTNode.COMPILATION_UNIT, node.getNodeType()); |
9143 |
CompilationUnit unit = (CompilationUnit) node; |
9144 |
assertProblemsSize(unit, 0); |
9145 |
node = getASTNode(unit, 0, 0, 0); |
9146 |
assertEquals("Not a variable declaration statement", ASTNode.VARIABLE_DECLARATION_STATEMENT, node.getNodeType()); |
9147 |
VariableDeclarationStatement statement = (VariableDeclarationStatement) node; |
9148 |
List fragments = statement.fragments(); |
9149 |
assertEquals("Wrong size", 2, fragments.size()); |
9150 |
VariableDeclarationFragment fragment = (VariableDeclarationFragment) fragments.get(0); |
9151 |
IVariableBinding binding = fragment.resolveBinding(); |
9152 |
IAnnotationBinding[] annotations = binding.getAnnotations(); |
9153 |
assertEquals("Wrong size", 1, annotations.length); |
9154 |
fragment = (VariableDeclarationFragment) fragments.get(1); |
9155 |
binding = fragment.resolveBinding(); |
9156 |
annotations = binding.getAnnotations(); |
9157 |
assertEquals("Wrong size", 1, annotations.length); |
9158 |
} |
9159 |
|
9160 |
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=192774 |
9161 |
//Test ability to distinguish AST nodes of multiple similar annotations. |
9162 |
public void test0276() throws JavaModelException { |
9163 |
this.workingCopy = getWorkingCopy("/Converter15/src/X.java", true/*resolve*/); |
9164 |
String contents = |
9165 |
"@interface Annot {\n" + |
9166 |
" public int value();\n" + |
9167 |
"}\n" + |
9168 |
"\n" + |
9169 |
"public class X {\n" + |
9170 |
" @Annot(1) String foo1() { return null; }\n" + |
9171 |
" @Annot(1) String foo2() { return null; }\n" + |
9172 |
"}"; |
9173 |
this.workingCopy.getBuffer().setContents(contents); |
9174 |
|
9175 |
class CompilationUnitRequestor extends ASTRequestor { |
9176 |
public void acceptAST(ICompilationUnit source, CompilationUnit node) { |
9177 |
MethodDeclaration methodDeclaration = (MethodDeclaration)getASTNode(node, 1, 0); |
9178 |
IMethodBinding methodBinding = methodDeclaration.resolveBinding(); |
9179 |
IAnnotationBinding annoBinding = methodBinding.getAnnotations()[0]; |
9180 |
ASTNode annoNode = node.findDeclaringNode(annoBinding); |
9181 |
int position1 = annoNode.getStartPosition(); |
9182 |
|
9183 |
methodDeclaration = (MethodDeclaration)getASTNode(node, 1, 1); |
9184 |
methodBinding = methodDeclaration.resolveBinding(); |
9185 |
IAnnotationBinding annoBinding2 = methodBinding.getAnnotations()[0]; |
9186 |
annoNode = node.findDeclaringNode(annoBinding2); |
9187 |
int position2 = annoNode.getStartPosition(); |
9188 |
assertTrue("Anno 2 position <= anno 1 position", position2 > position1); |
9189 |
} |
9190 |
} |
9191 |
|
9192 |
CompilationUnitRequestor requestor = new CompilationUnitRequestor(); |
9193 |
ASTParser parser = ASTParser.newParser(AST.JLS3); |
9194 |
parser.setResolveBindings(true); |
9195 |
parser.setProject(this.getJavaProject("Converter15")); |
9196 |
parser.setKind(ASTParser.K_COMPILATION_UNIT); |
9197 |
parser.createASTs(new ICompilationUnit[]{this.workingCopy}, new String[0], requestor, null); |
9198 |
} |
9101 |
} |
9199 |
} |