update
This commit is contained in:
parent
53b8ebaa1a
commit
3074eb2c09
2
.gitignore
vendored
2
.gitignore
vendored
@ -9,3 +9,5 @@ target/
|
||||
tests_rtl
|
||||
log_files
|
||||
test.txt
|
||||
|
||||
build.bat
|
170
Cargo.lock
generated
170
Cargo.lock
generated
@ -56,12 +56,6 @@ version = "1.0.72"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3b13c32d80ecc7ab747b80c3784bce54ee8a7a0cc4fbda9bf4cda2cf6fe90854"
|
||||
|
||||
[[package]]
|
||||
name = "arrayvec"
|
||||
version = "0.5.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "23b62fc65de8e4e7f52534fb52b0f3ed04746ae267519eef2a83941e8085068b"
|
||||
|
||||
[[package]]
|
||||
name = "async-trait"
|
||||
version = "0.1.72"
|
||||
@ -135,12 +129,6 @@ version = "3.16.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c"
|
||||
|
||||
[[package]]
|
||||
name = "bytecount"
|
||||
version = "0.3.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f861d9ce359f56dbcb6e0c2a1cb84e52ad732cadb57b806adeb3c7668caccbd8"
|
||||
|
||||
[[package]]
|
||||
name = "bytecount"
|
||||
version = "0.6.3"
|
||||
@ -223,6 +211,7 @@ dependencies = [
|
||||
"regex",
|
||||
"ropey",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"serde_yaml",
|
||||
"structopt",
|
||||
"strum",
|
||||
@ -254,19 +243,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a258e46cdc063eb8519c00b9fc845fc47bcfca4130e2f08e88665ceda8474245"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"windows-sys 0.52.0",
|
||||
"windows-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "flexi_logger"
|
||||
version = "0.27.4"
|
||||
version = "0.29.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "469e584c031833564840fb0cdbce99bdfe946fd45480a188545e73a76f45461c"
|
||||
checksum = "a250587a211932896a131f214a4f64c047b826ce072d2018764e5ff5141df8fa"
|
||||
dependencies = [
|
||||
"chrono",
|
||||
"glob",
|
||||
"is-terminal",
|
||||
"lazy_static",
|
||||
"log",
|
||||
"nu-ansi-term",
|
||||
"regex",
|
||||
@ -419,7 +406,7 @@ version = "0.5.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e3d1354bf6b7235cb4a0576c2619fd4ed18183f689b12b006a0ee7329eeff9a5"
|
||||
dependencies = [
|
||||
"windows-sys 0.52.0",
|
||||
"windows-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -471,17 +458,6 @@ dependencies = [
|
||||
"hashbrown",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "is-terminal"
|
||||
version = "0.4.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cb0889898416213fab133e1d33a0e5858a48177452750691bde3666d0fdbaf8b"
|
||||
dependencies = [
|
||||
"hermit-abi 0.3.9",
|
||||
"rustix",
|
||||
"windows-sys 0.48.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "itoa"
|
||||
version = "1.0.9"
|
||||
@ -503,19 +479,6 @@ version = "1.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
|
||||
|
||||
[[package]]
|
||||
name = "lexical-core"
|
||||
version = "0.7.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6607c62aa161d23d17a9072cc5da0be67cdfc89d3afb1e8d9c842bebc2525ffe"
|
||||
dependencies = [
|
||||
"arrayvec",
|
||||
"bitflags 1.3.2",
|
||||
"cfg-if",
|
||||
"ryu",
|
||||
"static_assertions",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.152"
|
||||
@ -563,6 +526,12 @@ version = "2.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d"
|
||||
|
||||
[[package]]
|
||||
name = "minimal-lexical"
|
||||
version = "0.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a"
|
||||
|
||||
[[package]]
|
||||
name = "miniz_oxide"
|
||||
version = "0.6.2"
|
||||
@ -574,42 +543,39 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "nom"
|
||||
version = "5.1.3"
|
||||
version = "7.1.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "08959a387a676302eebf4ddbcbc611da04285579f76f88ee0506c63b1a61dd4b"
|
||||
checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a"
|
||||
dependencies = [
|
||||
"lexical-core",
|
||||
"memchr",
|
||||
"version_check",
|
||||
"minimal-lexical",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "nom-greedyerror"
|
||||
version = "0.2.0"
|
||||
version = "0.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "005188fda7f3ea919ee32f9c71e99a0aff25031c7403a2e1b40210627602b180"
|
||||
checksum = "73f359007d505b20cd6e4974ff0d5c8e4565f0f9e15823937238221ccb74b516"
|
||||
dependencies = [
|
||||
"nom",
|
||||
"nom_locate 1.0.0",
|
||||
"nom_locate 2.1.0",
|
||||
"nom_locate",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "nom-packrat"
|
||||
version = "0.4.0"
|
||||
version = "0.7.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c3ec62525e98be79d646fda5144d70afc71bee2375ab847a3d78ffe5eaeb8260"
|
||||
checksum = "ec2613a0891d298a6dd6330d0eb7a2ff37f5b2e0f8b2656c89517f0c560602c1"
|
||||
dependencies = [
|
||||
"nom-packrat-macros",
|
||||
"nom_locate 1.0.0",
|
||||
"nom_locate 2.1.0",
|
||||
"nom_locate",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "nom-packrat-macros"
|
||||
version = "0.4.0"
|
||||
version = "0.7.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4a845d4abd19861ab38dd485e90daf0a29a4f7bdc675c4fcce4be7af788140c2"
|
||||
checksum = "738db4817fcc69a720675cad108968ef14d72b9e4d9cc0d4eb90e52f4d15a392"
|
||||
dependencies = [
|
||||
"quote",
|
||||
"syn 1.0.109",
|
||||
@ -617,20 +583,19 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "nom-recursive"
|
||||
version = "0.2.0"
|
||||
version = "0.5.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b12e0cf53f6ea38a53a6a4b10e7b170ea1cc56166dcb4fcab9a53c4890b205b2"
|
||||
checksum = "38dde6bfc697f9a5f19dd3afcc7e3d60367c0a00fe8f29a5aebb6fc9ca9aeb7a"
|
||||
dependencies = [
|
||||
"nom-recursive-macros",
|
||||
"nom_locate 1.0.0",
|
||||
"nom_locate 2.1.0",
|
||||
"nom_locate",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "nom-recursive-macros"
|
||||
version = "0.2.0"
|
||||
version = "0.5.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2d69ac6bb21fb4ffc328bcec8cea7b1a07114e1a9ed10d5a630feb7e2a243dbe"
|
||||
checksum = "e16984d78cb05a960e79cc03219e8fc2da932666d5cef7cbd7c55c9a1a4ef3ce"
|
||||
dependencies = [
|
||||
"quote",
|
||||
"syn 1.0.109",
|
||||
@ -638,21 +603,20 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "nom-tracable"
|
||||
version = "0.6.2"
|
||||
version = "0.9.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1875762c6bd471741e093a85fd66f6b9b93b14203b592b66ec7b41b31f553559"
|
||||
checksum = "6a39d3ec4e5bc9816ca540bd6b1e4885c0275536eb3293d317d984bb17f9a294"
|
||||
dependencies = [
|
||||
"nom",
|
||||
"nom-tracable-macros",
|
||||
"nom_locate 1.0.0",
|
||||
"nom_locate 2.1.0",
|
||||
"nom_locate",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "nom-tracable-macros"
|
||||
version = "0.6.2"
|
||||
version = "0.9.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a8b4ba141c87dc4f398331f8772b629d546dc25fb469999ee0ed0c63145c13fb"
|
||||
checksum = "c9c68f5316254dae193b3ce083f6caf19ae1a58471e6585e89f0796b9e5bdf4a"
|
||||
dependencies = [
|
||||
"quote",
|
||||
"syn 1.0.109",
|
||||
@ -660,33 +624,22 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "nom_locate"
|
||||
version = "1.0.0"
|
||||
version = "4.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f932834fd8e391fc7710e2ba17e8f9f8645d846b55aa63207e17e110a1e1ce35"
|
||||
checksum = "1e3c83c053b0713da60c5b8de47fe8e494fe3ece5267b2f23090a07a053ba8f3"
|
||||
dependencies = [
|
||||
"bytecount 0.3.2",
|
||||
"memchr",
|
||||
"nom",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "nom_locate"
|
||||
version = "2.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a67484adf5711f94f2f28b653bf231bff8e438be33bf5b0f35935a0db4f618a2"
|
||||
dependencies = [
|
||||
"bytecount 0.6.3",
|
||||
"bytecount",
|
||||
"memchr",
|
||||
"nom",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "nu-ansi-term"
|
||||
version = "0.49.0"
|
||||
version = "0.50.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c073d3c1930d0751774acf49e66653acecb416c3a54c6ec095a9b11caddb5a68"
|
||||
checksum = "d4a28e057d01f97e61255210fcff094d74ed0466038633e95017f5beb68e4399"
|
||||
dependencies = [
|
||||
"windows-sys 0.48.0",
|
||||
"windows-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -938,7 +891,7 @@ dependencies = [
|
||||
"errno",
|
||||
"libc",
|
||||
"linux-raw-sys",
|
||||
"windows-sys 0.52.0",
|
||||
"windows-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -1038,12 +991,6 @@ version = "1.13.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67"
|
||||
|
||||
[[package]]
|
||||
name = "static_assertions"
|
||||
version = "1.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f"
|
||||
|
||||
[[package]]
|
||||
name = "str-concat"
|
||||
version = "0.2.0"
|
||||
@ -1107,9 +1054,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "sv-parser"
|
||||
version = "0.8.3"
|
||||
version = "0.13.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5febd467eca0820285e6d8dc7f794430c56d446f01638f320d6122931808d4ae"
|
||||
checksum = "425309b8d5bbd38fe592ba1a19e91ccdaab66e1ef312eb0ce0b8d6e4295ef4cb"
|
||||
dependencies = [
|
||||
"nom",
|
||||
"nom-greedyerror",
|
||||
@ -1121,35 +1068,35 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "sv-parser-error"
|
||||
version = "0.8.3"
|
||||
version = "0.13.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8d4783f356ec80fb2a3f3003d9b9c743376a86069c5809dff8cd506f91d9cf30"
|
||||
checksum = "d702ef215611db3c9cbd57c39a543fc72924eff9defb2b5e0461617929ef1a86"
|
||||
dependencies = [
|
||||
"thiserror",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "sv-parser-macros"
|
||||
version = "0.8.3"
|
||||
version = "0.13.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1c5d18eaf59472f37a75e9f9c5b056df280eb5ffdd2aca9f677a5e34b8c31753"
|
||||
checksum = "6a2eba85c18b26226dee76a6f07a1cb189130012a32109474ae182666b4e9b00"
|
||||
dependencies = [
|
||||
"quote",
|
||||
"syn 1.0.109",
|
||||
"syn 2.0.28",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "sv-parser-parser"
|
||||
version = "0.8.3"
|
||||
version = "0.13.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cbc24d617443cda9daadd80fb60e139a1584e4e3726f2b68df50b9bfddbecb71"
|
||||
checksum = "1ccb13fe101bdf64fa533121759d96f75b4e3038c03320fad4cd697063f9e101"
|
||||
dependencies = [
|
||||
"nom",
|
||||
"nom-greedyerror",
|
||||
"nom-packrat",
|
||||
"nom-recursive",
|
||||
"nom-tracable",
|
||||
"nom_locate 2.1.0",
|
||||
"nom_locate",
|
||||
"str-concat",
|
||||
"sv-parser-macros",
|
||||
"sv-parser-syntaxtree",
|
||||
@ -1157,9 +1104,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "sv-parser-pp"
|
||||
version = "0.8.3"
|
||||
version = "0.13.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2e1cb4ac6171b99c04e3504867c25018cbf425fe72e088e599df2c9dbe0c2a48"
|
||||
checksum = "9d580999e597ef78b966343276e3a948b2d99348dbc58ddc1e9a596c3a7a8a10"
|
||||
dependencies = [
|
||||
"nom",
|
||||
"nom-greedyerror",
|
||||
@ -1170,9 +1117,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "sv-parser-syntaxtree"
|
||||
version = "0.8.3"
|
||||
version = "0.13.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a100af4bf3ce8e6650349c7f020ca715c9918d2dfd27dfac00d6148173e66670"
|
||||
checksum = "75394b4b48cf789e5eb148f4a47f82c119424166572e13e3dee5394fc1da7ad0"
|
||||
dependencies = [
|
||||
"regex",
|
||||
"sv-parser-macros",
|
||||
@ -1522,7 +1469,7 @@ dependencies = [
|
||||
"home",
|
||||
"once_cell",
|
||||
"rustix",
|
||||
"windows-sys 0.52.0",
|
||||
"windows-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -1565,15 +1512,6 @@ dependencies = [
|
||||
"windows-targets 0.48.5",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-sys"
|
||||
version = "0.48.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9"
|
||||
dependencies = [
|
||||
"windows-targets 0.48.5",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-sys"
|
||||
version = "0.52.0"
|
||||
|
@ -5,18 +5,19 @@ authors = ["LSTM-Kirigaya <1193466151@qq.com>"]
|
||||
edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
sv-parser = "0.8.2"
|
||||
sv-parser = "0.13.3"
|
||||
log = "0.4.19"
|
||||
tower-lsp = "0.20.0"
|
||||
flexi_logger = "0.27.4"
|
||||
flexi_logger = "0.29.0"
|
||||
ropey = "1.6.0"
|
||||
tokio = { version = "1.29.1", features = ["macros", "io-std", "rt-multi-thread"] }
|
||||
path-clean = "1.0.1"
|
||||
pathdiff = "0.2.1"
|
||||
walkdir = "2.3.3"
|
||||
serde = { version = "1.0", features = ["derive"] }
|
||||
serde_json = "1.0"
|
||||
serde_yaml = "0.9.25"
|
||||
anyhow = "1.0.72"
|
||||
serde = "1.0.179"
|
||||
which = "6.0.0"
|
||||
regex = "1.9.1"
|
||||
structopt = "0.3.26"
|
||||
|
@ -1,5 +1,6 @@
|
||||
use tower_lsp::lsp_types::*;
|
||||
|
||||
//
|
||||
pub fn keyword_completions(keywords: &[(&str, &str)]) -> Vec<CompletionItem> {
|
||||
let mut items: Vec<CompletionItem> = Vec::new();
|
||||
for key in keywords {
|
||||
|
2
src/core/hdl_param.rs
Normal file
2
src/core/hdl_param.rs
Normal file
@ -0,0 +1,2 @@
|
||||
use std::collections::HashMap;
|
||||
|
155
src/core/paser_struct.rs
Normal file
155
src/core/paser_struct.rs
Normal file
@ -0,0 +1,155 @@
|
||||
// use std::collections::HashMap;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Serialize, Deserialize)]
|
||||
pub struct RangeInfo {
|
||||
line: u32,
|
||||
character: usize,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize)]
|
||||
pub struct Range {
|
||||
start: RangeInfo,
|
||||
end: RangeInfo,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize)]
|
||||
pub struct Parameter {
|
||||
name: String,
|
||||
parameter_type: String,
|
||||
init: String,
|
||||
range: Range,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize)]
|
||||
pub struct Port {
|
||||
name: String,
|
||||
port_type: String,
|
||||
net_type: String,
|
||||
width: String,
|
||||
range: Range,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize)]
|
||||
pub struct Instance {
|
||||
name: String,
|
||||
instance_type: String,
|
||||
instparams: Range,
|
||||
instports: Range,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize)]
|
||||
pub struct SvlogModule {
|
||||
name: String,
|
||||
params: Vec<Parameter>,
|
||||
ports: Vec<Port>,
|
||||
instances: Vec<Instance>,
|
||||
range: Range
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize)]
|
||||
pub struct SvlogInfo {
|
||||
pub fast: Vec<SvlogModule>
|
||||
}
|
||||
|
||||
impl SvlogInfo {
|
||||
pub fn new_module(&mut self, symbol_name: &str, symbol_line: u32, start_col: usize, end_col: usize) {
|
||||
let new_mod = SvlogModule {
|
||||
name: symbol_name.to_string(),
|
||||
range: Range {
|
||||
start: RangeInfo {
|
||||
line: symbol_line,
|
||||
character: start_col
|
||||
},
|
||||
end: RangeInfo {
|
||||
line: symbol_line,
|
||||
character: end_col
|
||||
}
|
||||
},
|
||||
params: Vec::new(),
|
||||
ports: Vec::new(),
|
||||
instances: Vec::new()
|
||||
};
|
||||
self.fast.push(new_mod);
|
||||
}
|
||||
|
||||
pub fn add_parameter(&mut self, param_name: &str, param_type: &str, start_line: u32, start_col: usize, end_line: u32, end_col: usize) {
|
||||
if let Some(last_mod) = self.fast.last_mut() {
|
||||
let parameter = Parameter {
|
||||
name: param_name.to_string(),
|
||||
parameter_type: param_type.to_string(),
|
||||
init: "unknown".to_string(),
|
||||
range: Range {
|
||||
start: RangeInfo {
|
||||
line: start_line,
|
||||
character: start_col
|
||||
},
|
||||
end: RangeInfo {
|
||||
line: end_line,
|
||||
character: end_col
|
||||
}
|
||||
}
|
||||
};
|
||||
(*last_mod).params.push(parameter);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn add_port(&mut self, port_name: &str, port_net_type: &str, port_dir: &str, start_line: u32, start_col: usize, end_line: u32, end_col: usize) {
|
||||
if let Some(last_mod) = self.fast.last_mut() {
|
||||
let port = Port {
|
||||
name: port_name.to_string(),
|
||||
port_type: port_dir.to_string(),
|
||||
net_type: port_net_type.to_string(),
|
||||
width: "unknown".to_string(),
|
||||
range: Range {
|
||||
start: RangeInfo {
|
||||
line: start_line,
|
||||
character: start_col
|
||||
},
|
||||
end: RangeInfo {
|
||||
line: end_line,
|
||||
character: end_col
|
||||
}
|
||||
}
|
||||
};
|
||||
(*last_mod).ports.push(port);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn add_instance(&mut self, symbol_name: &str) {
|
||||
if let Some(last_mod) = self.fast.last_mut() {
|
||||
let instance = Instance {
|
||||
name: symbol_name.to_string(),
|
||||
instance_type: (*last_mod.name).to_string(),
|
||||
instparams: Range {
|
||||
start: RangeInfo {
|
||||
line: 0,
|
||||
character: 0
|
||||
},
|
||||
end: RangeInfo {
|
||||
line: 0,
|
||||
character: 0
|
||||
}
|
||||
},
|
||||
instports: Range {
|
||||
start: RangeInfo {
|
||||
line: 0,
|
||||
character: 0
|
||||
},
|
||||
end: RangeInfo {
|
||||
line: 0,
|
||||
character: 0
|
||||
}
|
||||
}
|
||||
};
|
||||
(*last_mod).instances.push(instance);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// const RS2JSON_RENAME_LIST: [(&str, &str); 4] = [
|
||||
// ("parameter_type", "type"),
|
||||
// ("port_type", "type"),
|
||||
// ("net_type", "netType"),
|
||||
// ("instance_type", "type"),
|
||||
// ];
|
27
src/custom_request.rs
Normal file
27
src/custom_request.rs
Normal file
@ -0,0 +1,27 @@
|
||||
use serde::Deserialize;
|
||||
use serde_json::{json, Value};
|
||||
use tower_lsp::jsonrpc::Result;
|
||||
use tower_lsp::lsp_types::*;
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
pub struct CustomRequestParams {
|
||||
// 定义你需要的参数
|
||||
pub data: Value,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
pub struct CustomResponse {
|
||||
result: serde_json::Value
|
||||
}
|
||||
|
||||
|
||||
pub async fn customRequest() -> Result<i32> {
|
||||
// let command = params[0].clone();
|
||||
// let message = String::from("receive command: ") + &command;
|
||||
|
||||
// let response = CustomResponse {
|
||||
// result: serde_json::Value::String(message),
|
||||
// };
|
||||
|
||||
Ok(123)
|
||||
}
|
@ -7,3 +7,4 @@ pub mod format;
|
||||
pub mod server;
|
||||
pub mod sources;
|
||||
pub mod support;
|
||||
pub mod custom_request;
|
13
src/main.rs
13
src/main.rs
@ -1,5 +1,6 @@
|
||||
#![recursion_limit = "256"]
|
||||
|
||||
use custom_request::customRequest;
|
||||
use log::info;
|
||||
use std::sync::Arc;
|
||||
use structopt::StructOpt;
|
||||
@ -11,6 +12,7 @@ mod diagnostics;
|
||||
mod format;
|
||||
mod server;
|
||||
mod sources;
|
||||
mod custom_request;
|
||||
#[cfg(test)]
|
||||
mod support;
|
||||
use server::Backend;
|
||||
@ -31,6 +33,13 @@ async fn main() {
|
||||
let stdin = tokio::io::stdin();
|
||||
let stdout = tokio::io::stdout();
|
||||
|
||||
let (service, messages) = LspService::new(|client| Arc::new(Backend::new(client, log_handle)));
|
||||
Server::new(stdin, stdout, messages).serve(service).await;
|
||||
// let (service, socket) = LspService::new(|client| Arc::new(Backend::new(client, log_handle)));
|
||||
|
||||
let (service, socket) = LspService::build(|client| Arc::new(Backend::new(client, log_handle)))
|
||||
.custom_method("custom/request", customRequest)
|
||||
.finish();
|
||||
|
||||
Server::new(stdin, stdout, socket)
|
||||
.serve(service)
|
||||
.await;
|
||||
}
|
||||
|
@ -1,10 +1,10 @@
|
||||
use crate::sources::*;
|
||||
|
||||
use crate::completion::keyword::*;
|
||||
use flexi_logger::LoggerHandle;
|
||||
use log::{debug, info, warn};
|
||||
use path_clean::PathClean;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::collections::HashSet;
|
||||
use std::env::current_dir;
|
||||
use std::fs::File;
|
||||
use std::io::Read;
|
||||
@ -41,6 +41,7 @@ impl LSPServer {
|
||||
pub struct Backend {
|
||||
client: Client,
|
||||
server: LSPServer,
|
||||
watched_files: HashSet<String>
|
||||
}
|
||||
|
||||
impl Backend {
|
||||
@ -48,6 +49,7 @@ impl Backend {
|
||||
Backend {
|
||||
client,
|
||||
server: LSPServer::new(Some(log_handle)),
|
||||
watched_files: HashSet::new()
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -294,14 +296,17 @@ impl LanguageServer for Backend {
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
async fn initialized(&self, _: InitializedParams) {
|
||||
self.client
|
||||
.log_message(MessageType::INFO, "digital lsp initialized!")
|
||||
.await;
|
||||
}
|
||||
|
||||
async fn shutdown(&self) -> Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn did_open(&self, params: DidOpenTextDocumentParams) {
|
||||
let diagnostics = self.server.did_open(params);
|
||||
self.client
|
||||
@ -312,9 +317,11 @@ impl LanguageServer for Backend {
|
||||
)
|
||||
.await;
|
||||
}
|
||||
|
||||
async fn did_change(&self, params: DidChangeTextDocumentParams) {
|
||||
self.server.did_change(params);
|
||||
}
|
||||
|
||||
async fn did_save(&self, params: DidSaveTextDocumentParams) {
|
||||
let diagnostics = self.server.did_save(params);
|
||||
self.client
|
||||
@ -325,33 +332,57 @@ impl LanguageServer for Backend {
|
||||
)
|
||||
.await;
|
||||
}
|
||||
|
||||
async fn did_change_watched_files(&self, params: DidChangeWatchedFilesParams) {
|
||||
// for change in params.changes {
|
||||
// let file_uri = change.uri.to_string();
|
||||
// match change.typ {
|
||||
// FileChangeType::CREATED | FileChangeType::CHANGED => {
|
||||
// self.watched_files.insert(file_uri.clone());
|
||||
// self.client.log_message(MessageType::INFO, format!("File added/changed: {}", file_uri)).await;
|
||||
// }
|
||||
// FileChangeType::DELETED => {
|
||||
// self.watched_files.remove(&file_uri);
|
||||
// self.client.log_message(MessageType::INFO, format!("File deleted: {}", file_uri)).await;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
async fn completion(&self, params: CompletionParams) -> Result<Option<CompletionResponse>> {
|
||||
Ok(self.server.completion(params))
|
||||
}
|
||||
|
||||
async fn goto_definition(
|
||||
&self,
|
||||
params: GotoDefinitionParams,
|
||||
) -> Result<Option<GotoDefinitionResponse>> {
|
||||
Ok(self.server.goto_definition(params))
|
||||
}
|
||||
|
||||
async fn hover(&self, params: HoverParams) -> Result<Option<Hover>> {
|
||||
Ok(self.server.hover(params))
|
||||
}
|
||||
|
||||
async fn document_symbol(
|
||||
&self,
|
||||
params: DocumentSymbolParams,
|
||||
) -> Result<Option<DocumentSymbolResponse>> {
|
||||
Ok(self.server.document_symbol(params))
|
||||
}
|
||||
|
||||
async fn formatting(&self, params: DocumentFormattingParams) -> Result<Option<Vec<TextEdit>>> {
|
||||
Ok(self.server.formatting(params))
|
||||
}
|
||||
|
||||
async fn range_formatting(
|
||||
&self,
|
||||
params: DocumentRangeFormattingParams,
|
||||
) -> Result<Option<Vec<TextEdit>>> {
|
||||
Ok(self.server.range_formatting(params))
|
||||
}
|
||||
|
||||
async fn document_highlight(
|
||||
&self,
|
||||
params: DocumentHighlightParams,
|
||||
|
@ -378,6 +378,7 @@ pub fn parse(
|
||||
&HashMap::new(),
|
||||
&includes,
|
||||
false,
|
||||
true
|
||||
) {
|
||||
Ok((syntax_tree, _)) => {
|
||||
debug!("parse complete of {}", uri);
|
||||
|
Loading…
x
Reference in New Issue
Block a user