@@ -78,6 +78,8 @@ function getRobotMechanismsCategory(editor: Editor): toolboxItems.Category {
7878 if ( mechanisms . length ) {
7979 const mechanismBlocks : toolboxItems . Block [ ] = [ ] ;
8080 mechanisms . forEach ( mechanism => {
81+ // Here we need all the components (regular and private) from the mechanism because we need
82+ // to create port parameters for all the components.
8183 const components = editor . getAllComponentsFromMechanism ( mechanism ) ;
8284 mechanismBlocks . push ( createMechanismBlock ( mechanism , components ) ) ;
8385 } ) ;
@@ -110,11 +112,13 @@ function getRobotMechanismsCategory(editor: Editor): toolboxItems.Category {
110112 contents : mechanismMethodBlocks ,
111113 } ) ;
112114
113- // Get the public components from the mechanism and add the blocks for calling the component functions.
115+ // Get the public components from the mechanism and add the blocks for calling the
116+ // component functions.
114117 const componentsFromMechanism = editor . getComponentsFromMechanism ( mechanism ) ;
115118 if ( componentsFromMechanism . length > 0 ) {
116119 const componentBlocks : toolboxItems . ContentsType [ ] = [ ] ;
117120 componentsFromMechanism . forEach ( component => {
121+ // Get the blocks for this specific component.
118122 componentBlocks . push ( {
119123 kind : 'category' ,
120124 name : component . name ,
@@ -202,12 +206,13 @@ function getComponentsCategory(
202206 contents : getAllPossibleComponents ( moduleType ) ,
203207 } ) ;
204208
205- // Get components from the current workspace.
206- const componentsToShow = moduleType === storageModule . ModuleType . MECHANISM
207- ? editor . getAllComponentsFromWorkspace ( ) // Show all components (including private) when editing mechanisms
208- : editor . getComponentsFromWorkspace ( ) ; // Show only regular components when editing robots
209-
210- componentsToShow . forEach ( component => {
209+ // Get all (regular and private) components from the current workspace.
210+ // For a robot module, we can only have regular components. For a mechanism module, we can have
211+ // regular and/or private components. Rather than checking what the current module type is, it's
212+ // simpler to just call getAllComponentsFromWorkspace for both robot and mechanism modules. Since
213+ // robot modules don't have private components, getAllComponentsFromWorkspace is equivalent to
214+ // getComponentsFromWorkspace for a robot module.
215+ editor . getAllComponentsFromWorkspace ( ) . forEach ( component => {
211216 // Get the blocks for this specific component
212217 contents . push ( {
213218 kind : 'category' ,
0 commit comments