From edcbf24af2c8ca316c1eee36c9e4230f1eefefe4 Mon Sep 17 00:00:00 2001 From: Adam Obuchowicz Date: Tue, 30 Mar 2021 17:49:19 +0200 Subject: [PATCH] Fix output port type when there are grey ports [ci changelog not needed] (https://github.com/enso-org/ide/pull/1409) Original commit: https://github.com/enso-org/ide/commit/a189a74a3622314ee0a03432c7f7df6c067c3ddf --- ide/src/rust/ide/src/ide/integration.rs | 11 ++++--- .../src/component/node/expression.rs | 20 +++++++------ .../src/component/node/output/area.rs | 2 +- .../ide/view/src/debug_scenes/interface.rs | 30 +++++++++++-------- 4 files changed, 34 insertions(+), 29 deletions(-) diff --git a/ide/src/rust/ide/src/ide/integration.rs b/ide/src/rust/ide/src/ide/integration.rs index 32567fa944e4..b880aede27cf 100644 --- a/ide/src/rust/ide/src/ide/integration.rs +++ b/ide/src/rust/ide/src/ide/integration.rs @@ -616,13 +616,12 @@ impl Model { /// Update the expression of the node and all related properties e.g., types, ports). fn refresh_node_expression(&self, id:graph_editor::NodeId, node:&controller::graph::Node, trees:NodeTrees) { - let expression = node.info.expression().repr(); - let pattern = node.info.pattern().map(|t|t.repr()); let code_and_trees = graph_editor::component::node::Expression { - pattern, - code : expression, - input_span_tree : trees.inputs, - output_span_tree : trees.outputs.unwrap_or_else(default) + pattern : node.info.pattern().map(|t|t.repr()), + code : node.info.expression().repr(), + whole_expression_id : node.info.expression().id , + input_span_tree : trees.inputs, + output_span_tree : trees.outputs.unwrap_or_else(default) }; if !self.expression_views.borrow().get(&id).contains(&&code_and_trees) { for sub_expression in node.info.ast().iter_recursive() { diff --git a/ide/src/rust/ide/view/graph-editor/src/component/node/expression.rs b/ide/src/rust/ide/view/graph-editor/src/component/node/expression.rs index db87f6730930..3f992925acc2 100644 --- a/ide/src/rust/ide/view/graph-editor/src/component/node/expression.rs +++ b/ide/src/rust/ide/view/graph-editor/src/component/node/expression.rs @@ -11,20 +11,22 @@ use span_tree::traits::*; #[derive(Clone,Default,Eq,PartialEq)] pub struct Expression { - pub pattern : Option, - pub code : String, - pub input_span_tree : SpanTree, - pub output_span_tree : SpanTree, + pub pattern : Option, + pub code : String, + pub whole_expression_id : Option, + pub input_span_tree : SpanTree, + pub output_span_tree : SpanTree, } impl Expression { /// Constructor without output SpanTree and with single node as an input SpanTree. pub fn new_plain(code:impl Into) -> Self { - let pattern = default(); - let code = code.into(); - let input_span_tree = code.generate_tree(&span_tree::generate::context::Empty).unwrap_or_default(); - let output_span_tree = default(); - Self {pattern,code,input_span_tree,output_span_tree} + let pattern = default(); + let code = code.into(); + let input_span_tree = code.generate_tree(&span_tree::generate::context::Empty).unwrap_or_default(); + let output_span_tree = default(); + let whole_expression_id = default(); + Self {pattern,code,input_span_tree,output_span_tree,whole_expression_id} } } diff --git a/ide/src/rust/ide/view/graph-editor/src/component/node/output/area.rs b/ide/src/rust/ide/view/graph-editor/src/component/node/output/area.rs index 9d4fe93dcbc8..7020a9935841 100644 --- a/ide/src/rust/ide/view/graph-editor/src/component/node/output/area.rs +++ b/ide/src/rust/ide/view/graph-editor/src/component/node/output/area.rs @@ -97,7 +97,7 @@ impl From for Expression { fn from(expr:node::Expression) -> Self { let code = expr.pattern.clone(); let whole_expr_type = expr.input_span_tree.root.tp().map(|t|t.to_owned().into()); - let whole_expr_id = expr.input_span_tree.root.ast_id; + let whole_expr_id = expr.whole_expression_id; let mut span_tree = expr.output_span_tree.map(|_| port::Model::default()); span_tree.root_ref_mut().dfs_with_layer_data((),|node,()| { let span = node.span(); diff --git a/ide/src/rust/ide/view/src/debug_scenes/interface.rs b/ide/src/rust/ide/view/src/debug_scenes/interface.rs index 3b5a07295efb..0f532a6a83b3 100644 --- a/ide/src/rust/ide/view/src/debug_scenes/interface.rs +++ b/ide/src/rust/ide/view/src/debug_scenes/interface.rs @@ -259,16 +259,17 @@ use span_tree::traits::*; pub fn expression_mock_string(label:&str) -> Expression { - let pattern = Some(label.to_string()); - let code = format!("\"{}\"", label); - let parser = Parser::new_or_panic(); - let parameters = vec![]; - let ast = parser.parse_line(&code).unwrap(); - let invocation_info = span_tree::generate::context::CalledMethodInfo {parameters}; - let ctx = span_tree::generate::MockContext::new_single(ast.id.unwrap(),invocation_info); - let output_span_tree = span_tree::SpanTree::default(); - let input_span_tree = span_tree::SpanTree::new(&ast,&ctx).unwrap(); - Expression {pattern,code,input_span_tree,output_span_tree} + let pattern = Some(label.to_string()); + let code = format!("\"{}\"", label); + let parser = Parser::new_or_panic(); + let parameters = vec![]; + let ast = parser.parse_line(&code).unwrap(); + let invocation_info = span_tree::generate::context::CalledMethodInfo {parameters}; + let ctx = span_tree::generate::MockContext::new_single(ast.id.unwrap(),invocation_info); + let output_span_tree = span_tree::SpanTree::default(); + let input_span_tree = span_tree::SpanTree::new(&ast,&ctx).unwrap(); + let whole_expression_id = default(); + Expression {pattern,code,input_span_tree,output_span_tree,whole_expression_id} } pub fn expression_mock() -> Expression { @@ -285,7 +286,8 @@ pub fn expression_mock() -> Expression { let ctx = span_tree::generate::MockContext::new_single(ast.id.unwrap(),invocation_info); let output_span_tree = span_tree::SpanTree::default(); let input_span_tree = span_tree::SpanTree::new(&ast,&ctx).unwrap(); - Expression {pattern,code,input_span_tree,output_span_tree} + let whole_expression_id = default(); + Expression {pattern,code,input_span_tree,output_span_tree,whole_expression_id} } pub fn expression_mock2() -> Expression { @@ -323,7 +325,8 @@ pub fn expression_mock2() -> Expression { .done() .add_empty_child(36,span_tree::node::InsertionPointType::Append) .build(); - Expression {pattern,code,input_span_tree,output_span_tree} + let whole_expression_id = default(); + Expression {pattern,code,input_span_tree,output_span_tree,whole_expression_id} } pub fn expression_mock3() -> Expression { @@ -357,5 +360,6 @@ pub fn expression_mock3() -> Expression { let ctx = span_tree::generate::MockContext::new_single(ast.id.unwrap(),invocation_info); let output_span_tree = span_tree::SpanTree::new(&ast,&ctx).unwrap();//span_tree::SpanTree::default(); let input_span_tree = span_tree::SpanTree::new(&ast,&ctx).unwrap(); - Expression {pattern,code,input_span_tree,output_span_tree} + let whole_expression_id = default(); + Expression {pattern,code,input_span_tree,output_span_tree,whole_expression_id} }