From 443fd371a46d8494c34531fa973602a9f8c4cc9b Mon Sep 17 00:00:00 2001 From: benkobalog Date: Tue, 8 May 2018 16:22:04 +0200 Subject: [PATCH 1/2] Fix #4454 '.' after Number literal is not highlighted --- .../dotty/tools/dotc/printing/SyntaxHighlighting.scala | 8 +++++--- .../tools/dotc/printing/SyntaxHighlightingTests.scala | 2 ++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/compiler/src/dotty/tools/dotc/printing/SyntaxHighlighting.scala b/compiler/src/dotty/tools/dotc/printing/SyntaxHighlighting.scala index 08a34a2e9fbc..ff42e6550c35 100644 --- a/compiler/src/dotty/tools/dotc/printing/SyntaxHighlighting.scala +++ b/compiler/src/dotty/tools/dotc/printing/SyntaxHighlighting.scala @@ -129,9 +129,11 @@ object SyntaxHighlighting { } else if (n.isUpper && keywordStart) appendWhile(n, !typeEnders.contains(_), typeDef) - else if (numberStart(n)) - appendWhile(n, { x => x.isDigit || x == '.' || x == '\u0000'}, literal) - else + else if (numberStart(n)) { + def isNumber(c: Char): Boolean = + c.isDigit || c == '\u0000' || (c == '.' && remaining.nonEmpty && remaining.head.isDigit) + appendWhile(n, isNumber , literal) + } else newBuf += n; prev = n } } diff --git a/compiler/test/dotty/tools/dotc/printing/SyntaxHighlightingTests.scala b/compiler/test/dotty/tools/dotc/printing/SyntaxHighlightingTests.scala index 7166d3cb0db1..cceaa48cf5b3 100644 --- a/compiler/test/dotty/tools/dotc/printing/SyntaxHighlightingTests.scala +++ b/compiler/test/dotty/tools/dotc/printing/SyntaxHighlightingTests.scala @@ -41,6 +41,8 @@ class SyntaxHighlightingTests { @Test def literals = { test("1", "") + test("1.1", "") + test("1.1.toString", ".toString") // test("1L", "") } From b4430e741e82a1a9f74d81e9b8c74852a6b01f39 Mon Sep 17 00:00:00 2001 From: "Paolo G. Giarrusso" Date: Tue, 8 May 2018 21:20:06 +0200 Subject: [PATCH 2/2] Style fix --- compiler/src/dotty/tools/dotc/printing/SyntaxHighlighting.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/src/dotty/tools/dotc/printing/SyntaxHighlighting.scala b/compiler/src/dotty/tools/dotc/printing/SyntaxHighlighting.scala index ff42e6550c35..410a6a0c8266 100644 --- a/compiler/src/dotty/tools/dotc/printing/SyntaxHighlighting.scala +++ b/compiler/src/dotty/tools/dotc/printing/SyntaxHighlighting.scala @@ -132,7 +132,7 @@ object SyntaxHighlighting { else if (numberStart(n)) { def isNumber(c: Char): Boolean = c.isDigit || c == '\u0000' || (c == '.' && remaining.nonEmpty && remaining.head.isDigit) - appendWhile(n, isNumber , literal) + appendWhile(n, isNumber, literal) } else newBuf += n; prev = n }