@@ -244,46 +244,4 @@ export class Editor {
244244 throw e ;
245245 }
246246 }
247-
248- private getComponentNamesImpl ( componentClassName : string ) : string [ ] {
249- if ( ! this . projectContent ) {
250- throw new Error ( 'getComponentNames: this.projectContent is null.' ) ;
251- }
252- const components = commonStorage . extractComponents ( this . projectContent ) ;
253-
254- // TODO(lizlooney): Remove this fake code after getComponents (above) has been implemented.
255- components . push ( { name : 'frontTouch' , className : 'rev_touch_sensor.RevTouchSensor' } ) ;
256- components . push ( { name : 'backTouch' , className : 'rev_touch_sensor.RevTouchSensor' } ) ;
257- components . push ( { name : 'leftMotor' , className : 'smart_motor.SmartMotor' } ) ;
258- components . push ( { name : 'rightMotor' , className : 'smart_motor.SmartMotor' } ) ;
259- components . push ( { name : 'clawServo' , className : 'servo.Servo' } ) ;
260- components . push ( { name : 'colorSensor' , className : 'color_range_sensor.ColorRangeSensor' } ) ;
261- components . push ( { name : 'ledStick' , className : 'sparkfun_led_stick.SparkFunLEDStick' } ) ;
262- // End of fake code
263-
264- const componentNames : string [ ] = [ ] ;
265- components . forEach ( ( component ) => {
266- if ( component . className === componentClassName ) {
267- componentNames . push ( component . name ) ;
268- }
269- } ) ;
270- return componentNames ;
271- }
272-
273- public static getComponentNames (
274- workspace : Blockly . Workspace , componentClassName : string ) : string [ ] {
275-
276- let editor : Editor | null = null ;
277- if ( workspace . id in Editor . workspaceIdToEditor ) {
278- editor = Editor . workspaceIdToEditor [ workspace . id ] ;
279- } else {
280- // If the workspace id was not found, it might be because the workspace is associated with the
281- // toolbox flyout, not a real workspace. In that case, use the first editor.
282- const allEditors = Object . values ( Editor . workspaceIdToEditor ) ;
283- if ( allEditors . length ) {
284- editor = allEditors [ 0 ] ;
285- }
286- }
287- return editor ? editor . getComponentNamesImpl ( componentClassName ) : [ ] ;
288- }
289247}
0 commit comments