Skip to content

Commit

Permalink
Merging with Dmitry's #6655
Browse files Browse the repository at this point in the history
  • Loading branch information
JaroslavTulach committed May 14, 2023
2 parents f2df70c + 7067917 commit 50e1da7
Show file tree
Hide file tree
Showing 89 changed files with 2,278 additions and 496 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@
belongs to the node.][6487].
- [List Editor Widget][6470]. Now you can edit lists by clicking buttons on
nodes or by dragging the elements.
- [Visualisations now show a loading spinner while waiting on data.][6512].
- [Fixed text visualisations which were being cut off at the last line.][6421]
- [Fixed a bug where, when scrolling or dragging on a full-screen visualization,
the view of the graph changed as well.][6530]
Expand All @@ -153,10 +154,13 @@
execution shortcuts changed from
<kbd>cmd</kbd>+<kbd>shift</kbd>+<kbd>t</kbd>/<kbd>r</kbd> to
<kbd>cmd</kbd>+<kbd>alt</kbd>+<kbd>t</kbd>/<kbd>r</kbd>.
- [Fixed a bug where selecting a nested breadcrumb would cause the order of
breadcrumbs to change incorrectly.][6617]

[6421]: https://github.com/enso-org/enso/pull/6421
[6530]: https://github.com/enso-org/enso/pull/6530
[6620]: https://github.com/enso-org/enso/pull/6620
[6617]: https://github.com/enso-org/enso/pull/6617

#### EnsoGL (rendering engine)

Expand Down Expand Up @@ -224,6 +228,7 @@
[6487]: https://github.com/enso-org/enso/pull/6487
[6341]: https://github.com/enso-org/enso/pull/6341
[6470]: https://github.com/enso-org/enso/pull/6470
[6512]: https://github.com/enso-org/enso/pull/6512

#### Enso Standard Library

Expand Down Expand Up @@ -430,6 +435,7 @@
- [Implemented `Column.format` for in-memory `Column`s.][6538]
- [Added `at_least_one` flag to `Table.tokenize_to_rows`.][6539]
- [Moved `Redshift` connector into a separate `AWS` library.][6550]
- [Added `Date_Range`.][6621]

[debug-shortcuts]:
https://github.com/enso-org/enso/blob/develop/app/gui/docs/product/shortcuts.md#debug
Expand Down Expand Up @@ -639,6 +645,7 @@
[6538]: https://github.com/enso-org/enso/pull/6538
[6539]: https://github.com/enso-org/enso/pull/6539
[6550]: https://github.com/enso-org/enso/pull/6550
[6621]: https://github.com/enso-org/enso/pull/6621

#### Enso Compiler

Expand Down
12 changes: 12 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions app/gui/docs/product/shortcuts.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ broken and require further investigation.
#### Debug

| Shortcut | Action |
| ------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------ | ---------------------- |
| ------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------ |
| <kbd>ctrl</kbd> + <kbd>shift</kbd> + <kbd>d</kbd> | Toggle Debug Mode. All actions below are only possible when it is activated. |
| <kbd>ctrl</kbd> + <kbd>alt</kbd> + <kbd>shift</kbd> + <kbd>i</kbd> | Open the developer console. |
| <kbd>ctrl</kbd> + <kbd>alt</kbd> + <kbd>shift</kbd> + <kbd>r</kbd> | Reload the visual interface. |
Expand All @@ -137,4 +137,4 @@ broken and require further investigation.
| <kbd>ctrl</kbd> + <kbd>shift</kbd> + <kbd>enter</kbd> | Push a hardcoded breadcrumb without navigating. |
| <kbd>ctrl</kbd> + <kbd>shift</kbd> + <kbd>arrow up</kbd> | Pop a breadcrumb without navigating. |
| <kbd>cmd</kbd> + <kbd>i</kbd> | Reload visualizations. To see the effect in the currently shown visualizations, you need to switch to another and switch back. |
| <kbd>ctrl</kbd> + <kbd>shift</kbd> + <kbd>b</kbd> | | Toggle read-only mode. |
| <kbd>ctrl</kbd> + <kbd>shift</kbd> + <kbd>b</kbd> | Toggle read-only mode. |
74 changes: 46 additions & 28 deletions app/gui/src/controller/graph/executed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ use crate::model::execution_context::VisualizationUpdateData;
use double_representation::name::QualifiedName;
use engine_protocol::language_server::ExecutionEnvironment;
use engine_protocol::language_server::MethodPointer;
use futures::stream;
use futures::TryStreamExt;
use span_tree::generate::context::CalledMethodInfo;
use span_tree::generate::context::Context;

Expand Down Expand Up @@ -65,10 +67,10 @@ pub enum Notification {
/// The notification from the execution context about the computed value information
/// being updated.
ComputedValueInfo(model::execution_context::ComputedValueExpressions),
/// Notification emitted when the node has been entered.
EnteredNode(LocalCall),
/// Notification emitted when the node was step out.
SteppedOutOfNode(double_representation::node::Id),
/// Notification emitted when a call stack has been entered.
EnteredStack(Vec<LocalCall>),
/// Notification emitted when a number of frames of the call stack have been exited.
ExitedStack(usize),
}


