@@ -28,18 +28,19 @@ export function register({ sourceFiles, getCssLs, jsonLs, templateTsLs, scriptTs
28
28
function useDiagnostics ( sourceFile : SourceFile ) {
29
29
30
30
const {
31
- cssLsStyles,
32
- virtualJsonBlocks,
33
- scriptLsScript,
34
- lastUpdateChanged,
31
+ cssLsDocuments,
32
+ cssLsSourceMaps,
33
+ sfcJsons,
34
+ sfcScriptForScriptLs,
35
+ lastUpdated : lastUpdateChanged ,
35
36
sfcErrors,
36
- virtualTemplateRaw ,
37
+ sfcTemplate ,
37
38
descriptor,
38
39
vueDoc,
39
- templateLsTemplateScript ,
40
+ sfcTemplateScript ,
40
41
templateScriptData,
41
- templateLsScript ,
42
- templatetTsSourceMaps ,
42
+ sfcScriptForTemplateLs ,
43
+ templateLsSourceMaps : templateTsSourceMaps ,
43
44
} = sourceFile . refs ;
44
45
45
46
const templateTsProjectVersion = ref < string > ( ) ;
@@ -52,8 +53,8 @@ export function register({ sourceFiles, getCssLs, jsonLs, templateTsLs, scriptTs
52
53
result : ComputedRef < Promise < vscode . Diagnostic [ ] > | vscode . Diagnostic [ ] > ;
53
54
cache : ComputedRef < Promise < vscode . Diagnostic [ ] > | vscode . Diagnostic [ ] > ;
54
55
} , number , vscode . Diagnostic [ ] ] [ ] = [
55
- [ useStylesValidation ( computed ( ( ) => cssLsStyles . textDocuments . value ) ) , 0 , [ ] ] ,
56
- [ useJsonsValidation ( computed ( ( ) => virtualJsonBlocks . textDocuments . value ) ) , 0 , [ ] ] ,
56
+ [ useStylesValidation ( computed ( ( ) => cssLsDocuments . value ) ) , 0 , [ ] ] ,
57
+ [ useJsonsValidation ( computed ( ( ) => sfcJsons . textDocuments . value ) ) , 0 , [ ] ] ,
57
58
[ useTemplateValidation ( ) , 0 , [ ] ] ,
58
59
[ useScriptExistValidation ( ) , 0 , [ ] ] ,
59
60
] ;
@@ -69,11 +70,11 @@ export function register({ sourceFiles, getCssLs, jsonLs, templateTsLs, scriptTs
69
70
result : ComputedRef < vscode . Diagnostic [ ] > ;
70
71
cache : ComputedRef < vscode . Diagnostic [ ] > ;
71
72
} , number , vscode . Diagnostic [ ] ] [ ] = [
72
- [ useScriptValidation ( scriptLsScript . textDocument , 1 ) , 0 , [ ] ] ,
73
- [ useScriptValidation ( scriptLsScript . textDocument , 2 ) , 0 , [ ] ] ,
74
- [ useScriptValidation ( computed ( ( ) => scriptLsScript . textDocumentForSuggestion . value ?? scriptLsScript . textDocument . value ) , 3 ) , 0 , [ ] ] ,
73
+ [ useScriptValidation ( sfcScriptForScriptLs . textDocument , 1 ) , 0 , [ ] ] ,
74
+ [ useScriptValidation ( sfcScriptForScriptLs . textDocument , 2 ) , 0 , [ ] ] ,
75
+ [ useScriptValidation ( computed ( ( ) => sfcScriptForScriptLs . textDocumentForSuggestion . value ?? sfcScriptForScriptLs . textDocument . value ) , 3 ) , 0 , [ ] ] ,
75
76
// [useScriptValidation(virtualScriptGen.textDocument, 4), 0, []], // TODO: support cancel because it's very slow
76
- [ useScriptValidation ( computed ( ( ) => anyNoUnusedEnabled ? scriptLsScript . textDocumentForSuggestion . value : undefined ) , 1 , true ) , 0 , [ ] ] ,
77
+ [ useScriptValidation ( computed ( ( ) => anyNoUnusedEnabled ? sfcScriptForScriptLs . textDocumentForSuggestion . value : undefined ) , 1 , true ) , 0 , [ ] ] ,
77
78
] ;
78
79
79
80
return async ( response : ( diags : vscode . Diagnostic [ ] ) => void , isCancel ?: ( ) => Promise < boolean > ) => {
@@ -153,15 +154,15 @@ export function register({ sourceFiles, getCssLs, jsonLs, templateTsLs, scriptTs
153
154
154
155
function useTemplateValidation ( ) {
155
156
const htmlErrors = computed ( ( ) => {
156
- if ( virtualTemplateRaw . textDocument . value && virtualTemplateRaw . htmlDocument . value ) {
157
- return getVueCompileErrors ( virtualTemplateRaw . textDocument . value ) ;
157
+ if ( sfcTemplate . textDocument . value && sfcTemplate . htmlDocument . value ) {
158
+ return getVueCompileErrors ( sfcTemplate . textDocument . value ) ;
158
159
}
159
160
return [ ] ;
160
161
} ) ;
161
162
const pugErrors = computed ( ( ) => {
162
163
const result : vscode . Diagnostic [ ] = [ ] ;
163
- if ( virtualTemplateRaw . textDocument . value && virtualTemplateRaw . pugDocument . value ) {
164
- const pugDoc = virtualTemplateRaw . pugDocument . value ;
164
+ if ( sfcTemplate . textDocument . value && sfcTemplate . pugDocument . value ) {
165
+ const pugDoc = sfcTemplate . pugDocument . value ;
165
166
const astError = pugDoc . error ;
166
167
if ( astError ) {
167
168
result . push ( {
@@ -213,8 +214,8 @@ export function register({ sourceFiles, getCssLs, jsonLs, templateTsLs, scriptTs
213
214
}
214
215
vueCompileError . message += errorText ;
215
216
vueCompileError . range = {
216
- start : virtualTemplateRaw . textDocument . value . positionAt ( 0 ) ,
217
- end : virtualTemplateRaw . textDocument . value . positionAt ( virtualTemplateRaw . textDocument . value . getText ( ) . length ) ,
217
+ start : sfcTemplate . textDocument . value . positionAt ( 0 ) ,
218
+ end : sfcTemplate . textDocument . value . positionAt ( sfcTemplate . textDocument . value . getText ( ) . length ) ,
218
219
} ;
219
220
result . push ( vueCompileError ) ;
220
221
}
@@ -231,10 +232,10 @@ export function register({ sourceFiles, getCssLs, jsonLs, templateTsLs, scriptTs
231
232
return cacheWithSourceMap . value ;
232
233
} ) ;
233
234
const cacheWithSourceMap = computed ( ( ) => {
234
- if ( ! virtualTemplateRaw . textDocument . value ) return [ ] ;
235
+ if ( ! sfcTemplate . textDocument . value ) return [ ] ;
235
236
return [
236
- ...toSourceDiags ( htmlErrors . value , virtualTemplateRaw . textDocument . value . uri , virtualTemplateRaw . htmlSourceMap . value ? [ virtualTemplateRaw . htmlSourceMap . value ] : [ ] ) ,
237
- ...toSourceDiags ( pugErrors . value , virtualTemplateRaw . textDocument . value . uri , virtualTemplateRaw . pugSourceMap . value ? [ virtualTemplateRaw . pugSourceMap . value ] : [ ] ) ,
237
+ ...toSourceDiags ( htmlErrors . value , sfcTemplate . textDocument . value . uri , sfcTemplate . htmlSourceMap . value ? [ sfcTemplate . htmlSourceMap . value ] : [ ] ) ,
238
+ ...toSourceDiags ( pugErrors . value , sfcTemplate . textDocument . value . uri , sfcTemplate . pugSourceMap . value ? [ sfcTemplate . pugSourceMap . value ] : [ ] ) ,
238
239
] ;
239
240
} ) ;
240
241
return {
@@ -320,7 +321,7 @@ export function register({ sourceFiles, getCssLs, jsonLs, templateTsLs, scriptTs
320
321
const cacheWithSourceMap = computed ( ( ) => {
321
322
let result : vscode . Diagnostic [ ] = [ ] ;
322
323
for ( const [ uri , errs ] of errors_cache . value ) {
323
- result = result . concat ( toSourceDiags ( errs , uri , cssLsStyles . sourceMaps . value ) ) ;
324
+ result = result . concat ( toSourceDiags ( errs , uri , cssLsSourceMaps . value ) ) ;
324
325
}
325
326
return result as vscode . Diagnostic [ ] ;
326
327
} ) ;
@@ -360,7 +361,7 @@ export function register({ sourceFiles, getCssLs, jsonLs, templateTsLs, scriptTs
360
361
let result : vscode . Diagnostic [ ] = [ ] ;
361
362
if ( errors_cache . value ) {
362
363
for ( const [ uri , errs ] of await errors_cache . value ) {
363
- result = result . concat ( toSourceDiags ( errs , uri , virtualJsonBlocks . sourceMaps . value ) ) ;
364
+ result = result . concat ( toSourceDiags ( errs , uri , sfcJsons . sourceMaps . value ) ) ;
364
365
}
365
366
}
366
367
return result as vscode . Diagnostic [ ] ;
@@ -373,7 +374,7 @@ export function register({ sourceFiles, getCssLs, jsonLs, templateTsLs, scriptTs
373
374
function useScriptExistValidation ( ) {
374
375
const result = computed ( ( ) => {
375
376
const diags : vscode . Diagnostic [ ] = [ ] ;
376
- if ( ! scriptTsLs . __internal__ . getValidTextDocument ( scriptLsScript . textDocument . value . uri ) ) {
377
+ if ( ! scriptTsLs . __internal__ . getValidTextDocument ( sfcScriptForScriptLs . textDocument . value . uri ) ) {
377
378
for ( const script of [ descriptor . script , descriptor . scriptSetup ] ) {
378
379
if ( ! script || script . content === '' ) continue ;
379
380
const error = vscode . Diagnostic . create (
@@ -426,7 +427,7 @@ export function register({ sourceFiles, getCssLs, jsonLs, templateTsLs, scriptTs
426
427
const cacheWithSourceMap = computed ( ( ) => {
427
428
const doc = document . value ;
428
429
if ( ! doc ) return [ ] ;
429
- let result = toTsSourceDiags ( 'script' , errors_cache . value , doc . uri , templatetTsSourceMaps . value ) ;
430
+ let result = toTsSourceDiags ( 'script' , errors_cache . value , doc . uri , templateTsSourceMaps . value ) ;
430
431
if ( onlyUnusedCheck ) {
431
432
result = result . filter ( error => error . tags ?. includes ( vscode . DiagnosticTag . Unnecessary ) ) ;
432
433
}
@@ -442,7 +443,7 @@ export function register({ sourceFiles, getCssLs, jsonLs, templateTsLs, scriptTs
442
443
if ( mode === 1 ) { // watching
443
444
templateTsProjectVersion . value ;
444
445
}
445
- const doc = templateLsTemplateScript . textDocument . value ;
446
+ const doc = sfcTemplateScript . textDocument . value ;
446
447
if ( ! doc ) return [ ] ;
447
448
if ( mode === 1 ) {
448
449
return templateTsLs . doValidation ( doc . uri , { semantic : true } ) ;
@@ -460,18 +461,18 @@ export function register({ sourceFiles, getCssLs, jsonLs, templateTsLs, scriptTs
460
461
} ) ;
461
462
const errors_2 = computed ( ( ) => {
462
463
const result : vscode . Diagnostic [ ] = [ ] ;
463
- if ( ! templateLsTemplateScript . textDocument . value
464
- || ! templateLsTemplateScript . teleportSourceMap . value
464
+ if ( ! sfcTemplateScript . textDocument . value
465
+ || ! sfcTemplateScript . teleportSourceMap . value
465
466
) return result ;
466
467
for ( const diag of errors_1 . value ) {
467
- const spanText = templateLsTemplateScript . textDocument . value . getText ( diag . range ) ;
468
+ const spanText = sfcTemplateScript . textDocument . value . getText ( diag . range ) ;
468
469
if ( ! templateScriptData . setupReturns . includes ( spanText ) ) continue ;
469
- const propRights = templateLsTemplateScript . teleportSourceMap . value . getMappedRanges ( diag . range . start , diag . range . end ) ;
470
+ const propRights = sfcTemplateScript . teleportSourceMap . value . getMappedRanges ( diag . range . start , diag . range . end ) ;
470
471
for ( const propRight of propRights ) {
471
472
if ( propRight . data . isAdditionalReference ) continue ;
472
- const definitions = templateTsLs . findDefinition ( templateLsTemplateScript . textDocument . value . uri , propRight . start ) ;
473
+ const definitions = templateTsLs . findDefinition ( sfcTemplateScript . textDocument . value . uri , propRight . start ) ;
473
474
for ( const definition of definitions ) {
474
- if ( definition . targetUri !== templateLsScript . textDocument . value . uri ) continue ;
475
+ if ( definition . targetUri !== sfcScriptForTemplateLs . textDocument . value . uri ) continue ;
475
476
result . push ( {
476
477
...diag ,
477
478
range : definition . targetSelectionRange ,
@@ -489,17 +490,17 @@ export function register({ sourceFiles, getCssLs, jsonLs, templateTsLs, scriptTs
489
490
return cacheWithSourceMap . value ;
490
491
} ) ;
491
492
const cacheWithSourceMap = computed ( ( ) => {
492
- const result_1 = templateLsTemplateScript . textDocument . value ? toTsSourceDiags (
493
+ const result_1 = sfcTemplateScript . textDocument . value ? toTsSourceDiags (
493
494
'template' ,
494
495
errors_1_cache . value ,
495
- templateLsTemplateScript . textDocument . value . uri ,
496
- templatetTsSourceMaps . value ,
496
+ sfcTemplateScript . textDocument . value . uri ,
497
+ templateTsSourceMaps . value ,
497
498
) : [ ] ;
498
- const result_2 = templateLsScript . textDocument . value ? toTsSourceDiags (
499
+ const result_2 = sfcScriptForTemplateLs . textDocument . value ? toTsSourceDiags (
499
500
'template' ,
500
501
errors_2_cache . value ,
501
- templateLsScript . textDocument . value . uri ,
502
- templatetTsSourceMaps . value ,
502
+ sfcScriptForTemplateLs . textDocument . value . uri ,
503
+ templateTsSourceMaps . value ,
503
504
) : [ ] ;
504
505
return [ ...result_1 , ...result_2 ] ;
505
506
} ) ;
0 commit comments