finish sv hdlparam
This commit is contained in:
parent
4b6f6a365d
commit
ce5e1c73bd
@ -100,6 +100,7 @@ pub struct Macro {
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct FastHdlparam {
|
||||
pub fast_macro: Macro,
|
||||
pub content: Vec<Module>
|
||||
|
@ -3,6 +3,7 @@ use std::io::BufRead;
|
||||
use std::{collections::HashMap, io::BufReader};
|
||||
use std::path::PathBuf;
|
||||
use sv_parser::{parse_sv, unwrap_node, ConstantMintypmaxExpression, GateInstantiation, ListOfParameterAssignments, ListOfPortConnections, Locate, PackedDimensionRange, RefNode, SyntaxTree};
|
||||
|
||||
use super::fast_hdlparam::{FastHdlparam, Macro};
|
||||
|
||||
pub fn sv_parser(path: &str) -> Option<FastHdlparam> {
|
||||
@ -586,11 +587,9 @@ fn get_column_by_offset(content: &[String], offset: usize) -> usize {
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use std::fs;
|
||||
use std::path::Path;
|
||||
|
||||
use super::sv_parser;
|
||||
|
||||
const testfiles_dir: &str = "testfiles";
|
||||
const TESTFILES_DIR: &str = "testfiles";
|
||||
|
||||
macro_rules! unwrap_result {
|
||||
($expr:expr) => {
|
||||
@ -612,7 +611,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_sv_parse() {
|
||||
let entries = unwrap_result!(fs::read_dir(testfiles_dir));
|
||||
let entries = unwrap_result!(fs::read_dir(TESTFILES_DIR));
|
||||
for entry in entries {
|
||||
let entry = unwrap_result!(entry);
|
||||
let file_path = entry.path();
|
||||
|
@ -6,7 +6,7 @@ use log::info;
|
||||
use ropey::Rope;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use tower_lsp::jsonrpc::Result;
|
||||
use tower_lsp::{lsp_types::*, LanguageServer};
|
||||
use tower_lsp::lsp_types::*;
|
||||
|
||||
use crate::core::fast_hdlparam::FastHdlparam;
|
||||
use crate::core::sv_parser::make_fast_from_syntaxtree;
|
||||
|
@ -1,3 +1,5 @@
|
||||
use std::path::PathBuf;
|
||||
|
||||
use crate::definition::extract_defs::get_ident;
|
||||
use crate::server::LSPServer;
|
||||
use crate::sources::LSPSupport;
|
||||
@ -162,6 +164,21 @@ pub fn get_language_id_by_uri(uri: &Url) -> String {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_language_id_by_path(path: &PathBuf) -> String {
|
||||
let path = path.as_path();
|
||||
let ext_name = std::path::Path::new(path)
|
||||
.extension()
|
||||
.and_then(std::ffi::OsStr::to_str)
|
||||
.unwrap_or("");
|
||||
|
||||
match ext_name {
|
||||
"vhd" | "vhdl" | "vho" | "vht" => "vhdl".to_string(),
|
||||
"v" | "V" | "vh" | "vl" => "verilog".to_string(),
|
||||
"sv" | "svh" => "systemverilog".to_string(),
|
||||
_ => "plaintext".to_string()
|
||||
}
|
||||
}
|
||||
|
||||
type ScopesAndDefs = Option<(Vec<Box<dyn Scope>>, Vec<Box<dyn Definition>>)>;
|
||||
|
||||
/// Take a given syntax node from a sv-parser syntax tree and extract out the definition/scope at
|
||||
|
@ -2,7 +2,6 @@ use crate::definition::def_types::*;
|
||||
use crate::definition::get_scopes;
|
||||
use crate::diagnostics::{get_diagnostics, is_hidden};
|
||||
use crate::server::LSPServer;
|
||||
use log::info;
|
||||
use log::{debug, error};
|
||||
use pathdiff::diff_paths;
|
||||
use ropey::{Rope, RopeSlice};
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit 4960ea3fb7c848462ce6e78dbae454ffc775803f
|
||||
Subproject commit af11f5ff1ef091562d2b17cdf4de3614aedf2286
|
Loading…
x
Reference in New Issue
Block a user