@@ -19,46 +19,47 @@ import { CoreService } from '../../common/protocol';
1919@injectable ( )
2020export class VerifySketch extends CoreServiceContribution {
2121 @inject ( BoardsDataStore )
22- private readonly boardsDataStore : BoardsDataStore ;
22+ protected readonly boardsDataStore : BoardsDataStore ;
2323
2424 @inject ( BoardsServiceProvider )
2525 private readonly boardsServiceProvider : BoardsServiceProvider ;
2626
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 ;
2930 private verifyInProgress = false ;
3031
3132 override registerCommands ( registry : CommandRegistry ) : void {
32- registry . registerCommand ( VerifySketch . Commands . VERIFY_SKETCH , {
33+ registry . registerCommand ( VerifySketchCommands . VERIFY_SKETCH , {
3334 execute : async ( exportBinaries ?: boolean ) => {
3435 return this . verifySketch ( exportBinaries ) ;
3536 } ,
3637 isEnabled : ( ) => ! this . verifyInProgress ,
3738 } ) ;
38- registry . registerCommand ( VerifySketch . Commands . EXPORT_BINARIES , {
39+ registry . registerCommand ( VerifySketchCommands . EXPORT_BINARIES , {
3940 execute : async ( ) => {
4041 return this . verifySketch ( true ) ;
4142 } ,
4243 isEnabled : ( ) => ! this . verifyInProgress ,
4344 } ) ;
44- registry . registerCommand ( VerifySketch . Commands . VERIFY_SKETCH_TOOLBAR , {
45+ registry . registerCommand ( VerifySketchCommands . VERIFY_SKETCH_TOOLBAR , {
4546 isVisible : ( widget ) =>
4647 ArduinoToolbar . is ( widget ) && widget . side === 'left' ,
4748 isEnabled : ( ) => ! this . verifyInProgress ,
4849 isToggled : ( ) => this . verifyInProgress ,
4950 execute : ( ) =>
50- registry . executeCommand ( VerifySketch . Commands . VERIFY_SKETCH . id ) ,
51+ registry . executeCommand ( VerifySketchCommands . VERIFY_SKETCH . id ) ,
5152 } ) ;
5253 }
5354
5455 override registerMenus ( registry : MenuModelRegistry ) : void {
5556 registry . registerMenuAction ( ArduinoMenus . SKETCH__MAIN_GROUP , {
56- commandId : VerifySketch . Commands . VERIFY_SKETCH . id ,
57+ commandId : VerifySketchCommands . VERIFY_SKETCH . id ,
5758 label : nls . localize ( 'arduino/sketch/verifyOrCompile' , 'Verify/Compile' ) ,
5859 order : '0' ,
5960 } ) ;
6061 registry . registerMenuAction ( ArduinoMenus . SKETCH__MAIN_GROUP , {
61- commandId : VerifySketch . Commands . EXPORT_BINARIES . id ,
62+ commandId : VerifySketchCommands . EXPORT_BINARIES . id ,
6263 label : nls . localize (
6364 'arduino/sketch/exportBinary' ,
6465 'Export Compiled Binary'
@@ -69,43 +70,43 @@ export class VerifySketch extends CoreServiceContribution {
6970
7071 override registerKeybindings ( registry : KeybindingRegistry ) : void {
7172 registry . registerKeybinding ( {
72- command : VerifySketch . Commands . VERIFY_SKETCH . id ,
73+ command : VerifySketchCommands . VERIFY_SKETCH . id ,
7374 keybinding : 'CtrlCmd+R' ,
7475 } ) ;
7576 registry . registerKeybinding ( {
76- command : VerifySketch . Commands . EXPORT_BINARIES . id ,
77+ command : VerifySketchCommands . EXPORT_BINARIES . id ,
7778 keybinding : 'CtrlCmd+Alt+S' ,
7879 } ) ;
7980 }
8081
8182 override registerToolbarItems ( registry : TabBarToolbarRegistry ) : void {
8283 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 ,
8586 tooltip : nls . localize ( 'arduino/sketch/verify' , 'Verify' ) ,
8687 priority : 0 ,
87- onDidChange : this . onDidChange ,
88+ onDidChange : this . onVerifyInProgressDidChange ,
8889 } ) ;
8990 }
9091
91- private async verifySketch (
92+ protected async verifySketch (
9293 exportBinaries ?: boolean
93- ) : Promise < undefined | VerifySketch . Ref > {
94+ ) : Promise < undefined | VerifyParams > {
9495 if ( this . verifyInProgress ) {
9596 return undefined ;
9697 }
9798
9899 const originalFqbn =
99100 this . boardsServiceProvider . boardsConfig . selectedBoard ?. fqbn ;
100- const options = await this . options ( exportBinaries ) ;
101+ const options = await this . verifyOptions ( exportBinaries ) ;
101102 if ( ! options ) {
102103 return undefined ;
103104 }
104105
105106 try {
106107 this . verifyInProgress = true ;
107108 this . coreErrorHandler . reset ( ) ;
108- this . onDidChangeEmitter . fire ( ) ;
109+ this . onVerifyInProgressDidChangeEmitter . fire ( ) ;
109110 await this . doWithProgress ( {
110111 progressText : nls . localize (
111112 'arduino/sketch/compile' ,
@@ -132,11 +133,11 @@ export class VerifySketch extends CoreServiceContribution {
132133 return undefined ;
133134 } finally {
134135 this . verifyInProgress = false ;
135- this . onDidChangeEmitter . fire ( ) ;
136+ this . onVerifyInProgressDidChangeEmitter . fire ( ) ;
136137 }
137138 }
138139
139- private async options (
140+ private async verifyOptions (
140141 exportBinaries ?: boolean
141142 ) : Promise < CoreService . Options . Compile | undefined > {
142143 const sketch = await this . sketchServiceClient . currentSketch ( ) ;
@@ -165,20 +166,18 @@ export class VerifySketch extends CoreServiceContribution {
165166 }
166167}
167168
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+ } ;
184179}
180+ export type VerifyParams = CoreService . Options . SketchBased &
181+ Readonly < {
182+ fqbn : { original ?: string | undefined ; decorated ?: string | undefined } ;
183+ } > ;
0 commit comments