完成自动补全的 output 自动申明 | 完成配置文件的前后端更新系统
This commit is contained in:
commit
12e1b25f11
@ -167,6 +167,30 @@ fn get_position_port_param_completion(
|
|||||||
// 补全当前 module 的所有 param
|
// 补全当前 module 的所有 param
|
||||||
if let Some((inst_module, file_type, _)) = hdl_param.find_module_context_by_name(&instance.inst_type) {
|
if let Some((inst_module, file_type, _)) = hdl_param.find_module_context_by_name(&instance.inst_type) {
|
||||||
let mut completion_items = Vec::<CompletionItem>::new();
|
let mut completion_items = Vec::<CompletionItem>::new();
|
||||||
|
match file_type.as_str() {
|
||||||
|
"primitives" => {
|
||||||
|
if let Some(primitives_inst) = inst_module.instances.first() {
|
||||||
|
for param_assignment in &primitives_inst.intstparam_assignments {
|
||||||
|
let label_details = CompletionItemLabelDetails {
|
||||||
|
detail: None,
|
||||||
|
..CompletionItemLabelDetails::default()
|
||||||
|
};
|
||||||
|
|
||||||
|
let name = param_assignment.parameter.clone().unwrap();
|
||||||
|
let param_desc = format!("parameter {}", name);
|
||||||
|
|
||||||
|
let c_item = CompletionItem {
|
||||||
|
label: name,
|
||||||
|
detail: Some(param_desc),
|
||||||
|
label_details: Some(label_details),
|
||||||
|
kind: Some(CompletionItemKind::TYPE_PARAMETER),
|
||||||
|
..CompletionItem::default()
|
||||||
|
};
|
||||||
|
completion_items.push(c_item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_ => {
|
||||||
for param in inst_module.params {
|
for param in inst_module.params {
|
||||||
let label_details = CompletionItemLabelDetails {
|
let label_details = CompletionItemLabelDetails {
|
||||||
detail: None,
|
detail: None,
|
||||||
@ -180,9 +204,6 @@ fn get_position_port_param_completion(
|
|||||||
"ip" => {
|
"ip" => {
|
||||||
param.to_vhdl_description()
|
param.to_vhdl_description()
|
||||||
}
|
}
|
||||||
"primitives" => {
|
|
||||||
param.to_vlog_description()
|
|
||||||
}
|
|
||||||
_ => {
|
_ => {
|
||||||
param.to_vlog_description()
|
param.to_vlog_description()
|
||||||
}
|
}
|
||||||
@ -197,6 +218,8 @@ fn get_position_port_param_completion(
|
|||||||
};
|
};
|
||||||
completion_items.push(c_item);
|
completion_items.push(c_item);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
return Some(CompletionList {
|
return Some(CompletionList {
|
||||||
is_incomplete: false,
|
is_incomplete: false,
|
||||||
items: completion_items
|
items: completion_items
|
||||||
@ -210,6 +233,30 @@ fn get_position_port_param_completion(
|
|||||||
if port_range.contains(pos) {
|
if port_range.contains(pos) {
|
||||||
if let Some((inst_module, file_type, _)) = hdl_param.find_module_context_by_name(&instance.inst_type) {
|
if let Some((inst_module, file_type, _)) = hdl_param.find_module_context_by_name(&instance.inst_type) {
|
||||||
let mut completion_items = Vec::<CompletionItem>::new();
|
let mut completion_items = Vec::<CompletionItem>::new();
|
||||||
|
match file_type.as_str() {
|
||||||
|
"primitives" => {
|
||||||
|
if let Some(primitives_inst) = inst_module.instances.first() {
|
||||||
|
for port_assignment in &primitives_inst.intstport_assignments {
|
||||||
|
let label_details = CompletionItemLabelDetails {
|
||||||
|
detail: None,
|
||||||
|
..CompletionItemLabelDetails::default()
|
||||||
|
};
|
||||||
|
|
||||||
|
let name = port_assignment.port.clone().unwrap();
|
||||||
|
let port_desc = format!("parameter {}", name);
|
||||||
|
|
||||||
|
let c_item = CompletionItem {
|
||||||
|
label: name,
|
||||||
|
detail: Some(port_desc),
|
||||||
|
label_details: Some(label_details),
|
||||||
|
kind: Some(CompletionItemKind::PROPERTY),
|
||||||
|
..CompletionItem::default()
|
||||||
|
};
|
||||||
|
completion_items.push(c_item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_ => {
|
||||||
for port in inst_module.ports {
|
for port in inst_module.ports {
|
||||||
let label_details = CompletionItemLabelDetails {
|
let label_details = CompletionItemLabelDetails {
|
||||||
detail: None,
|
detail: None,
|
||||||
@ -223,9 +270,6 @@ fn get_position_port_param_completion(
|
|||||||
"ip" => {
|
"ip" => {
|
||||||
port.to_vhdl_description()
|
port.to_vhdl_description()
|
||||||
}
|
}
|
||||||
"primitives" => {
|
|
||||||
port.to_vlog_description()
|
|
||||||
}
|
|
||||||
_ => {
|
_ => {
|
||||||
port.to_vlog_description()
|
port.to_vlog_description()
|
||||||
}
|
}
|
||||||
@ -240,6 +284,8 @@ fn get_position_port_param_completion(
|
|||||||
};
|
};
|
||||||
completion_items.push(c_item);
|
completion_items.push(c_item);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
return Some(CompletionList {
|
return Some(CompletionList {
|
||||||
is_incomplete: false,
|
is_incomplete: false,
|
||||||
items: completion_items
|
items: completion_items
|
||||||
|
@ -201,6 +201,34 @@ fn get_completion_token(text: &Rope, line: RopeSlice, pos: Position) -> String {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn make_primitives_instantiation_code(text: &str) -> String {
|
||||||
|
let mut instantiations = text.lines()
|
||||||
|
.filter(|line| !line.trim().is_empty() && !line.trim().starts_with("//"))
|
||||||
|
.collect::<Vec<&str>>();
|
||||||
|
// remove fake module and endmodule
|
||||||
|
instantiations.remove(0);
|
||||||
|
instantiations.pop();
|
||||||
|
|
||||||
|
instantiations.iter().map(|line| {
|
||||||
|
let trimmed = line.trim_start();
|
||||||
|
if trimmed.contains('.') {
|
||||||
|
format!("\t{}", trimmed)
|
||||||
|
} else {
|
||||||
|
trimmed.to_string()
|
||||||
|
}
|
||||||
|
}).collect::<Vec<String>>().join("\n")
|
||||||
|
}
|
||||||
|
|
||||||
|
fn make_primitives_module_profile_code(text: &str) -> String {
|
||||||
|
let mut lines: Vec<&str> = text.split_inclusive('\n').collect();
|
||||||
|
|
||||||
|
if lines.len() > 1 {
|
||||||
|
lines.remove(0);
|
||||||
|
lines.pop();
|
||||||
|
}
|
||||||
|
|
||||||
|
lines.join("")
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
fn make_instantiation_code(module: &crate::core::hdlparam::Module) -> String {
|
fn make_instantiation_code(module: &crate::core::hdlparam::Module) -> String {
|
||||||
@ -324,6 +352,8 @@ fn make_module_completions(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
module_completioms
|
module_completioms
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user