This repository has been archived by the owner on Dec 28, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 34
Create new project action in searcher. #1566
Merged
Merged
Changes from 19 commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
074aefe
WIP
farmaazon ca89039
WIP
farmaazon c44ad20
Refactored project setup
farmaazon ec93597
Create new project action
farmaazon 1be198c
Fixes
farmaazon 1b11b70
Code cleanup
farmaazon 6df60f5
Self-review
farmaazon 99f32f1
Merge remote-tracking branch 'origin/develop' into wip/ao/create-new-…
farmaazon 9a65231
Fix compilation
farmaazon 679d654
Update src/rust/ide/src/controller/ide/desktop.rs
farmaazon a0ee9e5
Update src/rust/ide/src/controller/ide/desktop.rs
farmaazon 589a403
Update src/rust/ide/src/controller/ide/desktop.rs
farmaazon 5148154
Update src/rust/ide/src/controller/project.rs
farmaazon 58b10ec
Update src/rust/ide/src/controller/ide/plain.rs
farmaazon b929f64
Update src/rust/ide/src/controller/project.rs
farmaazon 75d5366
Update src/rust/ide/src/controller/project.rs
farmaazon 384b9a0
Fixes
farmaazon b675ee4
Applying @mwu-two review
farmaazon ab849cb
Merge remote-tracking branch 'origin/develop' into wip/ao/create-new-…
farmaazon 245c21f
Applying @wdanilo review
farmaazon 84921d7
Merge remote-tracking branch 'origin/develop' into wip/ao/create-new-…
farmaazon a58d8bc
Linter fixes
farmaazon 9b9c14d
Merge branch 'develop' into wip/ao/create-new-project2
farmaazon ccda769
prettify CHANGELOG
farmaazon c264a2c
Fix tests
farmaazon File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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>) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd bikeshed a few more names here. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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>; | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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>; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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") | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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!