Lines 122-128
Link Here
|
122 |
static { |
122 |
static { |
123 |
// TESTS_NAMES = new String[] {"test0602"}; |
123 |
// TESTS_NAMES = new String[] {"test0602"}; |
124 |
// TESTS_RANGE = new int[] { 670, -1 }; |
124 |
// TESTS_RANGE = new int[] { 670, -1 }; |
125 |
// TESTS_NUMBERS = new int[] { 702 }; |
125 |
// TESTS_NUMBERS = new int[] { 708 }; |
126 |
} |
126 |
} |
127 |
public static Test suite() { |
127 |
public static Test suite() { |
128 |
return buildModelTestSuite(ASTConverterTestAST3_2.class); |
128 |
return buildModelTestSuite(ASTConverterTestAST3_2.class); |
Lines 4115-4122
Link Here
|
4115 |
parser.setCompilerOptions(JavaCore.getOptions()); |
4115 |
parser.setCompilerOptions(JavaCore.getOptions()); |
4116 |
ASTNode result2 = parser.createAST(null); |
4116 |
ASTNode result2 = parser.createAST(null); |
4117 |
assertNotNull("No node", result2); |
4117 |
assertNotNull("No node", result2); |
4118 |
assertTrue("not a compilation unit", result2.getNodeType() == ASTNode.COMPILATION_UNIT); |
4118 |
assertTrue("not a type declaration", result2.getNodeType() == ASTNode.TYPE_DECLARATION); |
4119 |
CompilationUnit compilationUnit = (CompilationUnit) result2; |
4119 |
CompilationUnit compilationUnit = (CompilationUnit) ((TypeDeclaration) result2).getParent(); |
4120 |
assertEquals("wrong problem size", 1, compilationUnit.getProblems().length); |
4120 |
assertEquals("wrong problem size", 1, compilationUnit.getProblems().length); |
4121 |
} |
4121 |
} |
4122 |
/** |
4122 |
/** |
Lines 4140-4147
Link Here
|
4140 |
parser.setCompilerOptions(JavaCore.getOptions()); |
4140 |
parser.setCompilerOptions(JavaCore.getOptions()); |
4141 |
ASTNode result2 = parser.createAST(null); |
4141 |
ASTNode result2 = parser.createAST(null); |
4142 |
assertNotNull("No node", result2); |
4142 |
assertNotNull("No node", result2); |
4143 |
assertTrue("not a compilation unit", result2.getNodeType() == ASTNode.COMPILATION_UNIT); |
4143 |
assertTrue("not a type declaration", result2.getNodeType() == ASTNode.TYPE_DECLARATION); |
4144 |
CompilationUnit compilationUnit = (CompilationUnit) result2; |
4144 |
CompilationUnit compilationUnit = (CompilationUnit) ((TypeDeclaration) result2).getParent(); |
4145 |
assertEquals("wrong problem size", 1, compilationUnit.getProblems().length); |
4145 |
assertEquals("wrong problem size", 1, compilationUnit.getProblems().length); |
4146 |
} |
4146 |
} |
4147 |
/** |
4147 |
/** |
Lines 4165-4172
Link Here
|
4165 |
parser.setCompilerOptions(JavaCore.getOptions()); |
4165 |
parser.setCompilerOptions(JavaCore.getOptions()); |
4166 |
ASTNode result2 = parser.createAST(null); |
4166 |
ASTNode result2 = parser.createAST(null); |
4167 |
assertNotNull("No node", result2); |
4167 |
assertNotNull("No node", result2); |
4168 |
assertTrue("not a compilation unit", result2.getNodeType() == ASTNode.COMPILATION_UNIT); |
4168 |
assertTrue("not a type declaration", result2.getNodeType() == ASTNode.TYPE_DECLARATION); |
4169 |
CompilationUnit compilationUnit = (CompilationUnit) result2; |
4169 |
CompilationUnit compilationUnit = (CompilationUnit) ((TypeDeclaration) result2).getParent(); |
4170 |
assertEquals("wrong problem size", 1, compilationUnit.getProblems().length); |
4170 |
assertEquals("wrong problem size", 1, compilationUnit.getProblems().length); |
4171 |
} |
4171 |
} |
4172 |
/** |
4172 |
/** |
Lines 10104-10120
Link Here
|
10104 |
} |
10104 |
} |
10105 |
} |
10105 |
} |
10106 |
/** |
10106 |
/** |
10107 |
* https://bugs.eclipse.org/bugs/show_bug.cgi?id=264590 |
10107 |
* http://dev.eclipse.org/bugs/show_bug.cgi?id=270148 |
10108 |
*/ |
10108 |
*/ |
10109 |
public void _test0702() throws JavaModelException { |
10109 |
public void test0702() throws JavaModelException { |
|
|
10110 |
final char[] source = ("void foo() {\n" + |
10111 |
" Integer I = new ${cursor}\n" + |
10112 |
"}").toCharArray(); |
10110 |
ASTParser parser = ASTParser.newParser(AST.JLS3); |
10113 |
ASTParser parser = ASTParser.newParser(AST.JLS3); |
10111 |
parser.setKind(ASTParser.K_EXPRESSION); |
10114 |
parser.setKind(ASTParser.K_CLASS_BODY_DECLARATIONS); |
10112 |
String commentsText = "/**\n * @generated\n */\n"; |
10115 |
parser.setStatementsRecovery(true); |
10113 |
char[] source = commentsText.toCharArray(); |
|
|
10114 |
parser.setSource(source); |
10116 |
parser.setSource(source); |
10115 |
parser.setSourceRange(0, source.length); |
10117 |
ASTNode root = parser.createAST(null); |
10116 |
parser.setCompilerOptions(JavaCore.getOptions()); |
10118 |
assertEquals("Not a type declaration", ASTNode.TYPE_DECLARATION, root.getNodeType()); |
10117 |
ASTNode result = parser.createAST(null); |
10119 |
TypeDeclaration typeDeclaration = (TypeDeclaration) root; |
10118 |
assertEquals("not a compilation unit", ASTNode.COMPILATION_UNIT, result.getNodeType()); |
10120 |
List bodyDeclarations = typeDeclaration.bodyDeclarations(); |
|
|
10121 |
assertEquals("Wrong size", 1, bodyDeclarations.size()); |
10122 |
BodyDeclaration bodyDeclaration = (BodyDeclaration) bodyDeclarations.get(0); |
10123 |
assertEquals("Not a method declaration", ASTNode.METHOD_DECLARATION, bodyDeclaration.getNodeType()); |
10124 |
MethodDeclaration declaration = (MethodDeclaration) bodyDeclaration; |
10125 |
// check if there is a body with one statement in it |
10126 |
assertEquals("No statement found", 1, declaration.getBody().statements().size()); |
10127 |
} |
10128 |
/** |
10129 |
* http://dev.eclipse.org/bugs/show_bug.cgi?id=270148 |
10130 |
*/ |
10131 |
public void test0703() throws JavaModelException { |
10132 |
final char[] source = ("public class Try {\n" + |
10133 |
" void foo() {\n" + |
10134 |
" Integer I = new ${cursor}\n" + |
10135 |
" }\n" + |
10136 |
"}").toCharArray(); |
10137 |
ASTParser parser = ASTParser.newParser(AST.JLS3); |
10138 |
parser.setKind(ASTParser.K_COMPILATION_UNIT); |
10139 |
parser.setStatementsRecovery(true); |
10140 |
parser.setSource(source); |
10141 |
ASTNode root = parser.createAST(null); |
10142 |
assertEquals("Not a compilation declaration", ASTNode.COMPILATION_UNIT, root.getNodeType()); |
10143 |
TypeDeclaration typeDeclaration = (TypeDeclaration) ((CompilationUnit) root).types().get(0); |
10144 |
List bodyDeclarations = typeDeclaration.bodyDeclarations(); |
10145 |
assertEquals("Wrong size", 1, bodyDeclarations.size()); |
10146 |
BodyDeclaration bodyDeclaration = (BodyDeclaration) bodyDeclarations.get(0); |
10147 |
assertEquals("Not a method declaration", ASTNode.METHOD_DECLARATION, bodyDeclaration.getNodeType()); |
10148 |
MethodDeclaration declaration = (MethodDeclaration) bodyDeclaration; |
10149 |
// check if there is a body with one statement in it |
10150 |
assertEquals("No statement found", 1, declaration.getBody().statements().size()); |
10151 |
} |
10152 |
/** |
10153 |
* http://dev.eclipse.org/bugs/show_bug.cgi?id=270148 |
10154 |
*/ |
10155 |
public void test0704() throws JavaModelException { |
10156 |
final char[] source = ("{\n" + |
10157 |
" Integer I = new ${cursor}\n" + |
10158 |
"}").toCharArray(); |
10159 |
ASTParser parser = ASTParser.newParser(AST.JLS3); |
10160 |
parser.setKind(ASTParser.K_CLASS_BODY_DECLARATIONS); |
10161 |
parser.setStatementsRecovery(true); |
10162 |
parser.setSource(source); |
10163 |
ASTNode root = parser.createAST(null); |
10164 |
assertEquals("Not a type declaration", ASTNode.TYPE_DECLARATION, root.getNodeType()); |
10165 |
TypeDeclaration typeDeclaration = (TypeDeclaration) root; |
10166 |
List bodyDeclarations = typeDeclaration.bodyDeclarations(); |
10167 |
assertEquals("Wrong size", 1, bodyDeclarations.size()); |
10168 |
BodyDeclaration bodyDeclaration = (BodyDeclaration) bodyDeclarations.get(0); |
10169 |
assertEquals("Not an initializer", ASTNode.INITIALIZER, bodyDeclaration.getNodeType()); |
10170 |
Initializer initializer = (Initializer) bodyDeclaration; |
10171 |
// check if there is a body with one statement in it |
10172 |
assertEquals("No statement found", 1, initializer.getBody().statements().size()); |
10173 |
} |
10174 |
/** |
10175 |
* http://dev.eclipse.org/bugs/show_bug.cgi?id=270148 |
10176 |
*/ |
10177 |
public void test0705() throws JavaModelException { |
10178 |
final char[] source = ("{\n" + |
10179 |
" Integer I = new ${cursor}\n" + |
10180 |
"}\n" + |
10181 |
"{\n" + |
10182 |
" Integer I = new ${cursor}\n" + |
10183 |
"}").toCharArray(); |
10184 |
ASTParser parser = ASTParser.newParser(AST.JLS3); |
10185 |
parser.setKind(ASTParser.K_CLASS_BODY_DECLARATIONS); |
10186 |
parser.setStatementsRecovery(true); |
10187 |
parser.setSource(source); |
10188 |
ASTNode root = parser.createAST(null); |
10189 |
assertEquals("Not a type declaration", ASTNode.TYPE_DECLARATION, root.getNodeType()); |
10190 |
TypeDeclaration typeDeclaration = (TypeDeclaration) root; |
10191 |
List bodyDeclarations = typeDeclaration.bodyDeclarations(); |
10192 |
assertEquals("Wrong size", 2, bodyDeclarations.size()); |
10193 |
BodyDeclaration bodyDeclaration = (BodyDeclaration) bodyDeclarations.get(0); |
10194 |
assertEquals("Not an initializer", ASTNode.INITIALIZER, bodyDeclaration.getNodeType()); |
10195 |
Initializer initializer = (Initializer) bodyDeclaration; |
10196 |
// check if there is a body with one statement in it |
10197 |
assertEquals("No statement found", 1, initializer.getBody().statements().size()); |
10198 |
bodyDeclaration = (BodyDeclaration) bodyDeclarations.get(1); |
10199 |
assertEquals("Not an initializer", ASTNode.INITIALIZER, bodyDeclaration.getNodeType()); |
10200 |
initializer = (Initializer) bodyDeclaration; |
10201 |
// check if there is a body with one statement in it |
10202 |
assertEquals("No statement found", 1, initializer.getBody().statements().size()); |
10203 |
} |
10204 |
/** |
10205 |
* http://dev.eclipse.org/bugs/show_bug.cgi?id=270148 |
10206 |
*/ |
10207 |
public void test0706() throws JavaModelException { |
10208 |
final char[] source = ("public class Try {\n" + |
10209 |
" Integer i = new Integer() {\n" + |
10210 |
" Integer I = new ${cursor}\n" + |
10211 |
" };\"\n" + |
10212 |
"}").toCharArray(); |
10213 |
ASTParser parser = ASTParser.newParser(AST.JLS3); |
10214 |
parser.setKind(ASTParser.K_COMPILATION_UNIT); |
10215 |
parser.setStatementsRecovery(true); |
10216 |
parser.setSource(source); |
10217 |
ASTNode root = parser.createAST(null); |
10218 |
assertEquals("Not a compilation declaration", ASTNode.COMPILATION_UNIT, root.getNodeType()); |
10219 |
TypeDeclaration typeDeclaration = (TypeDeclaration) ((CompilationUnit) root).types().get(0); |
10220 |
List bodyDeclarations = typeDeclaration.bodyDeclarations(); |
10221 |
assertEquals("Wrong size", 1, bodyDeclarations.size()); |
10222 |
} |
10223 |
/** |
10224 |
* http://dev.eclipse.org/bugs/show_bug.cgi?id=270148 |
10225 |
*/ |
10226 |
public void test0707() throws JavaModelException { |
10227 |
final char[] source = ("Integer i = new Integer() {\n" + |
10228 |
" Integer I = new ${cursor}\n" + |
10229 |
"};").toCharArray(); |
10230 |
ASTParser parser = ASTParser.newParser(AST.JLS3); |
10231 |
parser.setKind(ASTParser.K_CLASS_BODY_DECLARATIONS); |
10232 |
parser.setStatementsRecovery(true); |
10233 |
parser.setSource(source); |
10234 |
ASTNode root = parser.createAST(null); |
10235 |
assertEquals("Not a type declaration", ASTNode.TYPE_DECLARATION, root.getNodeType()); |
10236 |
List bodyDeclarations = ((TypeDeclaration) root).bodyDeclarations(); |
10237 |
assertEquals("Wrong size", 1, bodyDeclarations.size()); |
10238 |
} |
10239 |
/** |
10240 |
* http://dev.eclipse.org/bugs/show_bug.cgi?id=270148 |
10241 |
*/ |
10242 |
public void test0708() throws JavaModelException { |
10243 |
final char[] source = ("System.out.println()\nint i;\n").toCharArray(); |
10244 |
ASTParser parser = ASTParser.newParser(AST.JLS3); |
10245 |
parser.setKind(ASTParser.K_STATEMENTS); |
10246 |
parser.setStatementsRecovery(true); |
10247 |
parser.setSource(source); |
10248 |
ASTNode root = parser.createAST(null); |
10249 |
assertEquals("Not a block", ASTNode.BLOCK, root.getNodeType()); |
10250 |
Block block = (Block) root; |
10251 |
List statements = block.statements(); |
10252 |
assertEquals("Wrong size", 2, statements.size()); |
10119 |
} |
10253 |
} |
10120 |
} |
10254 |
} |