实现三种诊断模式
This commit is contained in:
parent
b9c8a2f451
commit
c24b90ea96
@ -271,7 +271,6 @@ mod tests {
|
|||||||
const TESTDIR: &str = "primitive_files";
|
const TESTDIR: &str = "primitive_files";
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
||||||
fn gen_primitive_bin() {
|
fn gen_primitive_bin() {
|
||||||
if let Ok(primitive_info) = init_parse_primitive_files("primitive_files") {
|
if let Ok(primitive_info) = init_parse_primitive_files("primitive_files") {
|
||||||
let serialized_data = bincode::serialize(&primitive_info).unwrap();
|
let serialized_data = bincode::serialize(&primitive_info).unwrap();
|
||||||
|
@ -21,8 +21,19 @@ pub async fn publish_diagnostics(
|
|||||||
|
|
||||||
// 考虑到性能,如果后端文本缓冲器内存在当前路径的 文本备份,则使用它作为 rope
|
// 考虑到性能,如果后端文本缓冲器内存在当前路径的 文本备份,则使用它作为 rope
|
||||||
// 否则,进行 IO 后再转换
|
// 否则,进行 IO 后再转换
|
||||||
let rope = open_doc_as_rope(&pathbuf).unwrap();
|
info!("open {:?} as rope", pathbuf);
|
||||||
let diagnostics_params = provide_diagnostics(uri, &rope, &backend.server);
|
let diagnostics_params = if let Some(source) = backend.server.db.get_source(&path_string) {
|
||||||
|
let source_handle = source.read().unwrap();
|
||||||
|
provide_diagnostics(uri, &source_handle.text, &backend.server)
|
||||||
|
} else {
|
||||||
|
// 读取文件,vscode 前端是有可能存在不存在的文件的,如果文件不存在,直接返回
|
||||||
|
let rope = open_doc_as_rope(&pathbuf);
|
||||||
|
if rope.is_none() {
|
||||||
|
return Ok(None);
|
||||||
|
}
|
||||||
|
provide_diagnostics(uri, &rope.unwrap(), &backend.server)
|
||||||
|
};
|
||||||
|
|
||||||
backend.client.publish_diagnostics(
|
backend.client.publish_diagnostics(
|
||||||
diagnostics_params.uri,
|
diagnostics_params.uri,
|
||||||
diagnostics_params.diagnostics,
|
diagnostics_params.diagnostics,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user