Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Always send configFileDiagEvent and instead set triggerFile for more consistency #58462

Merged
merged 4 commits into from
May 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
131 changes: 59 additions & 72 deletions src/server/editorServices.ts

Large diffs are not rendered by default.

30 changes: 23 additions & 7 deletions src/server/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2741,7 +2741,7 @@ export class AutoImportProviderProject extends Project {
*/
export class ConfiguredProject extends Project {
/** @internal */
pendingUpdateLevel: ProgramUpdateLevel | undefined;
pendingUpdateLevel: ProgramUpdateLevel;
/** @internal */
pendingUpdateReason: string | undefined;

Expand Down Expand Up @@ -2776,10 +2776,10 @@ export class ConfiguredProject extends Project {
private compilerHost?: CompilerHost;

/** @internal */
hasConfigFileDiagnostics?: boolean;
configDiagDiagnosticsReported?: number;

/** @internal */
skipConfigDiagEvent?: true;
triggerFileForConfigFileDiag?: NormalizedPath;

/** @internal */
deferredClose?: boolean;
Expand All @@ -2791,8 +2791,11 @@ export class ConfiguredProject extends Project {
projectService: ProjectService,
documentRegistry: DocumentRegistry,
cachedDirectoryStructureHost: CachedDirectoryStructureHost,
pendingUpdateReason: string,
) {
super(configFileName, ProjectKind.Configured, projectService, documentRegistry, /*hasExplicitListOfFiles*/ false, /*lastFileExceededProgramSize*/ undefined, /*compilerOptions*/ {}, /*compileOnSaveEnabled*/ false, /*watchOptions*/ undefined, cachedDirectoryStructureHost, getDirectoryPath(configFileName));
this.pendingUpdateLevel = ProgramUpdateLevel.Full;
this.pendingUpdateReason = pendingUpdateReason;
}

/** @internal */
Expand Down Expand Up @@ -2845,7 +2848,7 @@ export class ConfiguredProject extends Project {
*/
override updateGraph(): boolean {
if (this.deferredClose) return false;
const isInitialLoad = this.isInitialLoadPending();
const isDirty = this.dirty;
this.isInitialLoadPending = returnFalse;
const updateLevel = this.pendingUpdateLevel;
this.pendingUpdateLevel = ProgramUpdateLevel.Update;
Expand All @@ -2859,7 +2862,7 @@ export class ConfiguredProject extends Project {
this.openFileWatchTriggered.clear();
const reason = Debug.checkDefined(this.pendingUpdateReason);
this.pendingUpdateReason = undefined;
this.projectService.reloadConfiguredProject(this, reason, isInitialLoad, /*clearSemanticCache*/ false);
this.projectService.reloadConfiguredProject(this, reason, /*clearSemanticCache*/ false);
result = true;
break;
default:
Expand All @@ -2868,8 +2871,21 @@ export class ConfiguredProject extends Project {
this.compilerHost = undefined;
this.projectService.sendProjectLoadingFinishEvent(this);
this.projectService.sendProjectTelemetry(this);
if (!this.skipConfigDiagEvent && !result) { // If new program, send event if diagnostics presence has changed
this.projectService.sendConfigFileDiagEvent(this, /*triggerFile*/ undefined);
if (
updateLevel === ProgramUpdateLevel.Full || ( // Already sent event through reload
result && ( // Not new program
!isDirty ||
!this.triggerFileForConfigFileDiag ||
this.getCurrentProgram()!.structureIsReused === StructureIsReused.Completely
)
)
) {
// Dont send the configFileDiag
this.triggerFileForConfigFileDiag = undefined;
}
else if (!this.triggerFileForConfigFileDiag) {
// If we arent tracking to send configFileDiag, send event if diagnostics presence has changed
this.projectService.sendConfigFileDiagEvent(this, /*triggerFile*/ undefined, /*force*/ false);
}
return result;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,6 @@ Info seq [hh:mm:ss:mss] request:
"type": "request"
}
Info seq [hh:mm:ss:mss] Finding references to /packages/b/index.ts position 12 in project /packages/b/tsconfig.json
Info seq [hh:mm:ss:mss] Loading configured project /tsconfig.json
Info seq [hh:mm:ss:mss] event:
{
"seq": 0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1364,6 +1364,23 @@ Info seq [hh:mm:ss:mss] Files (2)
/user/username/rootfolder/otherfolder/a/b/app.ts SVC-1-0 "import _ from 'lodash';"

Info seq [hh:mm:ss:mss] -----------------------------------------------
Info seq [hh:mm:ss:mss] event:
{
"seq": 0,
"type": "event",
"event": "configFileDiag",
"body": {
"triggerFile": "/user/username/rootfolder/otherfolder/a/b/tsconfig.json",
"configFile": "/user/username/rootfolder/otherfolder/a/b/tsconfig.json",
"diagnostics": [
{
"text": "Cannot find type definition file for 'lodash'.\n The file is in the program because:\n Entry point for implicit type library 'lodash'",
"code": 2688,
"category": "error"
}
]
}
}
Info seq [hh:mm:ss:mss] Running: *ensureProjectForOpenFiles*
Info seq [hh:mm:ss:mss] Before ensureProjectForOpenFiles:
Info seq [hh:mm:ss:mss] Project '/user/username/rootfolder/otherfolder/a/b/tsconfig.json' (Configured)
Expand Down Expand Up @@ -2212,6 +2229,17 @@ Info seq [hh:mm:ss:mss] Files (3)
Matched by default include pattern '**/*'

Info seq [hh:mm:ss:mss] -----------------------------------------------
Info seq [hh:mm:ss:mss] event:
{
"seq": 0,
"type": "event",
"event": "configFileDiag",
"body": {
"triggerFile": "/user/username/rootfolder/otherfolder/a/b/tsconfig.json",
"configFile": "/user/username/rootfolder/otherfolder/a/b/tsconfig.json",
"diagnostics": []
}
}
Info seq [hh:mm:ss:mss] Running: *ensureProjectForOpenFiles*
Info seq [hh:mm:ss:mss] Before ensureProjectForOpenFiles:
Info seq [hh:mm:ss:mss] Project '/user/username/rootfolder/otherfolder/a/b/tsconfig.json' (Configured)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,23 @@ Info seq [hh:mm:ss:mss] Files (4)
Matched by default include pattern '**/*'

Info seq [hh:mm:ss:mss] -----------------------------------------------
Info seq [hh:mm:ss:mss] event:
{
"seq": 0,
"type": "event",
"event": "configFileDiag",
"body": {
"triggerFile": "/user/username/projects/myproject/tsconfig.json",
"configFile": "/user/username/projects/myproject/tsconfig.json",
"diagnostics": [
{
"text": "Cannot write file '/user/username/projects/myproject/test/file1.d.ts' because it would overwrite input file.",
"code": 5055,
"category": "error"
}
]
}
}
Info seq [hh:mm:ss:mss] response:
{
"response": false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,23 @@ Info seq [hh:mm:ss:mss] Files (4)
Matched by default include pattern '**/*'

Info seq [hh:mm:ss:mss] -----------------------------------------------
Info seq [hh:mm:ss:mss] event:
{
"seq": 0,
"type": "event",
"event": "configFileDiag",
"body": {
"triggerFile": "/user/username/projects/myproject/tsconfig.json",
"configFile": "/user/username/projects/myproject/tsconfig.json",
"diagnostics": [
{
"text": "Cannot write file '/user/username/projects/myproject/test/file1.d.ts' because it would overwrite input file.",
"code": 5055,
"category": "error"
}
]
}
}
Info seq [hh:mm:ss:mss] response:
{
"response": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,23 @@ Info seq [hh:mm:ss:mss] Files (4)
Matched by default include pattern '**/*'

Info seq [hh:mm:ss:mss] -----------------------------------------------
Info seq [hh:mm:ss:mss] event:
{
"seq": 0,
"type": "event",
"event": "configFileDiag",
"body": {
"triggerFile": "/user/username/projects/myproject/tsconfig.json",
"configFile": "/user/username/projects/myproject/tsconfig.json",
"diagnostics": [
{
"text": "Cannot write file '/user/username/projects/myproject/test/file1.d.ts' because it would overwrite input file.",
"code": 5055,
"category": "error"
}
]
}
}
Info seq [hh:mm:ss:mss] response:
{
"response": false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,6 @@ Projects::
projectProgramVersion: 1

Info seq [hh:mm:ss:mss] Running: /a/b/projects/project/tsconfig.json
Info seq [hh:mm:ss:mss] Loading configured project /a/b/projects/project/tsconfig.json
Info seq [hh:mm:ss:mss] event:
{
"seq": 0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,6 @@ Projects::
projectProgramVersion: 1

Info seq [hh:mm:ss:mss] Running: /a/b/projects/project/tsconfig.json
Info seq [hh:mm:ss:mss] Reloading configured project /a/b/projects/project/tsconfig.json
Info seq [hh:mm:ss:mss] event:
{
"seq": 0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -645,7 +645,6 @@ Before running Timeout callback:: count: 2
3: *ensureProjectForOpenFiles*

Info seq [hh:mm:ss:mss] Running: /a/b/tsconfig.json
Info seq [hh:mm:ss:mss] Reloading configured project /a/b/tsconfig.json
Info seq [hh:mm:ss:mss] event:
{
"seq": 0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,6 @@ Projects::
projectProgramVersion: 1

Info seq [hh:mm:ss:mss] Running: /a/b/tsconfig.json
Info seq [hh:mm:ss:mss] Reloading configured project /a/b/tsconfig.json
Info seq [hh:mm:ss:mss] event:
{
"seq": 0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,6 @@ Projects::
dirty: true

Info seq [hh:mm:ss:mss] Running: /user/username/projects/myproject/tsconfig.json
Info seq [hh:mm:ss:mss] Loading configured project /user/username/projects/myproject/tsconfig.json
Info seq [hh:mm:ss:mss] event:
{
"seq": 0,
Expand Down Expand Up @@ -574,7 +573,6 @@ Projects::
deferredClose: undefined *changed*

Info seq [hh:mm:ss:mss] Running: /user/username/projects/myproject/tsconfig.json
Info seq [hh:mm:ss:mss] Reloading configured project /user/username/projects/myproject/tsconfig.json
Info seq [hh:mm:ss:mss] event:
{
"seq": 0,
Expand Down Expand Up @@ -1485,7 +1483,6 @@ Projects::
deferredClose: undefined *changed*

Info seq [hh:mm:ss:mss] Running: /user/username/projects/myproject/tsconfig.json
Info seq [hh:mm:ss:mss] Reloading configured project /user/username/projects/myproject/tsconfig.json
Info seq [hh:mm:ss:mss] event:
{
"seq": 0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,6 @@ Info seq [hh:mm:ss:mss] request:
"type": "request"
}
Info seq [hh:mm:ss:mss] getConfigFileNameForFile:: File: /user/username/projects/myproject/folder/commonFile2.ts ProjectRootPath: undefined:: Result: /user/username/projects/myproject/tsconfig.json
Info seq [hh:mm:ss:mss] Loading configured project /user/username/projects/myproject/tsconfig.json
Info seq [hh:mm:ss:mss] event:
{
"seq": 0,
Expand Down Expand Up @@ -333,7 +332,7 @@ Info seq [hh:mm:ss:mss] event:
"type": "event",
"event": "configFileDiag",
"body": {
"triggerFile": "/user/username/projects/myproject/tsconfig.json",
"triggerFile": "/user/username/projects/myproject/folder/commonFile2.ts",
"configFile": "/user/username/projects/myproject/tsconfig.json",
"diagnostics": []
}
Expand Down Expand Up @@ -421,7 +420,6 @@ Projects::

Info seq [hh:mm:ss:mss] Running: /user/username/projects/myproject/tsconfig.json
Info seq [hh:mm:ss:mss] Running: /user/username/projects/myproject/folder/tsconfig.json
Info seq [hh:mm:ss:mss] Reloading configured project /user/username/projects/myproject/folder/tsconfig.json
Info seq [hh:mm:ss:mss] event:
{
"seq": 0,
Expand Down Expand Up @@ -1290,7 +1288,6 @@ Projects::
dirty: true

Info seq [hh:mm:ss:mss] Running: /user/username/projects/myproject/tsconfig.json
Info seq [hh:mm:ss:mss] Loading configured project /user/username/projects/myproject/tsconfig.json
Info seq [hh:mm:ss:mss] event:
{
"seq": 0,
Expand Down Expand Up @@ -1512,7 +1509,6 @@ Projects::
projectProgramVersion: 1

Info seq [hh:mm:ss:mss] Running: /user/username/projects/myproject/folder/tsconfig.json
Info seq [hh:mm:ss:mss] Reloading configured project /user/username/projects/myproject/folder/tsconfig.json
Info seq [hh:mm:ss:mss] event:
{
"seq": 0,
Expand Down Expand Up @@ -2372,7 +2368,6 @@ Info seq [hh:mm:ss:mss] request:
"type": "request"
}
Info seq [hh:mm:ss:mss] getConfigFileNameForFile:: File: /user/username/projects/myproject/folder/commonFile2.ts ProjectRootPath: undefined:: Result: /user/username/projects/myproject/tsconfig.json
Info seq [hh:mm:ss:mss] Loading configured project /user/username/projects/myproject/tsconfig.json
Info seq [hh:mm:ss:mss] event:
{
"seq": 0,
Expand Down Expand Up @@ -2424,7 +2419,7 @@ Info seq [hh:mm:ss:mss] event:
"type": "event",
"event": "configFileDiag",
"body": {
"triggerFile": "/user/username/projects/myproject/tsconfig.json",
"triggerFile": "/user/username/projects/myproject/folder/commonFile2.ts",
"configFile": "/user/username/projects/myproject/tsconfig.json",
"diagnostics": []
}
Expand Down Expand Up @@ -2985,7 +2980,6 @@ Info seq [hh:mm:ss:mss] request:
"type": "request"
}
Info seq [hh:mm:ss:mss] getConfigFileNameForFile:: File: /user/username/projects/myproject/folder/commonFile2.ts ProjectRootPath: undefined:: Result: /user/username/projects/myproject/tsconfig.json
Info seq [hh:mm:ss:mss] Loading configured project /user/username/projects/myproject/tsconfig.json
Info seq [hh:mm:ss:mss] event:
{
"seq": 0,
Expand Down Expand Up @@ -3037,7 +3031,7 @@ Info seq [hh:mm:ss:mss] event:
"type": "event",
"event": "configFileDiag",
"body": {
"triggerFile": "/user/username/projects/myproject/tsconfig.json",
"triggerFile": "/user/username/projects/myproject/folder/commonFile2.ts",
"configFile": "/user/username/projects/myproject/tsconfig.json",
"diagnostics": []
}
Expand Down Expand Up @@ -3769,7 +3763,6 @@ Info seq [hh:mm:ss:mss] request:
"type": "request"
}
Info seq [hh:mm:ss:mss] getConfigFileNameForFile:: File: /user/username/projects/myproject/folder/commonFile2.ts ProjectRootPath: undefined:: Result: /user/username/projects/myproject/tsconfig.json
Info seq [hh:mm:ss:mss] Loading configured project /user/username/projects/myproject/tsconfig.json
Info seq [hh:mm:ss:mss] event:
{
"seq": 0,
Expand Down Expand Up @@ -3821,7 +3814,7 @@ Info seq [hh:mm:ss:mss] event:
"type": "event",
"event": "configFileDiag",
"body": {
"triggerFile": "/user/username/projects/myproject/tsconfig.json",
"triggerFile": "/user/username/projects/myproject/folder/commonFile2.ts",
"configFile": "/user/username/projects/myproject/tsconfig.json",
"diagnostics": []
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,6 @@ Projects::
dirty: true *changed*

Info seq [hh:mm:ss:mss] Running: /a/b/tsconfig.json
Info seq [hh:mm:ss:mss] Reloading configured project /a/b/tsconfig.json
Info seq [hh:mm:ss:mss] event:
{
"seq": 0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,6 @@ Projects::
dirty: true *changed*

Info seq [hh:mm:ss:mss] Running: /a/b/tsconfig.json
Info seq [hh:mm:ss:mss] Reloading configured project /a/b/tsconfig.json
Info seq [hh:mm:ss:mss] event:
{
"seq": 0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,6 @@ Projects::
dirty: true

Info seq [hh:mm:ss:mss] Running: /user/username/projects/myproject/a/c/tsconfig.json
Info seq [hh:mm:ss:mss] Loading configured project /user/username/projects/myproject/a/c/tsconfig.json
Info seq [hh:mm:ss:mss] event:
{
"seq": 0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,6 @@ Projects::
projectProgramVersion: 1

Info seq [hh:mm:ss:mss] Running: /a/b/tsconfig.json
Info seq [hh:mm:ss:mss] Reloading configured project /a/b/tsconfig.json
Info seq [hh:mm:ss:mss] event:
{
"seq": 0,
Expand Down
Loading