Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMateusz Matela2019-09-22 16:18:23 -0400
committerMateusz Matela2019-09-22 16:24:22 -0400
commit9a673eda953a579a6fad0db94aa8a0f836f8d317 (patch)
treeb4d4115027bf9eb1cf78f5f6ed76108e7bca2c0c
parentc15f6eb4389b2ebadf7b97668d2430f32a530398 (diff)
downloadeclipse.jdt.core-9a673eda953a579a6fad0db94aa8a0f836f8d317.tar.gz
eclipse.jdt.core-9a673eda953a579a6fad0db94aa8a0f836f8d317.tar.xz
eclipse.jdt.core-9a673eda953a579a6fad0db94aa8a0f836f8d317.zip
Bug 551189 - Consistent ArrayIndexOutOfBounds when saving an incorrectI20190922-1800
Java file when code clean-up is enabled Change-Id: I227175e1677341e1262fc5dd70a648642367db59 Signed-off-by: Mateusz Matela <mateusz.matela@gmail.com>
-rw-r--r--org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/FormatterBugsTests.java16
-rw-r--r--org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/OneLineEnforcer.java8
2 files changed, 22 insertions, 2 deletions
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/FormatterBugsTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/FormatterBugsTests.java
index 305d9b3b01..96e0469d51 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/FormatterBugsTests.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/FormatterBugsTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2018 IBM Corporation and others.
+ * Copyright (c) 2000, 2019 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -13022,4 +13022,18 @@ public void testBug413193c() {
" }\n" +
"}");
}
+/**
+ * https://bugs.eclipse.org/551189 - Consistent ArrayIndexOutOfBounds when saving an incorrect Java file when code clean-up is enabled
+ */
+public void testBug551189() {
+ formatSource(
+ "public class AAA {\n" +
+ "\n" +
+ "import java.awt.*;\n" +
+ "\n" +
+ "public class BBB {\n" +
+ " int a;\n" +
+ "\n" +
+ "}}");
+}
}
diff --git a/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/OneLineEnforcer.java b/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/OneLineEnforcer.java
index 9d9763fe05..9b2671a09c 100644
--- a/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/OneLineEnforcer.java
+++ b/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/OneLineEnforcer.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2014, 2018 Mateusz Matela and others.
+ * Copyright (c) 2018, 2019 Mateusz Matela and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -59,6 +59,12 @@ public class OneLineEnforcer extends ASTVisitor {
}
@Override
+ public boolean preVisit2(ASTNode node) {
+ boolean isMalformed = (node.getFlags() & ASTNode.MALFORMED) != 0;
+ return !isMalformed;
+ }
+
+ @Override
public void endVisit(TypeDeclaration node) {
if (node.getParent().getLength() == 0)
return; // this is a fake block created by parsing in statements mode

Back to the top