Expand Down Expand Up @@ -196,7 +198,7 @@ impl Handle {
.boxed_local();

let streams = vec![value_stream, graph_stream, self_stream, db_stream, update_stream];
futures::stream::select_all(streams)
stream::select_all(streams)
}

// Note [Argument Names-related invalidations]
Expand All @@ -216,29 +218,38 @@ impl Handle {
registry.clone_ref().get_type(id)
}

/// Enter node by given node ID and method pointer.
/// Enter the given stack of nodes by node ID and method pointer.
///
/// This will cause pushing a new stack frame to the execution context and changing the graph
/// controller to point to a new definition.
/// This will push new stack frames to the execution context and change the graph controller to
/// point to a new definition.
///
/// ### Errors
/// - Fails if method graph cannot be created (see `graph_for_method` documentation).
/// - Fails if the project is in read-only mode.
pub async fn enter_method_pointer(&self, local_call: &LocalCall) -> FallibleResult {
pub async fn enter_stack(&self, stack: Vec<LocalCall>) -> FallibleResult {
if self.project.read_only() {
Err(ReadOnly.into())
} else {
debug!("Entering node {}.", local_call.call);
let method_ptr = &local_call.definition;
let graph = controller::Graph::new_method(&self.project, method_ptr);
let graph = graph.await?;
self.execution_ctx.push(local_call.clone()).await?;
debug!("Replacing graph with {graph:?}.");
self.graph.replace(graph);
debug!("Sending graph invalidation signal.");
self.notifier.publish(Notification::EnteredNode(local_call.clone())).await;

Ok(())
let mut successful_calls = Vec::new();
let result = stream::iter(stack)
.then(|local_call| async {
debug!("Entering node {}.", local_call.call);
self.execution_ctx.push(local_call.clone()).await?;
Ok(local_call)
})
.map_ok(|local_call| successful_calls.push(local_call))
.try_collect::<()>()
.await;
if let Some(last_successful_call) = successful_calls.last() {
let graph =
controller::Graph::new_method(&self.project, &last_successful_call.definition)
.await?;
debug!("Replacing graph with {graph:?}.");
self.graph.replace(graph);
debug!("Sending graph invalidation signal.");
self.notifier.publish(Notification::EnteredStack(successful_calls)).await;
}
result
}
}

Expand All @@ -255,22 +266,29 @@ impl Handle {
Ok(node_info)
}

/// Leave the current node. Reverse of `enter_node`.
/// Leave the given number of stack frames. Reverse of `enter_stack`.
///
/// ### Errors
/// - Fails if this execution context is already at the stack's root or if the parent graph
/// cannot be retrieved.
/// - Fails if the project is in read-only mode.
pub async fn exit_node(&self) -> FallibleResult {
pub async fn exit_stack(&self, frame_count: usize) -> FallibleResult {
if self.project.read_only() {
Err(ReadOnly.into())
} else {
let frame = self.execution_ctx.pop().await?;
let method = self.execution_ctx.current_method();
let graph = controller::Graph::new_method(&self.project, &method).await?;
self.graph.replace(graph);
self.notifier.publish(Notification::SteppedOutOfNode(frame.call)).await;
Ok(())
let mut successful_pop_count = 0;
let result = stream::iter(0..frame_count)
.then(|_| self.execution_ctx.pop())
.map_ok(|_| successful_pop_count += 1)
.try_collect::<()>()
.await;
if successful_pop_count > 0 {
let method = self.execution_ctx.current_method();
let graph = controller::Graph::new_method(&self.project, &method).await?;
self.graph.replace(graph);
self.notifier.publish(Notification::ExitedStack(successful_pop_count)).await;
}
result
}
}

Expand Down
11 changes: 4 additions & 7 deletions app/gui/src/controller/project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,13 +189,10 @@ impl Project {
) {
// Restore the call stack from the metadata.
let initial_call_stack = main_module.with_project_metadata(|m| m.call_stack.clone());
for frame in initial_call_stack {
// Push as many frames as possible. We should not be too concerned about failure here.
// It is to be assumed that metadata can get broken.
if let Err(e) = main_graph.enter_method_pointer(&frame).await {
warn!("Failed to push initial stack frame: {frame:?}: {e}");
break;
}
// We should not be too concerned about failure here. It is to be assumed that metadata can
// get broken.
if let Err(error) = main_graph.enter_stack(initial_call_stack).await {
warn!("Failed to push initial call stack. {error}");
}
}

Expand Down
4 changes: 2 additions & 2 deletions app/gui/src/presenter/graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -833,8 +833,8 @@ impl Graph {
},
executed::Notification::ComputedValueInfo(expressions) =>
update_expressions.emit(expressions),
executed::Notification::EnteredNode(_) => update_view.emit(()),
executed::Notification::SteppedOutOfNode(_) => update_view.emit(()),
executed::Notification::EnteredStack(_)
| executed::Notification::ExitedStack(_) => update_view.emit(()),
}
std::future::ready(())
})
Expand Down
Loading

0 comments on commit 50e1da7

Please sign in to comment.