@@ -33,7 +33,6 @@ import ToolboxSettingsModal from './reactComponents/ToolboxSettings';
3333import * as Tabs from './reactComponents/Tabs' ;
3434import { TabType } from './types/TabType' ;
3535
36- import { createGeneratorContext , GeneratorContext } from './editor/generator_context' ;
3736import * as editor from './editor/editor' ;
3837import { extendedPythonGenerator } from './editor/extended_python_generator' ;
3938
@@ -172,8 +171,6 @@ const AppContent: React.FC<AppContentProps> = ({ project, setProject }): React.J
172171 const [ languageInitialized , setLanguageInitialized ] = React . useState ( false ) ;
173172 const [ themeInitialized , setThemeInitialized ] = React . useState ( false ) ;
174173
175- const generatorContext = React . useRef < GeneratorContext | null > ( null ) ;
176-
177174 /** modulePaths controls how BlocklyComponents are created. */
178175 const modulePaths = React . useRef < string [ ] > ( [ ] ) ;
179176 const modulePathToBlocklyComponent = React . useRef < { [ modulePath : string ] : BlocklyComponentType } > ( { } ) ;
@@ -434,7 +431,6 @@ const AppContent: React.FC<AppContentProps> = ({ project, setProject }): React.J
434431 // Initialize blocks when app loads
435432 React . useEffect ( ( ) => {
436433 initializeBlocks ( ) ;
437- generatorContext . current = createGeneratorContext ( ) ;
438434 } , [ ] ) ;
439435
440436 React . useEffect ( ( ) => {
@@ -443,9 +439,6 @@ const AppContent: React.FC<AppContentProps> = ({ project, setProject }): React.J
443439
444440 // Update generator context and load module blocks when current module changes
445441 React . useEffect ( ( ) => {
446- if ( generatorContext . current ) {
447- generatorContext . current . setModule ( currentModule ) ;
448- }
449442 if ( currentModule ) {
450443 if ( modulePaths . current . includes ( currentModule . modulePath ) ) {
451444 activateEditor ( ) ;
@@ -460,9 +453,6 @@ const AppContent: React.FC<AppContentProps> = ({ project, setProject }): React.J
460453 if ( ! project || ! currentModule ) {
461454 return ;
462455 }
463- if ( generatorContext . current ) {
464- generatorContext . current . setModule ( currentModule ) ;
465- }
466456 for ( const modulePath in modulePathToBlocklyComponent . current ) {
467457 const blocklyComponent = modulePathToBlocklyComponent . current [ modulePath ] ;
468458 const active = ( modulePath === currentModule . modulePath ) ;
@@ -485,7 +475,7 @@ const AppContent: React.FC<AppContentProps> = ({ project, setProject }): React.J
485475 } ;
486476
487477 const setupWorkspace = ( modulePath : string , newWorkspace : Blockly . WorkspaceSvg ) => {
488- if ( ! project || ! storage || ! generatorContext . current ) {
478+ if ( ! project || ! storage ) {
489479 return ;
490480 }
491481 const module = storageProject . findModuleByModulePath ( project , modulePath ) ;
@@ -506,7 +496,7 @@ const AppContent: React.FC<AppContentProps> = ({ project, setProject }): React.J
506496 }
507497
508498 const newEditor = new editor . Editor (
509- newWorkspace , module , project , generatorContext . current , storage , modulePathToContentText ) ;
499+ newWorkspace , module , project , storage , modulePathToContentText ) ;
510500 modulePathToEditor . current [ modulePath ] = newEditor ;
511501 newEditor . loadModuleBlocks ( ) ;
512502 newEditor . updateToolbox ( shownPythonToolboxCategories ) ;
@@ -519,11 +509,11 @@ const AppContent: React.FC<AppContentProps> = ({ project, setProject }): React.J
519509 // Generate code when module or regeneration trigger changes
520510 React . useEffect ( ( ) => {
521511 let generatedCode = '' ;
522- if ( currentModule && generatorContext . current ) {
512+ if ( currentModule ) {
523513 if ( currentModule . modulePath in modulePathToBlocklyComponent . current ) {
524514 const blocklyComponent = modulePathToBlocklyComponent . current [ currentModule . modulePath ] ;
525515 generatedCode = extendedPythonGenerator . mrcWorkspaceToCode (
526- blocklyComponent . getBlocklyWorkspace ( ) , generatorContext . current ) ;
516+ blocklyComponent . getBlocklyWorkspace ( ) , currentModule ) ;
527517 }
528518 }
529519 setGeneratedCode ( generatedCode ) ;
0 commit comments