tree-sitter-delphi13 1.2.1 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +53 -9
- package/grammar.js +23 -1
- package/package.json +7 -2
- package/prebuilds/win32-x64/tree-sitter-delphi13.node +0 -0
- package/queries/folds.scm +56 -0
- package/queries/highlights.scm +328 -0
- package/queries/indents.scm +58 -0
- package/queries/injections.scm +34 -0
- package/queries/outline.scm +35 -0
- package/queries/tags.scm +183 -0
- package/src/grammar.json +72 -2
- package/src/parser.c +346693 -345532
- package/tree-sitter-delphi13.wasm +0 -0
- package/tree-sitter.json +39 -0
package/queries/tags.scm
ADDED
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
; tags.scm -- tree-sitter-delphi13
|
|
2
|
+
;
|
|
3
|
+
; Symbol extraction in the standard tree-sitter "tags" format. This is the file
|
|
4
|
+
; code-intelligence consumers read to build a symbol index: GitHub's tree-sitter
|
|
5
|
+
; tags CLI, nvim-treesitter, and the VS Code / Cursor codebase indexers.
|
|
6
|
+
;
|
|
7
|
+
; Capture convention (tree-sitter-tags):
|
|
8
|
+
; @name the identifier indexed for the symbol
|
|
9
|
+
; @definition.<kind> the node the symbol spans
|
|
10
|
+
; @reference.<kind> a use site
|
|
11
|
+
; Every @name MUST sit inside its @definition node.
|
|
12
|
+
;
|
|
13
|
+
; NODE NAMES ARE DELPHI-SHAPED
|
|
14
|
+
; This grammar uses declType / declClass / declIntf / declHelper / declProc /
|
|
15
|
+
; defProc / declProp -- NOT the class_declaration / procedure_declaration names
|
|
16
|
+
; of the generic Pascal grammars. A tags query copied from a Pascal grammar
|
|
17
|
+
; compiles here but matches nothing.
|
|
18
|
+
;
|
|
19
|
+
; GENERICS
|
|
20
|
+
; `TFoo<T: class>` parses as (genericTpl entity: (identifier) args: ...), so every
|
|
21
|
+
; declaration pattern below is written twice: once for a plain or dotted name,
|
|
22
|
+
; once unwrapping `entity:` out of a generic. Without the second form the indexed
|
|
23
|
+
; symbol would be the literal text `TFoo<T: class>` rather than `TFoo` -- which
|
|
24
|
+
; matters a great deal in Spring4D-heavy code.
|
|
25
|
+
;
|
|
26
|
+
; Qualified implementation names (`TFoo<T>.Bar`) are captured whole, matching
|
|
27
|
+
; queries/outline.scm, so the indexed symbol stays unambiguous.
|
|
28
|
+
|
|
29
|
+
;; ---------------------------------------------------------------- modules --
|
|
30
|
+
|
|
31
|
+
(unit (moduleName) @name) @definition.module
|
|
32
|
+
(program (moduleName) @name) @definition.module
|
|
33
|
+
(library (moduleName) @name) @definition.module
|
|
34
|
+
(package (moduleName) @name) @definition.module
|
|
35
|
+
|
|
36
|
+
(declUsesUnit (moduleName) @name) @reference.module
|
|
37
|
+
|
|
38
|
+
;; ------------------------------------------------------------------ types --
|
|
39
|
+
|
|
40
|
+
; type TFoo = class(TBar, IBaz) ... end; / = object ... end;
|
|
41
|
+
(declType
|
|
42
|
+
name: [(identifier) (genericDot)] @name
|
|
43
|
+
type: [(declClass (kClass)) (type (declClass (kClass)))]) @definition.class
|
|
44
|
+
(declType
|
|
45
|
+
name: (genericTpl entity: [(identifier) (genericDot)] @name)
|
|
46
|
+
type: [(declClass (kClass)) (type (declClass (kClass)))]) @definition.class
|
|
47
|
+
|
|
48
|
+
(declType
|
|
49
|
+
name: [(identifier) (genericDot)] @name
|
|
50
|
+
type: [(declClass (kObject)) (type (declClass (kObject)))]) @definition.class
|
|
51
|
+
(declType
|
|
52
|
+
name: (genericTpl entity: [(identifier) (genericDot)] @name)
|
|
53
|
+
type: [(declClass (kObject)) (type (declClass (kObject)))]) @definition.class
|
|
54
|
+
|
|
55
|
+
; type TFoo = record ... end;
|
|
56
|
+
(declType
|
|
57
|
+
name: [(identifier) (genericDot)] @name
|
|
58
|
+
type: [(declClass (kRecord)) (type (declClass (kRecord)))]) @definition.struct
|
|
59
|
+
(declType
|
|
60
|
+
name: (genericTpl entity: [(identifier) (genericDot)] @name)
|
|
61
|
+
type: [(declClass (kRecord)) (type (declClass (kRecord)))]) @definition.struct
|
|
62
|
+
|
|
63
|
+
; type IFoo = interface / dispinterface ... end;
|
|
64
|
+
(declType
|
|
65
|
+
name: [(identifier) (genericDot)] @name
|
|
66
|
+
type: (declIntf)) @definition.interface
|
|
67
|
+
(declType
|
|
68
|
+
name: (genericTpl entity: [(identifier) (genericDot)] @name)
|
|
69
|
+
type: (declIntf)) @definition.interface
|
|
70
|
+
|
|
71
|
+
; type TFooHelper = class helper for TFoo ... end;
|
|
72
|
+
(declType
|
|
73
|
+
name: [(identifier) (genericDot)] @name
|
|
74
|
+
type: (declHelper)) @definition.class
|
|
75
|
+
(declType
|
|
76
|
+
name: (genericTpl entity: [(identifier) (genericDot)] @name)
|
|
77
|
+
type: (declHelper)) @definition.class
|
|
78
|
+
|
|
79
|
+
; type TColor = (clRed, clGreen);
|
|
80
|
+
(declType
|
|
81
|
+
name: [(identifier) (genericDot)] @name
|
|
82
|
+
type: (type (declEnum))) @definition.enum
|
|
83
|
+
|
|
84
|
+
(declEnumValue name: (identifier) @name) @definition.constant
|
|
85
|
+
|
|
86
|
+
; aliases, sets, arrays, strings, files, procedural types, metaclasses, subranges
|
|
87
|
+
(declType
|
|
88
|
+
name: [(identifier) (genericDot)] @name
|
|
89
|
+
type: [
|
|
90
|
+
(identifier)
|
|
91
|
+
(subrangeType)
|
|
92
|
+
(type (typeref))
|
|
93
|
+
(type (declSet))
|
|
94
|
+
(type (declArray))
|
|
95
|
+
(type (declString))
|
|
96
|
+
(type (declFile))
|
|
97
|
+
(type (declProcRef))
|
|
98
|
+
(type (declMetaClass))
|
|
99
|
+
]) @definition.type
|
|
100
|
+
(declType
|
|
101
|
+
name: (genericTpl entity: [(identifier) (genericDot)] @name)
|
|
102
|
+
type: [
|
|
103
|
+
(identifier)
|
|
104
|
+
(subrangeType)
|
|
105
|
+
(type (typeref))
|
|
106
|
+
(type (declSet))
|
|
107
|
+
(type (declArray))
|
|
108
|
+
(type (declString))
|
|
109
|
+
(type (declFile))
|
|
110
|
+
(type (declProcRef))
|
|
111
|
+
(type (declMetaClass))
|
|
112
|
+
]) @definition.type
|
|
113
|
+
|
|
114
|
+
;; ---------------------------------------------------------------- methods --
|
|
115
|
+
;
|
|
116
|
+
; Routines declared inside a class / record / interface / helper body, either
|
|
117
|
+
; directly or under a visibility section (private / protected / public /
|
|
118
|
+
; published / strict private ...).
|
|
119
|
+
|
|
120
|
+
(declClass (declProc name: (identifier) @name) @definition.method)
|
|
121
|
+
(declClass (declProc name: (genericTpl entity: (identifier) @name)) @definition.method)
|
|
122
|
+
(declClass (declSection (declProc name: (identifier) @name) @definition.method))
|
|
123
|
+
(declClass (declSection (declProc name: (genericTpl entity: (identifier) @name)) @definition.method))
|
|
124
|
+
|
|
125
|
+
(declIntf (declProc name: (identifier) @name) @definition.method)
|
|
126
|
+
(declIntf (declProc name: (genericTpl entity: (identifier) @name)) @definition.method)
|
|
127
|
+
(declIntf (declSection (declProc name: (identifier) @name) @definition.method))
|
|
128
|
+
(declIntf (declSection (declProc name: (genericTpl entity: (identifier) @name)) @definition.method))
|
|
129
|
+
|
|
130
|
+
(declHelper (declProc name: (identifier) @name) @definition.method)
|
|
131
|
+
(declHelper (declProc name: (genericTpl entity: (identifier) @name)) @definition.method)
|
|
132
|
+
(declHelper (declSection (declProc name: (identifier) @name) @definition.method))
|
|
133
|
+
(declHelper (declSection (declProc name: (genericTpl entity: (identifier) @name)) @definition.method))
|
|
134
|
+
|
|
135
|
+
; property Name: string read GetName write SetName;
|
|
136
|
+
(declProp name: (identifier) @name) @definition.property
|
|
137
|
+
|
|
138
|
+
; FName: string; (only ever occurs in a class-like body)
|
|
139
|
+
(declField name: (identifier) @name) @definition.field
|
|
140
|
+
|
|
141
|
+
;; -------------------------------------------------------------- functions --
|
|
142
|
+
;
|
|
143
|
+
; Free routines: declared in the interface section, forward-declared in the
|
|
144
|
+
; implementation section, or written straight into a program / library /
|
|
145
|
+
; package / bare include fragment.
|
|
146
|
+
|
|
147
|
+
(interface (declProc name: (identifier) @name) @definition.function)
|
|
148
|
+
(implementation (declProc name: (identifier) @name) @definition.function)
|
|
149
|
+
(program (declProc name: (identifier) @name) @definition.function)
|
|
150
|
+
(library (declProc name: (identifier) @name) @definition.function)
|
|
151
|
+
(package (declProc name: (identifier) @name) @definition.function)
|
|
152
|
+
(root (declProc name: (identifier) @name) @definition.function)
|
|
153
|
+
|
|
154
|
+
(interface (declProc name: (genericTpl entity: (identifier) @name)) @definition.function)
|
|
155
|
+
(implementation (declProc name: (genericTpl entity: (identifier) @name)) @definition.function)
|
|
156
|
+
(program (declProc name: (genericTpl entity: (identifier) @name)) @definition.function)
|
|
157
|
+
(library (declProc name: (genericTpl entity: (identifier) @name)) @definition.function)
|
|
158
|
+
(package (declProc name: (genericTpl entity: (identifier) @name)) @definition.function)
|
|
159
|
+
(root (declProc name: (genericTpl entity: (identifier) @name)) @definition.function)
|
|
160
|
+
|
|
161
|
+
; Implemented bodies.
|
|
162
|
+
; procedure TFoo.Bar; begin ... end; -> a method implementation
|
|
163
|
+
; function Helper(...); begin ... end; -> a free routine implementation
|
|
164
|
+
(defProc header: (declProc name: (genericDot) @name)) @definition.method
|
|
165
|
+
(defProc header: (declProc name: (identifier) @name)) @definition.function
|
|
166
|
+
(defProc header: (declProc name: (genericTpl entity: (identifier) @name))) @definition.function
|
|
167
|
+
|
|
168
|
+
;; ------------------------------------------------------ constants and vars --
|
|
169
|
+
|
|
170
|
+
(declConst name: (identifier) @name) @definition.constant
|
|
171
|
+
(declVar name: (identifier) @name) @definition.variable
|
|
172
|
+
|
|
173
|
+
;; ------------------------------------------------------------- references --
|
|
174
|
+
|
|
175
|
+
; Foo(...), Unit.Foo(...) / Obj.Foo(...), Foo<T>(...)
|
|
176
|
+
(exprCall entity: (identifier) @name) @reference.call
|
|
177
|
+
(exprCall entity: (exprDot rhs: (identifier) @name)) @reference.call
|
|
178
|
+
(exprCall entity: (exprTpl entity: (identifier) @name)) @reference.call
|
|
179
|
+
|
|
180
|
+
; Ancestor class and implemented interfaces.
|
|
181
|
+
(declClass parent: (typeref (identifier) @name) @reference.implementation)
|
|
182
|
+
(declIntf parent: (typeref (identifier) @name) @reference.implementation)
|
|
183
|
+
(declHelper parent: (typeref (identifier) @name) @reference.implementation)
|
package/src/grammar.json
CHANGED
|
@@ -3671,8 +3671,22 @@
|
|
|
3671
3671
|
"type": "CHOICE",
|
|
3672
3672
|
"members": [
|
|
3673
3673
|
{
|
|
3674
|
-
"type": "
|
|
3675
|
-
"
|
|
3674
|
+
"type": "CHOICE",
|
|
3675
|
+
"members": [
|
|
3676
|
+
{
|
|
3677
|
+
"type": "SYMBOL",
|
|
3678
|
+
"name": "identifier"
|
|
3679
|
+
},
|
|
3680
|
+
{
|
|
3681
|
+
"type": "ALIAS",
|
|
3682
|
+
"content": {
|
|
3683
|
+
"type": "SYMBOL",
|
|
3684
|
+
"name": "kAtWord"
|
|
3685
|
+
},
|
|
3686
|
+
"named": true,
|
|
3687
|
+
"value": "identifier"
|
|
3688
|
+
}
|
|
3689
|
+
]
|
|
3676
3690
|
},
|
|
3677
3691
|
{
|
|
3678
3692
|
"type": "BLANK"
|
|
@@ -7195,6 +7209,44 @@
|
|
|
7195
7209
|
}
|
|
7196
7210
|
]
|
|
7197
7211
|
},
|
|
7212
|
+
{
|
|
7213
|
+
"type": "SEQ",
|
|
7214
|
+
"members": [
|
|
7215
|
+
{
|
|
7216
|
+
"type": "SYMBOL",
|
|
7217
|
+
"name": "identifier"
|
|
7218
|
+
},
|
|
7219
|
+
{
|
|
7220
|
+
"type": "STRING",
|
|
7221
|
+
"value": "("
|
|
7222
|
+
},
|
|
7223
|
+
{
|
|
7224
|
+
"type": "SEQ",
|
|
7225
|
+
"members": [
|
|
7226
|
+
{
|
|
7227
|
+
"type": "SYMBOL",
|
|
7228
|
+
"name": "identifier"
|
|
7229
|
+
},
|
|
7230
|
+
{
|
|
7231
|
+
"type": "STRING",
|
|
7232
|
+
"value": "("
|
|
7233
|
+
},
|
|
7234
|
+
{
|
|
7235
|
+
"type": "SYMBOL",
|
|
7236
|
+
"name": "identifier"
|
|
7237
|
+
},
|
|
7238
|
+
{
|
|
7239
|
+
"type": "STRING",
|
|
7240
|
+
"value": ")"
|
|
7241
|
+
}
|
|
7242
|
+
]
|
|
7243
|
+
},
|
|
7244
|
+
{
|
|
7245
|
+
"type": "STRING",
|
|
7246
|
+
"value": ")"
|
|
7247
|
+
}
|
|
7248
|
+
]
|
|
7249
|
+
},
|
|
7198
7250
|
{
|
|
7199
7251
|
"type": "SEQ",
|
|
7200
7252
|
"members": [
|
|
@@ -9658,6 +9710,15 @@
|
|
|
9658
9710
|
},
|
|
9659
9711
|
"named": true,
|
|
9660
9712
|
"value": "identifier"
|
|
9713
|
+
},
|
|
9714
|
+
{
|
|
9715
|
+
"type": "ALIAS",
|
|
9716
|
+
"content": {
|
|
9717
|
+
"type": "SYMBOL",
|
|
9718
|
+
"name": "kOperator"
|
|
9719
|
+
},
|
|
9720
|
+
"named": true,
|
|
9721
|
+
"value": "identifier"
|
|
9661
9722
|
}
|
|
9662
9723
|
]
|
|
9663
9724
|
},
|
|
@@ -9689,6 +9750,15 @@
|
|
|
9689
9750
|
},
|
|
9690
9751
|
"named": true,
|
|
9691
9752
|
"value": "identifier"
|
|
9753
|
+
},
|
|
9754
|
+
{
|
|
9755
|
+
"type": "ALIAS",
|
|
9756
|
+
"content": {
|
|
9757
|
+
"type": "SYMBOL",
|
|
9758
|
+
"name": "kOperator"
|
|
9759
|
+
},
|
|
9760
|
+
"named": true,
|
|
9761
|
+
"value": "identifier"
|
|
9692
9762
|
}
|
|
9693
9763
|
]
|
|
9694
9764
|
}
|