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 54001 Details for
Bug 157570
Bug in ASTParser
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Fix for recovery
bug157570_003.txt (text/plain), 7.97 KB, created by
David Audel
on 2006-11-16 12:47:40 EST
(
hide
)
Description:
Fix for recovery
Filename:
MIME Type:
Creator:
David Audel
Created:
2006-11-16 12:47:40 EST
Size:
7.97 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.core.tests.compiler >Index: src/org/eclipse/jdt/core/tests/compiler/parser/DietRecoveryTest.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/DietRecoveryTest.java,v >retrieving revision 1.48 >diff -u -r1.48 DietRecoveryTest.java >--- src/org/eclipse/jdt/core/tests/compiler/parser/DietRecoveryTest.java 13 Nov 2006 10:43:04 -0000 1.48 >+++ src/org/eclipse/jdt/core/tests/compiler/parser/DietRecoveryTest.java 16 Nov 2006 17:40:35 -0000 >@@ -7588,4 +7588,102 @@ > expectedFullUnitToString, > expectedCompletionDietUnitToString, testName); > } >+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=157570 >+public void test124() { >+ String s = >+ "public class Test {\n" + >+ " void aMethod() {\n" + >+ " public static void m1()\n" + >+ " {\n" + >+ " int a;\n" + >+ " int b;\n" + >+ " }\n" + >+ " public static void m2()\n" + >+ " {\n" + >+ " int c;\n" + >+ " int d;\n" + >+ " }\n" + >+ " }\n" + >+ "}\n"; >+ >+ String expectedDietUnitToString = >+ "public class Test {\n" + >+ " public Test() {\n" + >+ " }\n" + >+ " void aMethod() {\n" + >+ " }\n" + >+ "}\n"; >+ >+ String expectedDietPlusBodyUnitToString = >+ "public class Test {\n" + >+ " public Test() {\n" + >+ " super();\n" + >+ " }\n" + >+ " void aMethod() {\n" + >+ " }\n" + >+ "}\n"; >+ >+ String expectedDietPlusBodyPlusStatementsRecoveryUnitToString = null; >+ if(COMPLIANCE_1_3.equals(this.complianceLevel) || >+ COMPLIANCE_1_4.equals(this.complianceLevel)) { >+ expectedDietPlusBodyPlusStatementsRecoveryUnitToString = >+ "public class Test {\n" + >+ " public Test() {\n" + >+ " super();\n" + >+ " }\n" + >+ " void aMethod() {\n" + >+ " m1();\n" + >+ " {\n" + >+ " int a;\n" + >+ " int b;\n" + >+ " }\n" + >+ " m2();\n" + >+ " {\n" + >+ " int c;\n" + >+ " int d;\n" + >+ " }\n" + >+ " }\n" + >+ "}\n"; >+ } else { >+ expectedDietPlusBodyPlusStatementsRecoveryUnitToString = >+ "public class Test {\n" + >+ " public Test() {\n" + >+ " super();\n" + >+ " }\n" + >+ " void aMethod() {\n" + >+ " public static @m1() enum $missing$ {\n" + >+ " public $missing$() {\n" + >+ " super();\n" + >+ " }\n" + >+ " <clinit>() {\n" + >+ " }\n" + >+ " }\n" + >+ " }\n" + >+ "}\n"; >+ } >+ >+ String expectedFullUnitToString = >+ "public class Test {\n" + >+ " public Test() {\n" + >+ " }\n" + >+ " void aMethod() {\n" + >+ " }\n" + >+ " public static void m1() {\n" + >+ " }\n" + >+ " public static void m2() {\n" + >+ " }\n" + >+ "}\n"; >+ >+ String expectedCompletionDietUnitToString = >+ expectedDietUnitToString; >+ >+ String testName = "test"; >+ checkParse( >+ s.toCharArray(), >+ expectedDietUnitToString, >+ expectedDietPlusBodyUnitToString, >+ expectedDietPlusBodyPlusStatementsRecoveryUnitToString, >+ expectedFullUnitToString, >+ expectedCompletionDietUnitToString, testName); >+} > } >#P org.eclipse.jdt.core >Index: compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java,v >retrieving revision 1.358 >diff -u -r1.358 Parser.java >--- compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java 13 Nov 2006 10:43:19 -0000 1.358 >+++ compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java 16 Nov 2006 17:40:41 -0000 >@@ -4160,7 +4160,13 @@ > if (this.currentElement.parseTree() == method && this.currentElement.parent != null) { > this.currentElement = this.currentElement.parent; > } >- } >+ } else if(this.currentToken == TokenNameLBRACE) { >+ if (this.currentElement instanceof RecoveredMethod && >+ ((RecoveredMethod)this.currentElement).methodDeclaration != method) { >+ this.ignoreNextOpeningBrace = true; >+ this.currentElement.bracketBalance++; >+ } >+ } > this.restartRecovery = true; // used to avoid branching back into the regular automaton > } > } >Index: dom/org/eclipse/jdt/core/dom/ASTParser.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ASTParser.java,v >retrieving revision 1.67 >diff -u -r1.67 ASTParser.java >--- dom/org/eclipse/jdt/core/dom/ASTParser.java 16 Nov 2006 04:08:02 -0000 1.67 >+++ dom/org/eclipse/jdt/core/dom/ASTParser.java 16 Nov 2006 17:40:41 -0000 >@@ -982,6 +982,7 @@ > compilationUnit.setLineEndTable(recordedParsingInformation.lineEnds); > if (constructorDeclaration != null) { > Block block = ast.newBlock(); >+ block.setSourceRange(this.sourceOffset, this.sourceOffset + this.sourceLength); > org.eclipse.jdt.internal.compiler.ast.Statement[] statements = constructorDeclaration.statements; > if (statements != null) { > int statementsLength = statements.length; >@@ -997,9 +998,6 @@ > } > } > rootNodeToCompilationUnit(ast, compilationUnit, block, recordedParsingInformation, data); >- if (data != null) { >- block.setFlags(block.getFlags() | ASTNode.RECOVERED); >- } > ast.setDefaultNodeFlag(0); > ast.setOriginalModificationCount(ast.modificationCount()); > return block; >@@ -1045,6 +1043,7 @@ > compilationUnit.setLineEndTable(recordedParsingInformation.lineEnds); > if (nodes != null) { > TypeDeclaration typeDeclaration = converter.convert(nodes); >+ typeDeclaration.setSourceRange(this.sourceOffset, this.sourceOffset + this.sourceLength); > rootNodeToCompilationUnit(typeDeclaration.getAST(), compilationUnit, typeDeclaration, codeSnippetParsingUtil.recordedParsingInformation, null); > ast.setDefaultNodeFlag(0); > ast.setOriginalModificationCount(ast.modificationCount()); >@@ -1078,9 +1077,7 @@ > if (problemsCount != 0) { > // propagate and record problems > final CategorizedProblem[] problems = recordedParsingInformation.problems; >- for (int i = 0, max = block.statements().size(); i < max; i++) { >- propagateErrors((ASTNode) block.statements().get(i), problems, data); >- } >+ propagateErrors(block, problems, data); > compilationUnit.setProblems(problems); > } > TypeDeclaration typeDeclaration = ast.newTypeDeclaration(); >@@ -1096,9 +1093,7 @@ > if (problemsCount != 0) { > // propagate and record problems > final CategorizedProblem[] problems = recordedParsingInformation.problems; >- for (int i = 0, max = typeDeclaration.bodyDeclarations().size(); i < max; i++) { >- propagateErrors((ASTNode) typeDeclaration.bodyDeclarations().get(i), problems, data); >- } >+ propagateErrors(typeDeclaration, problems, data); > compilationUnit.setProblems(problems); > } > compilationUnit.types().add(typeDeclaration); >#P org.eclipse.jdt.core.tests.model >Index: src/org/eclipse/jdt/core/tests/dom/ASTConverterTestAST3_2.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverterTestAST3_2.java,v >retrieving revision 1.106 >diff -u -r1.106 ASTConverterTestAST3_2.java >--- src/org/eclipse/jdt/core/tests/dom/ASTConverterTestAST3_2.java 16 Nov 2006 04:08:00 -0000 1.106 >+++ src/org/eclipse/jdt/core/tests/dom/ASTConverterTestAST3_2.java 16 Nov 2006 17:40:54 -0000 >@@ -8243,7 +8243,7 @@ > assertEquals("Not a block", ASTNode.BLOCK, result.getNodeType()); > Block block = (Block) result; > List statements = block.statements(); >- assertEquals("Should be empty", 2, statements.size()); >+ assertEquals("Should be empty", 4, statements.size()); > assertTrue("Not recovered", isRecovered(block)); > ASTNode root = block.getRoot(); > assertNotNull("No root", root);
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 157570
: 54001