Lines 1-5
Link Here
|
1 |
/******************************************************************************* |
1 |
/******************************************************************************* |
2 |
* Copyright (c) 2006, 2009 IBM Corporation and others. |
2 |
* Copyright (c) 2006, 2010 IBM Corporation and others. |
3 |
* All rights reserved. This program and the accompanying materials |
3 |
* All rights reserved. This program and the accompanying materials |
4 |
* are made available under the terms of the Eclipse Public License v1.0 |
4 |
* are made available under the terms of the Eclipse Public License v1.0 |
5 |
* which accompanies this distribution, and is available at |
5 |
* which accompanies this distribution, and is available at |
Lines 45-51
Link Here
|
45 |
|
45 |
|
46 |
static { |
46 |
static { |
47 |
// TESTS_NAMES = new String[] {"test0003"}; |
47 |
// TESTS_NAMES = new String[] {"test0003"}; |
48 |
// TESTS_NUMBERS = new int[] { 624 }; |
48 |
// TESTS_NUMBERS = new int[] { 19 }; |
49 |
} |
49 |
} |
50 |
public static Test suite() { |
50 |
public static Test suite() { |
51 |
return buildModelTestSuite(ASTConverterRecoveryTest.class); |
51 |
return buildModelTestSuite(ASTConverterRecoveryTest.class); |
Lines 992-995
Link Here
|
992 |
"Syntax error, insert \") Statement\" to complete BlockStatements\n", |
992 |
"Syntax error, insert \") Statement\" to complete BlockStatements\n", |
993 |
result); |
993 |
result); |
994 |
} |
994 |
} |
|
|
995 |
public void test0019() throws JavaModelException { |
996 |
this.workingCopies = new ICompilationUnit[1]; |
997 |
this.workingCopies[0] = getWorkingCopy( |
998 |
"/Converter/src/test/X.java", |
999 |
"package test;\n"+ |
1000 |
"public class X {\n"+ |
1001 |
" void foo() {\n" + |
1002 |
" field= new Object() {hash};\n" + |
1003 |
" }\n" + |
1004 |
"}\n"); |
1005 |
|
1006 |
char[] source = this.workingCopies[0].getSource().toCharArray(); |
1007 |
ASTNode result = runConversion(AST.JLS3, this.workingCopies[0], true, true); |
1008 |
|
1009 |
assertASTNodeEquals( |
1010 |
"package test;\n" + |
1011 |
"public class X {\n" + |
1012 |
" void foo(){\n" + |
1013 |
" field=new Object(){\n" + |
1014 |
" }\n" + |
1015 |
";\n" + |
1016 |
" }\n" + |
1017 |
"}\n", |
1018 |
result); |
1019 |
|
1020 |
ASTNode node = getASTNode((CompilationUnit) result, 0, 0); |
1021 |
assertNotNull(node); |
1022 |
assertTrue("Not a method declaration", node.getNodeType() == ASTNode.METHOD_DECLARATION); //$NON-NLS-1$ |
1023 |
MethodDeclaration methodDeclaration = (MethodDeclaration) node; |
1024 |
Block block = methodDeclaration.getBody(); |
1025 |
List statements = block.statements(); |
1026 |
assertEquals("wrong size", 1, statements.size()); //$NON-NLS-1$ |
1027 |
Statement statement = (Statement) statements.get(0); |
1028 |
assertTrue("Not an expression statement", statement.getNodeType() == ASTNode.EXPRESSION_STATEMENT); //$NON-NLS-1$ |
1029 |
ExpressionStatement expressionStatement = (ExpressionStatement) statement; |
1030 |
checkSourceRange(expressionStatement, "field= new Object() {hash};", source); //$NON-NLS-1$ |
1031 |
Expression expression = expressionStatement.getExpression(); |
1032 |
assertTrue("Not an assignment", expression.getNodeType() == ASTNode.ASSIGNMENT); //$NON-NLS-1$ |
1033 |
Assignment assignment = (Assignment) expression; |
1034 |
Expression anonymousClassDeclaration = assignment.getRightHandSide(); |
1035 |
checkSourceRange(anonymousClassDeclaration, "new Object() {hash}", source); //$NON-NLS-1$ |
1036 |
checkSourceRange(assignment, "field= new Object() {hash}", source); //$NON-NLS-1$ |
1037 |
} |
995 |
} |
1038 |
} |