mirror of
https://github.com/arduino/arduino-ide.git
synced 2025-07-25 20:26:38 +00:00
Improved creation of default debug configurations
This commit is contained in:
parent
a886a106f5
commit
36ac97d95d
@ -4,13 +4,36 @@ import { injectable } from "inversify";
|
|||||||
@injectable()
|
@injectable()
|
||||||
export class ArduinoDebugConfigurationManager extends DebugConfigurationManager {
|
export class ArduinoDebugConfigurationManager extends DebugConfigurationManager {
|
||||||
|
|
||||||
async addConfiguration() {
|
get defaultDebugger(): Promise<string | undefined> {
|
||||||
const { model } = this;
|
return this.debug.getDebuggersForLanguage('ino').then(debuggers => {
|
||||||
if (!model) {
|
if (debuggers.length === 0)
|
||||||
return;
|
return undefined;
|
||||||
}
|
return debuggers[0].type;
|
||||||
await this.doCreate(model);
|
});
|
||||||
await this.updateModels();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
protected async selectDebugType(): Promise<string | undefined> {
|
||||||
|
const widget = this.editorManager.currentEditor;
|
||||||
|
if (!widget) {
|
||||||
|
return this.defaultDebugger;
|
||||||
|
}
|
||||||
|
const { languageId } = widget.editor.document;
|
||||||
|
const debuggers = await this.debug.getDebuggersForLanguage(languageId);
|
||||||
|
if (debuggers.length === 0) {
|
||||||
|
return this.defaultDebugger;
|
||||||
|
}
|
||||||
|
return this.quickPick.show(debuggers.map(
|
||||||
|
({ label, type }) => ({ label, value: type }),
|
||||||
|
{ placeholder: 'Select Environment' })
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
async createDefaultConfiguration(): Promise<void> {
|
||||||
|
const { model } = this;
|
||||||
|
if (model) {
|
||||||
|
await this.doCreate(model);
|
||||||
|
await this.updateModels();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
@ -2,9 +2,10 @@ import { injectable, inject } from 'inversify';
|
|||||||
import { MenuModelRegistry } from '@theia/core';
|
import { MenuModelRegistry } from '@theia/core';
|
||||||
import { KeybindingRegistry } from '@theia/core/lib/browser';
|
import { KeybindingRegistry } from '@theia/core/lib/browser';
|
||||||
import { TabBarToolbarRegistry } from '@theia/core/lib/browser/shell/tab-bar-toolbar';
|
import { TabBarToolbarRegistry } from '@theia/core/lib/browser/shell/tab-bar-toolbar';
|
||||||
import { DebugFrontendApplicationContribution } from '@theia/debug/lib/browser/debug-frontend-application-contribution';
|
import { DebugFrontendApplicationContribution, DebugCommands } from '@theia/debug/lib/browser/debug-frontend-application-contribution';
|
||||||
import { DebugSessionOptions } from "@theia/debug/lib/browser/debug-session-options";
|
import { DebugSessionOptions } from "@theia/debug/lib/browser/debug-session-options";
|
||||||
import { EditorMode } from "arduino-ide-extension/lib/browser/editor-mode";
|
import { EditorMode } from "arduino-ide-extension/lib/browser/editor-mode";
|
||||||
|
import { ArduinoDebugConfigurationManager } from './arduino-debug-configuration-manager';
|
||||||
|
|
||||||
@injectable()
|
@injectable()
|
||||||
export class ArduinoDebugFrontendApplicationContribution extends DebugFrontendApplicationContribution {
|
export class ArduinoDebugFrontendApplicationContribution extends DebugFrontendApplicationContribution {
|
||||||
@ -13,12 +14,12 @@ export class ArduinoDebugFrontendApplicationContribution extends DebugFrontendAp
|
|||||||
protected readonly editorMode: EditorMode;
|
protected readonly editorMode: EditorMode;
|
||||||
|
|
||||||
async start(noDebug?: boolean, debugSessionOptions?: DebugSessionOptions): Promise<void> {
|
async start(noDebug?: boolean, debugSessionOptions?: DebugSessionOptions): Promise<void> {
|
||||||
let current = debugSessionOptions ? debugSessionOptions : this.configurations.current;
|
const configurations = this.configurations as ArduinoDebugConfigurationManager;
|
||||||
// If no configurations are currently present, create the `launch.json` and prompt users to select the config.
|
let current = debugSessionOptions ? debugSessionOptions : configurations.current;
|
||||||
|
// If no configurations are currently present, create them
|
||||||
if (!current) {
|
if (!current) {
|
||||||
await this.configurations.addConfiguration();
|
await configurations.createDefaultConfiguration();
|
||||||
await this.configurations.load()
|
current = configurations.current;
|
||||||
current = this.configurations.current;
|
|
||||||
}
|
}
|
||||||
if (current) {
|
if (current) {
|
||||||
if (noDebug !== undefined) {
|
if (noDebug !== undefined) {
|
||||||
@ -35,24 +36,33 @@ export class ArduinoDebugFrontendApplicationContribution extends DebugFrontendAp
|
|||||||
}
|
}
|
||||||
|
|
||||||
initializeLayout(): Promise<void> {
|
initializeLayout(): Promise<void> {
|
||||||
if (this.editorMode.proMode)
|
if (this.editorMode.proMode) {
|
||||||
return super.initializeLayout();
|
return super.initializeLayout();
|
||||||
|
}
|
||||||
return Promise.resolve();
|
return Promise.resolve();
|
||||||
}
|
}
|
||||||
|
|
||||||
registerMenus(menus: MenuModelRegistry): void {
|
registerMenus(menus: MenuModelRegistry): void {
|
||||||
if (this.editorMode.proMode)
|
if (this.editorMode.proMode) {
|
||||||
super.registerMenus(menus);
|
super.registerMenus(menus);
|
||||||
|
menus.unregisterMenuAction(DebugCommands.START_NO_DEBUG);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
registerKeybindings(keybindings: KeybindingRegistry): void {
|
registerKeybindings(keybindings: KeybindingRegistry): void {
|
||||||
if (this.editorMode.proMode)
|
if (this.editorMode.proMode) {
|
||||||
super.registerKeybindings(keybindings);
|
super.registerKeybindings(keybindings);
|
||||||
|
keybindings.unregisterKeybinding({
|
||||||
|
command: DebugCommands.START_NO_DEBUG.id,
|
||||||
|
keybinding: 'ctrl+f5'
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
registerToolbarItems(toolbar: TabBarToolbarRegistry): void {
|
registerToolbarItems(toolbar: TabBarToolbarRegistry): void {
|
||||||
if (this.editorMode.proMode)
|
if (this.editorMode.proMode) {
|
||||||
super.registerToolbarItems(toolbar);
|
super.registerToolbarItems(toolbar);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user