[debugger] Resolve URIs through FileSystem

This commit is contained in:
Miro Spönemann 2020-01-23 11:38:43 +01:00
parent 0f35821d14
commit 8c3fab824f
2 changed files with 17 additions and 8 deletions

View File

@ -75,7 +75,7 @@ export class ArduinoVariableResolver implements VariableContribution {
return undefined; return undefined;
} }
if (!fileStat.isDirectory && fileStat.uri.endsWith('.elf')) { if (!fileStat.isDirectory && fileStat.uri.endsWith('.elf')) {
return new URI(fileStat.uri).path.toString(); return this.fileSystem.getFsPath(fileStat.uri);
} }
let parent: FileStat | undefined; let parent: FileStat | undefined;
@ -106,7 +106,7 @@ export class ArduinoVariableResolver implements VariableContribution {
bin = parent.children.find(c => c.uri.endsWith('.elf')); bin = parent.children.find(c => c.uri.endsWith('.elf'));
} }
if (bin) { if (bin) {
return new URI(bin.uri).path.toString(); return this.fileSystem.getFsPath(bin.uri);
} }
} }
this.messageService.error('Cannot find sketch binary: ' + hint); this.messageService.error('Cannot find sketch binary: ' + hint);
@ -187,7 +187,7 @@ export class ArduinoVariableResolver implements VariableContribution {
} }
} }
return boardsConfig.selectedBoard.name; return undefined;
} }
} }

View File

@ -2,6 +2,7 @@ import * as PQueue from 'p-queue';
import { injectable, inject, postConstruct, named } from 'inversify'; import { injectable, inject, postConstruct, named } from 'inversify';
import { ILogger } from '@theia/core/lib/common/logger'; import { ILogger } from '@theia/core/lib/common/logger';
import { Deferred } from '@theia/core/lib/common/promise-util'; import { Deferred } from '@theia/core/lib/common/promise-util';
import { FileSystem } from '@theia/filesystem/lib/common';
import { import {
BoardsService, AttachedSerialBoard, BoardPackage, Board, AttachedNetworkBoard, BoardsServiceClient, BoardsService, AttachedSerialBoard, BoardPackage, Board, AttachedNetworkBoard, BoardsServiceClient,
Port, BoardDetails, Tool, ToolLocations, BoardDetailLocations Port, BoardDetails, Tool, ToolLocations, BoardDetailLocations
@ -16,7 +17,6 @@ import { ToolOutputServiceServer } from '../common/protocol/tool-output-service'
import { Installable } from '../common/protocol/installable'; import { Installable } from '../common/protocol/installable';
import { ConfigService } from '../common/protocol/config-service'; import { ConfigService } from '../common/protocol/config-service';
import * as path from 'path'; import * as path from 'path';
import URI from '@theia/core/lib/common/uri';
@injectable() @injectable()
export class BoardsServiceImpl implements BoardsService { export class BoardsServiceImpl implements BoardsService {
@ -37,6 +37,9 @@ export class BoardsServiceImpl implements BoardsService {
@inject(ConfigService) @inject(ConfigService)
protected readonly configService: ConfigService; protected readonly configService: ConfigService;
@inject(FileSystem)
protected readonly fileSystem: FileSystem;
protected discoveryInitialized = false; protected discoveryInitialized = false;
protected discoveryTimer: NodeJS.Timer | undefined; 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 // TODO: these location should come from the CLI/daemon rather than us botching them together
protected async getBoardLocations(details: BoardDetailsResp): Promise<BoardDetailLocations | undefined> { protected async getBoardLocations(details: BoardDetailsResp): Promise<BoardDetailLocations | undefined> {
const config = await this.configService.getConfiguration(); 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 { return {
debugScript: path.join(datadir, "packages", "arduino", "hardware", "samd", "1.8.4", "variants", "arduino_zero", "openocd_scripts", "arduino_zero.cfg") 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 // 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<ToolLocations | undefined> {
const config = await this.configService.getConfiguration(); const config = await this.configService.getConfiguration();
const datadir = new URI(config.dataDirUri).path.toString(); const datadir = await this.fileSystem.getFsPath(config.dataDirUri);
const toolBasePath = path.join(datadir, "packages", "arduino", "tools"); if (!datadir) {
return undefined;
}
const toolBasePath = path.join(datadir, "packages", "arduino", "tools");
let loc: ToolLocations = { let loc: ToolLocations = {
main: path.join(toolBasePath, t.getName(), t.getVersion()) main: path.join(toolBasePath, t.getName(), t.getVersion())
}; };