Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 77374 Details for
Bug 199668
IAE in ASTNode.setSourceRange while editing a class
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Proposed patch for 3.3.1
bug199668_331_002.txt (text/plain), 6.02 KB, created by
David Audel
on 2007-08-30 09:42:34 EDT
(
hide
)
Description:
Proposed patch for 3.3.1
Filename:
MIME Type:
Creator:
David Audel
Created:
2007-08-30 09:42:34 EDT
Size:
6.02 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.core.tests.model >Index: src/org/eclipse/jdt/core/tests/dom/ASTConverterTest2.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverterTest2.java,v >retrieving revision 1.179 >diff -u -r1.179 ASTConverterTest2.java >--- src/org/eclipse/jdt/core/tests/dom/ASTConverterTest2.java 14 Mar 2007 08:18:40 -0000 1.179 >+++ src/org/eclipse/jdt/core/tests/dom/ASTConverterTest2.java 30 Aug 2007 13:20:11 -0000 >@@ -5483,4 +5483,104 @@ > workingCopy.discardWorkingCopy(); > } > } >+ >+ /* >+ * Ensures that no exception is thrown in case of a syntax error in a for statement >+ * (regression test for bug 199668 IAE in ASTNode.setSourceRange while editing a class) >+ */ >+ public void test0608() throws CoreException { >+ ICompilationUnit workingCopy = null; >+ try { >+ workingCopy = getWorkingCopy( >+ "/Converter/src/X.java", >+ "public class X {\n" + >+ " void foo() {\n" + >+ " for (/*start*/int i=0,/*end*/; i<10; i++) {\n" + >+ " }\n" + >+ " }\n" + >+ "}" >+ ); >+ ASTNode node = buildAST(null, workingCopy, false, true); >+ assertNotNull("Should get an AST", node); >+ assertEquals("Unexpected node type", ASTNode.VARIABLE_DECLARATION_EXPRESSION, node.getNodeType()); >+ VariableDeclarationExpression variableDeclarationExpression = (VariableDeclarationExpression) node; >+ List fragments = variableDeclarationExpression.fragments(); >+ assertEquals("Wrong size", 2, fragments.size()); >+ VariableDeclarationFragment fragment = (VariableDeclarationFragment) fragments.get(1); >+ SimpleName name = fragment.getName(); >+ assertEquals("Wrong name", name.getIdentifier(), "$missing$"); >+ } finally { >+ if (workingCopy != null) >+ workingCopy.discardWorkingCopy(); >+ } >+ } >+ >+ /* >+ * Ensures that no exception is thrown in case of a syntax error in method parameter declarations >+ * (regression test for bug 200080 Endless illegal arg exceptions from java editor's ASTProvider) >+ */ >+ public void test0609() throws CoreException { >+ ICompilationUnit workingCopy = null; >+ try { >+ workingCopy = getWorkingCopy( >+ "/Converter/src/X.java", >+ "public class X {\n" + >+ " void foo(a, b, ) {\n" + >+ " if\n" + >+ " }\n" + >+ "}" >+ ); >+ CompilationUnit cu = workingCopy.reconcile(AST.JLS3, true, true, null, null); >+ assertNotNull("Should get an AST", cu); >+ ASTNode node = getASTNode(cu, 0, 0); >+ assertEquals("Unexpected node type", ASTNode.METHOD_DECLARATION, node.getNodeType()); >+ MethodDeclaration methodDeclaration = (MethodDeclaration) node; >+ List parameters = methodDeclaration.parameters(); >+ assertEquals("Wrong size", 0, parameters.size()); >+ Block body = methodDeclaration.getBody(); >+ assertNotNull("Should not be null", body); >+ List statements = body.statements(); >+ assertEquals("Wrong size", 1, statements.size()); >+ node = (ASTNode)statements.get(0); >+ assertEquals("Unexpected node type", ASTNode.VARIABLE_DECLARATION_STATEMENT, node.getNodeType()); >+ VariableDeclarationStatement variableDeclarationStatement = (VariableDeclarationStatement) node; >+ List fragments = variableDeclarationStatement.fragments(); >+ assertEquals("Wrong size", 2, fragments.size()); >+ VariableDeclarationFragment fragment = (VariableDeclarationFragment) fragments.get(1); >+ SimpleName name = fragment.getName(); >+ assertEquals("Wrong name", name.getIdentifier(), "$missing$"); >+ } finally { >+ if (workingCopy != null) >+ workingCopy.discardWorkingCopy(); >+ } >+ } >+ >+ /* >+ * (regression test for bug 199668) >+ */ >+ public void test0610() throws CoreException { >+ ICompilationUnit workingCopy = null; >+ try { >+ workingCopy = getWorkingCopy( >+ "/Converter/src/X.java", >+ "public class X {\n" + >+ " void foo() {\n" + >+ " /*start*/int i=0,/*end*/;\n" + >+ " }\n" + >+ "}" >+ ); >+ ASTNode node = buildAST(null, workingCopy, false, true); >+ assertNotNull("Should get an AST", node); >+ assertEquals("Unexpected node type", ASTNode.VARIABLE_DECLARATION_STATEMENT, node.getNodeType()); >+ VariableDeclarationStatement variableDeclarationStatement = (VariableDeclarationStatement) node; >+ List fragments = variableDeclarationStatement.fragments(); >+ assertEquals("Wrong size", 1, fragments.size()); >+ VariableDeclarationFragment fragment = (VariableDeclarationFragment) fragments.get(0); >+ SimpleName name = fragment.getName(); >+ assertEquals("Wrong name", name.getIdentifier(), "i"); >+ } finally { >+ if (workingCopy != null) >+ workingCopy.discardWorkingCopy(); >+ } >+ } > } >#P org.eclipse.jdt.core >Index: dom/org/eclipse/jdt/core/dom/ASTConverter.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ASTConverter.java,v >retrieving revision 1.248.2.1 >diff -u -r1.248.2.1 ASTConverter.java >--- dom/org/eclipse/jdt/core/dom/ASTConverter.java 27 Aug 2007 19:24:36 -0000 1.248.2.1 >+++ dom/org/eclipse/jdt/core/dom/ASTConverter.java 30 Aug 2007 13:20:15 -0000 >@@ -2992,6 +2992,13 @@ > name.setSourceRange(localDeclaration.sourceStart, localDeclaration.sourceEnd - localDeclaration.sourceStart + 1); > variableDeclarationFragment.setName(name); > int start = localDeclaration.sourceEnd; >+ if (localDeclaration.name == RecoveryScanner.FAKE_IDENTIFIER) { >+ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=199668 >+ // sourceEnd is equals to sourceStart - 1 when the token is empty (token created by the statements recovery). >+ // sourceStart must be used instead otherwise retrievePositionBeforeNextCommaOrSemiColon() could find the >+ // previous comma or semicolon. >+ start = localDeclaration.sourceStart; >+ } > org.eclipse.jdt.internal.compiler.ast.Expression initialization = localDeclaration.initialization; > boolean hasInitialization = initialization != null; > if (hasInitialization) {
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 199668
:
76210
| 77374 |
78886