Skip to content

Commit b9b1127

Browse files
Merge pull request #18456 from RyanCavanaugh/pluginWork
Properly report external filenames
2 parents 136a3ea + 9046fcb commit b9b1127

File tree

3 files changed

+11
-5
lines changed

3 files changed

+11
-5
lines changed

src/compiler/core.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1659,7 +1659,7 @@ namespace ts {
16591659
}
16601660

16611661
export function isRootedDiskPath(path: string) {
1662-
return getRootLength(path) !== 0;
1662+
return path && getRootLength(path) !== 0;
16631663
}
16641664

16651665
export function convertToRelativePath(absoluteOrRelativePath: string, basePath: string, getCanonicalFileName: (path: string) => string): string {

src/server/editorServices.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1190,7 +1190,8 @@ namespace ts.server {
11901190
/*languageServiceEnabled*/ !sizeLimitExceeded,
11911191
projectOptions.compileOnSave === undefined ? false : projectOptions.compileOnSave);
11921192

1193-
this.addFilesToProjectAndUpdateGraph(project, projectOptions.files, fileNamePropertyReader, clientFileName, projectOptions.typeAcquisition, configFileErrors);
1193+
const filesToAdd = projectOptions.files.concat(project.getExternalFiles());
1194+
this.addFilesToProjectAndUpdateGraph(project, filesToAdd, fileNamePropertyReader, clientFileName, projectOptions.typeAcquisition, configFileErrors);
11941195

11951196
project.watchConfigFile(project => this.onConfigChangedForConfiguredProject(project));
11961197
if (!sizeLimitExceeded) {
@@ -1210,7 +1211,7 @@ namespace ts.server {
12101211
}
12111212
}
12121213

1213-
private addFilesToProjectAndUpdateGraph<T>(project: ConfiguredProject | ExternalProject, files: T[], propertyReader: FilePropertyReader<T>, clientFileName: string, typeAcquisition: TypeAcquisition, configFileErrors: ReadonlyArray<Diagnostic>): void {
1214+
private addFilesToProjectAndUpdateGraph<T>(project: ConfiguredProject | ExternalProject, files: ReadonlyArray<T>, propertyReader: FilePropertyReader<T>, clientFileName: string, typeAcquisition: TypeAcquisition, configFileErrors: ReadonlyArray<Diagnostic>): void {
12141215
let errors: Diagnostic[];
12151216
for (const f of files) {
12161217
const rootFileName = propertyReader.getFileName(f);

src/server/project.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -746,7 +746,8 @@ namespace ts.server {
746746
}
747747
// compute and return the difference
748748
const lastReportedFileNames = this.lastReportedFileNames;
749-
const currentFiles = arrayToSet(this.getFileNames());
749+
const externalFiles = this.getExternalFiles().map(f => toNormalizedPath(f));
750+
const currentFiles = arrayToSet(this.getFileNames().concat(externalFiles));
750751

751752
const added: string[] = [];
752753
const removed: string[] = [];
@@ -769,7 +770,8 @@ namespace ts.server {
769770
else {
770771
// unknown version - return everything
771772
const projectFileNames = this.getFileNames();
772-
this.lastReportedFileNames = arrayToSet(projectFileNames);
773+
const externalFiles = this.getExternalFiles().map(f => toNormalizedPath(f));
774+
this.lastReportedFileNames = arrayToSet(projectFileNames.concat(externalFiles));
773775
this.lastReportedVersion = this.projectStructureVersion;
774776
return { info, files: projectFileNames, projectErrors: this.getGlobalProjectErrors() };
775777
}
@@ -1084,6 +1086,9 @@ namespace ts.server {
10841086
}
10851087
catch (e) {
10861088
this.projectService.logger.info(`A plugin threw an exception in getExternalFiles: ${e}`);
1089+
if (e.stack) {
1090+
this.projectService.logger.info(e.stack);
1091+
}
10871092
}
10881093
}));
10891094
}

0 commit comments

Comments
 (0)