aligned rename with the java IDE.

Signed-off-by: Akos Kitta <kittaakos@typefox.io>
This commit is contained in:
Akos Kitta
2020-08-01 15:31:12 +02:00
parent 111ba7fef3
commit ada0f4c7ed
4 changed files with 74 additions and 18 deletions

View File

@@ -1,5 +1,4 @@
import { inject, injectable } from 'inversify';
import URI from '@theia/core/lib/common/uri';
import { notEmpty } from '@theia/core/lib/common/objects';
import { FileSystem } from '@theia/filesystem/lib/common';
import { MessageService } from '@theia/core/lib/common/message-service';
@@ -35,7 +34,7 @@ export class SketchesServiceClientImpl {
async currentSketchFile(): Promise<string | undefined> {
const sketch = await this.currentSketch();
if (sketch) {
const uri = new URI(sketch.uri).resolve(`${sketch.name}.ino`).toString();
const uri = sketch.mainFileUri;
const exists = await this.fileSystem.exists(uri);
if (!exists) {
this.messageService.warn(`Could not find sketch file: ${uri}`);

View File

@@ -54,11 +54,15 @@ export namespace Sketch {
export function is(arg: any): arg is Sketch {
return !!arg && 'name' in arg && 'uri' in arg && typeof arg.name === 'string' && typeof arg.uri === 'string';
}
export namespace Extensions {
export const MAIN = ['.ino', '.pde'];
export const SOURCE = ['.c', '.cpp', '.s'];
export const ADDITIONAL = ['.h', '.c', '.hpp', '.hh', '.cpp', '.s'];
export const ALL = Array.from(new Set([...MAIN, ...SOURCE, ...ADDITIONAL]));
}
export function isInSketch(uri: string, sketch: Sketch): boolean {
const { mainFileUri, otherSketchFileUris, additionalFileUris } = sketch;
return [mainFileUri, ...otherSketchFileUris, additionalFileUris].indexOf(uri) !== -1;
}
}
export namespace Extensions {
export const MAIN = ['.ino', '.pde'];
export const SOURCE = ['.c', '.cpp', '.s'];
export const ADDITIONAL = ['.h', '.c', '.hpp', '.hh', '.cpp', '.s'];
export const ALL = Array.from(new Set([...MAIN, ...SOURCE, ...ADDITIONAL]));
}