@@ -19,46 +19,47 @@ import { CoreService } from '../../common/protocol';
19
19
@injectable ( )
20
20
export class VerifySketch extends CoreServiceContribution {
21
21
@inject ( BoardsDataStore )
22
- private readonly boardsDataStore : BoardsDataStore ;
22
+ protected readonly boardsDataStore : BoardsDataStore ;
23
23
24
24
@inject ( BoardsServiceProvider )
25
25
private readonly boardsServiceProvider : BoardsServiceProvider ;
26
26
27
- private readonly onDidChangeEmitter = new Emitter < void > ( ) ;
28
- private readonly onDidChange = this . onDidChangeEmitter . event ;
27
+ private readonly onVerifyInProgressDidChangeEmitter = new Emitter < void > ( ) ;
28
+ private readonly onVerifyInProgressDidChange =
29
+ this . onVerifyInProgressDidChangeEmitter . event ;
29
30
private verifyInProgress = false ;
30
31
31
32
override registerCommands ( registry : CommandRegistry ) : void {
32
- registry . registerCommand ( VerifySketch . Commands . VERIFY_SKETCH , {
33
+ registry . registerCommand ( VerifySketchCommands . VERIFY_SKETCH , {
33
34
execute : async ( exportBinaries ?: boolean ) => {
34
35
return this . verifySketch ( exportBinaries ) ;
35
36
} ,
36
37
isEnabled : ( ) => ! this . verifyInProgress ,
37
38
} ) ;
38
- registry . registerCommand ( VerifySketch . Commands . EXPORT_BINARIES , {
39
+ registry . registerCommand ( VerifySketchCommands . EXPORT_BINARIES , {
39
40
execute : async ( ) => {
40
41
return this . verifySketch ( true ) ;
41
42
} ,
42
43
isEnabled : ( ) => ! this . verifyInProgress ,
43
44
} ) ;
44
- registry . registerCommand ( VerifySketch . Commands . VERIFY_SKETCH_TOOLBAR , {
45
+ registry . registerCommand ( VerifySketchCommands . VERIFY_SKETCH_TOOLBAR , {
45
46
isVisible : ( widget ) =>
46
47
ArduinoToolbar . is ( widget ) && widget . side === 'left' ,
47
48
isEnabled : ( ) => ! this . verifyInProgress ,
48
49
isToggled : ( ) => this . verifyInProgress ,
49
50
execute : ( ) =>
50
- registry . executeCommand ( VerifySketch . Commands . VERIFY_SKETCH . id ) ,
51
+ registry . executeCommand ( VerifySketchCommands . VERIFY_SKETCH . id ) ,
51
52
} ) ;
52
53
}
53
54
54
55
override registerMenus ( registry : MenuModelRegistry ) : void {
55
56
registry . registerMenuAction ( ArduinoMenus . SKETCH__MAIN_GROUP , {
56
- commandId : VerifySketch . Commands . VERIFY_SKETCH . id ,
57
+ commandId : VerifySketchCommands . VERIFY_SKETCH . id ,
57
58
label : nls . localize ( 'arduino/sketch/verifyOrCompile' , 'Verify/Compile' ) ,
58
59
order : '0' ,
59
60
} ) ;
60
61
registry . registerMenuAction ( ArduinoMenus . SKETCH__MAIN_GROUP , {
61
- commandId : VerifySketch . Commands . EXPORT_BINARIES . id ,
62
+ commandId : VerifySketchCommands . EXPORT_BINARIES . id ,
62
63
label : nls . localize (
63
64
'arduino/sketch/exportBinary' ,
64
65
'Export Compiled Binary'
@@ -69,43 +70,43 @@ export class VerifySketch extends CoreServiceContribution {
69
70
70
71
override registerKeybindings ( registry : KeybindingRegistry ) : void {
71
72
registry . registerKeybinding ( {
72
- command : VerifySketch . Commands . VERIFY_SKETCH . id ,
73
+ command : VerifySketchCommands . VERIFY_SKETCH . id ,
73
74
keybinding : 'CtrlCmd+R' ,
74
75
} ) ;
75
76
registry . registerKeybinding ( {
76
- command : VerifySketch . Commands . EXPORT_BINARIES . id ,
77
+ command : VerifySketchCommands . EXPORT_BINARIES . id ,
77
78
keybinding : 'CtrlCmd+Alt+S' ,
78
79
} ) ;
79
80
}
80
81
81
82
override registerToolbarItems ( registry : TabBarToolbarRegistry ) : void {
82
83
registry . registerItem ( {
83
- id : VerifySketch . Commands . VERIFY_SKETCH_TOOLBAR . id ,
84
- command : VerifySketch . Commands . VERIFY_SKETCH_TOOLBAR . id ,
84
+ id : VerifySketchCommands . VERIFY_SKETCH_TOOLBAR . id ,
85
+ command : VerifySketchCommands . VERIFY_SKETCH_TOOLBAR . id ,
85
86
tooltip : nls . localize ( 'arduino/sketch/verify' , 'Verify' ) ,
86
87
priority : 0 ,
87
- onDidChange : this . onDidChange ,
88
+ onDidChange : this . onVerifyInProgressDidChange ,
88
89
} ) ;
89
90
}
90
91
91
- private async verifySketch (
92
+ protected async verifySketch (
92
93
exportBinaries ?: boolean
93
- ) : Promise < undefined | VerifySketch . Ref > {
94
+ ) : Promise < undefined | VerifyParams > {
94
95
if ( this . verifyInProgress ) {
95
96
return undefined ;
96
97
}
97
98
98
99
const originalFqbn =
99
100
this . boardsServiceProvider . boardsConfig . selectedBoard ?. fqbn ;
100
- const options = await this . options ( exportBinaries ) ;
101
+ const options = await this . verifyOptions ( exportBinaries ) ;
101
102
if ( ! options ) {
102
103
return undefined ;
103
104
}
104
105
105
106
try {
106
107
this . verifyInProgress = true ;
107
108
this . coreErrorHandler . reset ( ) ;
108
- this . onDidChangeEmitter . fire ( ) ;
109
+ this . onVerifyInProgressDidChangeEmitter . fire ( ) ;
109
110
await this . doWithProgress ( {
110
111
progressText : nls . localize (
111
112
'arduino/sketch/compile' ,
@@ -132,11 +133,11 @@ export class VerifySketch extends CoreServiceContribution {
132
133
return undefined ;
133
134
} finally {
134
135
this . verifyInProgress = false ;
135
- this . onDidChangeEmitter . fire ( ) ;
136
+ this . onVerifyInProgressDidChangeEmitter . fire ( ) ;
136
137
}
137
138
}
138
139
139
- private async options (
140
+ private async verifyOptions (
140
141
exportBinaries ?: boolean
141
142
) : Promise < CoreService . Options . Compile | undefined > {
142
143
const sketch = await this . sketchServiceClient . currentSketch ( ) ;
@@ -165,20 +166,18 @@ export class VerifySketch extends CoreServiceContribution {
165
166
}
166
167
}
167
168
168
- export namespace VerifySketch {
169
- export namespace Commands {
170
- export const VERIFY_SKETCH : Command = {
171
- id : 'arduino-verify-sketch' ,
172
- } ;
173
- export const EXPORT_BINARIES : Command = {
174
- id : 'arduino-export-binaries' ,
175
- } ;
176
- export const VERIFY_SKETCH_TOOLBAR : Command = {
177
- id : 'arduino-verify-sketch--toolbar' ,
178
- } ;
179
- }
180
- export type Ref = CoreService . Options . SketchBased &
181
- Readonly < {
182
- fqbn : { original ?: string | undefined ; decorated ?: string | undefined } ;
183
- } > ;
169
+ export namespace VerifySketchCommands {
170
+ export const VERIFY_SKETCH : Command = {
171
+ id : 'arduino-verify-sketch' ,
172
+ } ;
173
+ export const EXPORT_BINARIES : Command = {
174
+ id : 'arduino-export-binaries' ,
175
+ } ;
176
+ export const VERIFY_SKETCH_TOOLBAR : Command = {
177
+ id : 'arduino-verify-sketch--toolbar' ,
178
+ } ;
184
179
}
180
+ export type VerifyParams = CoreService . Options . SketchBased &
181
+ Readonly < {
182
+ fqbn : { original ?: string | undefined ; decorated ?: string | undefined } ;
183
+ } > ;
0 commit comments