Make RelativeWorkspacePathResolver a static class

This commit is contained in:
Matt Bierner
2019-06-24 16:27:17 -07:00
parent 8119b4aee7
commit e32e2a90c5
3 changed files with 3 additions and 5 deletions

View File

@@ -9,7 +9,6 @@ import { RelativeWorkspacePathResolver } from './relativePathResolver';
export class TypeScriptPluginPathsProvider {
public readonly relativePathResolver: RelativeWorkspacePathResolver = new RelativeWorkspacePathResolver();
public constructor(
private configuration: TypeScriptServiceConfiguration
@@ -32,7 +31,7 @@ export class TypeScriptPluginPathsProvider {
return [pluginPath];
}
const workspacePath = this.relativePathResolver.asAbsoluteWorkspacePath(pluginPath);
const workspacePath = RelativeWorkspacePathResolver.asAbsoluteWorkspacePath(pluginPath);
if (workspacePath !== undefined) {
return [workspacePath];
}

View File

@@ -6,7 +6,7 @@ import * as path from 'path';
import * as vscode from 'vscode';
export class RelativeWorkspacePathResolver {
public asAbsoluteWorkspacePath(relativePath: string): string | undefined {
public static asAbsoluteWorkspacePath(relativePath: string): string | undefined {
for (const root of vscode.workspace.workspaceFolders || []) {
const rootPrefixes = [`./${root.name}/`, `${root.name}/`, `.\\${root.name}\\`, `${root.name}\\`];
for (const rootPrefix of rootPrefixes) {

View File

@@ -88,7 +88,6 @@ export class TypeScriptVersion {
}
export class TypeScriptVersionProvider {
private readonly relativePathResolver: RelativeWorkspacePathResolver = new RelativeWorkspacePathResolver();
public constructor(
private configuration: TypeScriptServiceConfiguration
@@ -179,7 +178,7 @@ export class TypeScriptVersionProvider {
return [new TypeScriptVersion(tsdkPathSetting)];
}
const workspacePath = this.relativePathResolver.asAbsoluteWorkspacePath(tsdkPathSetting);
const workspacePath = RelativeWorkspacePathResolver.asAbsoluteWorkspacePath(tsdkPathSetting);
if (workspacePath !== undefined) {
return [new TypeScriptVersion(workspacePath, tsdkPathSetting)];
}