From c32bb85a520db5876bd3bed9312eb145fc68570b Mon Sep 17 00:00:00 2001 From: JackDevine Date: Mon, 18 Mar 2024 22:07:58 +1300 Subject: [PATCH 1/2] Make sure that parsedcode is of type Expr even is get_code_expr returns a Symbol --- src/TopologyUpdate.jl | 2 +- test/basic.jl | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/TopologyUpdate.jl b/src/TopologyUpdate.jl index 2f6c77f..772c5ad 100644 --- a/src/TopologyUpdate.jl +++ b/src/TopologyUpdate.jl @@ -39,7 +39,7 @@ function updated_topology( new_code_str = get_code_str(cell) if old_code.code !== new_code_str - parsedcode = get_code_expr(cell) + parsedcode = Expr(:block, get_code_expr(cell)) new_code = updated_codes[cell] = ExprAnalysisCache(new_code_str, parsedcode) new_reactive_node = ExpressionExplorer.compute_reactive_node(ExpressionExplorerExtras.pretransform_pluto(new_code.parsedcode)) diff --git a/test/basic.jl b/test/basic.jl index 08cdb50..49de9b7 100644 --- a/test/basic.jl +++ b/test/basic.jl @@ -24,4 +24,22 @@ import PlutoDependencyExplorer as PDE order = PDE.topological_order(topology); @test order.runnable == notebook[[2, 3, 1]] + + notebook = SimpleCell.([ + "foo" + "foo = 3" + ]); + + empty_topology = PDE.NotebookTopology{SimpleCell}(); + + topology = PDE.updated_topology( + empty_topology, + notebook, notebook; + get_code_str = c -> c.code, + get_code_expr = c -> Meta.parse(c.code), + ); + + order = PDE.topological_order(topology); + + @test order.runnable == notebook[[2, 1]] end \ No newline at end of file From b3010fc121271a54ed83645bce23306c610fb346 Mon Sep 17 00:00:00 2001 From: Fons van der Plas Date: Thu, 28 Mar 2024 13:32:34 +0100 Subject: [PATCH 2/2] Update TopologyUpdate.jl --- src/TopologyUpdate.jl | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/TopologyUpdate.jl b/src/TopologyUpdate.jl index 772c5ad..9a3536b 100644 --- a/src/TopologyUpdate.jl +++ b/src/TopologyUpdate.jl @@ -39,7 +39,9 @@ function updated_topology( new_code_str = get_code_str(cell) if old_code.code !== new_code_str - parsedcode = Expr(:block, get_code_expr(cell)) + parsedcode = let x = get_code_expr(cell) + x isa Expr ? x : Expr(:block, x) + end new_code = updated_codes[cell] = ExprAnalysisCache(new_code_str, parsedcode) new_reactive_node = ExpressionExplorer.compute_reactive_node(ExpressionExplorerExtras.pretransform_pluto(new_code.parsedcode))