ide на основе vs code · VibeGit
ide на основе vs code Это ide на основе vs code(code oss), в ней будет встроенный умный апи роутинг, свой маркет с плагинами(агент харнесс, поддержка java/kotlin/мобильной разработки, командная разработка проектов, orca, оркестратор агентов
krutaya-ide-na-osnove-vs-code / extensions / aura-kotlin / test / java.lsp.smoke.mjs 432 строк · изменён 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
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
import { createRequire } from 'node:module' ;
import * as fs from 'node:fs' ;
import * as os from 'node:os' ;
import * as path from 'node:path' ;
const require = createRequire ( import . meta
process path os
process path os
fs path os
fs path fs path
process
fs path
process
results
check name ok detail
results name ok
resolve ms
line character
a b c d
fsPath fsPath
value
text value
match text
match match text
beforeQuery rest match
uri beforeQuery
uri match
uri beforeQuery
uri rest
uri
path base base parts
value value
value
value
value language
contents
uri range
range message severity
label kind
items isIncomplete
value
label documentation
label documentation
name detail kind range selectionRange
title kind
uri range newText
listener listener
listener value
names name index
channels
collectionDiagnostics
commands
notifications
contentProviders
vscodeStub
id
items item dispose
text args index
path
notifications
section fallback
key
key process path process
key process fallback
fallback
contentProviders scheme provider
channel name channel text channel text
channels channel
channel
notifications
notifications
notifications
commands id
name
collectionDiagnostics uri diagnostics
collectionDiagnostics uri
collectionDiagnostics uri
collectionDiagnostics
originalLoad
request vscodeStub
originalLoad request parent isMain
sdkRoot
registerJavaLsp
planSources installedPlatformSources
parseJdtUri jdtSourceDocument
context
path process
path process
path process value
fs file
file
file
file
file
file
lines file offset
lines lines lines
t0
t0
sync
sync
classpath sync
androidJar classpath jar
aar classpath jar
classpath
androidJar
aar
client context sync
commands commands commands
commands commands
sdk
platformBefore sdk
plan classpath sdk
platformBefore plan
plan plan
client
sourcesLog channels channel line
downloadedLog sourcesLog line
downloadedLog
started client
started client
started
channel channels line channel
process
shadowLog channels channel line
shadowLog shadowLog
projectDir client
classpathFile projectDir path projectDir
classpathText classpathFile fs classpathFile fs classpathFile
attachments classpathText match
fs path root relative
androidAttachment attachments value path
jarAttachment attachments value
androidAttachment androidAttachment
jarAttachment
path
path
fs fs
process
activity
probe
deadline timeoutMs
deadline
client activity
client probe
collectionDiagnostics
diagnostics collectionDiagnostics
errors diagnostics diagnostic vscodeStub
diagnostic diagnostics
unresolvedAndroid errors diagnostic
unresolvedAndroid unresolvedAndroid d
missingImport errors diagnostic
missingImport missingImport message
completion client probe
items completion items
items item
items
prefixed client probe
prefixedLabels prefixed items item
prefixedLabels label prefixedLabels
importItems client activity
importCandidate importItems items item
importCandidate importCandidate label
importCandidate
resolved client importCandidate
attempt attempt resolved attempt
resolved client importCandidate
importEdits resolved arguments
methodItem prefixed items item
resolvedMethod methodItem client methodItem
methodText resolvedMethod insertText value resolvedMethod insertText
methodText methodText
importText resolved value resolved
importText importText
resolved command importEdits textEdit
importEdits textEdit
missingImport
actions client activity missingImport missingImport missingImport missingImport
importAction actions action
importAction importAction importAction
importAction
importAction edit
inserted importAction r
inserted inserted
organize client activity activity
organize action organize a
hover client probe
value line
hover hover value hover contents value
hover
definition client probe
definition definition definition
memberHover client probe
memberText memberHover contents value
memberText memberText
value value value value
provider contentProviders
provider provideTextDocumentContent contentProviders
client activity position
uri
target uri
content target provider provider uri
line content content
typeName expected
target sourceRelative expected target sourceRelative
content content content
line anchor line
orphanUri
orphan orphanUri
orphan orphan
parsed orphanUri parsed sourceRelative parsed orphanUri
symbols client probe
symbols length symbols s
client
fs
failed results result
process failed
.
url
)
;
const
PROJECT
=
.
argv
[
2
]
??
.
join
(
.
tmpdir
(
)
,
'aura-e2e'
,
'AuraTestApp'
)
;
const
JDTLS_DIR
=
.
env
.
JDTLS_DIR
??
.
join
(
.
tmpdir
(
)
,
'jdtls'
)
;
const
STORAGE
=
.
mkdtempSync
(
.
join
(
.
tmpdir
(
)
,
'aura-java-storage-'
)
)
;
if
(
!
.
existsSync
(
.
join
(
PROJECT
,
'settings.gradle'
)
)
&&
!
.
existsSync
(
.
join
(
PROJECT
,
'settings.gradle.kts'
)
)
)
{
console
.
log
(
` SKIP: нет gradle-проекта по пути ${ PROJECT } `
)
;
.
exit
(
0
)
;
}
if
(
!
.
existsSync
(
.
join
(
JDTLS_DIR
,
'plugins'
)
)
)
{
console
.
log
(
` SKIP: jdtls не найден в ${ JDTLS_DIR } (JDTLS_DIR=… чтобы указать свой) `
)
;
.
exit
(
0
)
;
}
const
=
[
]
;
const
=
(
,
,
=
''
)
=>
{
.
push
(
{
,
}
)
;
console
.
log
(
` ${ ok ? 'PASS' : 'FAIL' } ${ name} ${ detail ? ` — ${ detail} ` : '' } `
)
;
}
;
const
sleep
=
ms
=>
new
Promise
(
resolve
=>
setTimeout
(
,
)
)
;
class
Position
{
constructor
(
line, character
)
{
this
.
line
=
;
this
.
character
=
;
}
}
class
Range
{
constructor
(
a, b, c, d
)
{
this
.
start
=
new
Position
(
,
)
;
this
.
end
=
new
Position
(
,
)
;
}
}
class
Uri
{
constructor
(
fsPath
)
{
this
.
fsPath
=
;
this
.
scheme
=
'file'
;
this
.
path
=
String
(
)
.
replace
(
/ \\ / g
,
'/'
)
;
}
toString
(
)
{
return
` file:/// ${ String ( this . path ) . replace ( / \\ / g , '/' ) . replace ( / ^ \/ + / , '' ) } `
;
}
static
file
(
value
)
{
return
new
Uri
(
)
;
}
static
parse
(
value
)
{
const
=
String
(
)
;
const
=
/ ^ ( [ a- z A- Z ] [ a- z A- Z 0- 9 +.-] * ) :(?: \/ \/ ) ? ( . * ) $ /
.
exec
(
)
;
if
(
!
||
[
1
]
===
'file'
)
{
return
new
Uri
(
decodeURIComponent
(
.
replace
(
/ ^ file:\/ \/ \/ ? /
,
''
)
)
)
;
}
const
[
,
...
]
=
[
2
]
.
split
(
'?'
)
;
const
=
new
Uri
(
)
;
.
scheme
=
[
1
]
;
.
path
=
;
.
query
=
.
join
(
'?'
)
;
return
;
}
static
joinPath
(
base, ... parts
)
{
return
new
Uri
(
.
join
(
.
fsPath
??
,
...
)
)
;
}
}
class
MarkdownString
{
constructor
(
=
''
)
{
this
.
value
=
;
}
appendText
(
value
)
{
this
.
value
+=
;
return
this
;
}
appendMarkdown
(
value
)
{
this
.
value
+=
;
return
this
;
}
appendCodeblock
(
,
=
''
)
{
this
.
value
+=
`
\`\`\` ${ language}
${ value}
\`\`\`
`
;
return
this
;
}
}
class
Hover
{
constructor
(
contents
)
{
this
.
contents
=
;
}
}
class
Location
{
constructor
(
uri, range
)
{
this
.
uri
=
;
this
.
range
=
;
}
}
class
Diagnostic
{
constructor
(
range, message, severity
)
{
this
.
range
=
;
this
.
message
=
;
this
.
severity
=
;
}
}
class
CompletionItem
{
constructor
(
label, kind
)
{
this
.
label
=
;
this
.
kind
=
;
}
}
class
CompletionList
{
constructor
(
items, isIncomplete
)
{
this
.
items
=
;
this
.
isIncomplete
=
;
}
}
class
SnippetString
{
constructor
(
value
)
{
this
.
value
=
;
}
}
class
SignatureHelp
{
constructor
(
)
{
this
.
signatures
=
[
]
;
this
.
activeSignature
=
0
;
this
.
activeParameter
=
0
;
}
}
class
SignatureInformation
{
constructor
(
label, documentation
)
{
this
.
label
=
;
this
.
documentation
=
;
this
.
parameters
=
[
]
;
}
}
class
ParameterInformation
{
constructor
(
label, documentation
)
{
this
.
label
=
;
this
.
documentation
=
;
}
}
class
DocumentSymbol
{
constructor
(
name, detail, kind, range, selectionRange
)
{
this
.
name
=
;
this
.
detail
=
;
this
.
kind
=
;
this
.
range
=
;
this
.
selectionRange
=
;
this
.
children
=
[
]
;
}
}
class
CodeAction
{
constructor
(
title, kind
)
{
this
.
title
=
;
this
.
kind
=
;
}
}
class
WorkspaceEdit
{
constructor
(
)
{
this
.
replacements
=
[
]
;
}
replace
(
uri, range, newText
)
{
this
.
replacements
.
push
(
{
,
,
}
)
;
}
}
class
EventEmitter
{
constructor
(
)
{
this
.
listeners
=
new
Set
(
)
;
this
.
event
=
listener
=>
{
this
.
listeners
.
add
(
)
;
return
{
dispose
:
(
)
=>
this
.
listeners
.
delete
(
)
}
;
}
;
}
fire
(
value
)
{
for
(
const
of
this
.
listeners
)
{
listener
(
)
;
}
}
dispose
(
)
{
this
.
listeners
.
clear
(
)
;
}
}
const
enumOf
=
names
=>
Object
.
fromEntries
(
.
map
(
(
name, index
)
=>
[
,
+
1
]
)
)
;
const
=
[
]
;
const
=
new
Map
(
)
;
const
=
[
]
;
const
=
[
]
;
const
=
new
Map
(
)
;
const
=
{
Position
,
Range
,
Uri
,
MarkdownString
,
Hover
,
Location
,
Diagnostic
,
CompletionItem
,
CompletionList
,
SignatureHelp
,
SignatureInformation
,
ParameterInformation
,
DocumentSymbol
,
CodeAction
,
WorkspaceEdit
,
EventEmitter
,
SnippetString
,
ThemeIcon
:
class
{
constructor
(
id
)
{
this
.
id
=
;
}
}
,
DiagnosticSeverity
:
enumOf
(
[
'Error'
,
'Warning'
,
'Information'
,
'Hint'
]
)
,
CompletionItemKind
:
enumOf
(
[
'Text'
,
'Method'
,
'Function'
,
'Constructor'
,
'Field'
,
'Variable'
,
'Class'
,
'Interface'
,
'Module'
,
'Property'
,
'Unit'
,
'Value'
,
'Enum'
,
'Keyword'
,
'Snippet'
,
'Color'
,
'File'
,
'Reference'
,
'Folder'
,
'EnumMember'
,
'Constant'
,
'Struct'
,
'Event'
,
'Operator'
,
'TypeParameter'
]
)
,
SymbolKind
:
enumOf
(
[
'File'
,
'Module'
,
'Namespace'
,
'Package'
,
'Class'
,
'Method'
,
'Property'
,
'Field'
,
'Constructor'
,
'Enum'
,
'Interface'
,
'Variable'
,
'Constant'
,
'String'
,
'Number'
,
'Boolean'
,
'Array'
,
'Object'
,
'Key'
,
'Null'
,
'EnumMember'
,
'Struct'
,
'Event'
,
'Operator'
,
'TypeParameter'
]
)
,
StatusBarAlignment
:
{
Left
:
1
,
Right
:
2
}
,
ProgressLocation
:
{
SourceControl
:
1
,
Window
:
10
,
Notification
:
15
}
,
ViewColumn
:
{
Active
:
-
1
,
One
:
1
}
,
CodeActionKind
:
{
QuickFix
:
{
value
:
'quickfix'
}
,
Source
:
{
value
:
'source'
}
,
SourceOrganizeImports
:
{
value
:
'source.organizeImports'
}
}
,
Disposable
:
{
from
:
(
... items
)
=>
(
{
dispose
:
(
)
=>
.
forEach
(
item
=>
?.
?.
(
)
)
}
)
}
,
l10n
:
{
t
:
(
text, ... args
)
=>
String
(
)
.
replace
(
/ \{ ( \d + ) \} / g
,
(
_, index
)
=>
String
(
[
Number
(
)
]
??
''
)
)
}
,
workspace
:
{
workspaceFolders
:
[
{
uri
:
new
Uri
(
PROJECT
)
,
name
:
.
basename
(
PROJECT
)
,
index
:
0
}
]
,
textDocuments
:
[
]
,
applyEdit
:
async
(
edit
)
=>
{
.
push
(
` applyEdit: ${ edit?. replacements?. length ?? 0 } правок `
)
;
return
true
;
}
,
getConfiguration
:
(
section
)
=>
(
{
get
:
(
key, fallback
)
=>
{
if
(
!==
'auraKotlin'
)
{
return
;
}
if
(
===
'javaLspPath'
)
{
return
JDTLS_DIR
;
}
if
(
===
'javaPath'
)
{
return
.
env
.
JAVA_HOME
?
.
join
(
.
env
.
JAVA_HOME
,
'bin'
,
'java'
)
:
'java'
;
}
if
(
===
'androidSdkPath'
)
{
return
.
env
.
ANDROID_HOME
??
;
}
return
;
}
,
update
:
async
(
)
=>
undefined
,
}
)
,
createFileSystemWatcher
:
(
)
=>
(
{
dispose
(
)
{
}
,
onDidChange
:
(
)
=>
(
{
dispose
(
)
{
}
}
)
,
onDidCreate
:
(
)
=>
(
{
dispose
(
)
{
}
}
)
,
onDidDelete
:
(
)
=>
(
{
dispose
(
)
{
}
}
)
}
)
,
registerTextDocumentContentProvider
:
(
scheme, provider
)
=>
{
.
set
(
,
)
;
return
{
dispose
(
)
{
}
}
;
}
,
onDidOpenTextDocument
:
(
)
=>
(
{
dispose
(
)
{
}
}
)
,
onDidChangeTextDocument
:
(
)
=>
(
{
dispose
(
)
{
}
}
)
,
onDidSaveTextDocument
:
(
)
=>
(
{
dispose
(
)
{
}
}
)
,
onDidCloseTextDocument
:
(
)
=>
(
{
dispose
(
)
{
}
}
)
,
}
,
window
:
{
createOutputChannel
:
(
name
)
=>
{
const
=
{
,
lines
:
[
]
,
appendLine
:
(
text
)
=>
.
lines
.
push
(
String
(
)
)
,
append
:
(
text
)
=>
.
lines
.
push
(
String
(
)
)
,
show
(
)
{
}
,
dispose
(
)
{
}
}
;
.
push
(
)
;
return
;
}
,
createStatusBarItem
:
(
)
=>
(
{
show
(
)
{
}
,
hide
(
)
{
}
,
dispose
(
)
{
}
}
)
,
showInformationMessage
:
async
(
... args
)
=>
{
.
push
(
` info: ${ args[ 0 ] } `
)
;
return
undefined
;
}
,
showWarningMessage
:
async
(
... args
)
=>
{
.
push
(
` warn: ${ args[ 0 ] } `
)
;
return
undefined
;
}
,
showErrorMessage
:
async
(
... args
)
=>
{
.
push
(
` error: ${ args[ 0 ] } `
)
;
return
undefined
;
}
,
withProgress
:
async
(
_options, task
)
=>
task
(
{
report
(
)
{
}
}
,
{
isCancellationRequested
:
false
,
onCancellationRequested
:
(
)
=>
(
{
dispose
(
)
{
}
}
)
}
,
)
,
}
,
commands
:
{
registerCommand
:
(
id
)
=>
{
.
push
(
)
;
return
{
dispose
(
)
{
}
}
;
}
,
executeCommand
:
async
(
)
=>
undefined
,
}
,
languages
:
{
createDiagnosticCollection
:
(
name
)
=>
(
{
,
set
:
(
uri, diagnostics
)
=>
.
set
(
.
toString
(
)
,
)
,
get
:
(
uri
)
=>
.
get
(
.
toString
(
)
)
,
delete
:
(
uri
)
=>
.
delete
(
.
toString
(
)
)
,
clear
:
(
)
=>
.
clear
(
)
,
dispose
(
)
{
}
,
}
)
,
registerHoverProvider
:
(
)
=>
(
{
dispose
(
)
{
}
}
)
,
registerDefinitionProvider
:
(
)
=>
(
{
dispose
(
)
{
}
}
)
,
registerCompletionItemProvider
:
(
)
=>
(
{
dispose
(
)
{
}
}
)
,
registerSignatureHelpProvider
:
(
)
=>
(
{
dispose
(
)
{
}
}
)
,
registerDocumentSymbolProvider
:
(
)
=>
(
{
dispose
(
)
{
}
}
)
,
registerReferenceProvider
:
(
)
=>
(
{
dispose
(
)
{
}
}
)
,
registerRenameProvider
:
(
)
=>
(
{
dispose
(
)
{
}
}
)
,
registerCodeActionsProvider
:
(
)
=>
(
{
dispose
(
)
{
}
}
)
,
}
,
}
;
const
Module
=
require
(
'node:module'
)
;
const
=
Module
.
_load
;
Module
.
_load
=
function
(
request, parent, isMain
)
{
if
(
===
'vscode'
)
{
return
;
}
return
.
call
(
this
,
,
,
)
;
}
;
const
{
ClasspathSync
,
}
=
require
(
'../out/classpath.js'
)
;
const
{
,
JAVA_LSP_INFO
}
=
require
(
'../out/javaLsp.js'
)
;
const
{
,
}
=
require
(
'../out/javaSources.js'
)
;
const
{
,
}
=
require
(
'../out/javaUris.js'
)
;
const
=
{
extensionPath
:
.
join
(
.
cwd
(
)
,
'..'
)
,
extensionUri
:
Uri
.
file
(
.
join
(
.
cwd
(
)
,
'..'
)
)
,
globalStorageUri
:
Uri
.
file
(
STORAGE
)
,
subscriptions
:
[
]
,
globalState
:
{
get
:
(
)
=>
undefined
,
update
:
async
(
)
=>
undefined
}
,
workspaceState
:
{
get
:
(
)
=>
undefined
,
update
:
async
(
)
=>
undefined
}
,
asAbsolutePath
:
(
value
)
=>
.
join
(
.
cwd
(
)
,
'..'
,
)
,
}
;
const
source
=
(
file
)
=>
.
readFileSync
(
,
'utf8'
)
;
const
fileUri
=
(
file
)
=>
Uri
.
file
(
)
.
toString
(
)
;
const
document
=
(
file
)
=>
(
{
uri
:
Uri
.
file
(
)
,
fileName
:
,
languageId
:
'java'
,
version
:
1
,
lineCount
:
source
(
)
.
split
(
/ \r ? \n /
)
.
length
,
getText
:
(
)
=>
source
(
)
,
positionAt
:
(
offset
)
=>
{
const
=
source
(
)
.
slice
(
0
,
)
.
split
(
/ \r ? \n /
)
;
return
new
Position
(
.
length
-
1
,
[
.
length
-
1
]
.
length
)
;
}
,
}
)
;
const
=
Date
.
now
(
)
;
const
seconds
=
(
)
=>
(
(
Date
.
now
(
)
-
)
/
1000
)
.
toFixed
(
1
)
;
const
=
new
ClasspathSync
(
)
;
await
.
sync
(
'java-lsp-smoke'
)
;
const
=
.
classpath
;
const
=
.
jars
.
filter
(
jar
=>
.
endsWith
(
'android.jar'
)
)
.
length
;
const
=
.
jars
.
filter
(
jar
=>
.
endsWith
(
'.aar'
)
)
.
length
;
console
.
log
(
` \nclasspath: source= ${ classpath. source } , jar= ${ classpath. jars . length } , android.jar= ${ androidJar} , .aar= ${ aar} , модулей= ${ classpath. modules . length } ( ${ seconds ( ) } s) `
)
;
check
(
'classpath получен от Gradle'
,
.
source
===
'gradle'
,
` source= ${ classpath. source } `
)
;
check
(
'в classpath есть android.jar'
,
>
0
)
;
check
(
'в classpath есть .aar (будут развёрнуты в classes.jar)'
,
>
0
,
` ${ aar} шт. `
)
;
const
=
registerJavaLsp
(
,
)
;
check
(
'команды расширения зарегистрированы'
,
.
includes
(
'auraKotlin.java.restartLsp'
)
&&
.
includes
(
'auraKotlin.java.organizeImports'
)
,
.
join
(
', '
)
)
;
check
(
'команда скачивания исходников зарегистрирована'
,
.
includes
(
'auraKotlin.java.downloadSources'
)
,
.
join
(
', '
)
)
;
const
=
sdkRoot
(
)
;
const
=
[
...
installedPlatformSources
(
)
.
keys
(
)
]
;
const
=
planSources
(
.
jars
,
{
sdkRoot
:
,
storageRoot
:
STORAGE
}
)
;
console
.
log
(
` \nисходники: локально ${ plan. attached . size } , к скачиванию ${ plan. downloadable . length } , `
+
` платформа ${ plan. platform . map ( item => ` Android ${ item. api } ` ) . join ( ', ' ) || ( platformBefore. length ? ` Android ${ platformBefore. join ( ', ' ) } уже стоит ` : 'не определена' ) } , `
+
` без координат ${ plan. unresolved . length } (sdk= ${ sdk ?? 'нет' } ) `
)
;
check
(
'исходники платформы есть или запланированы'
,
.
length
>
0
||
.
platform
.
length
>
0
,
` Android ${ platformBefore. join ( ', ' ) || plan. platform . map ( item => item. api ) . join ( ', ' ) || 'нет' } `
)
;
check
(
'исходники библиотек есть или запланированы'
,
.
attached
.
size
+
.
downloadable
.
length
>
0
,
` ${ plan. attached . size } локально, ${ plan. downloadable . length } к скачиванию `
)
;
await
.
ensureSources
(
'manual'
)
;
const
=
.
flatMap
(
channel
=>
.
lines
)
.
filter
(
line
=>
.
includes
(
'[java] исходники'
)
)
;
const
=
.
find
(
line
=>
.
includes
(
'подключено'
)
)
??
''
;
console
.
log
(
.
trim
(
)
)
;
const
=
await
.
ensureStarted
(
)
;
check
(
'Java Language Server запущен'
,
&&
.
lsp
.
serverState
===
'running'
,
` state= ${ client. lsp . serverState } ( ${ seconds ( ) } s) `
)
;
if
(
!
)
{
for
(
const
of
)
{
console
.
log
(
` ${ channel. name } : `
)
;
for
(
const
of
.
lines
.
slice
(
0
,
20
)
)
{
console
.
log
(
` ${ line} `
)
;
}
}
console
.
log
(
` \n ${ results. filter ( r => ! r. ok ) . length } проверок провалено `
)
;
.
exit
(
1
)
;
}
const
=
.
flatMap
(
channel
=>
.
lines
)
.
find
(
line
=>
.
includes
(
'shadow-проект'
)
)
;
check
(
'shadow-проект собран (linked-исходники + classpath)'
,
/ shadow-проект: \d + каталогов исходников, \d + jar /
.
test
(
??
''
)
,
??
'нет записи в логе'
)
;
const
=
.
projectDir
;
const
=
?
.
join
(
,
'.classpath'
)
:
''
;
const
=
&&
.
existsSync
(
)
?
.
readFileSync
(
,
'utf8'
)
:
''
;
const
=
[
...
.
matchAll
(
/ sourcepath="( [ ^ "] + ) " / g
)
]
.
map
(
match
=>
[
1
]
)
;
const
hasFile
=
(
root, relative
)
=>
{
try
{
return
.
existsSync
(
.
join
(
,
)
)
;
}
catch
{
return
false
;
}
}
;
const
=
.
find
(
value
=>
hasFile
(
,
.
join
(
'android'
,
'widget'
,
'TextView.java'
)
)
)
;
const
=
.
find
(
value
=>
/ -sources\. jar$ /
.
test
(
)
)
;
console
.
log
(
` sourcepath в .classpath: ${ attachments. length } `
)
;
console
.
log
(
` android.jar → ${ androidAttachment ?? 'нет' } `
)
;
console
.
log
(
` пример библиотеки → ${ jarAttachment ?? 'нет' } `
)
;
check
(
'в .classpath есть sourcepath для android.jar, и он ведёт в дерево исходников'
,
!
!
,
??
'нет'
)
;
check
(
'в .classpath есть sourcepath для sources-jar библиотек'
,
!
!
,
` ${ attachments. length } закреплений `
)
;
const
JAVA_ACTIVITY
=
.
join
(
PROJECT
,
'app'
,
'src'
,
'main'
,
'java'
,
'com'
,
'aura'
,
'testapp'
,
'JavaActivity.java'
)
;
const
PROBE
=
.
join
(
PROJECT
,
'app'
,
'src'
,
'main'
,
'java'
,
'com'
,
'aura'
,
'testapp'
,
'CompletionProbe.java'
)
;
if
(
!
.
existsSync
(
JAVA_ACTIVITY
)
||
!
.
existsSync
(
PROBE
)
)
{
console
.
log
(
` SKIP: нет фикстур JavaActivity.java/CompletionProbe.java в ${ PROJECT } `
)
;
.
exit
(
0
)
;
}
const
=
document
(
JAVA_ACTIVITY
)
;
const
=
document
(
PROBE
)
;
const
waitFor
=
async
(
predicate, timeoutMs, label
)
=>
{
const
=
Date
.
now
(
)
+
;
while
(
Date
.
now
(
)
<
)
{
if
(
predicate
(
)
)
{
return
true
;
}
await
sleep
(
1000
)
;
}
console
.
log
(
` (ожидание « ${ label} » истекло) `
)
;
return
false
;
}
;
.
lsp
.
didOpen
(
)
;
.
lsp
.
didOpen
(
)
;
await
waitFor
(
(
)
=>
(
.
get
(
fileUri
(
JAVA_ACTIVITY
)
)
??
[
]
)
.
length
>
0
,
180_000
,
'диагностика JavaActivity'
)
;
const
=
.
get
(
fileUri
(
JAVA_ACTIVITY
)
)
??
[
]
;
const
=
.
filter
(
diagnostic
=>
.
severity
===
.
DiagnosticSeverity
.
Error
)
;
console
.
log
(
` \nдиагностика JavaActivity.java ( ${ diagnostics. length } , ошибок ${ errors. length } ) за ${ seconds ( ) } s: `
)
;
for
(
const
of
)
{
console
.
log
(
` [sev ${ diagnostic. severity } ] ${ diagnostic. range . start . line + 1 } : ${ diagnostic. message . split ( '\n' ) [ 0 ] . slice ( 0 , 120 ) } `
)
;
}
const
=
.
filter
(
diagnostic
=>
/ ( TextView| Bundle| Activity| R\. color) /
.
test
(
.
message
)
)
;
check
(
'android.jar и импорты androidx/android резолвятся (нет ошибок по TextView/Bundle/Activity)'
,
.
length
===
0
,
.
map
(
d
=>
.
message
.
split
(
'\n'
)
[
0
]
)
.
join
(
' | '
)
||
'ок'
)
;
const
=
.
find
(
diagnostic
=>
/ ContextCompat /
.
test
(
.
message
)
)
;
check
(
'неимпортированный ContextCompat отмечен как ошибка (нужен автоимпорт)'
,
!
!
,
?.
.
split
(
'\n'
)
[
0
]
??
'нет'
)
;
const
=
await
.
lsp
.
completion
(
,
new
Position
(
7
,
7
)
,
{
triggerKind
:
2
,
triggerCharacter
:
'.'
}
)
;
const
=
?.
??
[
]
;
console
.
log
(
` \nавтодополнение после «view.» — ${ items. length } элементов за ${ seconds ( ) } s `
)
;
console
.
log
(
' '
+
.
slice
(
0
,
12
)
.
map
(
item
=>
.
label
)
.
join
(
', '
)
)
;
check
(
'автодополнение для .java возвращает элементы'
,
.
length
>
20
,
` ${ items. length } шт. `
)
;
const
=
await
.
lsp
.
completion
(
,
new
Position
(
7
,
11
)
,
{
triggerKind
:
1
}
)
;
const
=
(
?.
??
[
]
)
.
map
(
item
=>
.
label
)
;
console
.
log
(
` автодополнение после «view.setTe» — ${ prefixedLabels. length } : ${ prefixedLabels. slice ( 0 , 8 ) . join ( ', ' ) } `
)
;
check
(
'члены android.widget.TextView предлагаются по префиксу'
,
.
some
(
label
=>
/ ^ setText/
.
test
(
)
)
,
.
slice
(
0
,
8
)
.
join
(
', '
)
||
'пусто'
)
;
const
=
await
.
lsp
.
completion
(
,
new
Position
(
15
,
17
)
,
{
triggerKind
:
1
}
)
;
const
=
(
?.
??
[
]
)
.
find
(
item
=>
/ ^ ContextCompat/
.
test
(
.
label
)
)
;
console
.
log
(
` подсказка ContextCompat: ${ importCandidate ? ` ${ importCandidate. label } ( ${ importCandidate. detail ?? '-' } ) ` : 'нет' } `
)
;
check
(
'в автодополнении предлагается неимпортированный ContextCompat'
,
!
!
,
?.
??
'нет'
)
;
if
(
)
{
let
=
await
.
lsp
.
resolveCompletionItem
(
)
;
for
(
let
=
0
;
<
3
&&
!
.
command
;
++
)
{
await
sleep
(
2000
)
;
=
await
.
lsp
.
resolveCompletionItem
(
)
;
}
const
=
.
command
?.
?.
[
1
]
??
[
]
;
const
=
(
?.
??
[
]
)
.
find
(
item
=>
/ ^ setText\( /
.
test
(
.
label
)
)
;
const
=
?
await
.
lsp
.
resolveCompletionItem
(
)
:
undefined
;
const
=
?.
?.
??
?.
;
console
.
log
(
` resolve метода: insertText= ${ JSON . stringify ( String ( methodText ?? '' ) ) . slice ( 0 , 60 ) } `
)
;
check
(
'resolve метода даёт текст вставки, а не описание из label'
,
/ ^ setText$ /
.
test
(
String
(
??
''
)
)
,
String
(
??
'нет'
)
)
;
console
.
log
(
` resolve: insertText= ${ JSON . stringify ( resolved. insertText ) } command= ${ resolved. command ?. command ?? 'нет' } `
)
;
const
=
.
insertText
?.
??
.
insertText
;
check
(
'resolve подставляет код вместо описания подсказки'
,
/ ^ ContextCompat$ /
.
test
(
String
(
)
)
,
String
(
)
)
;
check
(
'resolve приносит автоимпорт androidx.core.content.ContextCompat'
,
.
command
?.
===
'auraKotlin.applyLspTextEdits'
&&
.
some
(
textEdit
=>
/ import\s + androidx\. core\. content\. ContextCompat; /
.
test
(
.
newText
)
)
,
.
map
(
textEdit
=>
.
newText
.
trim
(
)
)
.
join
(
', '
)
||
'нет правок'
)
;
}
if
(
)
{
const
=
await
.
lsp
.
codeAction
(
,
new
Range
(
.
range
.
start
.
line
,
.
range
.
start
.
character
,
.
range
.
end
.
line
,
.
range
.
end
.
character
)
)
;
const
=
(
??
[
]
)
.
find
(
action
=>
/ import / i
.
test
(
.
title
)
)
;
console
.
log
(
` \nquick fix на ContextCompat ( ${ actions?. length ?? 0 } actions): ${ ( actions ?? [ ] ) . map ( a => a. title ) . join ( ' | ' ) || 'нет' } `
)
;
check
(
'quick fix «Import …ContextCompat» приходит с правкой'
,
!
!
&&
!
!
.
edit
&&
.
edit
.
replacements
.
length
>
0
,
?
` ${ importAction. title } → ${ importAction. edit ?. replacements. map ( r => r. newText . trim ( ) ) . join ( ', ' ) } `
:
'нет'
)
;
if
(
?.
)
{
const
=
.
edit
.
replacements
.
map
(
r
=>
.
newText
)
.
join
(
''
)
;
check
(
'правка автоимпорта вставляет import androidx.core.content.ContextCompat'
,
/ import\s + androidx\. core\. content\. ContextCompat; /
.
test
(
)
,
.
trim
(
)
)
;
}
}
const
=
await
.
lsp
.
codeAction
(
,
new
Range
(
0
,
0
,
.
lineCount
-
1
,
0
)
,
[
'source.organizeImports'
]
)
;
console
.
log
(
` organize imports: ${ ( organize ?? [ ] ) . map ( a => a. title ) . join ( ' | ' ) || 'нет' } `
)
;
check
(
'source.organizeImports доступен (автоимпорт всего файла)'
,
(
??
[
]
)
.
some
(
action
=>
/ organize / i
.
test
(
.
title
)
)
,
(
??
[
]
)
.
map
(
a
=>
.
title
)
.
join
(
', '
)
||
'сервер не предложил'
)
;
const
=
await
.
lsp
.
hover
(
,
new
Position
(
5
,
15
)
)
;
const
firstLine
=
(
value
)
=>
String
(
??
''
)
.
split
(
String
.
fromCharCode
(
10
)
)
.
map
(
line
=>
.
trim
(
)
)
.
filter
(
Boolean
)
[
0
]
??
''
;
check
(
'hover по типу проекта отвечает (MarkedString[] разобран)'
,
!
!
&&
/ CompletionProbe /
.
test
(
String
(
.
contents
?.
??
''
)
)
,
firstLine
(
?.
?.
)
||
'нет'
)
;
if
(
)
{
console
.
log
(
` hover: ${ firstLine ( hover. contents ?. value) . slice ( 0 , 100 ) } `
)
;
}
const
=
await
.
lsp
.
definition
(
,
new
Position
(
5
,
15
)
)
;
check
(
'переход к определению работает'
,
!
!
&&
(
Array
.
isArray
(
)
?
.
length
:
1
)
>
0
,
''
)
;
const
=
await
.
lsp
.
hover
(
,
new
Position
(
7
,
10
)
)
;
const
=
String
(
?.
?.
??
''
)
;
console
.
log
(
` hover по члену android.widget.TextView: ${ memberText. split ( String . fromCharCode ( 10 ) ) . map ( line => line. trim ( ) ) . filter ( Boolean ) . slice ( 0 , 3 ) . join ( ' / ' ) . slice ( 0 , 160 ) || 'пусто' } `
)
;
check
(
'hover по члену android.jar отдаёт javadoc из исходников'
,
/ setText\( CharSequence text\) /
.
test
(
)
&&
.
length
>
150
,
` ${ memberText. length } символов: ${ memberText. replace ( / \s + / g , ' ' ) . slice ( 0 , 130 ) } `
)
;
const
locations
=
(
value
)
=>
Array
.
isArray
(
)
?
:
?
[
]
:
[
]
;
const
=
.
get
(
'jdt'
)
;
check
(
'content provider для jdt:// зарегистрирован'
,
typeof
?.
===
'function'
,
[
...
.
keys
(
)
]
.
join
(
', '
)
||
'нет'
)
;
const
jump
=
async
(
label, position, expected, anchor
)
=>
{
const
location
=
locations
(
await
.
lsp
.
definition
(
,
)
)
[
0
]
;
if
(
!
location
)
{
check
(
` переход по ${ label} `
,
false
,
'сервер ничего не вернул'
)
;
return
;
}
const
=
location
.
uri
;
const
=
parseJdtUri
(
)
;
const
=
&&
?
await
.
provideTextDocumentContent
(
)
:
undefined
;
const
=
?
.
split
(
/ \r ? \n /
)
[
location
.
range
.
start
.
line
]
??
''
:
''
;
console
.
log
(
` \nпереход по ${ label} → ${ String ( uri) . slice ( 0 , 70 ) } … `
)
;
console
.
log
(
` исходник: ${ target?. sourceRelative ?? 'нет' } ( ${ content ? ` ${ content. split ( / \r ? \n / ) . length } строк ` : 'не открылся' } ) `
)
;
console
.
log
(
` строка ${ location . range . start . line + 1 } : ${ line. trim ( ) . slice ( 0 , 80 ) } `
)
;
const
=
.
split
(
'/'
)
.
pop
(
)
.
replace
(
/ \. java$ /
,
''
)
;
check
(
` переход по ${ label} ведёт в прикреплённый исходник `
,
?.
===
,
?.
??
'нет'
)
;
check
(
` исходник ${ expected} открывается через content provider `
,
!
!
&&
.
includes
(
` class ${ typeName} `
)
,
?
` ${ content. length } символов `
:
'пусто'
)
;
check
(
` строка ${ location . range . start . line + 1 } исходника совпадает с целью перехода `
,
.
includes
(
)
,
.
trim
(
)
.
slice
(
0
,
70
)
||
'пусто'
)
;
}
;
await
jump
(
'TextView'
,
new
Position
(
11
,
4
)
,
'android/widget/TextView.java'
,
'class TextView'
)
;
await
jump
(
'setText'
,
new
Position
(
12
,
8
)
,
'android/widget/TextView.java'
,
'setText(CharSequence'
)
;
await
jump
(
'ContextCompat'
,
new
Position
(
15
,
16
)
,
'androidx/core/content/ContextCompat.java'
,
'class ContextCompat'
)
;
const
=
Uri
.
parse
(
'jdt://contents/unknown.jar/com/example/Foo.java?=aura-java/C:/nowhere/unknown.jar<com.example(Foo.class'
)
;
const
=
jdtSourceDocument
(
undefined
,
)
;
check
(
'без прикреплённых исходников провайдер объясняет это текстом, а не пустой вкладкой'
,
/ Sources for com\/ example\/ Foo\. java are not attached /
.
test
(
??
''
)
,
String
(
??
''
)
.
trim
(
)
.
slice
(
0
,
100
)
)
;
check
(
'jdt-URI разобран в пару «jar + исходник»'
,
(
(
)
=>
{
const
=
parseJdtUri
(
)
;
return
?.
===
'com/example/Foo.java'
&&
/ unknown\. jar$ /
.
test
(
.
jarPath
)
;
}
)
(
)
,
JSON
.
stringify
(
parseJdtUri
(
)
)
)
;
const
=
await
.
lsp
.
documentSymbol
(
)
;
check
(
'documentSymbol отдаёт символы файла'
,
(
?.
??
0
)
>
0
,
(
??
[
]
)
.
map
(
s
=>
.
name
)
.
join
(
', '
)
)
;
.
dispose
(
)
;
try
{
.
rmSync
(
STORAGE
,
{
recursive
:
true
,
force
:
true
}
)
;
}
catch
{
}
const
=
.
filter
(
result
=>
!
.
ok
)
;
console
.
log
(
` \n ${ results. length - failed. length } / ${ results. length } проверок пройдено ( ${ seconds ( ) } s) `
)
;
.
exit
(
.
length
?
1
:
0
)
;