-
Notifications
You must be signed in to change notification settings - Fork 323
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enable the Code Editor, with new apply-text-edits algo. (#9055)
- Fix the UI problems with our CodeMirror integration (Fixed view stability; Fixed a focus bug; Fixed errors caused by diagnostics range exceptions; Fixed linter invalidation--see https://discuss.codemirror.net/t/problem-trying-to-force-linting/5823; Implemented edit-coalescing for performance). - Introduce an algorithm for applying text edits to an AST. Compared to the GUI1 approach, the new algorithm supports deeper identity-stability for expressions (which is important for subexpression metadata and Y.Js sync), as well as reordered-subtree identification. - Enable the code editor.
- Loading branch information
Showing
35 changed files
with
1,831 additions
and
534 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { Ast } from './tree' | ||
|
||
/// Returns a GraphViz graph illustrating parent/child relationships in the given subtree. | ||
export function graphParentPointers(ast: Ast) { | ||
const sanitize = (id: string) => id.replace('ast:', '').replace(/[^A-Za-z0-9]/g, '') | ||
const parentToChild = new Array<{ parent: string; child: string }>() | ||
const childToParent = new Array<{ child: string; parent: string }>() | ||
ast.visitRecursiveAst((ast) => { | ||
for (const child of ast.children()) { | ||
if (child instanceof Ast) | ||
parentToChild.push({ child: sanitize(child.id), parent: sanitize(ast.id) }) | ||
} | ||
const parent = ast.parentId | ||
if (parent) childToParent.push({ child: sanitize(ast.id), parent: sanitize(parent) }) | ||
}) | ||
let result = 'digraph parentPointers {\n' | ||
for (const { parent, child } of parentToChild) result += `${parent} -> ${child};\n` | ||
for (const { child, parent } of childToParent) | ||
result += `${child} -> ${parent} [weight=0; color=red; style=dotted];\n` | ||
result += '}\n' | ||
return result | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.