(pack: SplootPackage, file: SplootFile)
| 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) { |
no test coverage detected