Enable going to stdlib on serverless
This commit is contained in:
parent
582f8f6bb0
commit
c3d8989b24
|
@ -33,7 +33,7 @@ export function createLazyClientHost(
|
|||
return lazy(() => {
|
||||
const clientHost = new TypeScriptServiceClientHost(
|
||||
standardLanguageDescriptions,
|
||||
context.workspaceState,
|
||||
context,
|
||||
onCaseInsenitiveFileSystem,
|
||||
services,
|
||||
onCompletionAccepted);
|
||||
|
|
|
@ -57,7 +57,7 @@ export default class TypeScriptServiceClientHost extends Disposable {
|
|||
|
||||
constructor(
|
||||
descriptions: LanguageDescription[],
|
||||
workspaceState: vscode.Memento,
|
||||
context: vscode.ExtensionContext,
|
||||
onCaseInsenitiveFileSystem: boolean,
|
||||
services: {
|
||||
pluginManager: PluginManager,
|
||||
|
@ -75,7 +75,7 @@ export default class TypeScriptServiceClientHost extends Disposable {
|
|||
|
||||
const allModeIds = this.getAllModeIds(descriptions, services.pluginManager);
|
||||
this.client = this._register(new TypeScriptServiceClient(
|
||||
workspaceState,
|
||||
context,
|
||||
onCaseInsenitiveFileSystem,
|
||||
services,
|
||||
allModeIds));
|
||||
|
|
|
@ -97,6 +97,8 @@ export default class TypeScriptServiceClient extends Disposable implements IType
|
|||
private readonly pathSeparator: string;
|
||||
private readonly inMemoryResourcePrefix = '^';
|
||||
|
||||
private readonly workspaceState: vscode.Memento;
|
||||
|
||||
private _onReady?: { promise: Promise<void>; resolve: () => void; reject: () => void; };
|
||||
private _configuration: TypeScriptServiceConfiguration;
|
||||
private pluginPathsProvider: TypeScriptPluginPathsProvider;
|
||||
|
@ -125,7 +127,7 @@ export default class TypeScriptServiceClient extends Disposable implements IType
|
|||
private readonly processFactory: TsServerProcessFactory;
|
||||
|
||||
constructor(
|
||||
private readonly workspaceState: vscode.Memento,
|
||||
private readonly context: vscode.ExtensionContext,
|
||||
onCaseInsenitiveFileSystem: boolean,
|
||||
services: {
|
||||
pluginManager: PluginManager,
|
||||
|
@ -138,6 +140,8 @@ export default class TypeScriptServiceClient extends Disposable implements IType
|
|||
) {
|
||||
super();
|
||||
|
||||
this.workspaceState = context.workspaceState;
|
||||
|
||||
this.pluginManager = services.pluginManager;
|
||||
this.logDirectoryProvider = services.logDirectoryProvider;
|
||||
this.cancellerFactory = services.cancellerFactory;
|
||||
|
@ -686,6 +690,13 @@ export default class TypeScriptServiceClient extends Disposable implements IType
|
|||
}
|
||||
|
||||
public toResource(filepath: string): vscode.Uri {
|
||||
if (isWeb()) {
|
||||
// On web, treat absolute paths as pointing to standard lib files
|
||||
if (filepath.startsWith('/')) {
|
||||
return vscode.Uri.joinPath(this.context.extensionUri, 'node_modules', 'typescript-web', 'lib', filepath.slice(1));
|
||||
}
|
||||
}
|
||||
|
||||
if (filepath.startsWith(this.inMemoryResourcePrefix)) {
|
||||
const resource = vscode.Uri.parse(filepath.slice(1));
|
||||
return this.bufferSyncSupport.toVsCodeResource(resource);
|
||||
|
|
Loading…
Reference in a new issue