@@ -45,9 +45,9 @@ export class Editor {
4545 private eventsCategory : EventsCategory ;
4646 private currentModule : commonStorage . Module | null = null ;
4747 private modulePath : string = '' ;
48- private projectPath : string = '' ;
48+ private robotPath : string = '' ;
4949 private moduleContent : string = '' ;
50- private projectContent : string = '' ;
50+ private robotContent : string = '' ;
5151 private bindedOnChange : any = null ;
5252 private toolbox : Blockly . utils . toolbox . ToolboxDefinition = EMPTY_TOOLBOX ;
5353
@@ -73,11 +73,11 @@ export class Editor {
7373
7474 // TODO(lizlooney): As blocks are loaded, determine whether any blocks
7575 // are accessing variable or calling functions thar are defined in another
76- // blocks file (like a Project ) and check whether the variable or function
76+ // blocks file (like the Robot ) and check whether the variable or function
7777 // definition has changed. This might happen if the user defines a variable
78- // or function in the Project , uses the variable or function in the
78+ // or function in the Robot , uses the variable or function in the
7979 // OpMode, and then removes or changes the variable or function in the
80- // Project .
80+ // Robot .
8181
8282 // TODO(lizlooney): We will need a way to identify which variable or
8383 // function, other than by the variable name or function name, because the
@@ -88,15 +88,15 @@ export class Editor {
8888 // TODO(lizlooney): Look at blocks with type 'mrc_get_python_variable' or
8989 // 'mrc_set_python_variable', and where block.mrcExportedVariable === true.
9090 // Look at block.mrcImportModule and get the exported blocks for that module.
91- // ( It should be the project and we already have the project content.)
91+ // It could be from the Robot (or a Mechanism?) and we already have the Robot content.
9292 // Check whether block.mrcActualVariableName matches any exportedBlock's
9393 // extraState.actualVariableName. If there is no match, put a warning on the
9494 // block.
9595
9696 // TODO(lizlooney): Look at blocks with type 'mrc_call_python_function' and
9797 // where block.mrcExportedFunction === true.
9898 // Look at block.mrcImportModule and get the exported blocks for that module.
99- // ( It should be the project and we already have the project content.)
99+ // It could be from the Robot (or a Mechanism?) and we already have the Robot content.
100100 // Check whether block.mrcActualFunctionName matches any exportedBlock's
101101 // extraState.actualFunctionName. If there is no match, put a warning on the block.
102102 // If there is a match, check whether
@@ -124,21 +124,23 @@ export class Editor {
124124
125125 if ( currentModule ) {
126126 this . modulePath = currentModule . modulePath ;
127- this . projectPath = commonStorage . makeProjectPath ( currentModule . projectName ) ;
127+ this . robotPath = commonStorage . makeRobotPath ( currentModule . projectName ) ;
128128 } else {
129129 this . modulePath = '' ;
130- this . projectPath = '' ;
130+ this . robotPath = '' ;
131131 }
132132 this . moduleContent = '' ;
133- this . projectContent = '' ;
133+ this . robotContent = '' ;
134134 this . clearBlocklyWorkspace ( ) ;
135135
136136 if ( currentModule ) {
137+ // Fetch the content for the current module and the robot.
138+ // TODO: Also fetch the content for the mechanisms?
137139 const promises : { [ key : string ] : Promise < string > } = { } ; // key is module path, value is promise of module content.
138140 promises [ this . modulePath ] = this . storage . fetchModuleContent ( this . modulePath ) ;
139- if ( this . projectPath !== this . modulePath ) {
140- // Also fetch the project module content. It contains exported blocks that can be used.
141- promises [ this . projectPath ] = this . storage . fetchModuleContent ( this . projectPath )
141+ if ( this . robotPath !== this . modulePath ) {
142+ // Also fetch the robot module content. It contains components, etc, that can be used.
143+ promises [ this . robotPath ] = this . storage . fetchModuleContent ( this . robotPath )
142144 }
143145
144146 const moduleContents : { [ key : string ] : string } = { } ; // key is module path, value is module content
@@ -148,10 +150,10 @@ export class Editor {
148150 } )
149151 ) ;
150152 this . moduleContent = moduleContents [ this . modulePath ] ;
151- if ( this . projectPath === this . modulePath ) {
152- this . projectContent = this . moduleContent
153+ if ( this . robotPath === this . modulePath ) {
154+ this . robotContent = this . moduleContent
153155 } else {
154- this . projectContent = moduleContents [ this . projectPath ] ;
156+ this . robotContent = moduleContents [ this . robotPath ] ;
155157 }
156158 this . loadBlocksIntoBlocklyWorkspace ( ) ;
157159 }
@@ -187,8 +189,8 @@ export class Editor {
187189
188190 public updateToolbox ( shownPythonToolboxCategories : Set < string > ) : void {
189191 if ( this . currentModule ) {
190- if ( ! this . projectContent ) {
191- // The Project content hasn't been fetched yet. Try again in a bit.
192+ if ( ! this . robotContent ) {
193+ // The Robot content hasn't been fetched yet. Try again in a bit.
192194 setTimeout ( ( ) => {
193195 this . updateToolbox ( shownPythonToolboxCategories )
194196 } , 50 ) ;
@@ -229,7 +231,8 @@ export class Editor {
229231
230232 private getComponents ( ) : commonStorage . Component [ ] {
231233 const components : commonStorage . Component [ ] = [ ] ;
232- if ( this . currentModule ?. moduleType === commonStorage . MODULE_TYPE_PROJECT ) {
234+ if ( this . currentModule ?. moduleType === commonStorage . MODULE_TYPE_ROBOT ||
235+ this . currentModule ?. moduleType === commonStorage . MODULE_TYPE_MECHANISM ) {
233236 // TODO(lizlooney): Fill the components array.
234237 }
235238 return components ;
0 commit comments