Skip to content

Commit d0f3dc7

Browse files
committed
Change to object
1 parent 2145545 commit d0f3dc7

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
@@ -171,8 +171,16 @@ namespace ts.server {
171171
};
172172
}
173173

174+
export interface PluginCreateInfo {
175+
project: Project;
176+
languageService: LanguageService;
177+
serverHost: ServerHost;
178+
config: any;
179+
}
180+
174181
export interface PluginModule {
175-
create(proj: Project, languageService: LanguageService, config: any): LanguageService;
182+
create(createInfo: PluginCreateInfo): LanguageService;
183+
getExternalFiles?(proj: Project): string[];
176184
}
177185

178186
export abstract class Project {
@@ -855,6 +863,8 @@ namespace ts.server {
855863
private directoriesWatchedForWildcards: Map<FileWatcher>;
856864
private typeRootsWatchers: FileWatcher[];
857865

866+
private plugins: PluginModule[] = [];
867+
858868
/** Used for configured projects which may have multiple open roots */
859869
openRefCount = 0;
860870

@@ -902,7 +912,14 @@ namespace ts.server {
902912

903913
private enableProxy(pluginModule: PluginModule, configEntry: PluginImport) {
904914
try {
905-
this.languageService = pluginModule.create(this, this.languageService, configEntry);
915+
const info: PluginCreateInfo = {
916+
config: configEntry,
917+
project: this,
918+
languageService: this.languageService,
919+
serverHost: this.projectService.host
920+
};
921+
this.languageService = pluginModule.create(info);
922+
this.plugins.push(pluginModule);
906923
}
907924
catch (e) {
908925
this.projectService.logger.info(`Plugin activation failed: ${e}`);
@@ -930,8 +947,13 @@ namespace ts.server {
930947
}
931948

932949
getExternalFiles(): string[] {
933-
// TODO: Ask plugins for this information as well
934-
return [];
950+
const items: string[] = [];
951+
for (const plugin of this.plugins) {
952+
if (plugin.getExternalFiles) {
953+
items.push(...plugin.getExternalFiles(this));
954+
}
955+
}
956+
return items;
935957
}
936958

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

0 commit comments

Comments
 (0)