]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
runtime(vim): Update base-syntax, match protected constructors
authorDoug Kearns <dougkearns@gmail.com>
Sun, 23 Mar 2025 15:14:20 +0000 (16:14 +0100)
committerChristian Brabandt <cb@256bit.org>
Sun, 23 Mar 2025 15:14:20 +0000 (16:14 +0100)
Support for protected constructors was added in commit 7e89800.

closes: 16618

Signed-off-by: Doug Kearns <dougkearns@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
runtime/syntax/generator/vim.vim.base
runtime/syntax/testdir/dumps/vim9_constructor_00.dump [new file with mode: 0644]
runtime/syntax/testdir/input/vim9_constructor.vim [new file with mode: 0644]
runtime/syntax/vim.vim

index cf732443c93ad80dc9e0af3044ceba851d2b9873..4752c3fbda4db48295c671b33706ad58477eb9b2 100644 (file)
@@ -476,7 +476,7 @@ if s:vim9script
         \ skipwhite skipnl nextgroup=vim9MethodDefBody,vim9MethodDefComment,vimEnddef,vim9MethodDefReturnType,vimCommentError
         \ contains=vimDefParam,vim9Comment,vimFuncParamEquals
 
-  syn match    vim9ConstructorDefName  contained       "\<new\w*\>"
+  syn match    vim9ConstructorDefName  contained       "\<_\=new\w*\>"
         \ nextgroup=vim9ConstructorDefParams
         \ contains=@vim9MethodName
   syn match    vim9ConstructorDefParam contained       "\<\%(this\.\)\=\h\w*\>"
@@ -513,14 +513,14 @@ if s:vim9script
   if !exists("g:vimsyn_noerror") && !exists("g:vimsyn_novimfunctionerror")
     syn match  vim9MethodNameError contained   "\<[a-z0-9]\i\>"
   endif
-  syn match    vim9MethodName  contained       "\<new\w*\>"
+  syn match    vim9MethodName  contained       "\<_\=new\w*\>"
   syn keyword  vim9MethodName  contained       empty len string
 
   syn cluster  vim9MethodName  contains=vim9MethodName,vim9MethodNameError
 
   if exists("g:vimsyn_folding") && g:vimsyn_folding =~# 'f'
     syn region vim9MethodDefFold       contained       start="\%(^\s*\%(:\=static\s\+\)\=\)\@16<=:\=def\s\+\h\i*(" end="^\s*:\=enddef\>" contains=vim9MethodDef fold keepend extend transparent
-    syn region vim9MethodDefFold       contained       start="^\s*:\=def\s\+new\i*("                 end="^\s*:\=enddef\>" contains=vim9MethodDef fold keepend extend transparent
+    syn region vim9MethodDefFold       contained       start="^\s*:\=def\s\+_\=new\i*("                      end="^\s*:\=enddef\>" contains=vim9MethodDef fold keepend extend transparent
   endif
 
   syn cluster vim9MethodDef contains=vim9MethodDef,vim9MethodDefFold
