MCPcopy Create free account
hub / github.com/SplootCode/splootcode / openFile

Method openFile

packages/editor/src/context/editor_context.ts:61–90  ·  view source on GitHub ↗
(pack: SplootPackage, file: SplootFile)

Source from the content-addressed store, hash-verified

59 }
60
61 async openFile(pack: SplootPackage, file: SplootFile) {
62 const fileLoader = this.project.fileLoader
63 const loadedFile = await pack.getLoadedFile(fileLoader, file.name)
64
65 // Build scope
66 if (isPythonNode(loadedFile.rootNode)) {
67 await generatePythonScope(file.name, loadedFile.rootNode, this.analyser)
68 }
69
70 // Start up the analyzer
71 // We don't technically need to wait for it, but it helps give time for
72 // fonts to load correctly before render calculations happen.
73 const rootNode = loadedFile.rootNode as PythonFile
74 await this.analyser.loadFile(file.name, rootNode)
75 this.undoWatcher.setRootNode(rootNode)
76
77 // Make sure font is loaded before rendering.
78 await awaitFontsLoaded()
79 // Prep NodeBlocks for rendering
80 const newRootNode = new NodeBlock(null, loadedFile.rootNode, this.selection, 0)
81
82 // Hook up root node into selection manager.
83 // This will trigger calculating dimensions and building the cursor map.
84 this.setRootNode(newRootNode)
85
86 // Enable mutation firing
87 loadedFile.rootNode.recursivelySetMutations(true)
88 // Validate all nodes, firing validation mutations when invalid.
89 loadedFile.rootNode.recursivelyValidate()
90 }
91
92 @action
93 setRootNode(rootNode: NodeBlock) {

Callers 1

loadDefaultFileMethod · 0.95

Calls 8

setRootNodeMethod · 0.95
isPythonNodeFunction · 0.90
generatePythonScopeFunction · 0.90
awaitFontsLoadedFunction · 0.90
getLoadedFileMethod · 0.80
recursivelyValidateMethod · 0.80
loadFileMethod · 0.45

Tested by

no test coverage detected