Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dynamic dropdown support #4072

Merged
merged 30 commits into from
Feb 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
1b987f4
wip dynamic dropdown data update and widgets presenter
Frizi Jan 16, 2023
a17890a
query widget metadata and send it to dropdown widgets
Frizi Jan 16, 2023
55a407b
added target_id to the span tree argument entries, used for propagati…
Frizi Jan 18, 2023
c25c428
fix node widget views leaking, store last widget query data for immed…
Frizi Jan 20, 2023
0ac4271
cleanup widget update flow
Frizi Jan 23, 2023
699131d
do not spawn unnecessary task in widget query
Frizi Jan 23, 2023
a68ebdb
do not query for platform every time in new_glyph
Frizi Jan 23, 2023
0363997
do not reuse port shape on expression update, as it breaks connection…
Frizi Jan 23, 2023
56a2a53
use Set dirty flag for RemovedChildren for 5x faster dropdown openening
Frizi Jan 23, 2023
d5f0b05
cleanup widget data deserialization
Frizi Jan 24, 2023
710f408
hide widgets during node editing and fix another memory leak in unini…
Frizi Jan 25, 2023
98de98c
do not store any network reference in lazy dropdown
Frizi Jan 25, 2023
fedf066
improve span tree argument info generation, fix tests and lint issues
Frizi Jan 26, 2023
06a4611
added changelog entry
Frizi Jan 26, 2023
f011c3a
improve doc comment wording
Frizi Jan 26, 2023
d8d4715
refactor ApplicationBase
Frizi Jan 27, 2023
e744a67
refactor widget registration to only use call_id, remove target_id fr…
Frizi Jan 30, 2023
1e93152
fix tests and lints
Frizi Jan 31, 2023
7373218
refactor widgets controller
Frizi Jan 31, 2023
3942de6
improve names and comments, remove unnecessary ModelCommon
Frizi Jan 31, 2023
9ec00d3
improve request docs
Frizi Jan 31, 2023
c7aa654
add is_function_parameter to span-tree node kind
Frizi Jan 31, 2023
c2830e3
remove Unset widget kind in favour of using Option
Frizi Jan 31, 2023
16f5ee9
move port widget initialization to separate function
Frizi Feb 1, 2023
9b28ea0
lint
Frizi Feb 1, 2023
558cdf6
singular widget module name and uppercase ID
Frizi Feb 2, 2023
b922de4
fix docs
Frizi Feb 2, 2023
d7d6025
fmt
Frizi Feb 3, 2023
d023379
workaround spurious failures
hubertp Feb 3, 2023
16ba57d
Mark tests as flaky until test cleanup is fixed
hubertp Feb 3, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@
present only when the argument is of type that has a predefined set of values.
- [Separate component browser navigator sections for modules imported from
different namespaces][4044]
- [Added contextual suggestions to argument dropdowns][4072]. Dropdowns will now
contain suggestions which are based on evaluated data.

#### EnsoGL (rendering engine)

Expand Down Expand Up @@ -462,6 +464,7 @@
[4063]: https://github.com/enso-org/enso/pull/4063
[4078]: https://github.com/enso-org/enso/pull/4078
[4097]: https://github.com/enso-org/enso/pull/4097
[4072]: https://github.com/enso-org/enso/pull/4072

#### Enso Compiler

Expand Down
16 changes: 8 additions & 8 deletions app/gui/controller/double-representation/src/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ use std::cmp::Ordering;



/// Node Id is the Ast Id attached to the node's expression.
/// Node Id is the AST ID attached to the node's expression.
pub type Id = ast::Id;


Expand Down Expand Up @@ -224,7 +224,7 @@ impl NodeInfo {
expression_id_matches() || doc_comment_id_matches()
}

/// Get the ast id of the line with the node comment (if present).
/// Get the AST ID of the line with the node comment (if present).
pub fn doc_comment_id(&self) -> Option<ast::Id> {
self.documentation.as_ref().and_then(|comment| comment.ast().id())
}
Expand All @@ -245,7 +245,7 @@ impl NodeInfo {
/// Representation of the main line of the node (as opposed to a documentation line).
///
/// Each node must have exactly one main line.
/// Main line always contains an expression, either directly or under binding. The expression id
/// Main line always contains an expression, either directly or under binding. The expression ID
/// must be set and it serves as the whole node's expression.
#[derive(Clone, Debug)]
#[allow(missing_docs)]
Expand Down Expand Up @@ -419,7 +419,7 @@ impl MainLine {
}
}

