Skip to content

Commit

Permalink
workspace path acquiring implemented
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonah Iden committed Aug 31, 2022
1 parent d53824e commit cf87346
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 4 deletions.
1 change: 1 addition & 0 deletions typefox-test/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"@theia/core": "1.25.0",
"@theia/filesystem": "1.25.0",
"@theia/file-search": "1.25.0",
"@theia/workspace": "1.25.0",
"toml": "3.0.0"
},
"devDependencies": {
Expand Down
4 changes: 3 additions & 1 deletion typefox-test/src/browser/typefox-test-contribution.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { injectable, inject } from '@theia/core/shared/inversify';
import { Command, CommandContribution, CommandRegistry, MenuContribution, MenuModelRegistry} from '@theia/core/lib/common';
import { WorkspaceService } from '@theia/workspace/lib/browser'
import { CommonMenus, FrontendApplication, FrontendApplicationContribution } from '@theia/core/lib/browser';
import { IDependencyVersionCheckServer } from "../common/dependency-version-checker-protocoll";

Expand All @@ -13,11 +14,12 @@ export const dependencyVersionCheckCommand: Command = {
export class TypefoxTestCommandContribution implements CommandContribution {

@inject(IDependencyVersionCheckServer) depCheckServer: IDependencyVersionCheckServer;
@inject(WorkspaceService) workspaceService: WorkspaceService;

registerCommands(registry: CommandRegistry): void {
registry.registerCommand(dependencyVersionCheckCommand, {
execute: async () => {
const mismatches = await this.depCheckServer.analyzeDependencies();
const mismatches = await this.depCheckServer.analyzeDependencies(await this.workspaceService.tryGetRoots().map(r => r.resource.toString()));
console.log("mismatches recieved");
console.log(mismatches);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ export const servicePath = "/services/dependencyVersionChecker";

export const IDependencyVersionCheckServer = Symbol.for("DependencyVersionCheckerServer")
export interface IDependencyVersionCheckServer {
analyzeDependencies(): Promise<string[]>;
analyzeDependencies(rootPath: string[]): Promise<string[]>;
}
4 changes: 2 additions & 2 deletions typefox-test/src/node/dependency-version-checker-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ export class DependencyVersionCheckerServer implements IDependencyVersionCheckSe
/**
* analyzes the dependencies from the cargo.toml and returns a list of mismatches
*/
async analyzeDependencies(): Promise<string[]> {
async analyzeDependencies(rootPaths: string[]): Promise<string[]> {
// this path is hardcoded right now for my local test workspace because i couldn't figure out where to get the acutal path from
const cargoTomlFiles: string[] = await this.fileSearchService.find("cargo.toml", {rootUris: ["d:/Projekte/Kleinere_Projekte/Rust"]});
const cargoTomlFiles: string[] = await this.fileSearchService.find("cargo.toml", {rootUris: rootPaths});
const allDependencies: Dependency[] = []
for(let path of cargoTomlFiles) {
const tomlData = toml.parse(await this.getFileContent(path));
Expand Down

0 comments on commit cf87346

Please sign in to comment.