Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJay Arthanareeswaran2020-03-19 11:28:51 +0000
committerJay Arthanareeswaran2020-03-19 11:29:21 +0000
commit8f68ce4464f063259009e409d974e96ed60fe208 (patch)
tree0356e0a7669a420d472bc1bfe640329ed90f3beb
parent268f86fe8d807ed77eeb83bfc0abbf7661409e25 (diff)
downloadeclipse.jdt.core-8f68ce4464f063259009e409d974e96ed60fe208.tar.gz
eclipse.jdt.core-8f68ce4464f063259009e409d974e96ed60fe208.tar.xz
eclipse.jdt.core-8f68ce4464f063259009e409d974e96ed60fe208.zip
Bug 561251 - [14] CR followed by LF in the beginning of text block
inserts an additional line Change-Id: I34d6225df698a68289ff10dc497c3855ba1ce8fa Signed-off-by: Jay Arthanareeswaran <jarthana@in.ibm.com>
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/TextBlockTest.java27
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/Scanner.java1
2 files changed, 26 insertions, 2 deletions
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/TextBlockTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/TextBlockTest.java
index e502dd40f6..32906fb2ef 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/TextBlockTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/TextBlockTest.java
@@ -34,7 +34,7 @@ public class TextBlockTest extends AbstractRegressionTest {
static {
// TESTS_NUMBERS = new int [] { 40 };
-// TESTS_NAMES = new String[] { "testCompliances_13" };
+// TESTS_NAMES = new String[] { "testCompliances_14" };
}
public static Class<?> testClass() {
@@ -1283,6 +1283,31 @@ public class TextBlockTest extends AbstractRegressionTest {
getCompilerOptions(),
new String[] {"--enable-preview"});
}
+ public void testCompliances_14() {
+ runConformTest(
+ new String[] {
+ "C.java",
+ "@SuppressWarnings(\"preview\")\n" +
+ "public class C {\n" +
+ " public static void main(String argv[]) {\n" +
+ " String textBlock = \"\"\"\r\n" +
+ " This is a multi-line\n" +
+ " message that is super-\n" +
+ " exciting!\"\"\";\n" +
+ " System.out.print(compare(textBlock));\n" +
+ " }\n" +
+ " private static boolean compare(String textBlock) {\n" +
+ " String str = \"This is a multi-line\\n\" + \n" +
+ " \"message that is super-\\n\" + \n" +
+ " \"exciting!\";\n" +
+ " return textBlock.equals(str);\n" +
+ " }\n" +
+ "}"
+ },
+ "true",
+ getCompilerOptions(),
+ new String[] {"--enable-preview"});
+ }
public void testBug553252() {
Map<String, String> defaultOptions = super.getCompilerOptions();
Map<String, String> copy = new HashMap<String, String>(defaultOptions);
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 93976092de..2c13259862 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
@@ -587,7 +587,6 @@ protected final boolean scanForTextBlockBeginning() {
while (ScannerHelper.isWhitespace(c)) {
switch (c) {
case 10 : /* \ u000a: LINE FEED */
- case 13 : /* \ u000d: CARRIAGE RETURN */
this.currentCharacter = c;
this.currentPosition = temp;
return true;

Back to the top