/// Modify expression, preserving the AST id.
/// Modify expression, preserving the AST ID.
fn modify_expression(&mut self, f: impl FnOnce(&mut Ast)) {
let id = self.id();
match self {
Expand All @@ -431,15 +431,15 @@ impl MainLine {
self.set_id(id);
}

/// Add [`SKIP`] macro call to the AST. Preserves the expression id and [`FREEZE`] macro calls.
/// Add [`SKIP`] macro call to the AST. Preserves the expression ID and [`FREEZE`] macro calls.
fn add_skip_macro(&mut self) {
self.modify_expression(|ast| {
prepend_with_macro(ast, SKIP_MACRO_IDENTIFIER);
});
self.macros_info_mut().skip = true;
}

/// Remove [`SKIP`] macro call from the AST. Preserves the expression id and [`FREEZE`] macro
/// Remove [`SKIP`] macro call from the AST. Preserves the expression ID and [`FREEZE`] macro
/// calls.
fn remove_skip_macro(&mut self) {
self.modify_expression(|ast| {
Expand All @@ -448,15 +448,15 @@ impl MainLine {
self.macros_info_mut().skip = false;
}

/// Add [`FREEZE`] macro call to the AST. Preserves the expression id and [`SKIP`] macro calls.
/// Add [`FREEZE`] macro call to the AST. Preserves the expression ID and [`SKIP`] macro calls.
fn add_freeze_macro(&mut self) {
self.modify_expression(|ast| {
*ast = preserving_skip(ast, |ast| prepend_with_macro(ast, FREEZE_MACRO_IDENTIFIER));
});
self.macros_info_mut().freeze = true;
}

/// Remove [`FREEZE`] macro call from the AST. Preserves the expression id and [`SKIP`] macro
/// Remove [`FREEZE`] macro call from the AST. Preserves the expression ID and [`SKIP`] macro
/// calls.
fn remove_freeze_macro(&mut self) {
self.modify_expression(|ast| {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1117,8 +1117,8 @@ impl<T> FieldUpdate<T> {
}

#[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)]
#[serde(rename_all = "camelCase")]
#[allow(missing_docs)]
#[serde(tag = "type")]
pub enum SuggestionArgumentUpdate {
#[serde(rename_all = "camelCase")]
Add { index: usize, argument: SuggestionEntryArgument },
Expand Down
6 changes: 4 additions & 2 deletions app/gui/language/ast/impl/src/id_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,10 @@ impl IdMap {
self.vec.push((span.into(), id));
}
/// Generate random Uuid for span.
pub fn generate(&mut self, span: impl Into<enso_text::Range<Byte>>) {
self.vec.push((span.into(), Uuid::new_v4()));
pub fn generate(&mut self, span: impl Into<enso_text::Range<Byte>>) -> Uuid {
let uuid = Uuid::new_v4();
self.vec.push((span.into(), uuid));
uuid
}
}

Expand Down
2 changes: 1 addition & 1 deletion app/gui/language/ast/impl/src/known.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ impl<T> KnownAst<T> {
KnownAst { ast, phantom: default() }
}

/// Gets AST id.
/// Gets AST ID.
pub fn id(&self) -> Option<crate::Id> {
self.ast.id
}
Expand Down
16 changes: 8 additions & 8 deletions app/gui/language/ast/impl/src/opr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -260,18 +260,18 @@ impl GeneralizedInfix {
}

/// The self operand, target of the application.
pub fn target_operand(&self) -> Operand {
pub fn target_operand(&self) -> &Operand {
match self.assoc() {
Assoc::Left => self.left.clone(),
Assoc::Right => self.right.clone(),
Assoc::Left => &self.left,
Assoc::Right => &self.right,
}
}

/// Operand other than self.
pub fn argument_operand(&self) -> Operand {
pub fn argument_operand(&self) -> &Operand {
match self.assoc() {
Assoc::Left => self.right.clone(),
Assoc::Right => self.left.clone(),
Assoc::Left => &self.right,
Assoc::Right => &self.left,
}
}

Expand All @@ -283,11 +283,11 @@ impl GeneralizedInfix {
}

fn flatten_with_offset(&self, offset: usize) -> Chain {
let target = self.target_operand();
let target = self.target_operand().clone();
let rest = ChainElement {
offset,
operator: self.opr.clone(),
operand: self.argument_operand(),
operand: self.argument_operand().clone(),
infix_id: self.id,
};

Expand Down
8 changes: 4 additions & 4 deletions app/gui/language/span-tree/example/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ pub fn main() {
let parens_cr = ast::crumbs::MatchCrumb::Segs { val, index: 0 };
let _input_span_tree = builder::TreeBuilder::<()>::new(36)
.add_child(0, 14, node::Kind::Chained, PrefixCrumb::Func)
.add_child(0, 9, node::Kind::Operation, PrefixCrumb::Func)
.add_child(0, 9, node::Kind::operation(), PrefixCrumb::Func)
.set_ast_id(Uuid::new_v4())
.done()
.add_empty_child(10, InsertionPointType::BeforeTarget)
Expand All @@ -42,7 +42,7 @@ pub fn main() {
.set_ast_id(Uuid::new_v4())
.add_child(1, 19, node::Kind::argument(), parens_cr1)
.set_ast_id(Uuid::new_v4())
.add_child(0, 12, node::Kind::Operation, PrefixCrumb::Func)
.add_child(0, 12, node::Kind::operation(), PrefixCrumb::Func)
.set_ast_id(Uuid::new_v4())
.done()
.add_empty_child(13, InsertionPointType::BeforeTarget)
Expand All @@ -62,7 +62,7 @@ pub fn main() {
.crumbs(PrefixCrumb::Func)
.new_child(|t| {
t.size(9.bytes())
.kind(node::Kind::Operation)
.kind(node::Kind::operation())
.crumbs(PrefixCrumb::Func)
.new_ast_id()
})
Expand All @@ -86,7 +86,7 @@ pub fn main() {
.crumbs(parens_cr)
.new_child(|t| {
t.size(12.bytes())
.kind(node::Kind::Operation)
.kind(node::Kind::operation())
.crumbs(PrefixCrumb::Func)
.new_ast_id()
})
Expand Down
10 changes: 5 additions & 5 deletions app/gui/language/span-tree/src/action.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ impl<'a, T> Implementation for node::Ref<'a, T> {
use node::InsertionPointType::*;
let kind = &ins_point.kind;
let ast = root.get_traversing(&self.ast_crumbs)?;
let expect_arg = matches!(kind, ExpectedArgument(_));
let expect_arg = kind.is_expected_argument();
let extended_infix =
(!expect_arg).and_option_from(|| ast::opr::Chain::try_new(ast));
let new_ast = modify_preserving_id(ast, |ast| {
Expand Down Expand Up @@ -256,7 +256,7 @@ mod test {
fn run(&self, parser: &Parser) {
let ast = parser.parse_line_ast(self.expr).unwrap();
let ast_id = ast.id;
let tree = ast.generate_tree(&context::Empty).unwrap(): SpanTree;
let tree: SpanTree = ast.generate_tree(&context::Empty).unwrap();
let node = tree.root_ref().find_by_span(&self.span.clone().into());
let node = node.unwrap_or_else(|| {
panic!("Invalid case {:?}: no node with span {:?}", self, self.span)
Expand All @@ -269,7 +269,7 @@ mod test {
.unwrap();
let result_repr = result.repr();
assert_eq!(result_repr, self.expected, "Wrong answer for case {self:?}");
assert_eq!(ast_id, result.id, "Changed AST id in case {self:?}");
assert_eq!(ast_id, result.id, "Changed AST ID in case {self:?}");
}
}

Expand Down Expand Up @@ -401,7 +401,7 @@ mod test {
// Consider Span Tree for `foo bar` where `foo` is a method known to take 3 parameters.
// We can try setting each of 3 arguments to `baz`.
let tree = TreeBuilder::<()>::new(7)
.add_leaf(0, 3, node::Kind::Operation, PrefixCrumb::Func)
.add_leaf(0, 3, node::Kind::operation(), PrefixCrumb::Func)
.add_leaf(4, 7, node::Kind::this(), PrefixCrumb::Arg)
.add_empty_child(7, ExpectedArgument(1))
.add_empty_child(7, ExpectedArgument(2))
Expand All @@ -427,7 +427,7 @@ mod test {
// parameters. We can try setting each of 2 arguments to `baz`.
let tree: SpanTree = TreeBuilder::new(10)
.add_leaf(0, 4, node::Kind::this(), InfixCrumb::LeftOperand)
.add_leaf(5, 6, node::Kind::Operation, InfixCrumb::Operator)
.add_leaf(5, 6, node::Kind::operation(), InfixCrumb::Operator)
.add_leaf(7, 10, node::Kind::argument(), InfixCrumb::RightOperand)
.add_empty_child(10, ExpectedArgument(0))
.add_empty_child(10, ExpectedArgument(1))
Expand Down
Loading