@@ -33,7 +33,8 @@ import { createFieldDropdown } from '../fields/FieldDropdown';
3333import { createFieldNonEditableText } from '../fields/FieldNonEditableText' ;
3434import { MRC_STYLE_FUNCTIONS } from '../themes/styles'
3535import * as toolboxItems from '../toolbox/items' ;
36- import * as commonStorage from '../storage/common_storage' ;
36+ import * as storageModule from '../storage/module' ;
37+ import * as storageModuleContent from '../storage/module_content' ;
3738
3839
3940// A block to call a python function.
@@ -496,11 +497,11 @@ const CALL_PYTHON_FUNCTION = {
496497 } ,
497498 mutateMethodCaller : function (
498499 this : CallPythonFunctionBlock ,
499- methodOrEvent : commonStorage . Method | commonStorage . Event
500+ methodOrEvent : storageModuleContent . Method | storageModuleContent . Event
500501 ) : void {
501502 // mutateMethodCaller is called when the method or event definition block in the same module is modified.
502503 if ( this . mrcFunctionKind == FunctionKind . EVENT ) {
503- const event = methodOrEvent as commonStorage . Event ;
504+ const event = methodOrEvent as storageModuleContent . Event ;
504505 this . mrcArgs = [ ] ;
505506 event . args . forEach ( ( arg ) => {
506507 this . mrcArgs . push ( {
@@ -509,7 +510,7 @@ const CALL_PYTHON_FUNCTION = {
509510 } ) ;
510511 } ) ;
511512 } else if ( this . mrcFunctionKind == FunctionKind . INSTANCE_WITHIN ) {
512- const method = methodOrEvent as commonStorage . Method ;
513+ const method = methodOrEvent as storageModuleContent . Method ;
513514 this . mrcReturnType = method . returnType ;
514515 this . mrcArgs = [ ] ;
515516 // We don't include the arg for the self argument because we don't need a socket for it.
@@ -522,9 +523,9 @@ const CALL_PYTHON_FUNCTION = {
522523 }
523524 this . updateBlock_ ( ) ;
524525 } ,
525- getComponentsFromRobot : function ( this : CallPythonFunctionBlock ) : commonStorage . Component [ ] {
526+ getComponentsFromRobot : function ( this : CallPythonFunctionBlock ) : storageModuleContent . Component [ ] {
526527 // Get the list of components whose type matches this.mrcComponentClassName.
527- const components : commonStorage . Component [ ] = [ ] ;
528+ const components : storageModuleContent . Component [ ] = [ ] ;
528529 const editor = Editor . getEditorForBlocklyWorkspace ( this . workspace ) ;
529530 if ( editor ) {
530531 editor . getComponentsFromRobot ( ) . forEach ( component => {
@@ -550,9 +551,9 @@ const CALL_PYTHON_FUNCTION = {
550551 // visible warning on it.
551552 if ( this . mrcFunctionKind === FunctionKind . INSTANCE_COMPONENT ) {
552553 let foundComponent = false ;
553- const componentsInScope : commonStorage . Component [ ] = [ ] ;
554+ const componentsInScope : storageModuleContent . Component [ ] = [ ] ;
554555 componentsInScope . push ( ...this . getComponentsFromRobot ( ) ) ;
555- if ( editor . getCurrentModuleType ( ) === commonStorage . MODULE_TYPE_MECHANISM ) {
556+ if ( editor . getCurrentModuleType ( ) === storageModule . MODULE_TYPE_MECHANISM ) {
556557 componentsInScope . push ( ...editor . getComponentsFromWorkspace ( ) ) ;
557558 }
558559 for ( const component of componentsInScope ) {
@@ -599,7 +600,7 @@ const CALL_PYTHON_FUNCTION = {
599600 // If the robot method has changed, update the block if possible or put a
600601 // visible warning on it.
601602 if ( this . mrcFunctionKind === FunctionKind . INSTANCE_ROBOT ) {
602- if ( editor . getCurrentModuleType ( ) === commonStorage . MODULE_TYPE_MECHANISM ) {
603+ if ( editor . getCurrentModuleType ( ) === storageModule . MODULE_TYPE_MECHANISM ) {
603604 warnings . push ( 'This block is not allowed to be used inside a mechanism.' ) ;
604605 } else {
605606 let foundRobotMethod = false ;
@@ -645,7 +646,7 @@ const CALL_PYTHON_FUNCTION = {
645646 // If the method has changed, update the block if possible or put a
646647 // visible warning on it.
647648 if ( this . mrcFunctionKind === FunctionKind . INSTANCE_MECHANISM ) {
648- if ( editor . getCurrentModuleType ( ) === commonStorage . MODULE_TYPE_MECHANISM ) {
649+ if ( editor . getCurrentModuleType ( ) === storageModule . MODULE_TYPE_MECHANISM ) {
649650 warnings . push ( 'This block is not allowed to be used inside a mechanism.' ) ;
650651 } else {
651652 let foundMechanism = false ;
@@ -661,7 +662,7 @@ const CALL_PYTHON_FUNCTION = {
661662
662663 let foundMechanismMethod = false ;
663664 const mechanism = editor . getMechanism ( mechanismInRobot ) ;
664- const mechanismMethods : commonStorage . Method [ ] = mechanism
665+ const mechanismMethods : storageModuleContent . Method [ ] = mechanism
665666 ? editor . getMethodsFromMechanism ( mechanism ) : [ ] ;
666667 for ( const mechanismMethod of mechanismMethods ) {
667668 if ( mechanismMethod . blockId === this . mrcOtherBlockId ) {
@@ -790,11 +791,11 @@ export const pythonFromBlock = function(
790791 : block . getFieldValue ( FIELD_FUNCTION_NAME ) ;
791792 // Generate the correct code depending on the module type.
792793 switch ( generator . getModuleType ( ) ) {
793- case commonStorage . MODULE_TYPE_ROBOT :
794- case commonStorage . MODULE_TYPE_MECHANISM :
794+ case storageModule . MODULE_TYPE_ROBOT :
795+ case storageModule . MODULE_TYPE_MECHANISM :
795796 code = 'self.' ;
796797 break ;
797- case commonStorage . MODULE_TYPE_OPMODE :
798+ case storageModule . MODULE_TYPE_OPMODE :
798799 code = 'self.robot.' ;
799800 break ;
800801 }
@@ -815,13 +816,13 @@ export const pythonFromBlock = function(
815816 : block . getFieldValue ( FIELD_FUNCTION_NAME ) ;
816817 // Generate the correct code depending on the module type.
817818 switch ( generator . getModuleType ( ) ) {
818- case commonStorage . MODULE_TYPE_ROBOT :
819+ case storageModule . MODULE_TYPE_ROBOT :
819820 code = 'self.' + mechanismName ;
820821 break ;
821- case commonStorage . MODULE_TYPE_OPMODE :
822+ case storageModule . MODULE_TYPE_OPMODE :
822823 code = 'self.robot.' + mechanismName ;
823824 break ;
824- case commonStorage . MODULE_TYPE_MECHANISM :
825+ case storageModule . MODULE_TYPE_MECHANISM :
825826 // The INSTANCE_MECHANISM version should not be used in a mechanism.
826827 // TODO(lizlooney): What if the user copies a block from an robot or opmode and pastes
827828 // it into a mechanism?
@@ -882,7 +883,7 @@ export function renameMethodCallers(workspace: Blockly.Workspace, otherBlockId:
882883}
883884
884885export function mutateMethodCallers (
885- workspace : Blockly . Workspace , otherBlockId : string , methodOrEvent : commonStorage . Method | commonStorage . Event ) {
886+ workspace : Blockly . Workspace , otherBlockId : string , methodOrEvent : storageModuleContent . Method | storageModuleContent . Event ) {
886887 const oldRecordUndo = Blockly . Events . getRecordUndo ( ) ;
887888
888889 getMethodCallers ( workspace , otherBlockId ) . forEach ( block => {
@@ -1070,14 +1071,14 @@ function createInstanceMethodBlock(
10701071}
10711072
10721073export function addInstanceWithinBlocks (
1073- methods : commonStorage . Method [ ] ,
1074+ methods : storageModuleContent . Method [ ] ,
10741075 contents : toolboxItems . ContentsType [ ] ) {
10751076 methods . forEach ( method => {
10761077 contents . push ( createInstanceWithinBlock ( method ) ) ;
10771078 } ) ;
10781079}
10791080
1080- function createInstanceWithinBlock ( method : commonStorage . Method ) : toolboxItems . Block {
1081+ function createInstanceWithinBlock ( method : storageModuleContent . Method ) : toolboxItems . Block {
10811082 const extraState : CallPythonFunctionExtraState = {
10821083 functionKind : FunctionKind . INSTANCE_WITHIN ,
10831084 returnType : method . returnType ,
@@ -1088,7 +1089,7 @@ function createInstanceWithinBlock(method: commonStorage.Method): toolboxItems.B
10881089 const fields : { [ key : string ] : any } = { } ;
10891090 fields [ FIELD_FUNCTION_NAME ] = method . visibleName ;
10901091 const inputs : { [ key : string ] : any } = { } ;
1091- // Convert method.args from commonStorage .MethodArg[] to ArgData[].
1092+ // Convert method.args from storageModuleContent .MethodArg[] to ArgData[].
10921093 const args : ArgData [ ] = [ ] ;
10931094 // We don't include the arg for the self argument because we don't need a socket for it.
10941095 for ( let i = 1 ; i < method . args . length ; i ++ ) {
@@ -1103,7 +1104,7 @@ function createInstanceWithinBlock(method: commonStorage.Method): toolboxItems.B
11031104}
11041105
11051106export function getInstanceComponentBlocks (
1106- component : commonStorage . Component ) : toolboxItems . ContentsType [ ] {
1107+ component : storageModuleContent . Component ) : toolboxItems . ContentsType [ ] {
11071108 const contents : toolboxItems . ContentsType [ ] = [ ] ;
11081109
11091110 const classData = getClassData ( component . className ) ;
@@ -1131,7 +1132,7 @@ export function getInstanceComponentBlocks(
11311132}
11321133
11331134function createInstanceComponentBlock (
1134- component : commonStorage . Component , functionData : FunctionData ) : toolboxItems . Block {
1135+ component : storageModuleContent . Component , functionData : FunctionData ) : toolboxItems . Block {
11351136 const extraState : CallPythonFunctionExtraState = {
11361137 functionKind : FunctionKind . INSTANCE_COMPONENT ,
11371138 returnType : functionData . returnType ,
@@ -1155,14 +1156,14 @@ function createInstanceComponentBlock(
11551156}
11561157
11571158export function addInstanceRobotBlocks (
1158- methods : commonStorage . Method [ ] ,
1159+ methods : storageModuleContent . Method [ ] ,
11591160 contents : toolboxItems . ContentsType [ ] ) {
11601161 methods . forEach ( method => {
11611162 contents . push ( createInstanceRobotBlock ( method ) ) ;
11621163 } ) ;
11631164}
11641165
1165- function createInstanceRobotBlock ( method : commonStorage . Method ) : toolboxItems . Block {
1166+ function createInstanceRobotBlock ( method : storageModuleContent . Method ) : toolboxItems . Block {
11661167 const extraState : CallPythonFunctionExtraState = {
11671168 functionKind : FunctionKind . INSTANCE_ROBOT ,
11681169 returnType : method . returnType ,
@@ -1173,7 +1174,7 @@ function createInstanceRobotBlock(method: commonStorage.Method): toolboxItems.Bl
11731174 const fields : { [ key : string ] : any } = { } ;
11741175 fields [ FIELD_FUNCTION_NAME ] = method . visibleName ;
11751176 const inputs : { [ key : string ] : any } = { } ;
1176- // Convert method.args from commonStorage .MethodArg[] to ArgData[].
1177+ // Convert method.args from storageModuleContent .MethodArg[] to ArgData[].
11771178 const args : ArgData [ ] = [ ] ;
11781179 // We don't include the arg for the self argument because we don't need a socket for it.
11791180 for ( let i = 1 ; i < method . args . length ; i ++ ) {
@@ -1188,17 +1189,17 @@ function createInstanceRobotBlock(method: commonStorage.Method): toolboxItems.Bl
11881189}
11891190
11901191export function addInstanceMechanismBlocks (
1191- mechanismInRobot : commonStorage . MechanismInRobot ,
1192- methods : commonStorage . Method [ ] ,
1192+ mechanismInRobot : storageModuleContent . MechanismInRobot ,
1193+ methods : storageModuleContent . Method [ ] ,
11931194 contents : toolboxItems . ContentsType [ ] ) {
11941195 methods . forEach ( method => {
11951196 contents . push ( createInstanceMechanismBlock ( mechanismInRobot , method ) ) ;
11961197 } ) ;
11971198}
11981199
11991200function createInstanceMechanismBlock (
1200- mechanismInRobot : commonStorage . MechanismInRobot ,
1201- method : commonStorage . Method ) : toolboxItems . Block {
1201+ mechanismInRobot : storageModuleContent . MechanismInRobot ,
1202+ method : storageModuleContent . Method ) : toolboxItems . Block {
12021203 const extraState : CallPythonFunctionExtraState = {
12031204 functionKind : FunctionKind . INSTANCE_MECHANISM ,
12041205 returnType : method . returnType ,
@@ -1212,7 +1213,7 @@ function createInstanceMechanismBlock(
12121213 fields [ FIELD_MECHANISM_NAME ] = mechanismInRobot . name ;
12131214 fields [ FIELD_FUNCTION_NAME ] = method . visibleName ;
12141215 const inputs : { [ key : string ] : any } = { } ;
1215- // Convert method.args from commonStorage .MethodArg[] to ArgData[].
1216+ // Convert method.args from storageModuleContent .MethodArg[] to ArgData[].
12161217 const args : ArgData [ ] = [ ] ;
12171218 // For INSTANCE_MECHANISM functions, the 0 argument is 'self', but
12181219 // self is represented by the FIELD_MECHANISM_NAME field.
@@ -1229,14 +1230,14 @@ function createInstanceMechanismBlock(
12291230}
12301231
12311232export function addFireEventBlocks (
1232- events : commonStorage . Event [ ] ,
1233+ events : storageModuleContent . Event [ ] ,
12331234 contents : toolboxItems . ContentsType [ ] ) {
12341235 events . forEach ( event => {
12351236 contents . push ( createFireEventBlock ( event ) ) ;
12361237 } ) ;
12371238}
12381239
1239- function createFireEventBlock ( event : commonStorage . Event ) : toolboxItems . Block {
1240+ function createFireEventBlock ( event : storageModuleContent . Event ) : toolboxItems . Block {
12401241 const extraState : CallPythonFunctionExtraState = {
12411242 functionKind : FunctionKind . EVENT ,
12421243 returnType : RETURN_TYPE_NONE ,
@@ -1246,7 +1247,7 @@ function createFireEventBlock(event: commonStorage.Event): toolboxItems.Block {
12461247 const fields : { [ key : string ] : any } = { } ;
12471248 fields [ FIELD_EVENT_NAME ] = event . name ;
12481249 const inputs : { [ key : string ] : any } = { } ;
1249- // Convert event.args from commonStorage .MethodArg[] to ArgData[].
1250+ // Convert event.args from storageModuleContent .MethodArg[] to ArgData[].
12501251 const args : ArgData [ ] = [ ] ;
12511252 event . args . forEach ( methodArg => {
12521253 args . push ( {
0 commit comments