Skip to content

Commit ee54c65

Browse files
committed
fixing linting problemas
1 parent f8215dd commit ee54c65

File tree

1 file changed

+36
-30
lines changed

1 file changed

+36
-30
lines changed

editors/code/src/dependencies_provider.ts

Lines changed: 36 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,15 @@ import { CtxInit } from "./ctx";
55
import * as ra from "./lsp_ext";
66
import { FetchDependencyGraphResult } from "./lsp_ext";
77

8-
export class RustDependenciesProvider
9-
implements vscode.TreeDataProvider<Dependency | DependencyFile> {
10-
dependenciesMap: { [id: string]: Dependency | DependencyFile };
11-
ctx: CtxInit;
128

13-
constructor(private readonly workspaceRoot: string, ctx: CtxInit) {
14-
this.dependenciesMap = {};
9+
10+
export class RustDependenciesProvider implements vscode.TreeDataProvider<Dependency | DependencyFile>{
11+
12+
dependenciesMap: { [id: string]: Dependency | DependencyFile };ctx: CtxInit;
13+
14+
constructor(
15+
private readonly workspaceRoot: string,ctx: CtxInit) {
16+
this.dependenciesMap = {};
1517
this.ctx = ctx;
1618
}
1719

@@ -47,25 +49,31 @@ export class RustDependenciesProvider
4749
return element;
4850
}
4951

50-
getChildren(
51-
element?: Dependency | DependencyFile
52-
): vscode.ProviderResult<Dependency[] | DependencyFile[]> {
52+
getChildren(element?: Dependency | DependencyFile): vscode.ProviderResult<Dependency[] | DependencyFile[]> {
5353
return new Promise((resolve, _reject) => {
5454
if (!this.workspaceRoot) {
5555
void vscode.window.showInformationMessage("No dependency in empty workspace");
5656
return Promise.resolve([]);
5757
}
58+
5859
if (element) {
5960
const files = fs.readdirSync(element.dependencyPath).map((fileName) => {
6061
const filePath = fspath.join(element.dependencyPath, fileName);
6162
const collapsibleState = fs.lstatSync(filePath).isDirectory()
6263
? vscode.TreeItemCollapsibleState.Collapsed
63-
: vscode.TreeItemCollapsibleState.None;
64-
const dep = new DependencyFile(fileName, filePath, element, collapsibleState);
64+
:vscode.TreeItemCollapsibleState.None;
65+
const dep = new DependencyFile(
66+
fileName,
67+
filePath,
68+
element,
69+
collapsibleState);
70+
6571
this.dependenciesMap[dep.dependencyPath.toLowerCase()] = dep;
6672
return dep;
6773
});
68-
return resolve(files);
74+
return resolve(
75+
files
76+
);
6977
} else {
7078
return resolve(this.getRootDependencies());
7179
}
@@ -75,25 +83,24 @@ export class RustDependenciesProvider
7583
private async getRootDependencies(): Promise<Dependency[]> {
7684
const dependenciesResult: FetchDependencyGraphResult = await this.ctx.client.sendRequest(ra.fetchDependencyGraph, {});
7785
const crates = dependenciesResult.crates;
78-
7986
const deps = crates.map((crate) => {
80-
const dep = this.toDep(crate.name, crate.version, crate.path);
87+
const dep = this.toDep(crate.name, crate.version, crate.path);
8188
this.dependenciesMap[dep.dependencyPath.toLowerCase()] = dep;
82-
this.dependenciesMap[stdlib.dependencyPath.toLowerCase()] = stdlib;
83-
return dep;
89+
this.dependenciesMap[stdlib.dependencyPath.toLowerCase()] = stdlib;
90+
return dep;
8491
});
8592
return deps;
8693
}
8794

88-
private toDep(moduleName: string, version: string, path: string): Dependency {
89-
// const cratePath = fspath.join(basePath, `${moduleName}-${version}`);
90-
return new Dependency(
91-
moduleName,
92-
version,
93-
path,
94-
vscode.TreeItemCollapsibleState.Collapsed
95-
);
96-
}
95+
private toDep(moduleName: string, version: string, path: string): Dependency {
96+
//const cratePath = fspath.join(basePath, `${moduleName}-${version}`);
97+
return new Dependency(
98+
moduleName,
99+
version,
100+
path,
101+
vscode.TreeItemCollapsibleState.Collapsed
102+
);
103+
}
97104
}
98105

99106
export class Dependency extends vscode.TreeItem {
@@ -111,6 +118,7 @@ export class Dependency extends vscode.TreeItem {
111118
}
112119

113120
export class DependencyFile extends vscode.TreeItem {
121+
114122
constructor(
115123
readonly label: string,
116124
readonly dependencyPath: string,
@@ -121,13 +129,11 @@ export class DependencyFile extends vscode.TreeItem {
121129
const isDir = fs.lstatSync(this.dependencyPath).isDirectory();
122130
this.id = this.dependencyPath.toLowerCase();
123131
if (!isDir) {
124-
this.command = {
125-
command: "vscode.open",
132+
this.command = { command: "vscode.open",
126133
title: "Open File",
127134
arguments: [vscode.Uri.file(this.dependencyPath)],
128-
};
129-
}
130-
}
135+
};
136+
}}
131137
}
132138

133139
export type DependencyId = { id: string };

0 commit comments

Comments
 (0)