Skip to content

Commit 14b71e4

Browse files
author
Akos Kitta
committed
Reveal the error location after on failed verify.
Closes #608 Closes #229 Signed-off-by: Akos Kitta <[email protected]>
1 parent 4c62431 commit 14b71e4

24 files changed

+1548
-393
lines changed

Diff for: arduino-ide-extension/src/browser/arduino-ide-frontend-module.ts

+4
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,8 @@ import { PreferenceTreeGenerator } from './theia/preferences/preference-tree-gen
291291
import { PreferenceTreeGenerator as TheiaPreferenceTreeGenerator } from '@theia/preferences/lib/browser/util/preference-tree-generator';
292292
import { AboutDialog } from './theia/core/about-dialog';
293293
import { AboutDialog as TheiaAboutDialog } from '@theia/core/lib/browser/about-dialog';
294+
import { CoreErrorHandler } from './contributions/core-error-handler';
295+
import { CompilerErrors } from './contributions/compiler-errors';
294296

295297
MonacoThemingService.register({
296298
id: 'arduino-theme',
@@ -423,6 +425,7 @@ export default new ContainerModule((bind, unbind, isBound, rebind) => {
423425
)
424426
)
425427
.inSingletonScope();
428+
bind(CoreErrorHandler).toSelf().inSingletonScope();
426429

427430
// Serial monitor
428431
bind(MonitorWidget).toSelf();
@@ -670,6 +673,7 @@ export default new ContainerModule((bind, unbind, isBound, rebind) => {
670673
Contribution.configure(bind, AddZipLibrary);
671674
Contribution.configure(bind, PlotterFrontendContribution);
672675
Contribution.configure(bind, Format);
676+
Contribution.configure(bind, CompilerErrors);
673677

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

Diff for: arduino-ide-extension/src/browser/arduino-preferences.ts

+45
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(
@@ -180,6 +223,8 @@ export const ArduinoConfigSchema: PreferenceSchema = {
180223
export interface ArduinoConfiguration {
181224
'arduino.language.log': boolean;
182225
'arduino.compile.verbose': boolean;
226+
'arduino.compile.experimental': boolean;
227+
'arduino.compile.revealRange': ErrorRevealStrategy;
183228
'arduino.compile.warnings': CompilerWarnings;
184229
'arduino.upload.verbose': boolean;
185230
'arduino.upload.verify': boolean;

Diff for: arduino-ide-extension/src/browser/contributions/burn-bootloader.ts

+4-19
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)