Skip to content

Commit f738ccd

Browse files
committed
Always send configFileDiag and instead set triggerFile for more consistency
1 parent 468d91c commit f738ccd

File tree

111 files changed

+3370
-473
lines changed

Some content is hidden

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

111 files changed

+3370
-473
lines changed

src/server/editorServices.ts

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

src/server/project.ts

Lines changed: 22 additions & 5 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,6 +2848,7 @@ export class ConfiguredProject extends Project {
28452848
*/
28462849
override updateGraph(): boolean {
28472850
if (this.deferredClose) return false;
2851+
const isDirty = this.dirty;
28482852
this.isInitialLoadPending = returnFalse;
28492853
const updateLevel = this.pendingUpdateLevel;
28502854
this.pendingUpdateLevel = ProgramUpdateLevel.Update;
@@ -2867,8 +2871,21 @@ export class ConfiguredProject extends Project {
28672871
this.compilerHost = undefined;
28682872
this.projectService.sendProjectLoadingFinishEvent(this);
28692873
this.projectService.sendProjectTelemetry(this);
2870-
if (!this.skipConfigDiagEvent && !result) { // If new program, send event if diagnostics presence has changed
2871-
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);
28722889
}
28732890
return result;
28742891
}

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/configuredProjects/add-and-then-remove-a-config-file-when-parent-folder-has-config-file.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ Info seq [hh:mm:ss:mss] event:
332332
"type": "event",
333333
"event": "configFileDiag",
334334
"body": {
335-
"triggerFile": "/user/username/projects/myproject/tsconfig.json",
335+
"triggerFile": "/user/username/projects/myproject/folder/commonFile2.ts",
336336
"configFile": "/user/username/projects/myproject/tsconfig.json",
337337
"diagnostics": []
338338
}
@@ -2419,7 +2419,7 @@ Info seq [hh:mm:ss:mss] event:
24192419
"type": "event",
24202420
"event": "configFileDiag",
24212421
"body": {
2422-
"triggerFile": "/user/username/projects/myproject/tsconfig.json",
2422+
"triggerFile": "/user/username/projects/myproject/folder/commonFile2.ts",
24232423
"configFile": "/user/username/projects/myproject/tsconfig.json",
24242424
"diagnostics": []
24252425
}
@@ -3031,7 +3031,7 @@ Info seq [hh:mm:ss:mss] event:
30313031
"type": "event",
30323032
"event": "configFileDiag",
30333033
"body": {
3034-
"triggerFile": "/user/username/projects/myproject/tsconfig.json",
3034+
"triggerFile": "/user/username/projects/myproject/folder/commonFile2.ts",
30353035
"configFile": "/user/username/projects/myproject/tsconfig.json",
30363036
"diagnostics": []
30373037
}
@@ -3814,7 +3814,7 @@ Info seq [hh:mm:ss:mss] event:
38143814
"type": "event",
38153815
"event": "configFileDiag",
38163816
"body": {
3817-
"triggerFile": "/user/username/projects/myproject/tsconfig.json",
3817+
"triggerFile": "/user/username/projects/myproject/folder/commonFile2.ts",
38183818
"configFile": "/user/username/projects/myproject/tsconfig.json",
38193819
"diagnostics": []
38203820
}

tests/baselines/reference/tsserver/events/projectLoading/lazyConfiguredProjectsFromExternalProject-is-false-when-using-default-event-handler.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,17 @@ Info seq [hh:mm:ss:mss] event:
160160
}
161161
}
162162
}
163+
Info seq [hh:mm:ss:mss] event:
164+
{
165+
"seq": 0,
166+
"type": "event",
167+
"event": "configFileDiag",
168+
"body": {
169+
"triggerFile": "/user/username/projects/a/tsconfig.json",
170+
"configFile": "/user/username/projects/a/tsconfig.json",
171+
"diagnostics": []
172+
}
173+
}
163174
Info seq [hh:mm:ss:mss] Project '/user/username/projects/a/tsconfig.json' (Configured)
164175
Info seq [hh:mm:ss:mss] Files (2)
165176

tests/baselines/reference/tsserver/events/projectLoading/lazyConfiguredProjectsFromExternalProject-is-false-when-using-event-handler.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,17 @@ Info seq [hh:mm:ss:mss] event:
157157
"version": "FakeVersion"
158158
}
159159
}
160+
Info seq [hh:mm:ss:mss] event:
161+
{
162+
"seq": 0,
163+
"type": "event",
164+
"event": "CustomHandler::configFileDiag",
165+
"body": {
166+
"configFileName": "/user/username/projects/a/tsconfig.json",
167+
"diagnostics": [],
168+
"triggerFile": "/user/username/projects/a/tsconfig.json"
169+
}
170+
}
160171
Info seq [hh:mm:ss:mss] Project '/user/username/projects/a/tsconfig.json' (Configured)
161172
Info seq [hh:mm:ss:mss] Files (2)
162173

tests/baselines/reference/tsserver/events/projectLoading/lazyConfiguredProjectsFromExternalProject-is-true-and-file-is-opened-when-using-default-event-handler.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ Info seq [hh:mm:ss:mss] event:
199199
"type": "event",
200200
"event": "configFileDiag",
201201
"body": {
202-
"triggerFile": "/user/username/projects/a/tsconfig.json",
202+
"triggerFile": "/user/username/projects/a/a.ts",
203203
"configFile": "/user/username/projects/a/tsconfig.json",
204204
"diagnostics": []
205205
}

0 commit comments

Comments
 (0)