runtime(vim): Distinguish Vim9 constructor definitions from the :new ex command (#14050)
With the arrival of Vim9 classes, the syntax must allow for
_new_ constructors; multiple constructor definitions are
supported for a class, provided distinct suffix-names are
used. Currently, the defined constructors match either
vimCommand or vimFunctionError (for any newBar).
For example:
------------------------------------------------------------
vim9script
class Foo
def new()
enddef
def newBar()
enddef
endclass
------------------------------------------------------------
Since every constructor is required to bear a lower-cased
_new_ prefix name, it should suffice to distinguish them
from functions, and so there are no new highlight or syntax
groups introduced.
Signed-off-by: Aliaksei Budavei <0x000c70@gmail.com>
Signed-off-by: h-east <h.east.727@gmail.com>
Signed-off-by: Doug Kearns <dougkearns@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
20
runtime/syntax/testdir/dumps/vim_new_00.dump
Normal file
20
runtime/syntax/testdir/dumps/vim_new_00.dump
Normal file
@ -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| |:|n|e|w| |c|o|m@1|a|n|d| |a|n|d| |c|l|a|s@1| |c|o|n|s|t|r|u|c|t|o|r|s|.| +0#0000000&@32
|
||||
|c+0#af5f00255&|l|a|s@1| +0#0000000&|T|e|s|t| @64
|
||||
@8|d+0#af5f00255&|e|f| +0#0000000&|n|e|w|(+0#e000e06&|)| +0#0000000&@57
|
||||
@8|e+0#af5f00255&|n|d@1|e|f| +0#0000000&@60
|
||||
@8|d+0#af5f00255&|e|f| +0#0000000&|n|e|w|O|t|h|e|r|(+0#e000e06&|)| +0#0000000&@52
|
||||
@8|e+0#af5f00255&|n|d@1|e|f| +0#0000000&@60
|
||||
@8|d+0#af5f00255&|e|f| +0#0000000&|n|e|w|y|e|t|a|n|o|t|h|e|r|(+0#e000e06&|)| +0#0000000&@47
|
||||
@8|e+0#af5f00255&|n|d@1|e|f| +0#0000000&@60
|
||||
|e+0#af5f00255&|n|d|c|l|a|s@1| +0#0000000&@66
|
||||
@75
|
||||
|T|e|s|t|.+0#af5f00255&|n+0#0000000&|e|w|(+0#e000e06&|)| +0#0000000&@64
|
||||
|T|e|s|t|.+0#af5f00255&|n+0#0000000&|e|w|O|t|h|e|r|(+0#e000e06&|)| +0#0000000&@59
|
||||
|T|e|s|t|.+0#af5f00255&|n+0#0000000&|e|w|y|e|t|a|n|o|t|h|e|r|(+0#e000e06&|)| +0#0000000&@54
|
||||
|n+0#af5f00255&|e|w| +0#0000000&@71
|
||||
|q+0#af5f00255&|u|i|t| +0#0000000&@70
|
||||
|~+0#4040ff13&| @73
|
||||
|~| @73
|
||||
|"+0#0000000&|i|n|p|u|t|/|v|i|m|_|n|e|w|.|v|i|m|"| |1|7|L|,| |2|0|5|B| @27|1|,|1| @10|A|l@1|
|
||||
20
runtime/syntax/testdir/dumps/vim_new_99.dump
Normal file
20
runtime/syntax/testdir/dumps/vim_new_99.dump
Normal file
@ -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| |:|n|e|w| |c|o|m@1|a|n|d| |a|n|d| |c|l|a|s@1| |c|o|n|s|t|r|u|c|t|o|r|s|.| +0#0000000&@32
|
||||
|c+0#af5f00255&|l|a|s@1| +0#0000000&|T|e|s|t| @64
|
||||
@8|d+0#af5f00255&|e|f| +0#0000000&|n|e|w|(+0#e000e06&|)| +0#0000000&@57
|
||||
@8|e+0#af5f00255&|n|d@1|e|f| +0#0000000&@60
|
||||
@8|d+0#af5f00255&|e|f| +0#0000000&|n|e|w|O|t|h|e|r|(+0#e000e06&|)| +0#0000000&@52
|
||||
@8|e+0#af5f00255&|n|d@1|e|f| +0#0000000&@60
|
||||
@8|d+0#af5f00255&|e|f| +0#0000000&|n|e|w|y|e|t|a|n|o|t|h|e|r|(+0#e000e06&|)| +0#0000000&@47
|
||||
@8|e+0#af5f00255&|n|d@1|e|f| +0#0000000&@60
|
||||
|e+0#af5f00255&|n|d|c|l|a|s@1| +0#0000000&@66
|
||||
@75
|
||||
|T|e|s|t|.+0#af5f00255&|n+0#0000000&|e|w|(+0#e000e06&|)| +0#0000000&@64
|
||||
|T|e|s|t|.+0#af5f00255&|n+0#0000000&|e|w|O|t|h|e|r|(+0#e000e06&|)| +0#0000000&@59
|
||||
|T|e|s|t|.+0#af5f00255&|n+0#0000000&|e|w|y|e|t|a|n|o|t|h|e|r|(+0#e000e06&|)| +0#0000000&@54
|
||||
|n+0#af5f00255&|e|w| +0#0000000&@71
|
||||
>q+0#af5f00255&|u|i|t| +0#0000000&@70
|
||||
|~+0#4040ff13&| @73
|
||||
|~| @73
|
||||
|"+0#0000000&|i|n|p|u|t|/|v|i|m|_|n|e|w|.|v|i|m|"| |1|7|L|,| |2|0|5|B| @27|1|7|,|1| @9|A|l@1|
|
||||
17
runtime/syntax/testdir/input/vim_new.vim
Normal file
17
runtime/syntax/testdir/input/vim_new.vim
Normal file
@ -0,0 +1,17 @@
|
||||
vim9script
|
||||
|
||||
# Vim :new command and class constructors.
|
||||
class Test
|
||||
def new()
|
||||
enddef
|
||||
def newOther()
|
||||
enddef
|
||||
def newyetanother()
|
||||
enddef
|
||||
endclass
|
||||
|
||||
Test.new()
|
||||
Test.newOther()
|
||||
Test.newyetanother()
|
||||
new
|
||||
quit
|
||||
Reference in New Issue
Block a user