Skip to content
This repository has been archived by the owner on Dec 28, 2021. It is now read-only.

Create new project action in searcher. #1566

Merged
merged 25 commits into from
May 21, 2021
Merged
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
074aefe
WIP
farmaazon Apr 27, 2021
ca89039
WIP
farmaazon Apr 27, 2021
c44ad20
Refactored project setup
farmaazon May 12, 2021
ec93597
Create new project action
farmaazon May 12, 2021
1be198c
Fixes
farmaazon May 12, 2021
1b11b70
Code cleanup
farmaazon May 13, 2021
6df60f5
Self-review
farmaazon May 13, 2021
99f32f1
Merge remote-tracking branch 'origin/develop' into wip/ao/create-new-…
farmaazon May 13, 2021
9a65231
Fix compilation
farmaazon May 14, 2021
679d654
Update src/rust/ide/src/controller/ide/desktop.rs
farmaazon May 17, 2021
a0ee9e5
Update src/rust/ide/src/controller/ide/desktop.rs
farmaazon May 17, 2021
589a403
Update src/rust/ide/src/controller/ide/desktop.rs
farmaazon May 17, 2021
5148154
Update src/rust/ide/src/controller/project.rs
farmaazon May 17, 2021
58b10ec
Update src/rust/ide/src/controller/ide/plain.rs
farmaazon May 17, 2021
b929f64
Update src/rust/ide/src/controller/project.rs
farmaazon May 17, 2021
75d5366
Update src/rust/ide/src/controller/project.rs
farmaazon May 17, 2021
384b9a0
Fixes
farmaazon May 14, 2021
b675ee4
Applying @mwu-two review
farmaazon May 17, 2021
ab849cb
Merge remote-tracking branch 'origin/develop' into wip/ao/create-new-…
farmaazon May 17, 2021
245c21f
Applying @wdanilo review
farmaazon May 18, 2021
84921d7
Merge remote-tracking branch 'origin/develop' into wip/ao/create-new-…
farmaazon May 21, 2021
a58d8bc
Linter fixes
farmaazon May 21, 2021
9b9c14d
Merge branch 'develop' into wip/ao/create-new-project2
farmaazon May 21, 2021
ccda769
prettify CHANGELOG
farmaazon May 21, 2021
c264a2c
Fix tests
farmaazon May 21, 2021
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
47 changes: 45 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Enso 2.0.0-alpha.5 (2021-05-14)
# Next Release

<br/>![New Features](/docs/assets/tags/new_features.svg)

Expand All @@ -10,7 +10,6 @@

#### Visual Environment

- [Delete key will delete selected nodes][1538].
- [It is possible to move around after deleting a node with a selected
visualization][1556]. Deleting a node while its attached visualization was
selected made it impossible to pan or zoom around the stage afterwards. This
Expand All @@ -23,6 +22,35 @@

#### Enso Compiler

