Lines 5483-5486
Link Here
|
5483 |
workingCopy.discardWorkingCopy(); |
5483 |
workingCopy.discardWorkingCopy(); |
5484 |
} |
5484 |
} |
5485 |
} |
5485 |
} |
|
|
5486 |
|
5487 |
/* |
5488 |
* Ensures that no exception is thrown in case of a syntax error in a for statement |
5489 |
* (regression test for bug 199668 IAE in ASTNode.setSourceRange while editing a class) |
5490 |
*/ |
5491 |
public void test0608() throws CoreException { |
5492 |
ICompilationUnit workingCopy = null; |
5493 |
try { |
5494 |
workingCopy = getWorkingCopy( |
5495 |
"/Converter/src/X.java", |
5496 |
"public class X {\n" + |
5497 |
" void foo() {\n" + |
5498 |
" for (/*start*/int i=0,/*end*/; i<10; i++) {\n" + |
5499 |
" }\n" + |
5500 |
" }\n" + |
5501 |
"}" |
5502 |
); |
5503 |
ASTNode node = buildAST(null, workingCopy, false, true); |
5504 |
assertNotNull("Should get an AST", node); |
5505 |
assertEquals("Unexpected node type", ASTNode.VARIABLE_DECLARATION_EXPRESSION, node.getNodeType()); |
5506 |
VariableDeclarationExpression variableDeclarationExpression = (VariableDeclarationExpression) node; |
5507 |
List fragments = variableDeclarationExpression.fragments(); |
5508 |
assertEquals("Wrong size", 2, fragments.size()); |
5509 |
VariableDeclarationFragment fragment = (VariableDeclarationFragment) fragments.get(1); |
5510 |
SimpleName name = fragment.getName(); |
5511 |
assertEquals("Wrong name", name.getIdentifier(), "$missing$"); |
5512 |
} finally { |
5513 |
if (workingCopy != null) |
5514 |
workingCopy.discardWorkingCopy(); |
5515 |
} |
5516 |
} |
5517 |
|
5518 |
/* |
5519 |
* Ensures that no exception is thrown in case of a syntax error in method parameter declarations |
5520 |
* (regression test for bug 200080 Endless illegal arg exceptions from java editor's ASTProvider) |
5521 |
*/ |
5522 |
public void test0609() throws CoreException { |
5523 |
ICompilationUnit workingCopy = null; |
5524 |
try { |
5525 |
workingCopy = getWorkingCopy( |
5526 |
"/Converter/src/X.java", |
5527 |
"public class X {\n" + |
5528 |
" void foo(a, b, ) {\n" + |
5529 |
" if\n" + |
5530 |
" }\n" + |
5531 |
"}" |
5532 |
); |
5533 |
CompilationUnit cu = workingCopy.reconcile(AST.JLS3, true, true, null, null); |
5534 |
assertNotNull("Should get an AST", cu); |
5535 |
ASTNode node = getASTNode(cu, 0, 0); |
5536 |
assertEquals("Unexpected node type", ASTNode.METHOD_DECLARATION, node.getNodeType()); |
5537 |
MethodDeclaration methodDeclaration = (MethodDeclaration) node; |
5538 |
List parameters = methodDeclaration.parameters(); |
5539 |
assertEquals("Wrong size", 0, parameters.size()); |
5540 |
Block body = methodDeclaration.getBody(); |
5541 |
assertNotNull("Should not be null", body); |
5542 |
List statements = body.statements(); |
5543 |
assertEquals("Wrong size", 1, statements.size()); |
5544 |
node = (ASTNode)statements.get(0); |
5545 |
assertEquals("Unexpected node type", ASTNode.VARIABLE_DECLARATION_STATEMENT, node.getNodeType()); |
5546 |
VariableDeclarationStatement variableDeclarationStatement = (VariableDeclarationStatement) node; |
5547 |
List fragments = variableDeclarationStatement.fragments(); |
5548 |
assertEquals("Wrong size", 2, fragments.size()); |
5549 |
VariableDeclarationFragment fragment = (VariableDeclarationFragment) fragments.get(1); |
5550 |
SimpleName name = fragment.getName(); |
5551 |
assertEquals("Wrong name", name.getIdentifier(), "$missing$"); |
5552 |
} finally { |
5553 |
if (workingCopy != null) |
5554 |
workingCopy.discardWorkingCopy(); |
5555 |
} |
5556 |
} |
5557 |
|
5558 |
/* |
5559 |
* (regression test for bug 199668) |
5560 |
*/ |
5561 |
public void test0610() throws CoreException { |
5562 |
ICompilationUnit workingCopy = null; |
5563 |
try { |
5564 |
workingCopy = getWorkingCopy( |
5565 |
"/Converter/src/X.java", |
5566 |
"public class X {\n" + |
5567 |
" void foo() {\n" + |
5568 |
" /*start*/int i=0,/*end*/;\n" + |
5569 |
" }\n" + |
5570 |
"}" |
5571 |
); |
5572 |
ASTNode node = buildAST(null, workingCopy, false, true); |
5573 |
assertNotNull("Should get an AST", node); |
5574 |
assertEquals("Unexpected node type", ASTNode.VARIABLE_DECLARATION_STATEMENT, node.getNodeType()); |
5575 |
VariableDeclarationStatement variableDeclarationStatement = (VariableDeclarationStatement) node; |
5576 |
List fragments = variableDeclarationStatement.fragments(); |
5577 |
assertEquals("Wrong size", 1, fragments.size()); |
5578 |
VariableDeclarationFragment fragment = (VariableDeclarationFragment) fragments.get(0); |
5579 |
SimpleName name = fragment.getName(); |
5580 |
assertEquals("Wrong name", name.getIdentifier(), "i"); |
5581 |
} finally { |
5582 |
if (workingCopy != null) |
5583 |
workingCopy.discardWorkingCopy(); |
5584 |
} |
5585 |
} |
5486 |
} |
5586 |
} |