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 78886 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 fix + regression test
patch_199668.txt (text/plain), 8.98 KB, created by
Olivier Thomann
on 2007-09-20 15:12:49 EDT
(
hide
)
Description:
Proposed fix + regression test
Filename:
MIME Type:
Creator:
Olivier Thomann
Created:
2007-09-20 15:12:49 EDT
Size:
8.98 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.183 >diff -u -r1.183 ASTConverterTest2.java >--- src/org/eclipse/jdt/core/tests/dom/ASTConverterTest2.java 16 Aug 2007 14:59:30 -0000 1.183 >+++ src/org/eclipse/jdt/core/tests/dom/ASTConverterTest2.java 20 Sep 2007 19:10:36 -0000 >@@ -43,7 +43,7 @@ > > static { > // TESTS_NAMES = new String[] {"test0578"}; >-// TESTS_NUMBERS = new int[] { 606 }; >+// TESTS_NUMBERS = new int[] { 608 }; > } > public static Test suite() { > return buildModelTestSuite(ASTConverterTest2.class); >@@ -5501,8 +5501,20 @@ > " }\n" + > "}" > ); >- ASTNode cu = buildAST(null, workingCopy, false, true); >- assertNotNull("Should get an AST", cu); >+ ASTNode node = buildAST(null, workingCopy, false, true); >+ assertNotNull("Should get an AST", node); >+ assertEquals("Not a compilation unit", ASTNode.COMPILATION_UNIT, node.getNodeType()); >+ node = getASTNode((CompilationUnit) node, 0, 0, 0); >+ assertEquals("Not a for statement", ASTNode.FOR_STATEMENT, node.getNodeType()); >+ ForStatement forStatement = (ForStatement) node; >+ List initializers = forStatement.initializers(); >+ assertEquals("Wrong size", 1, initializers.size()); >+ VariableDeclarationExpression expression = (VariableDeclarationExpression) initializers.get(0); >+ List fragments = expression.fragments(); >+ assertEquals("Wrong size", 1, fragments.size()); >+ VariableDeclarationFragment fragment = (VariableDeclarationFragment) fragments.get(0); >+ assertEquals("Wrong name", "i", fragment.getName().getIdentifier()); >+ assertTrue("Should be a recovered fragment", isRecovered(expression)); > } finally { > if (workingCopy != null) > workingCopy.discardWorkingCopy(); >#P org.eclipse.jdt.core >Index: dom/org/eclipse/jdt/core/dom/ASTRecoveryPropagator.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ASTRecoveryPropagator.java,v >retrieving revision 1.5 >diff -u -r1.5 ASTRecoveryPropagator.java >--- dom/org/eclipse/jdt/core/dom/ASTRecoveryPropagator.java 10 Apr 2006 14:02:46 -0000 1.5 >+++ dom/org/eclipse/jdt/core/dom/ASTRecoveryPropagator.java 20 Sep 2007 19:10:38 -0000 >@@ -359,6 +359,26 @@ > } > } > >+ public void endVisit(ForStatement node) { >+ endVisitNode(node); >+ List initializers = node.initializers(); >+ if (initializers.size() == 1) { >+ Expression expression = (Expression) initializers.get(0); >+ if (expression.getNodeType() == ASTNode.VARIABLE_DECLARATION_EXPRESSION) { >+ VariableDeclarationExpression variableDeclarationExpression = (VariableDeclarationExpression) expression; >+ List fragments = variableDeclarationExpression.fragments(); >+ for (int i = 0, max = fragments.size(); i <max; i++) { >+ VariableDeclarationFragment fragment = (VariableDeclarationFragment) fragments.get(i); >+ SimpleName simpleName = fragment.getName(); >+ if (CharOperation.equals(RecoveryScanner.FAKE_IDENTIFIER, simpleName.getIdentifier().toCharArray())) { >+ fragments.remove(fragment); >+ variableDeclarationExpression.setFlags(variableDeclarationExpression.getFlags() | ASTNode.RECOVERED); >+ } >+ } >+ } >+ } >+ } >+ > public void endVisit(VariableDeclarationStatement node) { > endVisitNode(node); > List fragments = node.fragments(); >@@ -371,8 +391,8 @@ > SimpleName simpleName = (SimpleName) expression; > if (CharOperation.equals(RecoveryScanner.FAKE_IDENTIFIER, simpleName.getIdentifier().toCharArray())) { > fragment.setInitializer(null); >- fragment.setFlags(node.getFlags() | ASTNode.RECOVERED); >- } >+ fragment.setFlags(fragment.getFlags() | ASTNode.RECOVERED); >+ } > } > } > } >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.255 >diff -u -r1.255 ASTConverter.java >--- dom/org/eclipse/jdt/core/dom/ASTConverter.java 20 Sep 2007 18:46:18 -0000 1.255 >+++ dom/org/eclipse/jdt/core/dom/ASTConverter.java 20 Sep 2007 19:10:38 -0000 >@@ -378,20 +378,18 @@ > > protected void checkAndAddMultipleLocalDeclaration(org.eclipse.jdt.internal.compiler.ast.Statement[] stmts, int index, List blockStatements) { > if (index > 0 >- && stmts[index - 1] instanceof org.eclipse.jdt.internal.compiler.ast.LocalDeclaration) { >- org.eclipse.jdt.internal.compiler.ast.LocalDeclaration local1 = (org.eclipse.jdt.internal.compiler.ast.LocalDeclaration) stmts[index - 1]; >- org.eclipse.jdt.internal.compiler.ast.LocalDeclaration local2 = (org.eclipse.jdt.internal.compiler.ast.LocalDeclaration) stmts[index]; >- if (local2.name == RecoveryScanner.FAKE_IDENTIFIER) // workaround for bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=199668 >- return; >- if (local1.declarationSourceStart == local2.declarationSourceStart) { >- // we have a multiple local declarations >- // We retrieve the existing VariableDeclarationStatement to add the new VariableDeclarationFragment >- VariableDeclarationStatement variableDeclarationStatement = (VariableDeclarationStatement) blockStatements.get(blockStatements.size() - 1); >- variableDeclarationStatement.fragments().add(convertToVariableDeclarationFragment((org.eclipse.jdt.internal.compiler.ast.LocalDeclaration)stmts[index])); >- } else { >- // we can create a new FieldDeclaration >- blockStatements.add(convertToVariableDeclarationStatement((org.eclipse.jdt.internal.compiler.ast.LocalDeclaration)stmts[index])); >- } >+ && stmts[index - 1] instanceof org.eclipse.jdt.internal.compiler.ast.LocalDeclaration) { >+ org.eclipse.jdt.internal.compiler.ast.LocalDeclaration local1 = (org.eclipse.jdt.internal.compiler.ast.LocalDeclaration) stmts[index - 1]; >+ org.eclipse.jdt.internal.compiler.ast.LocalDeclaration local2 = (org.eclipse.jdt.internal.compiler.ast.LocalDeclaration) stmts[index]; >+ if (local1.declarationSourceStart == local2.declarationSourceStart) { >+ // we have a multiple local declarations >+ // We retrieve the existing VariableDeclarationStatement to add the new VariableDeclarationFragment >+ VariableDeclarationStatement variableDeclarationStatement = (VariableDeclarationStatement) blockStatements.get(blockStatements.size() - 1); >+ variableDeclarationStatement.fragments().add(convertToVariableDeclarationFragment((org.eclipse.jdt.internal.compiler.ast.LocalDeclaration)stmts[index])); >+ } else { >+ // we can create a new FieldDeclaration >+ blockStatements.add(convertToVariableDeclarationStatement((org.eclipse.jdt.internal.compiler.ast.LocalDeclaration)stmts[index])); >+ } > } else { > // we can create a new FieldDeclaration > blockStatements.add(convertToVariableDeclarationStatement((org.eclipse.jdt.internal.compiler.ast.LocalDeclaration)stmts[index])); >@@ -1739,16 +1737,11 @@ > // we know that we have at least one initialization > if (initializations[0] instanceof org.eclipse.jdt.internal.compiler.ast.LocalDeclaration) { > org.eclipse.jdt.internal.compiler.ast.LocalDeclaration initialization = (org.eclipse.jdt.internal.compiler.ast.LocalDeclaration) initializations[0]; >- if (initialization.name == RecoveryScanner.FAKE_IDENTIFIER) { // workaround for https://bugs.eclipse.org/bugs/show_bug.cgi?id=199668) >- return null; >- } > VariableDeclarationExpression variableDeclarationExpression = convertToVariableDeclarationExpression(initialization); > int initializationsLength = initializations.length; > for (int i = 1; i < initializationsLength; i++) { > initialization = (org.eclipse.jdt.internal.compiler.ast.LocalDeclaration)initializations[i]; >- if (initialization.name != RecoveryScanner.FAKE_IDENTIFIER) { // workaround for https://bugs.eclipse.org/bugs/show_bug.cgi?id=199668) >- variableDeclarationExpression.fragments().add(convertToVariableDeclarationFragment(initialization)); >- } >+ variableDeclarationExpression.fragments().add(convertToVariableDeclarationFragment(initialization)); > } > if (initializationsLength != 1) { > int start = variableDeclarationExpression.getStartPosition(); >@@ -2380,8 +2373,6 @@ > } > if (statement instanceof org.eclipse.jdt.internal.compiler.ast.LocalDeclaration) { > org.eclipse.jdt.internal.compiler.ast.LocalDeclaration localDeclaration = (org.eclipse.jdt.internal.compiler.ast.LocalDeclaration)statement; >- if (localDeclaration.name == RecoveryScanner.FAKE_IDENTIFIER) // workaround for https://bugs.eclipse.org/bugs/show_bug.cgi?id=199668 >- return null; > return convertToVariableDeclarationStatement(localDeclaration); > } > if (statement instanceof org.eclipse.jdt.internal.compiler.ast.AssertStatement) {
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