Updated code to current version

This commit is contained in:
Miro Spönemann 2019-12-17 14:58:48 +01:00
parent 2ffca88c02
commit 38ab95973e
4 changed files with 39 additions and 43 deletions

View File

@ -1,10 +1,17 @@
import { injectable } from "inversify"; import { injectable, inject } from 'inversify';
import { MenuModelRegistry } from '@theia/core';
import { KeybindingRegistry } from '@theia/core/lib/browser';
import { TabBarToolbarRegistry } from '@theia/core/lib/browser/shell/tab-bar-toolbar';
import { DebugFrontendApplicationContribution } from '@theia/debug/lib/browser/debug-frontend-application-contribution'; import { DebugFrontendApplicationContribution } 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";
@injectable() @injectable()
export class ArduinoDebugFrontendApplicationContribution extends DebugFrontendApplicationContribution { export class ArduinoDebugFrontendApplicationContribution extends DebugFrontendApplicationContribution {
@inject(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; let current = debugSessionOptions ? debugSessionOptions : this.configurations.current;
// If no configurations are currently present, create the `launch.json` and prompt users to select the config. // If no configurations are currently present, create the `launch.json` and prompt users to select the config.
@ -27,4 +34,25 @@ export class ArduinoDebugFrontendApplicationContribution extends DebugFrontendAp
} }
} }
} initializeLayout(): Promise<void> {
if (this.editorMode.proMode)
return super.initializeLayout();
return Promise.resolve();
}
registerMenus(menus: MenuModelRegistry): void {
if (this.editorMode.proMode)
super.registerMenus(menus);
}
registerKeybindings(keybindings: KeybindingRegistry): void {
if (this.editorMode.proMode)
super.registerKeybindings(keybindings);
}
registerToolbarItems(toolbar: TabBarToolbarRegistry): void {
if (this.editorMode.proMode)
super.registerToolbarItems(toolbar);
}
}

View File

@ -1,9 +1,7 @@
import { ContainerModule } from 'inversify'; import { ContainerModule } from 'inversify';
import { VariableContribution } from '@theia/variable-resolver/lib/browser'; import { VariableContribution } from '@theia/variable-resolver/lib/browser';
import { ArduinoVariableResolver } from './arduino-variable-resolver'; import { ArduinoVariableResolver } from './arduino-variable-resolver';
import { ArduinoAdvancedMode } from 'arduino-ide-extension/lib/browser/arduino-frontend-contribution';
import { DebugFrontendApplicationContribution } from '@theia/debug/lib/browser/debug-frontend-application-contribution'; import { DebugFrontendApplicationContribution } from '@theia/debug/lib/browser/debug-frontend-application-contribution';
import { SilentDebugFrontendApplicationContribution } from './silent-debug-frontend-application-contribution';
import { DebugConfigurationManager } from '@theia/debug/lib/browser/debug-configuration-manager'; import { DebugConfigurationManager } from '@theia/debug/lib/browser/debug-configuration-manager';
import { ArduinoDebugConfigurationManager } from './arduino-debug-configuration-manager'; import { ArduinoDebugConfigurationManager } from './arduino-debug-configuration-manager';
import { ArduinoDebugFrontendApplicationContribution } from './arduino-debug-frontend-application-contribution'; import { ArduinoDebugFrontendApplicationContribution } from './arduino-debug-frontend-application-contribution';
@ -11,14 +9,6 @@ import { ArduinoDebugFrontendApplicationContribution } from './arduino-debug-fro
export default new ContainerModule((bind, unbind, isBound, rebind) => { export default new ContainerModule((bind, unbind, isBound, rebind) => {
bind(ArduinoVariableResolver).toSelf().inSingletonScope(); bind(ArduinoVariableResolver).toSelf().inSingletonScope();
bind(VariableContribution).toService(ArduinoVariableResolver); bind(VariableContribution).toService(ArduinoVariableResolver);
rebind(DebugConfigurationManager).to(ArduinoDebugConfigurationManager).inSingletonScope();
if (!ArduinoAdvancedMode.TOGGLED) { rebind(DebugFrontendApplicationContribution).to(ArduinoDebugFrontendApplicationContribution);
unbind(DebugFrontendApplicationContribution);
bind(DebugFrontendApplicationContribution).to(SilentDebugFrontendApplicationContribution);
} else {
unbind(DebugConfigurationManager);
bind(DebugConfigurationManager).to(ArduinoDebugConfigurationManager).inSingletonScope();
unbind(DebugFrontendApplicationContribution);
bind(DebugFrontendApplicationContribution).to(ArduinoDebugFrontendApplicationContribution);
}
}); });

