소스 검색

Fix various syntax highlighting problems (#441)

Daelon Suzuka 2 년 전
부모
커밋
3ce256379f
2개의 변경된 파일43개의 추가작업 그리고 10개의 파일을 삭제
  1. 13 10
      syntaxes/GDScript.tmLanguage.json
  2. 30 0
      syntaxes/examples/gdscript1.gd

+ 13 - 10
syntaxes/GDScript.tmLanguage.json

@@ -117,8 +117,8 @@
                     "end": "(?:\\s*\\))",
                     "patterns": [
                         {
-                            "begin": "[\\\"\\']",
-                            "end": "[\\\"\\']",
+                            "begin": "[\"']",
+                            "end": "[\"']",
                             "name": "constant.character.escape"
                         },
                         {
@@ -177,8 +177,8 @@
             "end": "(?:\\))",
             "patterns": [
                 {
-                    "begin": "[\\\"\\']",
-                    "end": "[\\\"\\']",
+                    "begin": "[\"']",
+                    "end": "[\"']",
                     "name": "constant.character.escape",
                     "patterns": [
                         {
@@ -200,8 +200,8 @@
             "end": "(?:\\))",
             "patterns": [
                 {
-                    "begin": "[\\\"\\']",
-                    "end": "[\\\"\\']",
+                    "begin": "[\"']",
+                    "end": "[\"']",
                     "name": "constant.character.escape",
                     "patterns": [
                         {
@@ -345,8 +345,8 @@
             ]
         },
         "variable_definition": {
-            "begin": "\\b(?:(var)|(const))",
-            "end": "$",
+            "begin": "\\b(?:(var)|(const))\\s+",
+            "end": "$|;",
             "beginCaptures": {
                 "1": {
                     "name": "storage.type.var.gdscript"
@@ -504,7 +504,7 @@
         },
         "builtin_get_node_shorthand_quoted": {
             "begin": "(\\$)([\"'])",
-            "end": "([\"'])|$",
+            "end": "([\"'])",
             "name": "support.function.builtin.shorthand.gdscript",
             "beginCaptures": {
                 "1": {
@@ -525,7 +525,7 @@
                     "name": "keyword.control.flow"
                 },
                 {
-                    "match": "[^%]*",
+                    "match": "[^%^\"^']*",
                     "name": "constant.character.escape"
                 }
             ]
@@ -667,6 +667,9 @@
                             "name": "entity.name.type.class.gdscript"
                         }
                     }
+                },
+                {
+                    "include": "#base_expression"
                 }
             ]
         },

+ 30 - 0
syntaxes/examples/gdscript1.gd

@@ -10,6 +10,7 @@ var var_d : bool = true
 var var_e :    bool = true
 var var_f:bool=true
 var var_g : string = 'foo'
+var var_h : string = "foo"
 
 const const_a = 0
 const const_b = true
@@ -18,6 +19,11 @@ const const_d : bool = true
 const const_e :    bool = true
 const const_f:bool=true
 const const_g : string = 'foo'
+const const_h : string = "foo"
+
+var pls_no_a = "don't do this"; var pls_no_b = "I don't care if it's valid";
+var pls_no_c = 0; var pls_no_d = false; var pls_no_e = seriously_why();
+var pls_no_f: bool; var pls_no_g: int; var pls_no_h: string;
 
 var a
 remote var b = 10.0
@@ -34,6 +40,9 @@ signal sig_c(param1, param2)
 # 		param2: Dictionary,
 # 	)
 
+var variant_a = 0
+const variant_b = 0
+
 # ------------------------------------------------------------------------------
 
 var f = 40 setget set_f
@@ -109,6 +118,12 @@ func func_c(
 	):
 	pass
 
+# one line functions, please don't actually do this
+func one_line_int_fn() -> int: return 3
+func one_line_dict_fn() -> int: return {a=0, b=0.0, c='test'}
+func one_line_print() -> void: print("Uh oh")
+func one_line_fn() -> void: return
+
 # ------------------------------------------------------------------------------
 
 var q = "double quotes"
@@ -171,6 +186,19 @@ var node_path_a = NodePath("Child")
 var node_path_b = NodePath('Child/GrandChild')
 var node_path_c = NodePath('../Sibling')
 
+var node_method_result_a = get_node("Child").some_method()
+var node_method_result_b = get_node("Child/GrandChild").some_method()
+var node_method_result_c = get_node("%Child").some_method()
+var node_method_result_d = $Child.some_method()
+var node_method_result_e = $'Child'.some_method()
+var node_method_result_f = $'%Child'.some_method()
+var node_method_result_g = $Child/GrandChild.some_method()
+var node_method_result_h = $"Child/GrandChild".some_method()
+var node_method_result_i = $"%Child/GrandChild".some_method()
+var node_method_result_j = $Child.get_node('GrandChild').some_method()
+var node_method_result_k = $"Child".get_node('GrandChild').some_method()
+var node_method_result_l = $"%Child".get_node('GrandChild').some_method()
+
 # ------------------------------------------------------------------------------
 
 var _script = GDScript.new()
@@ -214,6 +242,8 @@ func if_test():
 	else:
 		pass
 
+	if some_bool: return
+
 # ------------------------------------------------------------------------------
 
 class InnerClass: