Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorManoj Palat2020-09-29 04:53:09 +0000
committerManoj Palat2020-09-29 06:28:08 +0000
commit27561fd83113216e5f697434e65c1535a3dfcdb5 (patch)
tree96b35a05d0371385bad12b24e608b4507f28309e
parentb3c492dde0fd224fd55b829810386b0137ce34a3 (diff)
downloadeclipse.jdt.core-I20200930-1800.tar.gz
eclipse.jdt.core-I20200930-1800.tar.xz
eclipse.jdt.core-I20200930-1800.zip
Bug 567319 - Parser error while editor => build failures popup andI20201001-1800I20200930-1800I20200929-1800
editor doesn't start Change-Id: I9517add3382d0cf4561174b6e7e199a036583573
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/SwitchExpressionsYieldTest.java33
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/Scanner.java4
2 files changed, 35 insertions, 2 deletions
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/SwitchExpressionsYieldTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/SwitchExpressionsYieldTest.java
index bb95d47818..7cb9cfa4f4 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/SwitchExpressionsYieldTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/SwitchExpressionsYieldTest.java
@@ -5925,4 +5925,37 @@ public class SwitchExpressionsYieldTest extends AbstractRegressionTest {
"----------\n"
);
}
+ public void testBug567112_001() {
+ runNegativeTest(
+ new String[] {
+ "X.java",
+ "import java.util.ArrayList;\n"+
+ "\n"+
+ "public class X {\n"+
+ " public void foo() {\n"+
+ " new ArrayList<>().stream().filter(p -> p != null)\n"+
+ " switch (\"\") {\n"+
+ " case \"\":\n"+
+ " }\n"+
+ " }\n"+
+ "}"
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 5)\n" +
+ " new ArrayList<>().stream().filter(p -> p != null)\n" +
+ " ^^^^^\n" +
+ "Syntax error on tokens, delete these tokens\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 8)\n" +
+ " }\n" +
+ " ^\n" +
+ "Syntax error, insert \")\" to complete Expression\n" +
+ "----------\n" +
+ "3. ERROR in X.java (at line 8)\n" +
+ " }\n" +
+ " ^\n" +
+ "Syntax error, insert \";\" to complete BlockStatements\n" +
+ "----------\n"
+ );
+ }
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/Scanner.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/Scanner.java
index 02bf1d262f..f3e57aeb33 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/Scanner.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/Scanner.java
@@ -5631,8 +5631,8 @@ private VanguardParser getNewVanguardParser(char[] src) {
}
int disambiguatedToken(int token) {
final VanguardParser parser = getVanguardParser();
- if (token == TokenNameARROW && mayBeAtCaseLabelExpr()) {
- assert this.caseStartPosition < this.startPosition;
+ if (token == TokenNameARROW && mayBeAtCaseLabelExpr() && this.caseStartPosition < this.startPosition) {
+ // this.caseStartPosition > this.startPositionpossible on recovery - bother only about correct ones.
int nSz = this.startPosition - this.caseStartPosition;
// add fake token of TokenNameCOLON, call vanguard on this modified source
// TODO: Inefficient method due to redoing of the same source, investigate alternate

Back to the top