View File

@ -1,25 +0,0 @@
import { injectable } from "inversify";
import { DebugFrontendApplicationContribution } from '@theia/debug/lib/browser/debug-frontend-application-contribution';
import { MenuModelRegistry, CommandRegistry } from "@theia/core";
import { KeybindingRegistry } from "@theia/core/lib/browser";
import { TabBarToolbarRegistry } from "@theia/core/lib/browser/shell/tab-bar-toolbar";
@injectable()
export class SilentDebugFrontendApplicationContribution extends DebugFrontendApplicationContribution {
async initializeLayout(): Promise<void> {
}
registerMenus(menus: MenuModelRegistry): void {
}
registerCommands(registry: CommandRegistry): void {
}
registerKeybindings(keybindings: KeybindingRegistry): void {
}
registerToolbarItems(toolbar: TabBarToolbarRegistry): void {
}
}

View File

@ -32,7 +32,7 @@ import { CmsisBackend } from './cmsis-backend';
// import { PyocdServer } from './pyocd-server'; // import { PyocdServer } from './pyocd-server';
import { PortScanner } from './port-scanner'; import { PortScanner } from './port-scanner';
import { SymbolTable } from './symbols'; import { SymbolTable } from './symbols';
import * as varMgr from 'cdt-gdb-adapter/dist/varManager'; import { VarManager } from 'cdt-gdb-adapter/dist/varManager';
import * as mi from './mi'; import * as mi from './mi';
import { OpenocdServer } from './openocd-server'; import { OpenocdServer } from './openocd-server';
@ -54,13 +54,16 @@ export class CmsisDebugSession extends GDBDebugSession {
protected portScanner = new PortScanner(); protected portScanner = new PortScanner();
protected symbolTable!: SymbolTable; protected symbolTable!: SymbolTable;
protected globalHandle!: number; protected globalHandle!: number;
protected varMgr: VarManager;
constructor() { constructor() {
super(); super();
} }
protected createBackend(): GDBBackend { protected createBackend(): GDBBackend {
return new CmsisBackend(); const gdb = new CmsisBackend();
this.varMgr = new VarManager(gdb);
return gdb;
} }
protected async launchRequest(response: DebugProtocol.LaunchResponse, args: CmsisRequestArguments): Promise<void> { protected async launchRequest(response: DebugProtocol.LaunchResponse, args: CmsisRequestArguments): Promise<void> {
@ -334,7 +337,7 @@ export class CmsisDebugSession extends GDBDebugSession {
} }
private async getVariables(frame: FrameReference, name: string, expression: string, depth: number): Promise<DebugProtocol.Variable> { private async getVariables(frame: FrameReference, name: string, expression: string, depth: number): Promise<DebugProtocol.Variable> {
let global = varMgr.getVar(frame.frameId, frame.threadId, depth, name); let global = this.varMgr.getVar(frame.frameId, frame.threadId, depth, name);
if (global) { if (global) {
// Update value if it is already loaded // Update value if it is already loaded
@ -351,7 +354,7 @@ export class CmsisDebugSession extends GDBDebugSession {
expression, expression,
}); });
global = varMgr.addVar(frame.frameId, frame.threadId, depth, name, true, false, varCreateResponse); global = this.varMgr.addVar(frame.frameId, frame.threadId, depth, name, true, false, varCreateResponse);
} }
return { return {