Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit fbf3fc6

Browse files
authoredJun 21, 2022
Merge branch 'main' into 1032-uploads-failing-with-monitor-open
2 parents 3830ba2 + 4611381 commit fbf3fc6

26 files changed

+1622
-396
lines changed
 

‎arduino-ide-extension/src/browser/arduino-ide-frontend-module.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,10 @@ import {
296296
SurveyNotificationService,
297297
SurveyNotificationServicePath,
298298
} from '../common/protocol/survey-service';
299+
import { WindowContribution } from './theia/core/window-contribution';
300+
import { WindowContribution as TheiaWindowContribution } from '@theia/core/lib/browser/window-contribution';
301+
import { CoreErrorHandler } from './contributions/core-error-handler';
302+
import { CompilerErrors } from './contributions/compiler-errors';
299303

300304
MonacoThemingService.register({
301305
id: 'arduino-theme',
@@ -428,6 +432,7 @@ export default new ContainerModule((bind, unbind, isBound, rebind) => {
428432
)
429433
)
430434
.inSingletonScope();
435+
bind(CoreErrorHandler).toSelf().inSingletonScope();
431436

432437
// Serial monitor
433438
bind(MonitorWidget).toSelf();
@@ -605,6 +610,10 @@ export default new ContainerModule((bind, unbind, isBound, rebind) => {
605610
bind(OutputToolbarContribution).toSelf().inSingletonScope();
606611
rebind(TheiaOutputToolbarContribution).toService(OutputToolbarContribution);
607612

613+
// To remove `New Window` from the `File` menu
614+
bind(WindowContribution).toSelf().inSingletonScope();
615+
rebind(TheiaWindowContribution).toService(WindowContribution);
616+
608617
bind(ArduinoDaemon)
609618
.toDynamicValue((context) =>
610619
WebSocketConnectionProvider.createProxy(
@@ -688,6 +697,7 @@ export default new ContainerModule((bind, unbind, isBound, rebind) => {
688697
Contribution.configure(bind, AddZipLibrary);
689698
Contribution.configure(bind, PlotterFrontendContribution);
690699
Contribution.configure(bind, Format);
700+
Contribution.configure(bind, CompilerErrors);
691701

692702
// Disabled the quick-pick customization from Theia when multiple formatters are available.
693703
// Use the default VS Code behavior, and pick the first one. In the IDE2, clang-format has `exclusive` selectors.

‎arduino-ide-extension/src/browser/arduino-preferences.ts

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,32 @@ export enum UpdateChannel {
1313
Stable = 'stable',
1414
Nightly = 'nightly',
1515
}
16+
export const ErrorRevealStrategyLiterals = [
17+
/**
18+
* Scroll vertically as necessary and reveal a line.
19+
*/
20+
'auto',
21+
/**
22+
* Scroll vertically as necessary and reveal a line centered vertically.
23+
*/
24+
'center',
25+
/**
26+
* Scroll vertically as necessary and reveal a line close to the top of the viewport, optimized for viewing a code definition.
27+
*/
28+
'top',
29+
/**
30+
* Scroll vertically as necessary and reveal a line centered vertically only if it lies outside the viewport.
31+
*/
32+
'centerIfOutsideViewport',
33+
] as const;
34+
export type ErrorRevealStrategy = typeof ErrorRevealStrategyLiterals[number];
35+
export namespace ErrorRevealStrategy {
36+
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any
37+
export function is(arg: any): arg is ErrorRevealStrategy {
38+
return !!arg && ErrorRevealStrategyLiterals.includes(arg);
39+
}
40+
export const Default: ErrorRevealStrategy = 'centerIfOutsideViewport';
41+
}
1642

1743
export const ArduinoConfigSchema: PreferenceSchema = {
1844
type: 'object',
@@ -33,6 +59,23 @@ export const ArduinoConfigSchema: PreferenceSchema = {
3359
),
3460
default: false,
3561
},
62+
'arduino.compile.experimental': {
63+
type: 'boolean',
64+
description: nls.localize(
65+
'arduino/preferences/compile.experimental',
66+
'True if the IDE should handle multiple compiler errors. False by default'
67+
),
68+
default: false,
69+
},
70+
'arduino.compile.revealRange': {
71+
enum: [...ErrorRevealStrategyLiterals],
72+
description: nls.localize(
73+
'arduino/preferences/compile.revealRange',
74+
"Adjusts how compiler errors are revealed in the editor after a failed verify/upload. Possible values: 'auto': Scroll vertically as necessary and reveal a line. 'center': Scroll vertically as necessary and reveal a line centered vertically. 'top': Scroll vertically as necessary and reveal a line close to the top of the viewport, optimized for viewing a code definition. 'centerIfOutsideViewport': Scroll vertically as necessary and reveal a line centered vertically only if it lies outside the viewport. The default value is '{0}'.",
75+
ErrorRevealStrategy.Default
76+
),
77+
default: ErrorRevealStrategy.Default,
78+
},
3679
'arduino.compile.warnings': {
3780
enum: [...CompilerWarningLiterals],
3881
description: nls.localize(
@@ -182,12 +225,22 @@ export const ArduinoConfigSchema: PreferenceSchema = {
182225
),
183226
default: true,
184227
},
228+
'arduino.cli.daemon.debug': {
229+
type: 'boolean',
230+
description: nls.localize(
231+
'arduino/preferences/cli.daemonDebug',
232+
"Enable debug logging of the gRPC calls to the Arduino CLI. A restart of the IDE is needed for this setting to take effect. It's false by default."
233+
),
234+
default: false,
235+
},
185236
},
186237
};
187238

188239
export interface ArduinoConfiguration {
189240
'arduino.language.log': boolean;
190241
'arduino.compile.verbose': boolean;
242+
'arduino.compile.experimental': boolean;
243+
'arduino.compile.revealRange': ErrorRevealStrategy;
191244
'arduino.compile.warnings': CompilerWarnings;
192245
'arduino.upload.verbose': boolean;
193246
'arduino.upload.verify': boolean;
@@ -207,6 +260,7 @@ export interface ArduinoConfiguration {
207260
'arduino.auth.audience': string;
208261
'arduino.auth.registerUri': string;
209262
'arduino.survey.notification': boolean;
263+
'arduino.cli.daemon.debug': boolean;
210264
}
211265

212266
export const ArduinoPreferences = Symbol('ArduinoPreferences');

‎arduino-ide-extension/src/browser/contributions/burn-bootloader.ts

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,23 @@
11
import { inject, injectable } from '@theia/core/shared/inversify';
2-
import { OutputChannelManager } from '@theia/output/lib/browser/output-channel';
3-
import { CoreService } from '../../common/protocol';
42
import { ArduinoMenus } from '../menu/arduino-menus';
53
import { BoardsDataStore } from '../boards/boards-data-store';
64
import { BoardsServiceProvider } from '../boards/boards-service-provider';
75
import {
8-
SketchContribution,
6+
CoreServiceContribution,
97
Command,
108
CommandRegistry,
119
MenuModelRegistry,
1210
} from './contribution';
1311
import { nls } from '@theia/core/lib/common';
1412

1513
@injectable()
16-
export class BurnBootloader extends SketchContribution {
17-
@inject(CoreService)
18-
protected readonly coreService: CoreService;
19-
20-
14+
export class BurnBootloader extends CoreServiceContribution {
2115
@inject(BoardsDataStore)
2216
protected readonly boardsDataStore: BoardsDataStore;
2317

2418
@inject(BoardsServiceProvider)
2519
protected readonly boardsServiceClientImpl: BoardsServiceProvider;
2620

27-
@inject(OutputChannelManager)
28-
protected override readonly outputChannelManager: OutputChannelManager;
29-
3021
override registerCommands(registry: CommandRegistry): void {
3122
registry.registerCommand(BurnBootloader.Commands.BURN_BOOTLOADER, {
3223
execute: () => this.burnBootloader(),
@@ -62,7 +53,7 @@ export class BurnBootloader extends SketchContribution {
6253
...boardsConfig.selectedBoard,
6354
name: boardsConfig.selectedBoard?.name || '',
6455
fqbn,
65-
}
56+
};
6657
this.outputChannelManager.getChannel('Arduino').clear();
6758
await this.coreService.burnBootloader({
6859
board,
@@ -81,13 +72,7 @@ export class BurnBootloader extends SketchContribution {
8172
}
8273
);
8374
} catch (e) {
84-
let errorMessage = "";
85-
if (typeof e === "string") {
86-
errorMessage = e;
87-
} else {
88-
errorMessage = e.toString();
89-
}
90-
this.messageService.error(errorMessage);
75+
this.handleError(e);
9176
}
9277
}
9378
}

0 commit comments

Comments
 (0)
Please sign in to comment.