Skip to content

Commit 05b2506

Browse files
author
Andy
authored
Expose ProjectService to plugins (microsoft#23824)
Add refreshDiagnostics() method to Project
1 parent e39e6fc commit 05b2506

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

src/server/editorServices.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -577,7 +577,8 @@ namespace ts.server {
577577
return this.pendingProjectUpdates.has(project.getProjectName());
578578
}
579579

580-
private sendProjectsUpdatedInBackgroundEvent() {
580+
/* @internal */
581+
sendProjectsUpdatedInBackgroundEvent() {
581582
if (!this.eventHandler) {
582583
return;
583584
}

src/server/project.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ namespace ts.server {
164164
return hasOneOrMoreJsAndNoTsFiles(this);
165165
}
166166

167-
public static resolveModule(moduleName: string, initialDir: string, host: ServerHost, log: (message: string) => void): {} {
167+
public static resolveModule(moduleName: string, initialDir: string, host: ServerHost, log: (message: string) => void): {} | undefined {
168168
const resolvedPath = normalizeSlashes(host.resolvePath(combinePaths(initialDir, "node_modules")));
169169
log(`Loading ${moduleName} from ${initialDir} (resolved to ${resolvedPath})`);
170170
const result = host.require(resolvedPath, moduleName);
@@ -1102,6 +1102,11 @@ namespace ts.server {
11021102
}
11031103
}
11041104

1105+
/** Starts a new check for diagnostics. Call this if some file has updated that would cause diagnostics to be changed. */
1106+
refreshDiagnostics() {
1107+
this.projectService.sendProjectsUpdatedInBackgroundEvent();
1108+
}
1109+
11051110
private enableProxy(pluginModuleFactory: PluginModuleFactory, configEntry: PluginImport) {
11061111
try {
11071112
if (typeof pluginModuleFactory !== "function") {

tests/baselines/reference/api/tsserverlibrary.d.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7748,7 +7748,7 @@ declare namespace ts.server {
77487748
private readonly cancellationToken;
77497749
isNonTsProject(): boolean;
77507750
isJsOnlyProject(): boolean;
7751-
static resolveModule(moduleName: string, initialDir: string, host: ServerHost, log: (message: string) => void): {};
7751+
static resolveModule(moduleName: string, initialDir: string, host: ServerHost, log: (message: string) => void): {} | undefined;
77527752
isKnownTypesPackageName(name: string): boolean;
77537753
installPackage(options: InstallPackageOptions): Promise<ApplyCodeActionCommandResult>;
77547754
private readonly typingsCache;
@@ -7829,6 +7829,8 @@ declare namespace ts.server {
78297829
protected removeRoot(info: ScriptInfo): void;
78307830
protected enableGlobalPlugins(): void;
78317831
protected enablePlugin(pluginConfigEntry: PluginImport, searchPaths: string[]): void;
7832+
/** Starts a new check for diagnostics. Call this if some file has updated that would cause diagnostics to be changed. */
7833+
refreshDiagnostics(): void;
78327834
private enableProxy;
78337835
}
78347836
/**
@@ -8081,7 +8083,6 @@ declare namespace ts.server {
80818083
updateTypingsForProject(response: SetTypings | InvalidateCachedTypings | PackageInstalledResponse): void;
80828084
private delayEnsureProjectForOpenFiles;
80838085
private delayUpdateProjectGraph;
8084-
private sendProjectsUpdatedInBackgroundEvent;
80858086
private delayUpdateProjectGraphs;
80868087
setCompilerOptionsForInferredProjects(projectCompilerOptions: protocol.ExternalProjectCompilerOptions, projectRootPath?: string): void;
80878088
findProject(projectName: string): Project | undefined;

0 commit comments

Comments
 (0)