Skip to content

Commit

Permalink
ruby_runtime: draft
Browse files Browse the repository at this point in the history
  • Loading branch information
vitallium committed Feb 22, 2025
1 parent c18be3e commit 70f8d6d
Show file tree
Hide file tree
Showing 25 changed files with 516 additions and 0 deletions.
31 changes: 31 additions & 0 deletions Cargo.lock

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

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ members = [
"crates/rich_text",
"crates/rope",
"crates/rpc",
"crates/ruby_runtime",
"crates/schema_generator",
"crates/search",
"crates/semantic_index",
Expand Down Expand Up @@ -313,6 +314,7 @@ reqwest_client = { path = "crates/reqwest_client" }
rich_text = { path = "crates/rich_text" }
rope = { path = "crates/rope" }
rpc = { path = "crates/rpc" }
ruby_runtime = { path = "crates/ruby_runtime" }
search = { path = "crates/search" }
semantic_index = { path = "crates/semantic_index" }
semantic_version = { path = "crates/semantic_version" }
Expand Down
1 change: 1 addition & 0 deletions crates/collab/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ rand.workspace = true
reqwest = { version = "0.11", features = ["json"] }
reqwest_client.workspace = true
rpc.workspace = true
ruby_runtime.workspace = true
rustc-demangle.workspace = true
scrypt = "0.11"
sea-orm = { version = "1.1.0-rc.1", features = ["sqlx-postgres", "postgres-array", "runtime-tokio-rustls", "with-uuid"] }
Expand Down
6 changes: 6 additions & 0 deletions crates/collab/src/tests/remote_editing_collaboration_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ use project::{
};
use remote::SshRemoteClient;
use remote_server::{HeadlessAppState, HeadlessProject};
use ruby_runtime::RubyRuntime;
use serde_json::json;
use settings::SettingsStore;
use std::{path::Path, sync::Arc};
Expand Down Expand Up @@ -74,6 +75,7 @@ async fn test_sharing_an_ssh_remote_project(
server_cx.update(HeadlessProject::init);
let remote_http_client = Arc::new(BlockedHttpClient);
let node = NodeRuntime::unavailable();
let ruby = RubyRuntime::unavailable();
let languages = Arc::new(LanguageRegistry::new(server_cx.executor()));
let _headless_project = server_cx.new(|cx| {
client::init_settings(cx);
Expand All @@ -83,6 +85,7 @@ async fn test_sharing_an_ssh_remote_project(
fs: remote_fs.clone(),
http_client: remote_http_client,
node_runtime: node,
ruby_runtime: ruby,
languages,
extension_host_proxy: Arc::new(ExtensionHostProxy::new()),
},
Expand Down Expand Up @@ -241,6 +244,7 @@ async fn test_ssh_collaboration_git_branches(
server_cx.update(HeadlessProject::init);
let remote_http_client = Arc::new(BlockedHttpClient);
let node = NodeRuntime::unavailable();
let ruby = RubyRuntime::unavailable();
let languages = Arc::new(LanguageRegistry::new(server_cx.executor()));
let headless_project = server_cx.new(|cx| {
client::init_settings(cx);
Expand All @@ -250,6 +254,7 @@ async fn test_ssh_collaboration_git_branches(
fs: remote_fs.clone(),
http_client: remote_http_client,
node_runtime: node,
ruby_runtime: ruby,
languages,
extension_host_proxy: Arc::new(ExtensionHostProxy::new()),
},
Expand Down Expand Up @@ -408,6 +413,7 @@ async fn test_ssh_collaboration_formatting_with_prettier(
fs: remote_fs.clone(),
http_client: remote_http_client,
node_runtime: NodeRuntime::unavailable(),
ruby_runtime: RubyRuntime::unavailable(),
languages,
extension_host_proxy: Arc::new(ExtensionHostProxy::new()),
},
Expand Down
2 changes: 2 additions & 0 deletions crates/collab/src/tests/test_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ use rpc::{
proto::{self, ChannelRole},
RECEIVE_TIMEOUT,
};
use ruby_runtime::RubyRuntime;
use semantic_version::SemanticVersion;
use serde_json::json;
use session::{AppSession, Session};
Expand Down Expand Up @@ -285,6 +286,7 @@ impl TestServer {
fs: fs.clone(),
build_window_options: |_, _| Default::default(),
node_runtime: NodeRuntime::unavailable(),
ruby_runtime: RubyRuntime::unavailable(),
session,
});

Expand Down
3 changes: 3 additions & 0 deletions crates/extension_api/src/extension_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ pub use wit::{
npm_package_latest_version,
},
zed::extension::platform::{current_platform, Architecture, Os},
zed::extension::ruby::{
gems_install_gem, gems_installed_version, gems_latest_version, ruby_binary_path,
},
zed::extension::slash_command::{
SlashCommand, SlashCommandArgumentCompletion, SlashCommandOutput, SlashCommandOutputSection,
},
Expand Down
1 change: 1 addition & 0 deletions crates/extension_api/wit/since_v0.2.0/extension.wit
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ world extension {
import http-client;
import platform;
import nodejs;
import ruby;

use common.{range};
use lsp.{completion, symbol};
Expand Down
13 changes: 13 additions & 0 deletions crates/extension_api/wit/since_v0.2.0/ruby.wit
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
interface ruby {
/// Returns the path to the currently active Ruby binary.
ruby-binary-path: func() -> result<string, string>;

/// Returns the latest version of the given Ruby gem.
gems-latest-version: func(gem-name: string) -> result<string, string>;

/// Returns the installed version of the given Ruby gem, if it exists.
gems-installed-version: func(gem-name: string) -> result<option<string>, string>;

/// Installs the specified Ruby gem.
gems-install-gem: func(gem-name: string, version: string, binaries: list<string>) -> result<_, string>;
}
1 change: 1 addition & 0 deletions crates/extension_host/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ paths.workspace = true
project.workspace = true
remote.workspace = true
release_channel.workspace = true
ruby_runtime.workspace = true
schemars.workspace = true
semantic_version.workspace = true
serde.workspace = true
Expand Down
5 changes: 5 additions & 0 deletions crates/extension_host/src/extension_host.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ use node_runtime::NodeRuntime;
use project::ContextProviderWithTasks;
use release_channel::ReleaseChannel;
use remote::SshRemoteClient;
use ruby_runtime::RubyRuntime;
use semantic_version::SemanticVersion;
use serde::{Deserialize, Serialize};
use settings::Settings;
Expand Down Expand Up @@ -182,6 +183,7 @@ pub fn init(
fs: Arc<dyn Fs>,
client: Arc<Client>,
node_runtime: NodeRuntime,
ruby_runtime: RubyRuntime,
cx: &mut App,
) {
ExtensionSettings::register(cx);
Expand All @@ -196,6 +198,7 @@ pub fn init(
client.http_client().clone(),
Some(client.telemetry().clone()),
node_runtime,
ruby_runtime,
cx,
)
});
Expand Down Expand Up @@ -228,6 +231,7 @@ impl ExtensionStore {
builder_client: Arc<dyn HttpClient>,
telemetry: Option<Arc<Telemetry>>,
node_runtime: NodeRuntime,
ruby_runtime: RubyRuntime,
cx: &mut Context<Self>,
) -> Self {
let work_dir = extensions_dir.join("work");
Expand All @@ -250,6 +254,7 @@ impl ExtensionStore {
fs.clone(),
http_client.clone(),
node_runtime,
ruby_runtime,
extension_host_proxy,
work_dir,
cx,
Expand Down
6 changes: 6 additions & 0 deletions crates/extension_host/src/extension_store_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ use parking_lot::Mutex;
use project::{Project, DEFAULT_COMPLETION_CONTEXT};
use release_channel::AppVersion;
use reqwest_client::ReqwestClient;
use ruby_runtime::RubyRuntime;
use serde_json::json;
use settings::{Settings as _, SettingsStore};
use std::{
Expand Down Expand Up @@ -269,6 +270,7 @@ async fn test_extension_store(cx: &mut TestAppContext) {
let language_registry = Arc::new(LanguageRegistry::test(cx.executor()));
language_extension::init(proxy.clone(), language_registry.clone());
let node_runtime = NodeRuntime::unavailable();
let ruby_runtime = RubyRuntime::unavailable();

let store = cx.new(|cx| {
ExtensionStore::new(
Expand All @@ -280,6 +282,7 @@ async fn test_extension_store(cx: &mut TestAppContext) {
http_client.clone(),
None,
node_runtime.clone(),
ruby_runtime.clone(),
cx,
)
});
Expand Down Expand Up @@ -406,6 +409,7 @@ async fn test_extension_store(cx: &mut TestAppContext) {
http_client.clone(),
None,
node_runtime.clone(),
ruby_runtime.clone(),
cx,
)
});
Expand Down Expand Up @@ -494,6 +498,7 @@ async fn test_extension_store_with_test_extension(cx: &mut TestAppContext) {
let language_registry = project.read_with(cx, |project, _cx| project.languages().clone());
language_extension::init(proxy.clone(), language_registry.clone());
let node_runtime = NodeRuntime::unavailable();
let ruby_runtime = RubyRuntime::unavailable();

let mut status_updates = language_registry.language_server_binary_statuses();

Expand Down Expand Up @@ -592,6 +597,7 @@ async fn test_extension_store_with_test_extension(cx: &mut TestAppContext) {
builder_client,
None,
node_runtime,
ruby_runtime,
cx,
)
});
Expand Down
3 changes: 3 additions & 0 deletions crates/extension_host/src/headless_host.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ use http_client::HttpClient;
use language::{LanguageConfig, LanguageName, LanguageQueries, LoadedLanguage};
use lsp::LanguageServerName;
use node_runtime::NodeRuntime;
use ruby_runtime::RubyRuntime;

use crate::wasm_host::{WasmExtension, WasmHost};

Expand Down Expand Up @@ -40,6 +41,7 @@ impl HeadlessExtensionStore {
extension_dir: PathBuf,
extension_host_proxy: Arc<ExtensionHostProxy>,
node_runtime: NodeRuntime,
ruby_runtime: RubyRuntime,
cx: &mut App,
) -> Entity<Self> {
cx.new(|cx| Self {
Expand All @@ -48,6 +50,7 @@ impl HeadlessExtensionStore {
fs.clone(),
http_client.clone(),
node_runtime,
ruby_runtime,
extension_host_proxy.clone(),
extension_dir.join("work"),
cx,
Expand Down
4 changes: 4 additions & 0 deletions crates/extension_host/src/wasm_host.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ use language::LanguageName;
use lsp::LanguageServerName;
use node_runtime::NodeRuntime;
use release_channel::ReleaseChannel;
use ruby_runtime::RubyRuntime;
use semantic_version::SemanticVersion;
use std::{
path::{Path, PathBuf},
Expand All @@ -40,6 +41,7 @@ pub struct WasmHost {
release_channel: ReleaseChannel,
http_client: Arc<dyn HttpClient>,
node_runtime: NodeRuntime,
ruby_runtime: RubyRuntime,
pub(crate) proxy: Arc<ExtensionHostProxy>,
fs: Arc<dyn Fs>,
pub work_dir: PathBuf,
Expand Down Expand Up @@ -329,6 +331,7 @@ impl WasmHost {
fs: Arc<dyn Fs>,
http_client: Arc<dyn HttpClient>,
node_runtime: NodeRuntime,
ruby_runtime: RubyRuntime,
proxy: Arc<ExtensionHostProxy>,
work_dir: PathBuf,
cx: &mut App,
Expand All @@ -345,6 +348,7 @@ impl WasmHost {
work_dir,
http_client,
node_runtime,
ruby_runtime,
proxy,
release_channel: ReleaseChannel::global(cx),
_main_thread_message_task: task,
Expand Down
Loading

0 comments on commit 70f8d6d

Please sign in to comment.