mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-06-11 10:46:28 -05:00
Rename through all projects with the same file symLink
This commit is contained in:
@@ -213,6 +213,10 @@ namespace ts.server {
|
||||
/*@internal*/
|
||||
readonly isDynamic: boolean;
|
||||
|
||||
/*@internal*/
|
||||
/** Set to real path if path is different from info.path */
|
||||
private realpath: Path | undefined;
|
||||
|
||||
constructor(
|
||||
private readonly host: ServerHost,
|
||||
readonly fileName: NormalizedPath,
|
||||
@@ -224,6 +228,7 @@ namespace ts.server {
|
||||
this.textStorage = new TextStorage(host, fileName);
|
||||
if (hasMixedContent || this.isDynamic) {
|
||||
this.textStorage.reload("");
|
||||
this.realpath = this.path;
|
||||
}
|
||||
this.scriptKind = scriptKind
|
||||
? scriptKind
|
||||
@@ -264,6 +269,30 @@ namespace ts.server {
|
||||
return this.textStorage.getSnapshot();
|
||||
}
|
||||
|
||||
private ensureRealPath() {
|
||||
if (this.realpath === undefined) {
|
||||
// Default is just the path
|
||||
this.realpath = this.path;
|
||||
if (this.host.realpath) {
|
||||
Debug.assert(!!this.containingProjects.length);
|
||||
const project = this.containingProjects[0];
|
||||
const realpath = this.host.realpath(this.path);
|
||||
if (realpath) {
|
||||
this.realpath = project.toPath(realpath);
|
||||
// If it is different from this.path, add to the map
|
||||
if (this.realpath !== this.path) {
|
||||
project.projectService.realpathToScriptInfos.add(this.realpath, this);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*@internal*/
|
||||
getRealpathIfDifferent(): Path | undefined {
|
||||
return this.realpath && this.realpath !== this.path ? this.realpath : undefined;
|
||||
}
|
||||
|
||||
getFormatCodeSettings() {
|
||||
return this.formatCodeSettings;
|
||||
}
|
||||
@@ -272,6 +301,9 @@ namespace ts.server {
|
||||
const isNew = !this.isAttached(project);
|
||||
if (isNew) {
|
||||
this.containingProjects.push(project);
|
||||
if (!project.getCompilerOptions().preserveSymlinks) {
|
||||
this.ensureRealPath();
|
||||
}
|
||||
}
|
||||
return isNew;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user