@@ -32,7 +32,10 @@ import {FieldTextInput} from '../core/field_textinput.js';
3232import { Msg } from '../core/msg.js' ;
3333import { MutatorIcon as Mutator } from '../core/icons/mutator_icon.js' ;
3434import { Names } from '../core/names.js' ;
35- import type { VariableModel } from '../core/variable_model.js' ;
35+ import type {
36+ IVariableModel ,
37+ IVariableState ,
38+ } from '../core/interfaces/i_variable_model.js' ;
3639import type { Workspace } from '../core/workspace.js' ;
3740import type { WorkspaceSvg } from '../core/workspace_svg.js' ;
3841import { config } from '../core/config.js' ;
@@ -48,7 +51,7 @@ export const blocks: {[key: string]: BlockDefinition} = {};
4851type ProcedureBlock = Block & ProcedureMixin ;
4952interface ProcedureMixin extends ProcedureMixinType {
5053 arguments_ : string [ ] ;
51- argumentVarModels_ : VariableModel [ ] ;
54+ argumentVarModels_ : IVariableModel < IVariableState > [ ] ;
5255 callType_ : string ;
5356 paramIds_ : string [ ] ;
5457 hasStatements_ : boolean ;
@@ -128,7 +131,7 @@ const PROCEDURE_DEF_COMMON = {
128131 for ( let i = 0 ; i < this . argumentVarModels_ . length ; i ++ ) {
129132 const parameter = xmlUtils . createElement ( 'arg' ) ;
130133 const argModel = this . argumentVarModels_ [ i ] ;
131- parameter . setAttribute ( 'name' , argModel . name ) ;
134+ parameter . setAttribute ( 'name' , argModel . getName ( ) ) ;
132135 parameter . setAttribute ( 'varid' , argModel . getId ( ) ) ;
133136 if ( opt_paramIds && this . paramIds_ ) {
134137 parameter . setAttribute ( 'paramId' , this . paramIds_ [ i ] ) ;
@@ -196,7 +199,7 @@ const PROCEDURE_DEF_COMMON = {
196199 state [ 'params' ] . push ( {
197200 // We don't need to serialize the name, but just in case we decide
198201 // to separate params from variables.
199- 'name' : this . argumentVarModels_ [ i ] . name ,
202+ 'name' : this . argumentVarModels_ [ i ] . getName ( ) ,
200203 'id' : this . argumentVarModels_ [ i ] . getId ( ) ,
201204 } ) ;
202205 }
@@ -224,7 +227,7 @@ const PROCEDURE_DEF_COMMON = {
224227 param [ 'name' ] ,
225228 '' ,
226229 ) ;
227- this . arguments_ . push ( variable . name ) ;
230+ this . arguments_ . push ( variable . getName ( ) ) ;
228231 this . argumentVarModels_ . push ( variable ) ;
229232 }
230233 }
@@ -352,7 +355,9 @@ const PROCEDURE_DEF_COMMON = {
352355 *
353356 * @returns List of variable models.
354357 */
355- getVarModels : function ( this : ProcedureBlock ) : VariableModel [ ] {
358+ getVarModels : function (
359+ this : ProcedureBlock ,
360+ ) : IVariableModel < IVariableState > [ ] {
356361 return this . argumentVarModels_ ;
357362 } ,
358363 /**
@@ -370,23 +375,23 @@ const PROCEDURE_DEF_COMMON = {
370375 newId : string ,
371376 ) {
372377 const oldVariable = this . workspace . getVariableById ( oldId ) ! ;
373- if ( oldVariable . type !== '' ) {
378+ if ( oldVariable . getType ( ) !== '' ) {
374379 // Procedure arguments always have the empty type.
375380 return ;
376381 }
377- const oldName = oldVariable . name ;
382+ const oldName = oldVariable . getName ( ) ;
378383 const newVar = this . workspace . getVariableById ( newId ) ! ;
379384
380385 let change = false ;
381386 for ( let i = 0 ; i < this . argumentVarModels_ . length ; i ++ ) {
382387 if ( this . argumentVarModels_ [ i ] . getId ( ) === oldId ) {
383- this . arguments_ [ i ] = newVar . name ;
388+ this . arguments_ [ i ] = newVar . getName ( ) ;
384389 this . argumentVarModels_ [ i ] = newVar ;
385390 change = true ;
386391 }
387392 }
388393 if ( change ) {
389- this . displayRenamedVar_ ( oldName , newVar . name ) ;
394+ this . displayRenamedVar_ ( oldName , newVar . getName ( ) ) ;
390395 Procedures . mutateCallers ( this ) ;
391396 }
392397 } ,
@@ -398,9 +403,9 @@ const PROCEDURE_DEF_COMMON = {
398403 */
399404 updateVarName : function (
400405 this : ProcedureBlock & BlockSvg ,
401- variable : VariableModel ,
406+ variable : IVariableModel < IVariableState > ,
402407 ) {
403- const newName = variable . name ;
408+ const newName = variable . getName ( ) ;
404409 let change = false ;
405410 let oldName ;
406411 for ( let i = 0 ; i < this . argumentVarModels_ . length ; i ++ ) {
@@ -473,12 +478,16 @@ const PROCEDURE_DEF_COMMON = {
473478 const getVarBlockState = {
474479 type : 'variables_get' ,
475480 fields : {
476- VAR : { name : argVar . name , id : argVar . getId ( ) , type : argVar . type } ,
481+ VAR : {
482+ name : argVar . getName ( ) ,
483+ id : argVar . getId ( ) ,
484+ type : argVar . getType ( ) ,
485+ } ,
477486 } ,
478487 } ;
479488 options . push ( {
480489 enabled : true ,
481- text : Msg [ 'VARIABLES_SET_CREATE_GET' ] . replace ( '%1' , argVar . name ) ,
490+ text : Msg [ 'VARIABLES_SET_CREATE_GET' ] . replace ( '%1' , argVar . getName ( ) ) ,
482491 callback : ContextMenu . callbackFactory ( this , getVarBlockState ) ,
483492 } ) ;
484493 }
@@ -623,7 +632,7 @@ type ArgumentMixinType = typeof PROCEDURES_MUTATORARGUMENT;
623632// TODO(#6920): This is kludgy.
624633type FieldTextInputForArgument = FieldTextInput & {
625634 oldShowEditorFn_ ( _e ?: Event , quietInput ?: boolean ) : void ;
626- createdVariables_ : VariableModel [ ] ;
635+ createdVariables_ : IVariableModel < IVariableState > [ ] ;
627636} ;
628637
629638const PROCEDURES_MUTATORARGUMENT = {
@@ -708,7 +717,7 @@ const PROCEDURES_MUTATORARGUMENT = {
708717 }
709718
710719 let model = outerWs . getVariable ( varName , '' ) ;
711- if ( model && model . name !== varName ) {
720+ if ( model && model . getName ( ) !== varName ) {
712721 // Rename the variable (case change)
713722 outerWs . renameVariableById ( model . getId ( ) , varName ) ;
714723 }
@@ -739,7 +748,7 @@ const PROCEDURES_MUTATORARGUMENT = {
739748 }
740749 for ( let i = 0 ; i < this . createdVariables_ . length ; i ++ ) {
741750 const model = this . createdVariables_ [ i ] ;
742- if ( model . name !== newText ) {
751+ if ( model . getName ( ) !== newText ) {
743752 outerWs . deleteVariableById ( model . getId ( ) ) ;
744753 }
745754 }
@@ -750,7 +759,7 @@ blocks['procedures_mutatorarg'] = PROCEDURES_MUTATORARGUMENT;
750759/** Type of a block using the PROCEDURE_CALL_COMMON mixin. */
751760type CallBlock = Block & CallMixin ;
752761interface CallMixin extends CallMixinType {
753- argumentVarModels_ : VariableModel [ ] ;
762+ argumentVarModels_ : IVariableModel < IVariableState > [ ] ;
754763 arguments_ : string [ ] ;
755764 defType_ : string ;
756765 quarkIds_ : string [ ] | null ;
@@ -1029,7 +1038,7 @@ const PROCEDURE_CALL_COMMON = {
10291038 *
10301039 * @returns List of variable models.
10311040 */
1032- getVarModels : function ( this : CallBlock ) : VariableModel [ ] {
1041+ getVarModels : function ( this : CallBlock ) : IVariableModel < IVariableState > [ ] {
10331042 return this . argumentVarModels_ ;
10341043 } ,
10351044 /**
0 commit comments