Skip to content

Commit b9c71c3

Browse files
authored
Always send configFileDiagEvent and instead set triggerFile for more consistency (#58462)
1 parent 9d714f4 commit b9c71c3

File tree

157 files changed

+3371
-623
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

157 files changed

+3371
-623
lines changed

src/server/editorServices.ts

Lines changed: 59 additions & 72 deletions
Large diffs are not rendered by default.

src/server/project.ts

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2741,7 +2741,7 @@ export class AutoImportProviderProject extends Project {
27412741
*/
27422742
export class ConfiguredProject extends Project {
27432743
/** @internal */
2744-
pendingUpdateLevel: ProgramUpdateLevel | undefined;
2744+
pendingUpdateLevel: ProgramUpdateLevel;
27452745
/** @internal */
27462746
pendingUpdateReason: string | undefined;
27472747

@@ -2776,10 +2776,10 @@ export class ConfiguredProject extends Project {
27762776
private compilerHost?: CompilerHost;
27772777

27782778
/** @internal */
2779-
hasConfigFileDiagnostics?: boolean;
2779+
configDiagDiagnosticsReported?: number;
27802780

27812781
/** @internal */
2782-
skipConfigDiagEvent?: true;
2782+
triggerFileForConfigFileDiag?: NormalizedPath;
27832783

27842784
/** @internal */
27852785
deferredClose?: boolean;
@@ -2791,8 +2791,11 @@ export class ConfiguredProject extends Project {
27912791
projectService: ProjectService,
27922792
documentRegistry: DocumentRegistry,
27932793
cachedDirectoryStructureHost: CachedDirectoryStructureHost,
2794+
pendingUpdateReason: string,
27942795
) {
27952796
super(configFileName, ProjectKind.Configured, projectService, documentRegistry, /*hasExplicitListOfFiles*/ false, /*lastFileExceededProgramSize*/ undefined, /*compilerOptions*/ {}, /*compileOnSaveEnabled*/ false, /*watchOptions*/ undefined, cachedDirectoryStructureHost, getDirectoryPath(configFileName));
2797+
this.pendingUpdateLevel = ProgramUpdateLevel.Full;
2798+
this.pendingUpdateReason = pendingUpdateReason;
27962799
}
27972800

27982801
/** @internal */
@@ -2845,7 +2848,7 @@ export class ConfiguredProject extends Project {
28452848
*/
28462849
override updateGraph(): boolean {
28472850
if (this.deferredClose) return false;
2848-
const isInitialLoad = this.isInitialLoadPending();
2851+
const isDirty = this.dirty;
28492852
this.isInitialLoadPending = returnFalse;
28502853
const updateLevel = this.pendingUpdateLevel;
28512854
this.pendingUpdateLevel = ProgramUpdateLevel.Update;
@@ -2859,7 +2862,7 @@ export class ConfiguredProject extends Project {
28592862
this.openFileWatchTriggered.clear();
28602863
const reason = Debug.checkDefined(this.pendingUpdateReason);
28612864
this.pendingUpdateReason = undefined;
2862-
this.projectService.reloadConfiguredProject(this, reason, isInitialLoad, /*clearSemanticCache*/ false);
2865+
this.projectService.reloadConfiguredProject(this, reason, /*clearSemanticCache*/ false);
28632866
result = true;
28642867
break;
28652868
default:
@@ -2868,8 +2871,21 @@ export class ConfiguredProject extends Project {
28682871
this.compilerHost = undefined;
28692872
this.projectService.sendProjectLoadingFinishEvent(this);
28702873
this.projectService.sendProjectTelemetry(this);
2871-
if (!this.skipConfigDiagEvent && !result) { // If new program, send event if diagnostics presence has changed
2872-
this.projectService.sendConfigFileDiagEvent(this, /*triggerFile*/ undefined);
2874+
if (
2875+
updateLevel === ProgramUpdateLevel.Full || ( // Already sent event through reload
2876+
result && ( // Not new program
2877+
!isDirty ||
2878+
!this.triggerFileForConfigFileDiag ||
2879+
this.getCurrentProgram()!.structureIsReused === StructureIsReused.Completely
2880+
)
2881+
)
2882+
) {
2883+
// Dont send the configFileDiag
2884+
this.triggerFileForConfigFileDiag = undefined;
2885+
}
2886+
else if (!this.triggerFileForConfigFileDiag) {
2887+
// If we arent tracking to send configFileDiag, send event if diagnostics presence has changed
2888+
this.projectService.sendConfigFileDiagEvent(this, /*triggerFile*/ undefined, /*force*/ false);
28732889
}
28742890
return result;
28752891
}

tests/baselines/reference/tsserver/autoImportProvider/Does-not-create-auto-import-providers-upon-opening-projects-for-find-all-references.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,6 @@ Info seq [hh:mm:ss:mss] request:
315315
"type": "request"
316316
}
317317
Info seq [hh:mm:ss:mss] Finding references to /packages/b/index.ts position 12 in project /packages/b/tsconfig.json
318-
Info seq [hh:mm:ss:mss] Loading configured project /tsconfig.json
319318
Info seq [hh:mm:ss:mss] event:
320319
{
321320
"seq": 0,

tests/baselines/reference/tsserver/cachingFileSystemInformation/npm-install-works-when-timeout-occurs-inbetween-installation.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1364,6 +1364,23 @@ Info seq [hh:mm:ss:mss] Files (2)
13641364
/user/username/rootfolder/otherfolder/a/b/app.ts SVC-1-0 "import _ from 'lodash';"
13651365

13661366
Info seq [hh:mm:ss:mss] -----------------------------------------------
1367+
Info seq [hh:mm:ss:mss] event:
1368+
{
1369+
"seq": 0,
1370+
"type": "event",
1371+
"event": "configFileDiag",
1372+
"body": {
1373+
"triggerFile": "/user/username/rootfolder/otherfolder/a/b/tsconfig.json",
1374+
"configFile": "/user/username/rootfolder/otherfolder/a/b/tsconfig.json",
1375+
"diagnostics": [
1376+
{
1377+
"text": "Cannot find type definition file for 'lodash'.\n The file is in the program because:\n Entry point for implicit type library 'lodash'",
1378+
"code": 2688,
1379+
"category": "error"
1380+
}
1381+
]
1382+
}
1383+
}
13671384
Info seq [hh:mm:ss:mss] Running: *ensureProjectForOpenFiles*
13681385
Info seq [hh:mm:ss:mss] Before ensureProjectForOpenFiles:
13691386
Info seq [hh:mm:ss:mss] Project '/user/username/rootfolder/otherfolder/a/b/tsconfig.json' (Configured)
@@ -2212,6 +2229,17 @@ Info seq [hh:mm:ss:mss] Files (3)
22122229
Matched by default include pattern '**/*'
22132230

22142231
Info seq [hh:mm:ss:mss] -----------------------------------------------
2232+
Info seq [hh:mm:ss:mss] event:
2233+
{
2234+
"seq": 0,
2235+
"type": "event",
2236+
"event": "configFileDiag",
2237+
"body": {
2238+
"triggerFile": "/user/username/rootfolder/otherfolder/a/b/tsconfig.json",
2239+
"configFile": "/user/username/rootfolder/otherfolder/a/b/tsconfig.json",
2240+
"diagnostics": []
2241+
}
2242+
}
22152243
Info seq [hh:mm:ss:mss] Running: *ensureProjectForOpenFiles*
22162244
Info seq [hh:mm:ss:mss] Before ensureProjectForOpenFiles:
22172245
Info seq [hh:mm:ss:mss] Project '/user/username/rootfolder/otherfolder/a/b/tsconfig.json' (Configured)

tests/baselines/reference/tsserver/compileOnSave/emit-with-richRepsonse-as-false.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,23 @@ Info seq [hh:mm:ss:mss] Files (4)
332332
Matched by default include pattern '**/*'
333333

334334
Info seq [hh:mm:ss:mss] -----------------------------------------------
335+
Info seq [hh:mm:ss:mss] event:
336+
{
337+
"seq": 0,
338+
"type": "event",
339+
"event": "configFileDiag",
340+
"body": {
341+
"triggerFile": "/user/username/projects/myproject/tsconfig.json",
342+
"configFile": "/user/username/projects/myproject/tsconfig.json",
343+
"diagnostics": [
344+
{
345+
"text": "Cannot write file '/user/username/projects/myproject/test/file1.d.ts' because it would overwrite input file.",
346+
"code": 5055,
347+
"category": "error"
348+
}
349+
]
350+
}
351+
}
335352
Info seq [hh:mm:ss:mss] response:
336353
{
337354
"response": false,

tests/baselines/reference/tsserver/compileOnSave/emit-with-richRepsonse-as-true.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,23 @@ Info seq [hh:mm:ss:mss] Files (4)
335335
Matched by default include pattern '**/*'
336336

337337
Info seq [hh:mm:ss:mss] -----------------------------------------------
338+
Info seq [hh:mm:ss:mss] event:
339+
{
340+
"seq": 0,
341+
"type": "event",
342+
"event": "configFileDiag",
343+
"body": {
344+
"triggerFile": "/user/username/projects/myproject/tsconfig.json",
345+
"configFile": "/user/username/projects/myproject/tsconfig.json",
346+
"diagnostics": [
347+
{
348+
"text": "Cannot write file '/user/username/projects/myproject/test/file1.d.ts' because it would overwrite input file.",
349+
"code": 5055,
350+
"category": "error"
351+
}
352+
]
353+
}
354+
}
338355
Info seq [hh:mm:ss:mss] response:
339356
{
340357
"response": {

tests/baselines/reference/tsserver/compileOnSave/emit-with-richRepsonse-as-undefined.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,23 @@ Info seq [hh:mm:ss:mss] Files (4)
330330
Matched by default include pattern '**/*'
331331

332332
Info seq [hh:mm:ss:mss] -----------------------------------------------
333+
Info seq [hh:mm:ss:mss] event:
334+
{
335+
"seq": 0,
336+
"type": "event",
337+
"event": "configFileDiag",
338+
"body": {
339+
"triggerFile": "/user/username/projects/myproject/tsconfig.json",
340+
"configFile": "/user/username/projects/myproject/tsconfig.json",
341+
"diagnostics": [
342+
{
343+
"text": "Cannot write file '/user/username/projects/myproject/test/file1.d.ts' because it would overwrite input file.",
344+
"code": 5055,
345+
"category": "error"
346+
}
347+
]
348+
}
349+
}
333350
Info seq [hh:mm:ss:mss] response:
334351
{
335352
"response": false,

tests/baselines/reference/tsserver/configFileSearch/tsconfig-for-the-file-does-not-exist.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,6 @@ Projects::
158158
projectProgramVersion: 1
159159

160160
Info seq [hh:mm:ss:mss] Running: /a/b/projects/project/tsconfig.json
161-
Info seq [hh:mm:ss:mss] Loading configured project /a/b/projects/project/tsconfig.json
162161
Info seq [hh:mm:ss:mss] event:
163162
{
164163
"seq": 0,

tests/baselines/reference/tsserver/configFileSearch/tsconfig-for-the-file-exists.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,6 @@ Projects::
335335
projectProgramVersion: 1
336336

337337
Info seq [hh:mm:ss:mss] Running: /a/b/projects/project/tsconfig.json
338-
Info seq [hh:mm:ss:mss] Reloading configured project /a/b/projects/project/tsconfig.json
339338
Info seq [hh:mm:ss:mss] event:
340339
{
341340
"seq": 0,

tests/baselines/reference/tsserver/configuredProjects/Open-ref-of-configured-project-when-open-file-gets-added-to-the-project-as-part-of-configured-file-update-buts-its-open-file-references-are-all-closed-when-the-update-happens.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -645,7 +645,6 @@ Before running Timeout callback:: count: 2
645645
3: *ensureProjectForOpenFiles*
646646

647647
Info seq [hh:mm:ss:mss] Running: /a/b/tsconfig.json
648-
Info seq [hh:mm:ss:mss] Reloading configured project /a/b/tsconfig.json
649648
Info seq [hh:mm:ss:mss] event:
650649
{
651650
"seq": 0,

tests/baselines/reference/tsserver/configuredProjects/Open-ref-of-configured-project-when-open-file-gets-added-to-the-project-as-part-of-configured-file-update.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -523,7 +523,6 @@ Projects::
523523
projectProgramVersion: 1
524524

525525
Info seq [hh:mm:ss:mss] Running: /a/b/tsconfig.json
526-
Info seq [hh:mm:ss:mss] Reloading configured project /a/b/tsconfig.json
527526
Info seq [hh:mm:ss:mss] event:
528527
{
529528
"seq": 0,

tests/baselines/reference/tsserver/configuredProjects/add-and-then-remove-a-config-file-in-a-folder-with-loose-files.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,6 @@ Projects::
225225
dirty: true
226226

227227
Info seq [hh:mm:ss:mss] Running: /user/username/projects/myproject/tsconfig.json
228-
Info seq [hh:mm:ss:mss] Loading configured project /user/username/projects/myproject/tsconfig.json
229228
Info seq [hh:mm:ss:mss] event:
230229
{
231230
"seq": 0,
@@ -574,7 +573,6 @@ Projects::
574573
deferredClose: undefined *changed*
575574

576575
Info seq [hh:mm:ss:mss] Running: /user/username/projects/myproject/tsconfig.json
577-
Info seq [hh:mm:ss:mss] Reloading configured project /user/username/projects/myproject/tsconfig.json
578576
Info seq [hh:mm:ss:mss] event:
579577
{
580578
"seq": 0,
@@ -1485,7 +1483,6 @@ Projects::
14851483
deferredClose: undefined *changed*
14861484

14871485
Info seq [hh:mm:ss:mss] Running: /user/username/projects/myproject/tsconfig.json
1488-
Info seq [hh:mm:ss:mss] Reloading configured project /user/username/projects/myproject/tsconfig.json
14891486
Info seq [hh:mm:ss:mss] event:
14901487
{
14911488
"seq": 0,

tests/baselines/reference/tsserver/configuredProjects/add-and-then-remove-a-config-file-when-parent-folder-has-config-file.js

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,6 @@ Info seq [hh:mm:ss:mss] request:
240240
"type": "request"
241241
}
242242
Info seq [hh:mm:ss:mss] getConfigFileNameForFile:: File: /user/username/projects/myproject/folder/commonFile2.ts ProjectRootPath: undefined:: Result: /user/username/projects/myproject/tsconfig.json
243-
Info seq [hh:mm:ss:mss] Loading configured project /user/username/projects/myproject/tsconfig.json
244243
Info seq [hh:mm:ss:mss] event:
245244
{
246245
"seq": 0,
@@ -333,7 +332,7 @@ Info seq [hh:mm:ss:mss] event:
333332
"type": "event",
334333
"event": "configFileDiag",
335334
"body": {
336-
"triggerFile": "/user/username/projects/myproject/tsconfig.json",
335+
"triggerFile": "/user/username/projects/myproject/folder/commonFile2.ts",
337336
"configFile": "/user/username/projects/myproject/tsconfig.json",
338337
"diagnostics": []
339338
}
@@ -421,7 +420,6 @@ Projects::
421420

422421
Info seq [hh:mm:ss:mss] Running: /user/username/projects/myproject/tsconfig.json
423422
Info seq [hh:mm:ss:mss] Running: /user/username/projects/myproject/folder/tsconfig.json
424-
Info seq [hh:mm:ss:mss] Reloading configured project /user/username/projects/myproject/folder/tsconfig.json
425423
Info seq [hh:mm:ss:mss] event:
426424
{
427425
"seq": 0,
@@ -1290,7 +1288,6 @@ Projects::
12901288
dirty: true
12911289
12921290
Info seq [hh:mm:ss:mss] Running: /user/username/projects/myproject/tsconfig.json
1293-
Info seq [hh:mm:ss:mss] Loading configured project /user/username/projects/myproject/tsconfig.json
12941291
Info seq [hh:mm:ss:mss] event:
12951292
{
12961293
"seq": 0,
@@ -1512,7 +1509,6 @@ Projects::
15121509
projectProgramVersion: 1
15131510
15141511
Info seq [hh:mm:ss:mss] Running: /user/username/projects/myproject/folder/tsconfig.json
1515-
Info seq [hh:mm:ss:mss] Reloading configured project /user/username/projects/myproject/folder/tsconfig.json
15161512
Info seq [hh:mm:ss:mss] event:
15171513
{
15181514
"seq": 0,
@@ -2372,7 +2368,6 @@ Info seq [hh:mm:ss:mss] request:
23722368
"type": "request"
23732369
}
23742370
Info seq [hh:mm:ss:mss] getConfigFileNameForFile:: File: /user/username/projects/myproject/folder/commonFile2.ts ProjectRootPath: undefined:: Result: /user/username/projects/myproject/tsconfig.json
2375-
Info seq [hh:mm:ss:mss] Loading configured project /user/username/projects/myproject/tsconfig.json
23762371
Info seq [hh:mm:ss:mss] event:
23772372
{
23782373
"seq": 0,
@@ -2424,7 +2419,7 @@ Info seq [hh:mm:ss:mss] event:
24242419
"type": "event",
24252420
"event": "configFileDiag",
24262421
"body": {
2427-
"triggerFile": "/user/username/projects/myproject/tsconfig.json",
2422+
"triggerFile": "/user/username/projects/myproject/folder/commonFile2.ts",
24282423
"configFile": "/user/username/projects/myproject/tsconfig.json",
24292424
"diagnostics": []
24302425
}
@@ -2985,7 +2980,6 @@ Info seq [hh:mm:ss:mss] request:
29852980
"type": "request"
29862981
}
29872982
Info seq [hh:mm:ss:mss] getConfigFileNameForFile:: File: /user/username/projects/myproject/folder/commonFile2.ts ProjectRootPath: undefined:: Result: /user/username/projects/myproject/tsconfig.json
2988-
Info seq [hh:mm:ss:mss] Loading configured project /user/username/projects/myproject/tsconfig.json
29892983
Info seq [hh:mm:ss:mss] event:
29902984
{
29912985
"seq": 0,
@@ -3037,7 +3031,7 @@ Info seq [hh:mm:ss:mss] event:
30373031
"type": "event",
30383032
"event": "configFileDiag",
30393033
"body": {
3040-
"triggerFile": "/user/username/projects/myproject/tsconfig.json",
3034+
"triggerFile": "/user/username/projects/myproject/folder/commonFile2.ts",
30413035
"configFile": "/user/username/projects/myproject/tsconfig.json",
30423036
"diagnostics": []
30433037
}
@@ -3769,7 +3763,6 @@ Info seq [hh:mm:ss:mss] request:
37693763
"type": "request"
37703764
}
37713765
Info seq [hh:mm:ss:mss] getConfigFileNameForFile:: File: /user/username/projects/myproject/folder/commonFile2.ts ProjectRootPath: undefined:: Result: /user/username/projects/myproject/tsconfig.json
3772-
Info seq [hh:mm:ss:mss] Loading configured project /user/username/projects/myproject/tsconfig.json
37733766
Info seq [hh:mm:ss:mss] event:
37743767
{
37753768
"seq": 0,
@@ -3821,7 +3814,7 @@ Info seq [hh:mm:ss:mss] event:
38213814
"type": "event",
38223815
"event": "configFileDiag",
38233816
"body": {
3824-
"triggerFile": "/user/username/projects/myproject/tsconfig.json",
3817+
"triggerFile": "/user/username/projects/myproject/folder/commonFile2.ts",
38253818
"configFile": "/user/username/projects/myproject/tsconfig.json",
38263819
"diagnostics": []
38273820
}

tests/baselines/reference/tsserver/configuredProjects/can-correctly-update-configured-project-when-set-of-root-files-has-changed-(new-file-in-list-of-files).js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,6 @@ Projects::
225225
dirty: true *changed*
226226

227227
Info seq [hh:mm:ss:mss] Running: /a/b/tsconfig.json
228-
Info seq [hh:mm:ss:mss] Reloading configured project /a/b/tsconfig.json
229228
Info seq [hh:mm:ss:mss] event:
230229
{
231230
"seq": 0,

tests/baselines/reference/tsserver/configuredProjects/can-update-configured-project-when-set-of-root-files-was-not-changed.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,6 @@ Projects::
239239
dirty: true *changed*
240240

241241
Info seq [hh:mm:ss:mss] Running: /a/b/tsconfig.json
242-
Info seq [hh:mm:ss:mss] Reloading configured project /a/b/tsconfig.json
243242
Info seq [hh:mm:ss:mss] event:
244243
{
245244
"seq": 0,

tests/baselines/reference/tsserver/configuredProjects/open-file-become-a-part-of-configured-project-if-it-is-referenced-from-root-file.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,6 @@ Projects::
309309
dirty: true
310310

311311
Info seq [hh:mm:ss:mss] Running: /user/username/projects/myproject/a/c/tsconfig.json
312-
Info seq [hh:mm:ss:mss] Loading configured project /user/username/projects/myproject/a/c/tsconfig.json
313312
Info seq [hh:mm:ss:mss] event:
314313
{
315314
"seq": 0,

tests/baselines/reference/tsserver/configuredProjects/should-properly-handle-module-resolution-changes-in-config-file.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,6 @@ Projects::
377377
projectProgramVersion: 1
378378

379379
Info seq [hh:mm:ss:mss] Running: /a/b/tsconfig.json
380-
Info seq [hh:mm:ss:mss] Reloading configured project /a/b/tsconfig.json
381380
Info seq [hh:mm:ss:mss] event:
382381
{
383382
"seq": 0,

0 commit comments

Comments
 (0)