Revert "Use special prefix to tell TS that a resource is in-memory only (#42001)"

This reverts commit 00f0f2c896.
This commit is contained in:
kieferrm 2018-01-22 21:21:12 -08:00
parent 7fbd338784
commit 200e401357
2 changed files with 15 additions and 27 deletions

View file

@ -48,7 +48,10 @@ class SyncedBuffer {
}
if (this.client.apiVersion.has230Features()) {
args.projectRootPath = this.client.getWorkspaceRootForResource(this.document.uri);
const root = this.client.getWorkspaceRootForResource(this.document.uri);
if (root) {
args.projectRootPath = root;
}
}
if (this.client.apiVersion.has240Features()) {

View file

@ -578,12 +578,12 @@ export default class TypeScriptServiceClient implements ITypeScriptServiceClient
}
public normalizePath(resource: Uri): string | null {
if (this._apiVersion.has213Features()) {
if (resource.scheme === fileSchemes.walkThroughSnippet || resource.scheme === fileSchemes.untitled) {
const dirName = path.dirname(resource.path);
const fileName = this.inMemoryResourcePrefix + path.basename(resource.path);
return resource.with({ path: path.join(dirName, fileName) }).toString(true);
}
if (resource.scheme === fileSchemes.walkThroughSnippet) {
return resource.toString();
}
if (resource.scheme === fileSchemes.untitled && this._apiVersion.has213Features()) {
return resource.toString();
}
if (resource.scheme !== fileSchemes.file) {
@ -599,24 +599,11 @@ export default class TypeScriptServiceClient implements ITypeScriptServiceClient
return result.replace(new RegExp('\\' + this.pathSeparator, 'g'), '/');
}
private get inMemoryResourcePrefix(): string {
return this._apiVersion.has270Features() ? '^' : '';
}
public asUrl(filepath: string): Uri {
if (this._apiVersion.has213Features()) {
if (filepath.startsWith(TypeScriptServiceClient.WALK_THROUGH_SNIPPET_SCHEME_COLON) || (filepath.startsWith(fileSchemes.untitled + ':'))
) {
let resource = Uri.parse(filepath);
if (this.inMemoryResourcePrefix) {
const dirName = path.dirname(resource.path);
const fileName = path.basename(resource.path);
if (fileName.startsWith(this.inMemoryResourcePrefix)) {
resource = resource.with({ path: path.join(dirName, fileName.slice(this.inMemoryResourcePrefix.length)) });
}
}
return resource;
}
if (filepath.startsWith(TypeScriptServiceClient.WALK_THROUGH_SNIPPET_SCHEME_COLON)
|| (filepath.startsWith(fileSchemes.untitled + ':') && this._apiVersion.has213Features())
) {
return Uri.parse(filepath);
}
return Uri.file(filepath);
}
@ -633,10 +620,8 @@ export default class TypeScriptServiceClient implements ITypeScriptServiceClient
return root.uri.fsPath;
}
}
return roots[0].uri.fsPath;
}
return undefined;
return roots[0].uri.fsPath;
}
public execute(command: string, args: any, expectsResultOrToken?: boolean | CancellationToken): Promise<any> {