From 8c3fab824fccd85f642059c0ebf2914f6f7e0212 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miro=20Sp=C3=B6nemann?= Date: Thu, 23 Jan 2020 11:38:43 +0100 Subject: [PATCH] [debugger] Resolve URIs through FileSystem --- .../src/browser/arduino-variable-resolver.ts | 6 +++--- .../src/node/boards-service-impl.ts | 19 ++++++++++++++----- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/arduino-debugger-extension/src/browser/arduino-variable-resolver.ts b/arduino-debugger-extension/src/browser/arduino-variable-resolver.ts index be5c0434..806cff4e 100644 --- a/arduino-debugger-extension/src/browser/arduino-variable-resolver.ts +++ b/arduino-debugger-extension/src/browser/arduino-variable-resolver.ts @@ -75,7 +75,7 @@ export class ArduinoVariableResolver implements VariableContribution { return undefined; } if (!fileStat.isDirectory && fileStat.uri.endsWith('.elf')) { - return new URI(fileStat.uri).path.toString(); + return this.fileSystem.getFsPath(fileStat.uri); } let parent: FileStat | undefined; @@ -106,7 +106,7 @@ export class ArduinoVariableResolver implements VariableContribution { bin = parent.children.find(c => c.uri.endsWith('.elf')); } if (bin) { - return new URI(bin.uri).path.toString(); + return this.fileSystem.getFsPath(bin.uri); } } this.messageService.error('Cannot find sketch binary: ' + hint); @@ -187,7 +187,7 @@ export class ArduinoVariableResolver implements VariableContribution { } } - return boardsConfig.selectedBoard.name; + return undefined; } } diff --git a/arduino-ide-extension/src/node/boards-service-impl.ts b/arduino-ide-extension/src/node/boards-service-impl.ts index 83fa9678..fd2bfbf2 100644 --- a/arduino-ide-extension/src/node/boards-service-impl.ts +++ b/arduino-ide-extension/src/node/boards-service-impl.ts @@ -2,6 +2,7 @@ import * as PQueue from 'p-queue'; import { injectable, inject, postConstruct, named } from 'inversify'; import { ILogger } from '@theia/core/lib/common/logger'; import { Deferred } from '@theia/core/lib/common/promise-util'; +import { FileSystem } from '@theia/filesystem/lib/common'; import { BoardsService, AttachedSerialBoard, BoardPackage, Board, AttachedNetworkBoard, BoardsServiceClient, Port, BoardDetails, Tool, ToolLocations, BoardDetailLocations @@ -16,7 +17,6 @@ import { ToolOutputServiceServer } from '../common/protocol/tool-output-service' import { Installable } from '../common/protocol/installable'; import { ConfigService } from '../common/protocol/config-service'; import * as path from 'path'; -import URI from '@theia/core/lib/common/uri'; @injectable() export class BoardsServiceImpl implements BoardsService { @@ -37,6 +37,9 @@ export class BoardsServiceImpl implements BoardsService { @inject(ConfigService) protected readonly configService: ConfigService; + @inject(FileSystem) + protected readonly fileSystem: FileSystem; + protected discoveryInitialized = false; protected discoveryTimer: NodeJS.Timer | undefined; /** @@ -251,7 +254,10 @@ export class BoardsServiceImpl implements BoardsService { // TODO: these location should come from the CLI/daemon rather than us botching them together protected async getBoardLocations(details: BoardDetailsResp): Promise { const config = await this.configService.getConfiguration(); - const datadir = new URI(config.dataDirUri).path.toString(); + const datadir = await this.fileSystem.getFsPath(config.dataDirUri); + if (!datadir) { + return undefined; + } return { debugScript: path.join(datadir, "packages", "arduino", "hardware", "samd", "1.8.4", "variants", "arduino_zero", "openocd_scripts", "arduino_zero.cfg") @@ -259,11 +265,14 @@ export class BoardsServiceImpl implements BoardsService { } // TODO: these location should come from the CLI/daemon rather than us botching them together - protected async getToolLocations(t: RequiredTool) { + protected async getToolLocations(t: RequiredTool): Promise { const config = await this.configService.getConfiguration(); - const datadir = new URI(config.dataDirUri).path.toString(); - const toolBasePath = path.join(datadir, "packages", "arduino", "tools"); + const datadir = await this.fileSystem.getFsPath(config.dataDirUri); + if (!datadir) { + return undefined; + } + const toolBasePath = path.join(datadir, "packages", "arduino", "tools"); let loc: ToolLocations = { main: path.join(toolBasePath, t.getName(), t.getVersion()) };