mirror of
https://github.com/erg-lang/erg.git
synced 2025-10-02 21:44:34 +00:00
refactor: DummyClient -> FakeClient
This commit is contained in:
parent
dcb42f68b9
commit
ac5b0548a3
4 changed files with 20 additions and 20 deletions
|
@ -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<Server> {
|
||||
pub fn bind_fake_client() -> FakeClient<Server> {
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ use molc::{add_char, oneline_range};
|
|||
|
||||
#[test]
|
||||
fn test_open() -> Result<(), Box<dyn std::error::Error>> {
|
||||
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<dyn std::error::Error>> {
|
|||
|
||||
#[test]
|
||||
fn test_completion() -> Result<(), Box<dyn std::error::Error>> {
|
||||
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<dyn std::error::Error>> {
|
|||
|
||||
#[test]
|
||||
fn test_neighbor_completion() -> Result<(), Box<dyn std::error::Error>> {
|
||||
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<dyn std::error::Error>> {
|
|||
|
||||
#[test]
|
||||
fn test_rename() -> Result<(), Box<dyn std::error::Error>> {
|
||||
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<dyn std::error::Error>> {
|
|||
|
||||
#[test]
|
||||
fn test_signature_help() -> Result<(), Box<dyn std::error::Error>> {
|
||||
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<dyn std::error::Error>> {
|
|||
|
||||
#[test]
|
||||
fn test_hover() -> Result<(), Box<dyn std::error::Error>> {
|
||||
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<dyn std::error::Error>> {
|
|||
|
||||
#[test]
|
||||
fn test_references() -> Result<(), Box<dyn std::error::Error>> {
|
||||
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<dyn std::error::Error>> {
|
|||
|
||||
#[test]
|
||||
fn test_goto_definition() -> Result<(), Box<dyn std::error::Error>> {
|
||||
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<dyn std::error::Error>> {
|
|||
|
||||
#[test]
|
||||
fn test_folding_range() -> Result<(), Box<dyn std::error::Error>> {
|
||||
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<dyn std::error::Error>> {
|
|||
|
||||
#[test]
|
||||
fn test_document_symbol() -> Result<(), Box<dyn std::error::Error>> {
|
||||
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)?;
|
||||
|
|
|
@ -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<Self> {
|
||||
fn bind_fake_client() -> FakeClient<Self> {
|
||||
// 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<dyn std::error::Error>> {
|
||||
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)?;
|
||||
|
|
|
@ -133,7 +133,7 @@ pub trait LangServer {
|
|||
fn dispatch(&mut self, msg: impl Into<Value>) -> Result<()>;
|
||||
}
|
||||
|
||||
pub struct DummyClient<LS: LangServer> {
|
||||
pub struct FakeClient<LS: LangServer> {
|
||||
server: LS,
|
||||
receiver: std::sync::mpsc::Receiver<Value>,
|
||||
server_capas: Option<ServerCapabilities>,
|
||||
|
@ -144,10 +144,10 @@ pub struct DummyClient<LS: LangServer> {
|
|||
req_id: i64,
|
||||
}
|
||||
|
||||
impl<LS: LangServer> DummyClient<LS> {
|
||||
impl<LS: LangServer> FakeClient<LS> {
|
||||
/// The server should send responses to the channel at least during testing.
|
||||
pub fn new(server: LS, receiver: std::sync::mpsc::Receiver<Value>) -> Self {
|
||||
DummyClient {
|
||||
FakeClient {
|
||||
receiver,
|
||||
responses: Vec::new(),
|
||||
ver: 0,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue