更加丰富的 vlog 的 sys task 补全
This commit is contained in:
parent
4dca88c5c1
commit
d9fe1e9ed5
@ -39,11 +39,11 @@ pub fn completion(server: &LSPServer, params: &CompletionParams) -> Option<Compl
|
|||||||
},
|
},
|
||||||
"$" => Some(CompletionList {
|
"$" => Some(CompletionList {
|
||||||
is_incomplete: false,
|
is_incomplete: false,
|
||||||
items: server.sys_tasks.clone(),
|
items: server.vlog_sys_tasks_completion_items.clone(),
|
||||||
}),
|
}),
|
||||||
"`" => Some(CompletionList {
|
"`" => Some(CompletionList {
|
||||||
is_incomplete: false,
|
is_incomplete: false,
|
||||||
items: server.directives.clone(),
|
items: server.vlog_directives.clone(),
|
||||||
}),
|
}),
|
||||||
"/" => {
|
"/" => {
|
||||||
info!("trigger include");
|
info!("trigger include");
|
||||||
@ -80,7 +80,13 @@ pub fn completion(server: &LSPServer, params: &CompletionParams) -> Option<Compl
|
|||||||
|
|
||||||
// 3. 根据 token 加入系统函数
|
// 3. 根据 token 加入系统函数
|
||||||
// TODO: 考虑使用前缀树进行优化
|
// TODO: 考虑使用前缀树进行优化
|
||||||
|
completion_items.items.extend::<Vec<CompletionItem>>(
|
||||||
|
server.vlog_sys_tasks_completion_items
|
||||||
|
.iter()
|
||||||
|
.filter(|x| x.label.starts_with(&token))
|
||||||
|
.cloned()
|
||||||
|
.collect(),
|
||||||
|
);
|
||||||
|
|
||||||
// 4. 加入例化自动补全的
|
// 4. 加入例化自动补全的
|
||||||
completion_items.items.extend::<Vec<CompletionItem>>(
|
completion_items.items.extend::<Vec<CompletionItem>>(
|
||||||
@ -105,11 +111,11 @@ pub fn completion(server: &LSPServer, params: &CompletionParams) -> Option<Compl
|
|||||||
)?),
|
)?),
|
||||||
'$' => Some(CompletionList {
|
'$' => Some(CompletionList {
|
||||||
is_incomplete: false,
|
is_incomplete: false,
|
||||||
items: server.sys_tasks.clone(),
|
items: server.vlog_sys_tasks_completion_items.clone(),
|
||||||
}),
|
}),
|
||||||
'`' => Some(CompletionList {
|
'`' => Some(CompletionList {
|
||||||
is_incomplete: false,
|
is_incomplete: false,
|
||||||
items: server.directives.clone(),
|
items: server.vlog_directives.clone(),
|
||||||
}),
|
}),
|
||||||
_ => {
|
_ => {
|
||||||
let mut completion_items = server.srcs.get_completions(
|
let mut completion_items = server.srcs.get_completions(
|
||||||
|
@ -310,10 +310,62 @@ pub const VLOG_REAL_MATH_FUNCTIONS_TASKS: &[(&str, &str, &str)] = &[
|
|||||||
("atanh", "$atanh($1);", "计算反双曲正切函数。\n```verilog\nreal result;\nresult = $atanh(value);\n```"),
|
("atanh", "$atanh($1);", "计算反双曲正切函数。\n```verilog\nreal result;\nresult = $atanh(value);\n```"),
|
||||||
];
|
];
|
||||||
|
|
||||||
fn make_function_profile(section: &str, description: &str) -> MarkupContent {
|
/// Specifying name of dump file ($dumpfile) tasks ieee1364 18.1.1
|
||||||
|
/// (&str, &str, &str): (label, snippet, description)
|
||||||
|
pub const VLOG_DUMPFILE_TASKS: &[(&str, &str, &str)] = &[
|
||||||
|
("dumpfile", "$dumpfile($1);", "指定波形转储文件的名称。\n```verilog\n$dumpfile(\"waveform.vcd\");\n```"),
|
||||||
|
];
|
||||||
|
|
||||||
|
/// Specifying variables to be dumped ($dumpvars) tasks ieee1364 18.1.2
|
||||||
|
/// (&str, &str, &str): (label, snippet, description)
|
||||||
|
pub const VLOG_DUMPVARS_TASKS: &[(&str, &str, &str)] = &[
|
||||||
|
("dumpvars", "$dumpvars($1, $2);", "指定要转储的变量。\n```verilog\n$dumpvars(1, module_instance);\n```"),
|
||||||
|
];
|
||||||
|
|
||||||
|
/// Stopping and resuming the dump ($dumpoff/$dumpon) tasks ieee1364 18.1.3
|
||||||
|
/// (&str, &str, &str): (label, snippet, description)
|
||||||
|
pub const VLOG_DUMPOFF_DUMPON_TASKS: &[(&str, &str, &str)] = &[
|
||||||
|
("dumpoff", "$dumpoff;", "暂停波形转储。\n```verilog\n$dumpoff;\n```"),
|
||||||
|
("dumpon", "$dumpon;", "恢复波形转储。\n```verilog\n$dumpon;\n```"),
|
||||||
|
];
|
||||||
|
|
||||||
|
/// Generating a checkpoint ($dumpall) tasks ieee1364 18.1.4
|
||||||
|
/// (&str, &str, &str): (label, snippet, description)
|
||||||
|
pub const VLOG_DUMPALL_TASKS: &[(&str, &str, &str)] = &[
|
||||||
|
("dumpall", "$dumpall;", "生成一个检查点,转储所有变量的当前状态。\n```verilog\n$dumpall;\n```"),
|
||||||
|
];
|
||||||
|
|
||||||
|
/// Limiting size of dump file ($dumplimit) tasks ieee1364 18.1.5
|
||||||
|
/// (&str, &str, &str): (label, snippet, description)
|
||||||
|
pub const VLOG_DUMPLIMIT_TASKS: &[(&str, &str, &str)] = &[
|
||||||
|
("dumplimit", "$dumplimit($1);", "限制波形转储文件的大小。\n```verilog\n$dumplimit(1000000);\n```"),
|
||||||
|
];
|
||||||
|
|
||||||
|
/// Reading dump file during simulation ($dumpflush) tasks ieee1364 18.1.6
|
||||||
|
/// (&str, &str, &str): (label, snippet, description)
|
||||||
|
pub const VLOG_DUMPFLUSH_TASKS: &[(&str, &str, &str)] = &[
|
||||||
|
("dumpflush", "$dumpflush;", "刷新波形转储文件,确保所有数据都写入文件。\n```verilog\n$dumpflush;\n```"),
|
||||||
|
];
|
||||||
|
|
||||||
|
/// FSDB related tasks
|
||||||
|
/// (&str, &str, &str): (label, snippet, description)
|
||||||
|
pub const VLOG_FSDB_TASKS: &[(&str, &str, &str)] = &[
|
||||||
|
("fsdbDumpfile", "$fsdbDumpfile($1);", "指定 FSDB 文件的名称。\n```verilog\n$fsdbDumpfile(\"waveform.fsdb\");\n```"),
|
||||||
|
("fsdbDumpvars", "$fsdbDumpvars($1, $2);", "指定要转储到 FSDB 文件的变量。\n```verilog\n$fsdbDumpvars(1, module_instance);\n```"),
|
||||||
|
("fsdbDumpoff", "$fsdbDumpoff;", "暂停 FSDB 文件的转储。\n```verilog\n$fsdbDumpoff;\n```"),
|
||||||
|
("fsdbDumpon", "$fsdbDumpon;", "恢复 FSDB 文件的转储。\n```verilog\n$fsdbDumpon;\n```"),
|
||||||
|
("fsdbDumpflush", "$fsdbDumpflush;", "刷新 FSDB 文件,确保所有数据都写入文件。\n```verilog\n$fsdbDumpflush;\n```"),
|
||||||
|
];
|
||||||
|
|
||||||
|
|
||||||
|
fn make_function_profile(
|
||||||
|
#[allow(unused)]
|
||||||
|
section: &str,
|
||||||
|
description: &str
|
||||||
|
) -> MarkupContent {
|
||||||
MarkupContent {
|
MarkupContent {
|
||||||
kind: MarkupKind::Markdown,
|
kind: MarkupKind::Markdown,
|
||||||
value: format!("{}\n---\n{}", section, description)
|
value: format!("{}", description)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -377,6 +429,13 @@ pub fn provide_vlog_sys_tasks_completions() -> Vec<CompletionItem> {
|
|||||||
update_task_completions(&mut items, VLOG_INTEGER_MATH_FUNCTIONS_TASKS, "Integer math functions tasks ieee1364 17.11.1");
|
update_task_completions(&mut items, VLOG_INTEGER_MATH_FUNCTIONS_TASKS, "Integer math functions tasks ieee1364 17.11.1");
|
||||||
update_task_completions(&mut items, VLOG_REAL_MATH_FUNCTIONS_TASKS, "Real math functions tasks ieee1364 17.11.2");
|
update_task_completions(&mut items, VLOG_REAL_MATH_FUNCTIONS_TASKS, "Real math functions tasks ieee1364 17.11.2");
|
||||||
|
|
||||||
|
update_task_completions(&mut items, VLOG_DUMPFILE_TASKS, "Specifying name of dump file ($dumpfile) tasks ieee1364 18.1.1");
|
||||||
|
update_task_completions(&mut items, VLOG_DUMPVARS_TASKS, "Specifying variables to be dumped ($dumpvars) tasks ieee1364 18.1.2");
|
||||||
|
update_task_completions(&mut items, VLOG_DUMPOFF_DUMPON_TASKS, "Stopping and resuming the dump ($dumpoff/$dumpon) tasks ieee1364 18.1.3");
|
||||||
|
update_task_completions(&mut items, VLOG_DUMPALL_TASKS, "Generating a checkpoint ($dumpall) tasks ieee1364 18.1.4");
|
||||||
|
update_task_completions(&mut items, VLOG_DUMPLIMIT_TASKS, "Limiting size of dump file ($dumplimit) tasks ieee1364 18.1.5");
|
||||||
|
update_task_completions(&mut items, VLOG_DUMPFLUSH_TASKS, "Reading dump file during simulation ($dumpflush) tasks ieee1364 18.1.6");
|
||||||
|
update_task_completions(&mut items, VLOG_FSDB_TASKS, "FSDB related tasks");
|
||||||
|
|
||||||
items
|
items
|
||||||
}
|
}
|
@ -15,8 +15,8 @@ pub struct LSPServer {
|
|||||||
pub cache: CacheManager,
|
pub cache: CacheManager,
|
||||||
pub vlog_keyword_completion_items: Vec<CompletionItem>,
|
pub vlog_keyword_completion_items: Vec<CompletionItem>,
|
||||||
pub vhdl_keyword_completiom_items: Vec<CompletionItem>,
|
pub vhdl_keyword_completiom_items: Vec<CompletionItem>,
|
||||||
pub sys_tasks: Vec<CompletionItem>,
|
pub vlog_sys_tasks_completion_items: Vec<CompletionItem>,
|
||||||
pub directives: Vec<CompletionItem>,
|
pub vlog_directives: Vec<CompletionItem>,
|
||||||
pub conf: Arc<RwLock<ProjectConfig>>,
|
pub conf: Arc<RwLock<ProjectConfig>>,
|
||||||
#[allow(unused)]
|
#[allow(unused)]
|
||||||
pub log_handle: Mutex<Option<LoggerHandle>>,
|
pub log_handle: Mutex<Option<LoggerHandle>>,
|
||||||
@ -31,8 +31,8 @@ impl LSPServer {
|
|||||||
cache: CacheManager::new(dide_home),
|
cache: CacheManager::new(dide_home),
|
||||||
vlog_keyword_completion_items: keyword_completions(VLOG_KEYWORDS),
|
vlog_keyword_completion_items: keyword_completions(VLOG_KEYWORDS),
|
||||||
vhdl_keyword_completiom_items: keyword_completions(VHDL_KEYWORDS),
|
vhdl_keyword_completiom_items: keyword_completions(VHDL_KEYWORDS),
|
||||||
sys_tasks: provide_vlog_sys_tasks_completions(),
|
vlog_sys_tasks_completion_items: provide_vlog_sys_tasks_completions(),
|
||||||
directives: other_completions(DIRECTIVES),
|
vlog_directives: other_completions(DIRECTIVES),
|
||||||
conf: Arc::new(RwLock::new(ProjectConfig::default())),
|
conf: Arc::new(RwLock::new(ProjectConfig::default())),
|
||||||
log_handle: Mutex::new(log_handle),
|
log_handle: Mutex::new(log_handle),
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user