File: vim9_super_this_keywords.vim

package info (click to toggle)
vim 2%3A9.1.1230-2
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 88,180 kB
  • sloc: ansic: 416,989; cpp: 6,324; makefile: 4,448; java: 2,226; sh: 1,861; perl: 1,419; python: 960; awk: 730; lisp: 501; cs: 458; objc: 369; xml: 247; sed: 8; csh: 6
file content (87 lines) | stat: -rw-r--r-- 1,511 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
vim9script

# Vim9 this and super keywords
# VIM_TEST_SETUP hi link vim9This Todo
# VIM_TEST_SETUP hi link vim9Super Todo

def Echo(...args: list<any>)
  echo args
enddef

class Foo
  var x: number = 42
  var y: number = this.x + 41
  var z: number = this.x + this.y

  def new()
    echo this.x this.y this.z
  enddef

  def newXY(this.x, this.y, this.z)
  enddef

  def Def1(arg = this.x)
    this.y = arg
    this.z += arg
  enddef

  def Def2(arg = (this.x + this.y + this.z))
    Echo(this, this.x, this.y, this.z)
    this->Echo(this.x, this.y, this.z)
  enddef

  def Def3(): Foo
    return this
  enddef

  def Def4(arg: Foo = this): Foo
    return arg
  enddef
endclass

class Bar extends Foo
  def Def1()
    super.Def1()
  enddef

  def Def2()
    var a = super.x * super.y * super.z
    var b = [super.x, super.y, super.z]
    var c = {super: super.x, this: super.y, true: super.z}
    var d = {super: c, this: c}
    echo c.super
    echo c.this
    echo d.super.this
    echo d.this.super
    echo a b c
  enddef

  def Def5()
    var a = this.x * this.y
    var b = (this.x * this.y)
    var c = [this.x, this.y]
    var d = {super: this.x, this: this.y}
    echo a b c d
  enddef

  def Def6()
    var x = this#super#x
    var y = super#this#y
    this#super#Func()
    super#this#Func()
  enddef

  def Def7(arg = super.Def3())
    echo arg
  enddef

  def Def8(): number
    var F = () => this.x
    var G = () => super.x
    return F() + G()
  enddef
endclass

defcompile Foo
defcompile Bar