Merge pull request #18456 from RyanCavanaugh/pluginWork

Properly report external filenames
This commit is contained in:
Ryan Cavanaugh
2017-09-20 10:51:54 -07:00
committed by GitHub
3 changed files with 11 additions and 5 deletions

View File

@@ -1659,7 +1659,7 @@ namespace ts {
}
export function isRootedDiskPath(path: string) {
return getRootLength(path) !== 0;
return path && getRootLength(path) !== 0;
}
export function convertToRelativePath(absoluteOrRelativePath: string, basePath: string, getCanonicalFileName: (path: string) => string): string {

View File

@@ -1190,7 +1190,8 @@ namespace ts.server {
/*languageServiceEnabled*/ !sizeLimitExceeded,
projectOptions.compileOnSave === undefined ? false : projectOptions.compileOnSave);
this.addFilesToProjectAndUpdateGraph(project, projectOptions.files, fileNamePropertyReader, clientFileName, projectOptions.typeAcquisition, configFileErrors);
const filesToAdd = projectOptions.files.concat(project.getExternalFiles());
this.addFilesToProjectAndUpdateGraph(project, filesToAdd, fileNamePropertyReader, clientFileName, projectOptions.typeAcquisition, configFileErrors);
project.watchConfigFile(project => this.onConfigChangedForConfiguredProject(project));
if (!sizeLimitExceeded) {
@@ -1210,7 +1211,7 @@ namespace ts.server {
}
}
private addFilesToProjectAndUpdateGraph<T>(project: ConfiguredProject | ExternalProject, files: T[], propertyReader: FilePropertyReader<T>, clientFileName: string, typeAcquisition: TypeAcquisition, configFileErrors: ReadonlyArray<Diagnostic>): void {
private addFilesToProjectAndUpdateGraph<T>(project: ConfiguredProject | ExternalProject, files: ReadonlyArray<T>, propertyReader: FilePropertyReader<T>, clientFileName: string, typeAcquisition: TypeAcquisition, configFileErrors: ReadonlyArray<Diagnostic>): void {
let errors: Diagnostic[];
for (const f of files) {
const rootFileName = propertyReader.getFileName(f);

View File

@@ -746,7 +746,8 @@ namespace ts.server {
}
// compute and return the difference
const lastReportedFileNames = this.lastReportedFileNames;
const currentFiles = arrayToSet(this.getFileNames());
const externalFiles = this.getExternalFiles().map(f => toNormalizedPath(f));
const currentFiles = arrayToSet(this.getFileNames().concat(externalFiles));
const added: string[] = [];
const removed: string[] = [];
@@ -769,7 +770,8 @@ namespace ts.server {
else {
// unknown version - return everything
const projectFileNames = this.getFileNames();
this.lastReportedFileNames = arrayToSet(projectFileNames);
const externalFiles = this.getExternalFiles().map(f => toNormalizedPath(f));
this.lastReportedFileNames = arrayToSet(projectFileNames.concat(externalFiles));
this.lastReportedVersion = this.projectStructureVersion;
return { info, files: projectFileNames, projectErrors: this.getGlobalProjectErrors() };
}
@@ -1084,6 +1086,9 @@ namespace ts.server {
}
catch (e) {
this.projectService.logger.info(`A plugin threw an exception in getExternalFiles: ${e}`);
if (e.stack) {
this.projectService.logger.info(e.stack);
}
}
}));
}