Skip to content

Commit 1c52714

Browse files
committed
Change to object
1 parent 2bf02b0 commit 1c52714

File tree

3 files changed

+29
-6
lines changed

3 files changed

+29
-6
lines changed

src/harness/fourslash.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,9 +248,10 @@ namespace FourSlash {
248248
static mockResolveModule(moduleName: string, _initialDir: string, _host: ts.server.ServerHost, log: (message: string) => void): ts.server.PluginModule {
249249
log(`Mock resolving ${moduleName}`);
250250
return {
251-
create(_proj: any, langSvc: any, _config: any) {
251+
create(info: ts.server.PluginCreateInfo) {
252252
// tslint:disable-next-line:no-null-keyword
253253
const proxy = Object.create(null);
254+
const langSvc: any = info.languageService;
254255
for (const k of Object.keys(langSvc)) {
255256
proxy[k] = function () {
256257
return langSvc[k].apply(langSvc, arguments);

src/harness/harness.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2028,5 +2028,5 @@ namespace Harness {
20282028
return { unitName: libFile, content: io.readFile(libFile) };
20292029
}
20302030

2031-
if (Error) (<any>Error).stackTraceLimit = 20;
2031+
if (Error) (<any>Error).stackTraceLimit = 1;
20322032
}

src/server/project.ts

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,16 @@ namespace ts.server {
9090
}
9191
}
9292

93+
export interface PluginCreateInfo {
94+
project: Project;
95+
languageService: LanguageService;
96+
serverHost: ServerHost;
97+
config: any;
98+
}
99+
93100
export interface PluginModule {
94-
create(proj: Project, languageService: LanguageService, config: any): LanguageService;
101+
create(createInfo: PluginCreateInfo): LanguageService;
102+
getExternalFiles?(proj: Project): string[];
95103
}
96104

97105
export abstract class Project {
@@ -763,6 +771,8 @@ namespace ts.server {
763771
private directoriesWatchedForWildcards: Map<FileWatcher>;
764772
private typeRootsWatchers: FileWatcher[];
765773

774+
private plugins: PluginModule[] = [];
775+
766776
/** Used for configured projects which may have multiple open roots */
767777
openRefCount = 0;
768778

@@ -806,7 +816,14 @@ namespace ts.server {
806816

807817
private enableProxy(pluginModule: PluginModule, configEntry: PluginImport) {
808818
try {
809-
this.languageService = pluginModule.create(this, this.languageService, configEntry);
819+
const info: PluginCreateInfo = {
820+
config: configEntry,
821+
project: this,
822+
languageService: this.languageService,
823+
serverHost: this.projectService.host
824+
};
825+
this.languageService = pluginModule.create(info);
826+
this.plugins.push(pluginModule);
810827
}
811828
catch (e) {
812829
this.projectService.logger.info(`Plugin activation failed: ${e}`);
@@ -834,8 +851,13 @@ namespace ts.server {
834851
}
835852

836853
getExternalFiles(): string[] {
837-
// TODO: Ask plugins for this information as well
838-
return [];
854+
const items: string[] = [];
855+
for (const plugin of this.plugins) {
856+
if (plugin.getExternalFiles) {
857+
items.push(...plugin.getExternalFiles(this));
858+
}
859+
}
860+
return items;
839861
}
840862

841863
watchConfigFile(callback: (project: ConfiguredProject) => void) {

0 commit comments

Comments
 (0)