ide на основе vs code · VibeGit
ide на основе vs code Это ide на основе vs code(code oss), в ней будет встроенный умный апи роутинг, свой маркет с плагинами(агент харнесс, поддержка java/kotlin/мобильной разработки, командная разработка проектов, orca, оркестратор агентов
krutaya-ide-na-osnove-vs-code / src / vs / editor / contrib / snippet / browser / snippetVariables.ts 394 строк · изменён 14 нояб., 04:52
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
import { normalizeDriveLetter } from '../../../../base/common/labels.js' ;
import * as path from '../../../../base/common/path.js' ;
import { dirname } from '../../../../base/common/resources.js' ;
import { commonPrefixLength, getLeadingWhitespace, isFalsyOrWhitespace, splitLines } from '../../../../base/common/strings.js' ;
import { generateUuid } from '../../../../base/common/uuid.js' ;
import { Selection } from '../../../common/core/selection.js' ;
import { ITextModel } from '../../../common/model.js' ;
ILanguageConfigurationService
Text Variable VariableResolver
OvertypingCapturer
nls
ILabelService
isSingleFolderWorkspaceIdentifier toWorkspaceIdentifier IWorkspaceContextService ISingleFolderWorkspaceIdentifier IWorkspaceIdentifier isEmptyWorkspaceIdentifier
KnownSnippetVariableNames Object
_delegates VariableResolver
variable Variable
delegate _delegates
value delegate variable
value
value
_model ITextModel
_selection Selection
_selectionIdx
_overtypingCapturer OvertypingCapturer
variable Variable
name variable
name name
value _model _selection
isMultiline _selection startLineNumber _selection endLineNumber
value _overtypingCapturer
info _overtypingCapturer _selectionIdx
info
value info value
isMultiline info multiline
value isMultiline variable snippet
line _model _selection startLineNumber
lineLeadingWhitespace line _selection startColumn
varLeadingWhitespace lineLeadingWhitespace
variable snippet marker
marker variable
marker
varLeadingWhitespace marker value
whitespaceCommonLength varLeadingWhitespace lineLeadingWhitespace
value value
m newline rest
value
name
_model _selection positionLineNumber
name
info _model
lineNumber _selection positionLineNumber
column _selection positionColumn
info info word
name
_selection positionLineNumber
name
_selection positionLineNumber
name
_selectionIdx
name
_selectionIdx
_labelService ILabelService
_model ITextModel
variable Variable
name variable
name
path _model uri fsPath
name
name path _model uri fsPath
idx name
idx
name
name idx
name
path _model uri fsPath
_labelService _model uri
name
path _model uri fsPath
path path _model uri fsPath
name
_labelService _model uri
name
_labelService _model uri relative noPrefix
_readClipboardText IReadClipboardText
_selectionIdx
_selectionCount
_spread
variable Variable
variable name
clipboardText
clipboardText
_spread
lines clipboardText s s
lines length _selectionCount
lines _selectionIdx
clipboardText
_model ITextModel
_selection Selection
_languageConfigurationService ILanguageConfigurationService
variable Variable
name variable
langId _model _selection selectionStartLineNumber _selection selectionStartColumn
config _languageConfigurationService langId comments
config
name
config lineCommentToken
name
config blockCommentStartToken
name
config blockCommentEndToken
dayNames nls nls nls nls nls nls nls
dayNamesShort nls nls nls nls nls nls nls
monthNames nls nls nls nls nls nls nls nls nls nls nls nls
monthNamesShort nls nls nls nls nls nls nls nls nls nls nls nls
_date
_timezoneName
variable Variable
name variable
name
_date
_date
_date
_date
_date
_date
_date
_date
TimeBasedVariableResolver dayNames _date
TimeBasedVariableResolver dayNamesShort _date
TimeBasedVariableResolver monthNames _date
TimeBasedVariableResolver monthNamesShort _date
Math _date
_date
rawTimeOffset _date
sign rawTimeOffset
hours Math Math rawTimeOffset
hoursString hours hours hours
minutes Math rawTimeOffset hours
minutesString minutes minutes minutes
sign hoursString minutesString
_timezoneName Intl timeZone
_workspaceService IWorkspaceContextService
variable Variable
_workspaceService
workspaceIdentifier _workspaceService
workspaceIdentifier
variable name
workspaceIdentifier
variable name
workspaceIdentifier
workspaceIdentifier IWorkspaceIdentifier ISingleFolderWorkspaceIdentifier
workspaceIdentifier
path workspaceIdentifier uri path
filename path workspaceIdentifier configPath path
filename
filename filename filename length length
filename
workspaceIdentifier IWorkspaceIdentifier ISingleFolderWorkspaceIdentifier
workspaceIdentifier
workspaceIdentifier uri fsPath
filename path workspaceIdentifier configPath path
folderpath workspaceIdentifier configPath fsPath
folderpath filename
folderpath folderpath folderpath length filename length
folderpath folderpath
variable Variable
name variable
name
Math
name
Math
name
import
{
}
from
'../../../common/languages/languageConfigurationRegistry.js'
;
import
{
,
,
}
from
'./snippetParser.js'
;
import
{
}
from
'../../suggest/browser/suggestOvertypingCapturer.js'
;
import
*
as
from
'../../../../nls.js'
;
import
{
}
from
'../../../../platform/label/common/label.js'
;
import
{
WORKSPACE_EXTENSION
,
,
,
,
,
,
}
from
'../../../../platform/workspace/common/workspace.js'
;
export
const
=
.
freeze < { [ key: string ] : true } >
(
{
'CURRENT_YEAR'
:
true
,
'CURRENT_YEAR_SHORT'
:
true
,
'CURRENT_MONTH'
:
true
,
'CURRENT_DATE'
:
true
,
'CURRENT_HOUR'
:
true
,
'CURRENT_MINUTE'
:
true
,
'CURRENT_SECOND'
:
true
,
'CURRENT_MILLISECOND'
:
true
,
'CURRENT_DAY_NAME'
:
true
,
'CURRENT_DAY_NAME_SHORT'
:
true
,
'CURRENT_MONTH_NAME'
:
true
,
'CURRENT_MONTH_NAME_SHORT'
:
true
,
'CURRENT_SECONDS_UNIX'
:
true
,
'CURRENT_MILLISECONDS_UNIX'
:
true
,
'CURRENT_TIMEZONE_OFFSET'
:
true
,
'CURRENT_TIMEZONE_NAME'
:
true
,
'SELECTION'
:
true
,
'CLIPBOARD'
:
true
,
'TM_SELECTED_TEXT'
:
true
,
'TM_CURRENT_LINE'
:
true
,
'TM_CURRENT_WORD'
:
true
,
'TM_LINE_INDEX'
:
true
,
'TM_LINE_NUMBER'
:
true
,
'TM_FILENAME'
:
true
,
'TM_FILENAME_BASE'
:
true
,
'TM_DIRECTORY'
:
true
,
'TM_DIRECTORY_BASE'
:
true
,
'TM_FILEPATH'
:
true
,
'CURSOR_INDEX'
:
true
,
'CURSOR_NUMBER'
:
true
,
'RELATIVE_FILEPATH'
:
true
,
'BLOCK_COMMENT_START'
:
true
,
'BLOCK_COMMENT_END'
:
true
,
'LINE_COMMENT'
:
true
,
'WORKSPACE_NAME'
:
true
,
'WORKSPACE_FOLDER'
:
true
,
'RANDOM'
:
true
,
'RANDOM_HEX'
:
true
,
'UUID'
:
true
}
)
;
export
class
CompositeSnippetVariableResolver
implements
VariableResolver
{
constructor
(
private
readonly
:
[
]
)
{
}
resolve
(
:
)
:
string
|
undefined
{
for
(
const
of
this
.
)
{
const
=
.
resolve
(
)
;
if
(
!==
undefined
)
{
return
;
}
}
return
undefined
;
}
}
export
class
SelectionBasedVariableResolver
implements
VariableResolver
{
constructor
(
private
readonly
:
,
private
readonly
:
,
private
readonly
:
number
,
private
readonly
:
|
undefined
)
{
}
resolve
(
:
)
:
string
|
undefined
{
const
{
}
=
;
if
(
===
'SELECTION'
||
===
'TM_SELECTED_TEXT'
)
{
let
=
this
.
.
getValueInRange
(
this
.
)
||
undefined
;
let
=
this
.
.
!==
this
.
.
;
if
(
!
&&
this
.
)
{
const
=
this
.
.
getLastOvertypedInfo
(
this
.
)
;
if
(
)
{
=
.
;
=
.
;
}
}
if
(
&&
&&
.
)
{
const
=
this
.
.
getLineContent
(
this
.
.
)
;
const
=
getLeadingWhitespace
(
,
0
,
this
.
.
-
1
)
;
let
=
;
.
.
walk
(
=>
{
if
(
===
)
{
return
false
;
}
if
(
instanceof
Text
)
{
=
getLeadingWhitespace
(
splitLines
(
.
)
.
pop
(
)
!
)
;
}
return
true
;
}
)
;
const
=
commonPrefixLength
(
,
)
;
=
.
replace
(
/ ( \r \n | \r | \n ) ( . * ) / g
,
(
,
,
)
=>
` ${ newline} ${ varLeadingWhitespace. substr ( whitespaceCommonLength) } ${ rest} `
)
;
}
return
;
}
else
if
(
===
'TM_CURRENT_LINE'
)
{
return
this
.
.
getLineContent
(
this
.
.
)
;
}
else
if
(
===
'TM_CURRENT_WORD'
)
{
const
=
this
.
.
getWordAtPosition
(
{
:
this
.
.
,
:
this
.
.
}
)
;
return
&&
.
||
undefined
;
}
else
if
(
===
'TM_LINE_INDEX'
)
{
return
String
(
this
.
.
-
1
)
;
}
else
if
(
===
'TM_LINE_NUMBER'
)
{
return
String
(
this
.
.
)
;
}
else
if
(
===
'CURSOR_INDEX'
)
{
return
String
(
this
.
)
;
}
else
if
(
===
'CURSOR_NUMBER'
)
{
return
String
(
this
.
+
1
)
;
}
return
undefined
;
}
}
export
class
ModelBasedVariableResolver
implements
VariableResolver
{
constructor
(
private
readonly
:
,
private
readonly
:
)
{
}
resolve
(
:
)
:
string
|
undefined
{
const
{
}
=
;
if
(
===
'TM_FILENAME'
)
{
return
.
basename
(
this
.
.
.
)
;
}
else
if
(
===
'TM_FILENAME_BASE'
)
{
const
=
.
basename
(
this
.
.
.
)
;
const
=
.
lastIndexOf
(
'.'
)
;
if
(
<=
0
)
{
return
;
}
else
{
return
.
slice
(
0
,
)
;
}
}
else
if
(
===
'TM_DIRECTORY'
)
{
if
(
.
dirname
(
this
.
.
.
)
===
'.'
)
{
return
''
;
}
return
this
.
.
getUriLabel
(
dirname
(
this
.
.
)
)
;
}
else
if
(
===
'TM_DIRECTORY_BASE'
)
{
if
(
.
dirname
(
this
.
.
.
)
===
'.'
)
{
return
''
;
}
return
.
basename
(
.
dirname
(
this
.
.
.
)
)
;
}
else
if
(
===
'TM_FILEPATH'
)
{
return
this
.
.
getUriLabel
(
this
.
.
)
;
}
else
if
(
===
'RELATIVE_FILEPATH'
)
{
return
this
.
.
getUriLabel
(
this
.
.
,
{
:
true
,
:
true
}
)
;
}
return
undefined
;
}
}
export
interface
IReadClipboardText
{
(
)
:
string
|
undefined
;
}
export
class
ClipboardBasedVariableResolver
implements
VariableResolver
{
constructor
(
private
readonly
:
,
private
readonly
:
number
,
private
readonly
:
number
,
private
readonly
:
boolean
)
{
}
resolve
(
:
)
:
string
|
undefined
{
if
(
.
!==
'CLIPBOARD'
)
{
return
undefined
;
}
const
=
this
.
_readClipboardText
(
)
;
if
(
!
)
{
return
undefined
;
}
if
(
this
.
)
{
const
=
.
split
(
/ \r \n | \n | \r /
)
.
filter
(
=>
!
isFalsyOrWhitespace
(
)
)
;
if
(
.
===
this
.
)
{
return
[
this
.
]
;
}
}
return
;
}
}
export
class
CommentBasedVariableResolver
implements
VariableResolver
{
constructor
(
private
readonly
:
,
private
readonly
:
,
@ ILanguageConfigurationService
private
readonly
:
)
{
}
resolve
(
:
)
:
string
|
undefined
{
const
{
}
=
;
const
=
this
.
.
getLanguageIdAtPosition
(
this
.
.
,
this
.
.
)
;
const
=
this
.
.
getLanguageConfiguration
(
)
.
;
if
(
!
)
{
return
undefined
;
}
if
(
===
'LINE_COMMENT'
)
{
return
.
||
undefined
;
}
else
if
(
===
'BLOCK_COMMENT_START'
)
{
return
.
||
undefined
;
}
else
if
(
===
'BLOCK_COMMENT_END'
)
{
return
.
||
undefined
;
}
return
undefined
;
}
}
export
class
TimeBasedVariableResolver
implements
VariableResolver
{
private
static
readonly
=
[
.
localize
(
'Sunday'
,
"Sunday"
)
,
.
localize
(
'Monday'
,
"Monday"
)
,
.
localize
(
'Tuesday'
,
"Tuesday"
)
,
.
localize
(
'Wednesday'
,
"Wednesday"
)
,
.
localize
(
'Thursday'
,
"Thursday"
)
,
.
localize
(
'Friday'
,
"Friday"
)
,
.
localize
(
'Saturday'
,
"Saturday"
)
]
;
private
static
readonly
=
[
.
localize
(
'SundayShort'
,
"Sun"
)
,
.
localize
(
'MondayShort'
,
"Mon"
)
,
.
localize
(
'TuesdayShort'
,
"Tue"
)
,
.
localize
(
'WednesdayShort'
,
"Wed"
)
,
.
localize
(
'ThursdayShort'
,
"Thu"
)
,
.
localize
(
'FridayShort'
,
"Fri"
)
,
.
localize
(
'SaturdayShort'
,
"Sat"
)
]
;
private
static
readonly
=
[
.
localize
(
'January'
,
"January"
)
,
.
localize
(
'February'
,
"February"
)
,
.
localize
(
'March'
,
"March"
)
,
.
localize
(
'April'
,
"April"
)
,
.
localize
(
'May'
,
"May"
)
,
.
localize
(
'June'
,
"June"
)
,
.
localize
(
'July'
,
"July"
)
,
.
localize
(
'August'
,
"August"
)
,
.
localize
(
'September'
,
"September"
)
,
.
localize
(
'October'
,
"October"
)
,
.
localize
(
'November'
,
"November"
)
,
.
localize
(
'December'
,
"December"
)
]
;
private
static
readonly
=
[
.
localize
(
'JanuaryShort'
,
"Jan"
)
,
.
localize
(
'FebruaryShort'
,
"Feb"
)
,
.
localize
(
'MarchShort'
,
"Mar"
)
,
.
localize
(
'AprilShort'
,
"Apr"
)
,
.
localize
(
'MayShort'
,
"May"
)
,
.
localize
(
'JuneShort'
,
"Jun"
)
,
.
localize
(
'JulyShort'
,
"Jul"
)
,
.
localize
(
'AugustShort'
,
"Aug"
)
,
.
localize
(
'SeptemberShort'
,
"Sep"
)
,
.
localize
(
'OctoberShort'
,
"Oct"
)
,
.
localize
(
'NovemberShort'
,
"Nov"
)
,
.
localize
(
'DecemberShort'
,
"Dec"
)
]
;
private
readonly
=
new
Date
(
)
;
private
:
string
|
undefined
;
resolve
(
:
)
:
string
|
undefined
{
const
{
}
=
;
switch
(
)
{
case
'CURRENT_YEAR'
:
return
String
(
this
.
.
getFullYear
(
)
)
;
case
'CURRENT_YEAR_SHORT'
:
return
String
(
this
.
.
getFullYear
(
)
)
.
slice
(
-
2
)
;
case
'CURRENT_MONTH'
:
return
String
(
this
.
.
getMonth
(
)
.
valueOf
(
)
+
1
)
.
padStart
(
2
,
'0'
)
;
case
'CURRENT_DATE'
:
return
String
(
this
.
.
getDate
(
)
.
valueOf
(
)
)
.
padStart
(
2
,
'0'
)
;
case
'CURRENT_HOUR'
:
return
String
(
this
.
.
getHours
(
)
.
valueOf
(
)
)
.
padStart
(
2
,
'0'
)
;
case
'CURRENT_MINUTE'
:
return
String
(
this
.
.
getMinutes
(
)
.
valueOf
(
)
)
.
padStart
(
2
,
'0'
)
;
case
'CURRENT_SECOND'
:
return
String
(
this
.
.
getSeconds
(
)
.
valueOf
(
)
)
.
padStart
(
2
,
'0'
)
;
case
'CURRENT_MILLISECOND'
:
return
String
(
this
.
.
getMilliseconds
(
)
.
valueOf
(
)
)
.
padStart
(
3
,
'0'
)
;
case
'CURRENT_DAY_NAME'
:
return
.
[
this
.
.
getDay
(
)
]
;
case
'CURRENT_DAY_NAME_SHORT'
:
return
.
[
this
.
.
getDay
(
)
]
;
case
'CURRENT_MONTH_NAME'
:
return
.
[
this
.
.
getMonth
(
)
]
;
case
'CURRENT_MONTH_NAME_SHORT'
:
return
.
[
this
.
.
getMonth
(
)
]
;
case
'CURRENT_SECONDS_UNIX'
:
return
String
(
.
floor
(
this
.
.
getTime
(
)
/
1000
)
)
;
case
'CURRENT_MILLISECONDS_UNIX'
:
return
String
(
this
.
.
getTime
(
)
)
;
case
'CURRENT_TIMEZONE_OFFSET'
:
{
const
=
this
.
.
getTimezoneOffset
(
)
;
const
=
>
0
?
'-'
:
'+'
;
const
=
.
trunc
(
.
abs
(
/
60
)
)
;
const
=
(
<
10
?
'0'
+
:
)
;
const
=
.
abs
(
)
-
*
60
;
const
=
(
<
10
?
'0'
+
:
)
;
return
+
+
':'
+
;
}
case
'CURRENT_TIMEZONE_NAME'
:
return
this
.
??=
.
DateTimeFormat
(
)
.
resolvedOptions
(
)
.
;
}
return
undefined
;
}
}
export
class
WorkspaceBasedVariableResolver
implements
VariableResolver
{
constructor
(
private
readonly
:
|
undefined
,
)
{
}
resolve
(
:
)
:
string
|
undefined
{
if
(
!
this
.
)
{
return
undefined
;
}
const
=
toWorkspaceIdentifier
(
this
.
.
getWorkspace
(
)
)
;
if
(
isEmptyWorkspaceIdentifier
(
)
)
{
return
undefined
;
}
if
(
.
===
'WORKSPACE_NAME'
)
{
return
this
.
_resolveWorkspaceName
(
)
;
}
else
if
(
.
===
'WORKSPACE_FOLDER'
)
{
return
this
.
_resoveWorkspacePath
(
)
;
}
return
undefined
;
}
private
_resolveWorkspaceName
(
:
|
)
:
string
|
undefined
{
if
(
isSingleFolderWorkspaceIdentifier
(
)
)
{
return
.
basename
(
.
.
)
;
}
let
=
.
basename
(
.
.
)
;
if
(
.
endsWith
(
WORKSPACE_EXTENSION
)
)
{
=
.
substr
(
0
,
.
-
WORKSPACE_EXTENSION
.
-
1
)
;
}
return
;
}
private
_resoveWorkspacePath
(
:
|
)
:
string
|
undefined
{
if
(
isSingleFolderWorkspaceIdentifier
(
)
)
{
return
normalizeDriveLetter
(
.
.
)
;
}
const
=
.
basename
(
.
.
)
;
let
=
.
.
;
if
(
.
endsWith
(
)
)
{
=
.
substr
(
0
,
.
-
.
-
1
)
;
}
return
(
?
normalizeDriveLetter
(
)
:
'/'
)
;
}
}
export
class
RandomBasedVariableResolver
implements
VariableResolver
{
resolve
(
:
)
:
string
|
undefined
{
const
{
}
=
;
if
(
===
'RANDOM'
)
{
return
.
random
(
)
.
toString
(
)
.
slice
(
-
6
)
;
}
else
if
(
===
'RANDOM_HEX'
)
{
return
.
random
(
)
.
toString
(
16
)
.
slice
(
-
6
)
;
}
else
if
(
===
'UUID'
)
{
return
generateUuid
(
)
;
}
return
undefined
;
}
}