If you're interested in the enhancements and fixes made to the Enso compiler,
you can find their release notes
[here](https://github.com/enso-org/enso/blob/main/RELEASES.md).

[1556]: https://github.com/enso-org/ide/pull/1556
[1561]: https://github.com/enso-org/ide/pull/1561

<br/>



# Enso 2.0.0-alpha.5 (2021-05-14)

<br/>![New Features](/docs/assets/tags/new_features.svg)

#### Visual Environment

#### EnsoGL (rendering engine)

<br/>![Bug Fixes](/docs/assets/tags/bug_fixes.svg)

#### Visual Environment

- [Delete key will delete selected nodes][1538].

#### EnsoGL (rendering engine)

#### Enso Compiler

- [Updated Enso engine to version 0.2.11][1541].

If you're interested in the enhancements and fixes made to the Enso compiler,
Expand All @@ -42,13 +70,24 @@ you can find their release notes
#### Visual Environment

- [Window management buttons.][1511]. The IDE now has components for
<<<<<<< HEAD
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thisi s a commited file with git conflicts!

"fullscreen" nad "close" buttons. They will be available only when running IDE
in a cloud environment.
- [Create New Project action in Searcher][1566]. When you bring the searcher
with tab having no node selected, a new action will be available next to the
examples and code suggestions: `Create New Project`. When you choose it by
clicking with mouse or selecting and pressing enter, a new unnamed project
will be created and opened in the application. Then you can give a name to
this project.
=======
"fullscreen" and "close" buttons. They will when running IDE in a cloud
environment where no native window buttons are available.
- [Customizable backend options][1531]. When invoking Enso IDE through command
line interface, it is possible to add the `--` argument separator. All
arguments following the separator will be passed to the backend.
- [Added `--verbose` parameter][1531]. If `--verbose` is given as command line
argument, the IDE and the backend will produce more detailed logs.
>>>>>>> origin/develop

<br/>![Bug Fixes](/docs/assets/tags/bug_fixes.svg)

Expand All @@ -69,9 +108,13 @@ you can find their release notes
[here](https://github.com/enso-org/enso/blob/main/RELEASES.md).

[1511]: https://github.com/enso-org/ide/pull/1511
<<<<<<< HEAD
[1566]: https://github.com/enso-org/ide/pull/1566
=======
[1536]: https://github.com/enso-org/ide/pull/1536
[1531]: https://github.com/enso-org/ide/pull/1531
[1531]: https://github.com/enso-org/ide/pull/1539
>>>>>>> origin/develop

<br/>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ pub type Event = json_rpc::handler::Event<Notification>;
// ============

/// A path is a representation of a path relative to a specified content root.
// FIXME [mwu] Consider rename to something like `FilePath`, see https://github.com/enso-org/enso/issues/708
#[derive(Clone,Debug,Serialize,Deserialize,Hash,PartialEq,Eq)]
#[serde(rename_all="camelCase")]
pub struct Path {
Expand Down
10 changes: 9 additions & 1 deletion src/rust/ide/lib/enso-protocol/src/project_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ impl Display for IpWithSocket {
}

/// Project name.
#[derive(Debug,Display,Clone,Serialize,Deserialize,From,PartialEq,Shrinkwrap)]
#[derive(Clone,Debug,Deserialize,Display,Eq,From,Hash,PartialEq,Serialize,Shrinkwrap)]
#[shrinkwrap(mutable)]
pub struct ProjectName(pub String);

Expand All @@ -111,6 +111,14 @@ impl ProjectName {
}
}

impl AsRef<str> for ProjectName {
fn as_ref(&self) -> &str { &self.0 }
}

impl From<ProjectName> for String {
fn from(name:ProjectName) -> Self { name.0 }
}

/// Project information, such as name, its id and last time it was opened.
#[derive(Debug,Clone,Serialize,Deserialize,PartialEq)]
pub struct ProjectMetadata {
Expand Down
18 changes: 6 additions & 12 deletions src/rust/ide/src/controller.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,22 @@
//! between clients of remote services (like language server and file manager)
//! and views.
//!
//! The controllers create a tree-like structure, with project controller being
//! a root, then module controllers below, then graph/text controller and so on.
//!
//! As a general rule, while the "upper" (i.e. closer to root) nodes may keep
//! handles to the "lower" nodes (e.g. to allow their reuse), they should never
//! manage their lifetime.
//!
//! Primarily views are considered owners of their respective controllers.
//! Additionally, controllers are allowed to keep strong handle "upwards".
//!
//! Controllers store their handles using `utils::cell` handle types to ensure
//! that mutable state is safely accessed.
//! The API of each controller is "view-facing", in contrast to the models in [`crate::model`] which
//! are focusing on reflecting the Engine entities (thus can be called "Engine-facing").

pub mod graph;
pub mod ide;
pub mod module;
pub mod text;
pub mod project;
pub mod visualization;
pub mod searcher;

pub use graph::Handle as Graph;
pub use graph::executed::Handle as ExecutedGraph;
pub use self::ide::Ide;
pub use module::Handle as Module;
pub use project::Project;
pub use text::Handle as Text;
pub use visualization::Handle as Visualization;
pub use searcher::Searcher;
Expand Down
150 changes: 150 additions & 0 deletions src/rust/ide/src/controller/ide.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
//! IDE controller
//!
//! The IDE controller expose functionality bound to the application as a whole, not to specific
//! component or opened project.

pub mod desktop;
pub mod plain;

use crate::prelude::*;

use crate::notification;

use mockall::automock;
use parser::Parser;



// ============================
// === Status Notifications ===
// ============================

/// The handle used to pair the ProcessStarted and ProcessFinished notifications.
pub type BackgroundTaskHandle = usize;

/// A notification which should be displayed to the User on the status bar.
#[allow(missing_docs)]
#[derive(Clone,Debug)]
pub enum StatusNotification {
/// Notification about single event, should be logged in an event log window.
Event { label:String },
/// Notification about new background task done in IDE (like compiling library).
BackgroundTaskStarted { label:String, handle: BackgroundTaskHandle },
/// Notification that some task notified in [`BackgroundTaskStarted`] has been finished.
BackgroundTaskFinished { handle:BackgroundTaskHandle },
}

/// A publisher for status notification events.
#[derive(Clone,CloneRef,Debug,Default)]
pub struct StatusNotificationPublisher {
publisher : notification::Publisher<StatusNotification>,
next_process_handle : Rc<Cell<usize>>,
}

impl StatusNotificationPublisher {
/// Constructor.
pub fn new() -> Self { default() }

/// Publish a new status event (see [`StatusNotification::Event`])
pub fn publish_event(&self, label:impl Into<String>) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd bikeshed a few more names here.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I dont understand this comment

let label = label.into();
let notification = StatusNotification::Event {label};
executor::global::spawn(self.publisher.publish(notification));
}

/// Publish a notification about new process (see [`StatusNotification::ProcessStarted`]).
///
/// Returns the handle to be used when notifying about process finishing.
pub fn publish_background_task(&self, label:impl Into<String>) -> BackgroundTaskHandle {
let label = label.into();
let handle = self.next_process_handle.get();
self.next_process_handle.set(handle + 1);
let notification = StatusNotification::BackgroundTaskStarted {label,handle};
executor::global::spawn(self.publisher.publish(notification));
handle
}

/// Publish a notfication that process has finished (see [`StatusNotification::ProcessFinished`])
pub fn published_background_task_finished(&self, handle:BackgroundTaskHandle) {
let notification = StatusNotification::BackgroundTaskFinished {handle};
executor::global::spawn(self.publisher.publish(notification));
}

/// The asynchronous stream of published notifications.
pub fn subscribe(&self) -> impl Stream<Item=StatusNotification> {
self.publisher.subscribe()
}
}



// ====================
// === Notification ===
// ====================

/// Notification of IDE Controller.
///
/// In contrast to [`StatusNotification`], which is a notification from any application part to
/// be delivered to User (displayed on some event log or status bar), this is a notification to be
/// used internally in code.
#[derive(Copy,Clone,Debug)]
pub enum Notification {
/// User created a new project. The new project is opened in IDE.
NewProjectCreated
}



// ===========
// === API ===
// ===========

/// The API of all project management operations.
///
/// It is a separate trait, because those methods are not supported in some environments (see also
/// [`API::manage_projects`]).
pub trait ManagingProjectAPI {

/// Create a new unnamed project and open it in the IDE.
fn create_new_project(&self) -> BoxFuture<FallibleResult>;
}

/// The API of IDE Controller.
#[automock]
pub trait API:Debug {
/// The model of currently opened project.
///
/// IDE can have only one project opened at a time.
fn current_project(&self) -> model::Project;

/// Getter of Status Notification Publisher.
fn status_notifications(&self) -> &StatusNotificationPublisher;
farmaazon marked this conversation as resolved.
Show resolved Hide resolved

/// The Parser Handle.
fn parser(&self) -> &Parser;

/// Subscribe the controller notifications.
fn subscribe(&self) -> StaticBoxStream<Notification>;

/// Return the Managing Project API.
///
/// It may be some delegated object or just the reference to self.
// Automock macro does not work without explicit lifetimes here.
#[allow(clippy::needless_lifetimes)]
fn manage_projects<'a>(&'a self) -> FallibleResult<&'a dyn ManagingProjectAPI>;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps IDE should also provide parser?


/// A polymorphic handle of IDE controller.
pub type Ide = Rc<dyn API>;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

alignment


/// The IDE Controller for desktop environments.
pub type Desktop = desktop::Handle;

/// The Plain IDE controller with a single project and no possibility to change it.
pub type Plain = plain::Handle;

impl Debug for MockAPI {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f,"Mocked Ide Controller")
}
}
Loading