[gtksourceview] groovy.lang: correctly highlight ${} placeholders with braces in them



commit 27de2221290d3a0565c798c9d4470488dc05f639
Author: Роман Донченко <dpb corrigendum ru>
Date:   Sun Jun 23 00:44:19 2019 +0300

    groovy.lang: correctly highlight ${} placeholders with braces in them
    
    Currently, the first closing brace encountered in such a placeholder
    is assumed to end it, even if it actually just ends a nested block.
    To correct this, treat braced blocks as nested contexts.

 data/language-specs/groovy.lang       | 13 +++++++++++++
 tests/syntax-highlighting/file.groovy |  2 +-
 2 files changed, 14 insertions(+), 1 deletion(-)
---
diff --git a/data/language-specs/groovy.lang b/data/language-specs/groovy.lang
index b491121a..82121a6c 100644
--- a/data/language-specs/groovy.lang
+++ b/data/language-specs/groovy.lang
@@ -324,6 +324,19 @@
         <context ref="operator"/>
         <context ref="null-value"/>
         <context ref="boolean"/>
+
+        <!--
+          To be able to tell apart closing braces that end a ${} placeholder
+          and ones that end a block inside such a placeholder,
+          treat braced blocks as nested contexts.
+        -->
+        <context>
+          <start>\{</start>
+          <end>\}</end>
+          <include>
+            <context ref="groovy"/>
+          </include>
+        </context>
       </include>
     </context>
   </definitions>
diff --git a/tests/syntax-highlighting/file.groovy b/tests/syntax-highlighting/file.groovy
index 82f01a05..ff8b7a88 100644
--- a/tests/syntax-highlighting/file.groovy
+++ b/tests/syntax-highlighting/file.groovy
@@ -36,7 +36,7 @@ def notSlashy = 1 /2/ 3 // not a slashy string; just two division operators
 def dollarSlashy = $/Dollar slashy string.
 
     There are three escape sequences: $$ $/ \
-    Interpolation works: $_ ${true}
+    Interpolation works: $_ ${x.collect { it + '\n' }.join('')}
     Dollars $ and backslashes \ on their own are interpreted literally./$
 
 0b10i + 0b0110_1011 // binary numbers


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]