diff --git a/crates/els/server.rs b/crates/els/server.rs index 455af0ab..24d14ecc 100644 --- a/crates/els/server.rs +++ b/crates/els/server.rs @@ -27,7 +27,7 @@ use erg_compiler::module::{SharedCompilerResource, SharedModuleGraph, SharedModu use erg_compiler::ty::HasType; pub use molc::RedirectableStdout; -use molc::{DummyClient, LangServer}; +use molc::{FakeClient, LangServer}; use lsp_types::request::{ CallHierarchyIncomingCalls, CallHierarchyOutgoingCalls, CallHierarchyPrepare, @@ -298,9 +298,9 @@ impl LangServer for Server { impl Server { #[allow(unused)] - pub fn bind_dummy_client() -> DummyClient { + pub fn bind_fake_client() -> FakeClient { let (sender, receiver) = std::sync::mpsc::channel(); - DummyClient::new(Server::new(ErgConfig::default(), Some(sender)), receiver) + FakeClient::new(Server::new(ErgConfig::default(), Some(sender)), receiver) } } diff --git a/crates/els/tests/test.rs b/crates/els/tests/test.rs index 582aba6e..6d39e657 100644 --- a/crates/els/tests/test.rs +++ b/crates/els/tests/test.rs @@ -13,7 +13,7 @@ use molc::{add_char, oneline_range}; #[test] fn test_open() -> Result<(), Box> { - let mut client = Server::bind_dummy_client(); + let mut client = Server::bind_fake_client(); client.request_initialize()?; client.notify_open(FILE_A)?; client.wait_messages(3)?; @@ -25,7 +25,7 @@ fn test_open() -> Result<(), Box> { #[test] fn test_completion() -> Result<(), Box> { - let mut client = Server::bind_dummy_client(); + let mut client = Server::bind_fake_client(); client.request_initialize()?; let uri = NormalizedUrl::from_file_path(Path::new(FILE_A).canonicalize()?)?; client.notify_open(FILE_A)?; @@ -43,7 +43,7 @@ fn test_completion() -> Result<(), Box> { #[test] fn test_neighbor_completion() -> Result<(), Box> { - let mut client = Server::bind_dummy_client(); + let mut client = Server::bind_fake_client(); client.request_initialize()?; let uri = NormalizedUrl::from_file_path(Path::new(FILE_A).canonicalize()?)?; client.notify_open(FILE_A)?; @@ -62,7 +62,7 @@ fn test_neighbor_completion() -> Result<(), Box> { #[test] fn test_rename() -> Result<(), Box> { - let mut client = Server::bind_dummy_client(); + let mut client = Server::bind_fake_client(); client.request_initialize()?; let uri = NormalizedUrl::from_file_path(Path::new(FILE_A).canonicalize()?)?; client.notify_open(FILE_A)?; @@ -77,7 +77,7 @@ fn test_rename() -> Result<(), Box> { #[test] fn test_signature_help() -> Result<(), Box> { - let mut client = Server::bind_dummy_client(); + let mut client = Server::bind_fake_client(); client.request_initialize()?; let uri = NormalizedUrl::from_file_path(Path::new(FILE_A).canonicalize()?)?; client.notify_open(FILE_A)?; @@ -95,7 +95,7 @@ fn test_signature_help() -> Result<(), Box> { #[test] fn test_hover() -> Result<(), Box> { - let mut client = Server::bind_dummy_client(); + let mut client = Server::bind_fake_client(); client.request_initialize()?; let uri = NormalizedUrl::from_file_path(Path::new(FILE_A).canonicalize()?)?; client.notify_open(FILE_A)?; @@ -120,7 +120,7 @@ fn test_hover() -> Result<(), Box> { #[test] fn test_references() -> Result<(), Box> { - let mut client = Server::bind_dummy_client(); + let mut client = Server::bind_fake_client(); client.request_initialize()?; let uri = NormalizedUrl::from_file_path(Path::new(FILE_A).canonicalize()?)?; client.notify_open(FILE_A)?; @@ -132,7 +132,7 @@ fn test_references() -> Result<(), Box> { #[test] fn test_goto_definition() -> Result<(), Box> { - let mut client = Server::bind_dummy_client(); + let mut client = Server::bind_fake_client(); client.request_initialize()?; let uri = NormalizedUrl::from_file_path(Path::new(FILE_A).canonicalize()?)?; client.notify_open(FILE_A)?; @@ -147,7 +147,7 @@ fn test_goto_definition() -> Result<(), Box> { #[test] fn test_folding_range() -> Result<(), Box> { - let mut client = Server::bind_dummy_client(); + let mut client = Server::bind_fake_client(); client.request_initialize()?; let uri = NormalizedUrl::from_file_path(Path::new(FILE_IMPORTS).canonicalize()?)?; client.notify_open(FILE_IMPORTS)?; @@ -168,7 +168,7 @@ fn test_folding_range() -> Result<(), Box> { #[test] fn test_document_symbol() -> Result<(), Box> { - let mut client = Server::bind_dummy_client(); + let mut client = Server::bind_fake_client(); client.request_initialize()?; let uri = NormalizedUrl::from_file_path(Path::new(FILE_A).canonicalize()?)?; client.notify_open(FILE_A)?; diff --git a/crates/molc/README.md b/crates/molc/README.md index 6a74012e..2c74106a 100644 --- a/crates/molc/README.md +++ b/crates/molc/README.md @@ -1,6 +1,6 @@ # `molc` -`molc` is a mock language client for testing language servers. +`molc` is a mock (fake) language client for testing language servers. ## Usage @@ -9,7 +9,7 @@ You can see specific examples of molc use in [ELS](https://github.com/erg-lang/e ```rust use lsp_types::{Url, Value}; -use molc::{DummyClient, LangServer, RedirectableStdout}; +use molc::{FakeClient, LangServer, RedirectableStdout}; use molc::oneline_range; pub struct Server { @@ -30,7 +30,7 @@ impl RedirectableStdout for Server { } impl Server { - fn bind_dummy_client() -> DummyClient { + fn bind_fake_client() -> FakeClient { // The server should send responses to this channel at least during testing. let (sender, receiver) = std::sync::mpsc::channel(); DummyClient::new( @@ -57,7 +57,7 @@ impl Server { #[test] fn test_references() -> Result<(), Box> { - let mut client = Server::bind_dummy_client(); + let mut client = Server::bind_fake_client(); client.request_initialize()?; let uri = Url::from_file_path(Path::new(FILE_A).canonicalize()?).unwrap(); client.notify_open(FILE_A)?; diff --git a/crates/molc/src/lib.rs b/crates/molc/src/lib.rs index 4047048a..4477f485 100644 --- a/crates/molc/src/lib.rs +++ b/crates/molc/src/lib.rs @@ -133,7 +133,7 @@ pub trait LangServer { fn dispatch(&mut self, msg: impl Into) -> Result<()>; } -pub struct DummyClient { +pub struct FakeClient { server: LS, receiver: std::sync::mpsc::Receiver, server_capas: Option, @@ -144,10 +144,10 @@ pub struct DummyClient { req_id: i64, } -impl DummyClient { +impl FakeClient { /// The server should send responses to the channel at least during testing. pub fn new(server: LS, receiver: std::sync::mpsc::Receiver) -> Self { - DummyClient { + FakeClient { receiver, responses: Vec::new(), ver: 0,