Set file in test_diagnostics
to excercise language server
This commit is contained in:
parent
7d8641afb6
commit
36ff31858b
2 changed files with 7 additions and 6 deletions
|
@ -247,12 +247,12 @@ pub trait LocalFile: File {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "test-support")]
|
#[cfg(any(test, feature = "test-support"))]
|
||||||
pub struct FakeFile {
|
pub struct FakeFile {
|
||||||
pub path: Arc<Path>,
|
pub path: Arc<Path>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "test-support")]
|
#[cfg(any(test, feature = "test-support"))]
|
||||||
impl File for FakeFile {
|
impl File for FakeFile {
|
||||||
fn as_local(&self) -> Option<&dyn LocalFile> {
|
fn as_local(&self) -> Option<&dyn LocalFile> {
|
||||||
Some(self)
|
Some(self)
|
||||||
|
@ -333,7 +333,7 @@ impl File for FakeFile {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "test-support")]
|
#[cfg(any(test, feature = "test-support"))]
|
||||||
impl LocalFile for FakeFile {
|
impl LocalFile for FakeFile {
|
||||||
fn abs_path(&self, _: &AppContext) -> PathBuf {
|
fn abs_path(&self, _: &AppContext) -> PathBuf {
|
||||||
self.path.to_path_buf()
|
self.path.to_path_buf()
|
||||||
|
@ -759,8 +759,6 @@ impl Buffer {
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
};
|
};
|
||||||
|
|
||||||
self.update_language_server(cx);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn did_save(
|
pub fn did_save(
|
||||||
|
|
|
@ -570,8 +570,11 @@ async fn test_diagnostics(mut cx: gpui::TestAppContext) {
|
||||||
"
|
"
|
||||||
.unindent();
|
.unindent();
|
||||||
|
|
||||||
|
let file = Box::new(FakeFile {
|
||||||
|
path: Path::new("/some/path").into(),
|
||||||
|
}) as Box<dyn File>;
|
||||||
let buffer = cx.add_model(|cx| {
|
let buffer = cx.add_model(|cx| {
|
||||||
Buffer::new(0, text, cx)
|
Buffer::from_file(0, text, file, cx)
|
||||||
.with_language(Arc::new(rust_lang), cx)
|
.with_language(Arc::new(rust_lang), cx)
|
||||||
.with_language_server(language_server, cx)
|
.with_language_server(language_server, cx)
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue