This commit is contained in:
锦恢 2024-12-04 00:57:59 +08:00
parent d9fe1e9ed5
commit ac37cd3e2b
3 changed files with 9 additions and 6 deletions

View File

@ -41,7 +41,7 @@ pub const VLOG_CONTINUOUS_MONITORING_TASKS: &[(&str, &str, &str)] = &[
/// File input-output system tasks and functions ieee1364 17.2.1
/// (&str, &str, &str): (label, snippet, description)
pub const VLOG_FILE_IO_TASKS: &[(&str, &str, &str)] = &[
("fopen", "$fopen($1);", "打开文件并返回文件句柄。\n```verilog\ninteger file_handle;\n// 默认以 \"w\" 作为 flag如果 file_handle == 0文件打开失败file_handle == 1文件打开成功\nfile_handle = $fopen(\"data.bin\", \"r\");\n```\n\n其余文件描述符\n| 参数 | 描述 |\n|------|-------|\n| `r` 或 `rb` | 以只读方式打开文件 |\n| `w` 或 `wb` | 截断文件长度为零或创建新文件以进行写入 |\n| `a` 或 `ab` | 追加;在文件末尾打开以进行写入,或创建新文件以进行写入 |\n| `r+`、`r+b` 或 `rb+` | 以读写方式打开文件 |\n| `w+`、`w+b` 或 `wb+` | 截断文件或创建新文件以进行读写 |\n| `a+`、`a+b` 或 `ab+` | 追加;在文件末尾打开或创建新文件以进行读写 |"),
("fopen", "$fopen($1, $2);", "打开文件并返回文件句柄。\n```verilog\ninteger file_handle;\n// 默认以 \"w\" 作为 flag如果 file_handle == 0文件打开失败file_handle == 1文件打开成功\nfile_handle = $fopen(\"data.bin\", \"r\");\n```\n\n其余文件描述符\n| 参数 | 描述 |\n|------|-------|\n| `r` 或 `rb` | 以只读方式打开文件 |\n| `w` 或 `wb` | 截断文件长度为零或创建新文件以进行写入 |\n| `a` 或 `ab` | 追加;在文件末尾打开以进行写入,或创建新文件以进行写入 |\n| `r+`、`r+b` 或 `rb+` | 以读写方式打开文件 |\n| `w+`、`w+b` 或 `wb+` | 截断文件或创建新文件以进行读写 |\n| `a+`、`a+b` 或 `ab+` | 追加;在文件末尾打开或创建新文件以进行读写 |"),
("fclose", "$fclose($1);", "关闭文件。\n```verilog\n$fclose(file_handle);\n```"),
];
@ -73,7 +73,6 @@ pub const VLOG_FILE_OUTPUT_TASKS: &[(&str, &str, &str)] = &[
/// Formatting data to a string tasks ieee1364 17.2.3
/// (&str, &str, &str): (label, snippet, description)
pub const VLOG_FORMATTING_TASKS: &[(&str, &str, &str)] = &[
("sscanf", "$sscanf($1, $2, $3);", "从字符串中读取格式化数据。\n```verilog\ninteger value;\n$sscanf(\"123\", \"%d\", value);\n```"),
("swrite", "$swrite($1, $2);", "将格式化字符串存储到字符串变量中,不自动添加换行符。\n```verilog\nstring formatted_string;\n$swrite(formatted_string, \"Data: %d\", data);\n```"),
("swriteb", "$swriteb($1, $2);", "将二进制格式的表达式存储到字符串变量中,不自动添加换行符。\n```verilog\nstring formatted_string;\n$swriteb(formatted_string, data);\n```"),
("swriteo", "$swriteo($1, $2);", "将八进制格式的表达式存储到字符串变量中,不自动添加换行符。\n```verilog\nstring formatted_string;\n$swriteo(formatted_string, data);\n```"),

View File

@ -11,12 +11,16 @@ mod verible;
mod verilator;
mod vivado;
pub fn get_diagnostics(
/// 获取诊断核心函数
pub fn provide_diagnostics(
uri: Url,
rope: &Rope,
#[allow(unused_variables)] files: Vec<Url>,
conf: &ProjectConfig,
) -> PublishDiagnosticsParams {
if !(cfg!(test) && (uri.to_string().starts_with("file:///test"))) {
let diagnostics = {
if conf.verilator.syntax.enabled {

View File

@ -6,7 +6,7 @@ use crate::core::vhdl_parser::vhdl_parse_str;
use crate::definition::def_types::*;
use crate::definition::get_scopes_from_syntax_tree;
use crate::definition::get_scopes_from_vhdl_fast;
use crate::diagnostics::{get_diagnostics, is_hidden};
use crate::diagnostics::{provide_diagnostics, is_hidden};
use crate::server::LSPServer;
use crate::server::ProjectConfig;
use crate::utils::to_escape_path;
@ -58,7 +58,7 @@ impl LSPServer {
let file_id = self.srcs.get_id(&uri);
if let Some(file) = self.srcs.get_file(file_id) {
let file = file.read().unwrap();
let diagnostics = get_diagnostics(
let diagnostics = provide_diagnostics(
uri,
&file.text,
urls,
@ -107,7 +107,7 @@ impl LSPServer {
if let Some(file) = self.srcs.get_file(file_id) {
let file = file.read().unwrap();
get_diagnostics(
provide_diagnostics(
uri,
&file.text,
urls,