diff --git a/runtime/syntax/testdir/dumps/vim9_constructor_00.dump b/runtime/syntax/testdir/dumps/vim9_constructor_00.dump
new file mode 100644 (file)
index 0000000..1b30c56
--- /dev/null
@@ -0,0 +1,20 @@
+>v+0#af5f00255#ffffff0|i|m|9|s|c|r|i|p|t| +0#0000000&@64
+@75
+|#+0#0000e05&| |V|i|m|9| |c|o|n|s|t|r|u|c|t|o|r| +0#0000000&@56
+@75
+@75
+|c+0#af5f00255&|l|a|s@1| +0#0000000&|A| @67
+@2|s+0#af5f00255&|t|a|t|i|c| +0#0000000&|v+0#af5f00255&|a|r| +0#0000000&|_|i|n|s|t|a|n|c|e|:| |A| @49
+@2|v+0#af5f00255&|a|r| +0#0000000&|s|t|r|:| |s+0#00e0003&|t|r|i|n|g| +0#0000000&@57
+@2|d+0#af5f00255&|e|f| +0#0000000&|_+0#00e0e07&|n|e|w|(+0#e000e06&|s+0#0000000&|t|r|:| |s+0#00e0003&|t|r|i|n|g|)+0#e000e06&| +0#0000000&@51
+@4|t+0#00e0e07&|h|i|s|.+0#af5f00255&|s+0#0000000&|t|r| |=+0#af5f00255&| +0#0000000&|s|t|r| @56
+@2|e+0#af5f00255&|n|d@1|e|f| +0#0000000&@66
+@2|s+0#af5f00255&|t|a|t|i|c| +0#0000000&|d+0#af5f00255&|e|f| +0#0000000&|G|e|t|I|n|s|t|a|n|c|e|(+0#e000e06&|s+0#0000000&|t|r|:| |s+0#00e0003&|t|r|i|n|g|)+0#e000e06&|:+0#0000000&| |A| @34
+@4|i+0#af5f00255&|f| +0#0000000&|_|i|n|s|t|a|n|c|e| |=+0#af5f00255&@1| +0#0000000&|n+0#e000002&|u|l@1| +0#0000000&@50
+@6|_|i|n|s|t|a|n|c|e| |=+0#af5f00255&| +0#0000000&|A|.|_+0#00e0e07&|n|e|w|(+0#e000e06&|s+0#0000000&|t|r|)+0#e000e06&| +0#0000000&@45
+@4|e+0#af5f00255&|n|d|i|f| +0#0000000&@65
+@4|r+0#af5f00255&|e|t|u|r|n| +0#0000000&|_|i|n|s|t|a|n|c|e| @54
+@2|e+0#af5f00255&|n|d@1|e|f| +0#0000000&@66
+|e+0#af5f00255&|n|d|c|l|a|s@1| +0#0000000&@66
+@75
+@57|1|,|1| @10|A|l@1| 
diff --git a/runtime/syntax/testdir/input/vim9_constructor.vim b/runtime/syntax/testdir/input/vim9_constructor.vim
new file mode 100644 (file)
index 0000000..71a2ea4
--- /dev/null
@@ -0,0 +1,19 @@
+vim9script
+
+# Vim9 constructor
+
+
+class A
+  static var _instance: A
+  var str: string
+  def _new(str: string)
+    this.str = str
+  enddef
+  static def GetInstance(str: string): A
+    if _instance == null
+      _instance = A._new(str)
+    endif
+    return _instance
+  enddef
+endclass
+
index 6a21c5f211ea572a538a9da603fcc75ee24e7b4a..5ce2a90c4b251d2bc9a7864f2f5be016e0822647 100644 (file)
@@ -526,7 +526,7 @@ if s:vim9script
         \ skipwhite skipnl nextgroup=vim9MethodDefBody,vim9MethodDefComment,vimEnddef,vim9MethodDefReturnType,vimCommentError
         \ contains=vimDefParam,vim9Comment,vimFuncParamEquals
 
-  syn match    vim9ConstructorDefName  contained       "\<new\w*\>"
+  syn match    vim9ConstructorDefName  contained       "\<_\=new\w*\>"
         \ nextgroup=vim9ConstructorDefParams
         \ contains=@vim9MethodName
   syn match    vim9ConstructorDefParam contained       "\<\%(this\.\)\=\h\w*\>"
@@ -563,14 +563,14 @@ if s:vim9script
   if !exists("g:vimsyn_noerror") && !exists("g:vimsyn_novimfunctionerror")
     syn match  vim9MethodNameError contained   "\<[a-z0-9]\i\>"
   endif
-  syn match    vim9MethodName  contained       "\<new\w*\>"
+  syn match    vim9MethodName  contained       "\<_\=new\w*\>"
   syn keyword  vim9MethodName  contained       empty len string
 
   syn cluster  vim9MethodName  contains=vim9MethodName,vim9MethodNameError
 
   if exists("g:vimsyn_folding") && g:vimsyn_folding =~# 'f'
     syn region vim9MethodDefFold       contained       start="\%(^\s*\%(:\=static\s\+\)\=\)\@16<=:\=def\s\+\h\i*(" end="^\s*:\=enddef\>" contains=vim9MethodDef fold keepend extend transparent
-    syn region vim9MethodDefFold       contained       start="^\s*:\=def\s\+new\i*("                 end="^\s*:\=enddef\>" contains=vim9MethodDef fold keepend extend transparent
+    syn region vim9MethodDefFold       contained       start="^\s*:\=def\s\+_\=new\i*("                      end="^\s*:\=enddef\>" contains=vim9MethodDef fold keepend extend transparent
   endif
 
   syn cluster vim9MethodDef contains=vim9MethodDef,vim9MethodDefFold