Skip to content

Commit 31006e9

Browse files
refactor(Common): Streamline effect capability access and organize DTOs
- Updated all effect constructors to directly access capabilities via `RunTime.Require()` instead of through `RunTime.GetEnvironment().Require()`, simplifying the capability access pattern in alignment with the final Land architecture where the runtime itself provides required capabilities - Added a top-level DTO module to centralize data transfer object definitions, including new `WorkSpaceEditDTO` for workspace operations - Implemented `ProviderType` enum in LanguageFeature DTOs to strongly type language feature provider registrations - Enhanced the `ActionEffect` type with a `map` method for output transformation This refactoring reduces boilerplate in effect definitions and establishes a clear structure for DTOs, improving consistency across the core abstraction layer while maintaining functional parity.
1 parent 079246f commit 31006e9

File tree

69 files changed

+248
-202
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+248
-202
lines changed

Source/Command/ExecuteCommand.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,12 @@ pub fn ExecuteCommand<TRunTime>(
3939
) -> ActionEffect<Arc<TRunTime>, CommonError, Value>
4040
where
4141
TRunTime: ApplicationRunTime + Send + Sync + 'static,
42-
TRunTime::EnvironmentType: Requires<Arc<dyn CommandExecutor>>, {
42+
TRunTime: Requires<Arc<dyn CommandExecutor>>, {
4343
ActionEffect::New(Arc::new(move |RunTime:Arc<TRunTime>| {
4444
let CommandIdentifierClone = CommandIdentifier.clone();
4545
let ArgumentClone = Argument.clone();
4646
Box::pin(async move {
47-
let Environment = RunTime.GetEnvironment();
48-
let Executor:Arc<dyn CommandExecutor> = Environment.Require();
47+
let Executor:Arc<dyn CommandExecutor> = RunTime.Require();
4948
Executor.ExecuteCommand(CommandIdentifierClone, ArgumentClone).await
5049
})
5150
}))

Source/Command/GetAllCommands.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,10 @@ use crate::{
2626
pub fn GetAllCommands<TRunTime>() -> ActionEffect<Arc<TRunTime>, CommonError, Vec<String>>
2727
where
2828
TRunTime: ApplicationRunTime + Send + Sync + 'static,
29-
TRunTime::EnvironmentType: Requires<Arc<dyn CommandExecutor>>, {
29+
TRunTime: Requires<Arc<dyn CommandExecutor>>, {
3030
ActionEffect::New(Arc::new(move |RunTime:Arc<TRunTime>| {
3131
Box::pin(async move {
32-
let Environment = RunTime.GetEnvironment();
33-
let Executor:Arc<dyn CommandExecutor> = Environment.Require();
32+
let Executor:Arc<dyn CommandExecutor> = RunTime.Require();
3433
Executor.GetAllCommands().await
3534
})
3635
}))

Source/Command/RegisterCommand.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,12 @@ pub fn RegisterCommand<TRunTime>(
3636
) -> ActionEffect<Arc<TRunTime>, CommonError, ()>
3737
where
3838
TRunTime: ApplicationRunTime + Send + Sync + 'static,
39-
TRunTime::EnvironmentType: Requires<Arc<dyn CommandExecutor>>, {
39+
TRunTime: Requires<Arc<dyn CommandExecutor>>, {
4040
ActionEffect::New(Arc::new(move |RunTime:Arc<TRunTime>| {
4141
let SidecarIdentifierClone = SidecarIdentifier.clone();
4242
let CommandIdentifierClone = CommandIdentifier.clone();
4343
Box::pin(async move {
44-
let Environment = RunTime.GetEnvironment();
45-
let Executor:Arc<dyn CommandExecutor> = Environment.Require();
44+
let Executor:Arc<dyn CommandExecutor> = RunTime.Require();
4645
Executor.RegisterCommand(SidecarIdentifierClone, CommandIdentifierClone).await
4746
})
4847
}))

Source/Command/UnregisterCommand.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,12 @@ pub fn UnregisterCommand<TRunTime>(
3333
) -> ActionEffect<Arc<TRunTime>, CommonError, ()>
3434
where
3535
TRunTime: ApplicationRunTime + Send + Sync + 'static,
36-
TRunTime::EnvironmentType: Requires<Arc<dyn CommandExecutor>>, {
36+
TRunTime: Requires<Arc<dyn CommandExecutor>>, {
3737
ActionEffect::New(Arc::new(move |RunTime:Arc<TRunTime>| {
3838
let SidecarIdentifierClone = SidecarIdentifier.clone();
3939
let CommandIdentifierClone = CommandIdentifier.clone();
4040
Box::pin(async move {
41-
let Environment = RunTime.GetEnvironment();
42-
let Executor:Arc<dyn CommandExecutor> = Environment.Require();
41+
let Executor:Arc<dyn CommandExecutor> = RunTime.Require();
4342
Executor.UnregisterCommand(SidecarIdentifierClone, CommandIdentifierClone).await
4443
})
4544
}))

Source/Configuration/GetConfiguration.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,12 @@ pub fn GetConfiguration<TRunTime>(
3838
) -> ActionEffect<Arc<TRunTime>, CommonError, Value>
3939
where
4040
TRunTime: ApplicationRunTime + Send + Sync + 'static,
41-
TRunTime::EnvironmentType: Requires<Arc<dyn ConfigurationProvider>>, {
41+
TRunTime: Requires<Arc<dyn ConfigurationProvider>>, {
4242
ActionEffect::New(Arc::new(move |RunTime:Arc<TRunTime>| {
4343
let SectionClone = Section.clone();
4444
let OverridesValueClone = OverridesValue.clone();
4545
Box::pin(async move {
46-
let Environment = RunTime.GetEnvironment();
47-
let Provider:Arc<dyn ConfigurationProvider> = Environment.Require();
46+
let Provider:Arc<dyn ConfigurationProvider> = RunTime.Require();
4847

4948
let OverridesParsed:ConfigurationOverridesDTO =
5049
serde_json::from_value(OverridesValueClone).map_err(|e| {

Source/Configuration/InspectConfiguration.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,12 @@ pub fn InspectConfiguration<TRunTime>(
4242
) -> ActionEffect<Arc<TRunTime>, CommonError, Option<InspectResultDataDTO>>
4343
where
4444
TRunTime: ApplicationRunTime + Send + Sync + 'static,
45-
TRunTime::EnvironmentType: Requires<Arc<dyn ConfigurationInspector>>, {
45+
TRunTime: Requires<Arc<dyn ConfigurationInspector>>, {
4646
ActionEffect::New(Arc::new(move |RunTime:Arc<TRunTime>| {
4747
let KeyClone = Key.clone();
4848
let OverridesValueClone = OverridesValue.clone();
4949
Box::pin(async move {
50-
let Environment = RunTime.GetEnvironment();
51-
let Inspector:Arc<dyn ConfigurationInspector> = Environment.Require();
50+
let Inspector:Arc<dyn ConfigurationInspector> = RunTime.Require();
5251

5352
let OverridesParsed:ConfigurationOverridesDTO =
5453
serde_json::from_value(OverridesValueClone).map_err(|e| {

Source/Configuration/UpdateConfiguration.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,14 @@ pub fn UpdateConfiguration<TRunTime>(
4646
) -> ActionEffect<Arc<TRunTime>, CommonError, ()>
4747
where
4848
TRunTime: ApplicationRunTime + Send + Sync + 'static,
49-
TRunTime::EnvironmentType: Requires<Arc<dyn ConfigurationProvider>>, {
49+
TRunTime: Requires<Arc<dyn ConfigurationProvider>>, {
5050
ActionEffect::New(Arc::new(move |RunTime:Arc<TRunTime>| {
5151
let KeyClone = Key.clone();
5252
let ValueToSetClone = ValueToSet.clone();
5353
let OverridesValueClone = OverridesValue.clone();
5454
let ScopeToLanguageClone = ScopeToLanguage;
5555
Box::pin(async move {
56-
let Environment = RunTime.GetEnvironment();
57-
let Provider:Arc<dyn ConfigurationProvider> = Environment.Require();
56+
let Provider:Arc<dyn ConfigurationProvider> = RunTime.Require();
5857

5958
// Deserialize the integer target into the enum.
6059
let TargetParsed:ConfigurationTarget = serde_json::from_value(Value::from(TargetAsU32)).map_err(|e| {

Source/DTO/WorkSpaceEditDTO.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
//! # WorkSpaceEditDTO
2+
//!
3+
//! Defines the Data Transfer Object for a workspace edit, which is a collection
4+
//! of changes to be applied across multiple files in the workspace.
5+
6+
use serde::{Deserialize, Serialize};
7+
use serde_json::Value;
8+
9+
/// A serializable struct representing a workspace edit, which is a batch of
10+
/// changes that can include text edits and file operations (create, delete,
11+
/// rename). This is analogous to `vscode.WorkspaceEdit`.
12+
#[derive(Serialize, Deserialize, Debug, Clone, Default)]
13+
#[serde(rename_all = "PascalCase")]
14+
pub struct WorkSpaceEditDTO {
15+
/// A list of text edits to apply, grouped by resource URI.
16+
/// The structure is `[ [uri_dto, [text_edit_dto, ...]], ... ]`
17+
pub Edits:Vec<(Value, Vec<Value>)>,
18+
// Future fields for file operations would go here:
19+
// pub file_operations: Vec<FileOperationDTO>,
20+
}

Source/DTO/mod.rs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
//! # Global DTO Module
2+
//!
3+
//! A top-level module that re-exports all Data Transfer Objects (DTOs) from the
4+
//! various service modules for convenient access across the application.
5+
//! It also contains DTOs that are shared across multiple services.
6+
7+
#![allow(non_snake_case, non_camel_case_types)]
8+
9+
pub mod WorkSpaceEditDTO;
10+
11+
// // Re-export shared DTOs
12+
// pub use self::WorkSpaceEditDTO::WorkSpaceEditDTO;
13+
14+
// // Re-export service-specific DTOs
15+
// pub use crate::Configuration::DTO::*;
16+
// pub use crate::FileSystem::DTO::*;
17+
// pub use crate::IPC::DTO::*;
18+
// pub use crate::LanguageFeature::DTO::*;
19+
// pub use crate::SourceControlManagement::DTO::*;
20+
// pub use crate::StatusBar::DTO::*;
21+
// pub use crate::TreeView::DTO::*;
22+
// pub use crate::UserInterface::DTO::*;
23+
// pub use crate::WebView::DTO::*;

Source/Diagnostic/ClearDiagnostics.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,11 @@ use crate::{
2828
pub fn ClearDiagnostics<TRunTime>(Owner:String) -> ActionEffect<Arc<TRunTime>, CommonError, ()>
2929
where
3030
TRunTime: ApplicationRunTime + Send + Sync + 'static,
31-
TRunTime::EnvironmentType: Requires<Arc<dyn DiagnosticManager>>, {
31+
TRunTime: Requires<Arc<dyn DiagnosticManager>>, {
3232
ActionEffect::New(Arc::new(move |RunTime:Arc<TRunTime>| {
3333
let OwnerClone = Owner.clone();
3434
Box::pin(async move {
35-
let Environment = RunTime.GetEnvironment();
36-
let Manager:Arc<dyn DiagnosticManager> = Environment.Require();
35+
let Manager:Arc<dyn DiagnosticManager> = RunTime.Require();
3736
Manager.ClearDiagnostics(OwnerClone).await
3837
})
3938
}))

0 commit comments

Comments
 (0)