Skip to content

Commit 2790efe

Browse files
committed
Add to_string for enum types
1 parent 978c5f4 commit 2790efe

File tree

3 files changed

+29
-2
lines changed

3 files changed

+29
-2
lines changed

vhdl_lang/src/analysis/declarative.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,16 @@ impl<'a> AnalyzeContext<'a> {
461461
parent.add_named_entity(literal_ent, diagnostics);
462462
}
463463

464-
parent.add_named_entity(enum_type.into(), diagnostics);
464+
parent.add_named_entity(enum_type.clone().into(), diagnostics);
465+
466+
if !self.is_standard_package() {
467+
let standard = self.expect_standard_package_analysis().unwrap();
468+
let standard_region =
469+
StandardRegion::new(&self.root.symbols, &standard.result().region);
470+
471+
parent
472+
.add_named_entity(standard_region.create_to_string(enum_type), diagnostics);
473+
}
465474
}
466475
TypeDefinition::ProtectedBody(ref mut body) => {
467476
body.type_reference.clear_reference();

vhdl_lang/src/analysis/tests/implicit.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,18 @@ end package;
7272
);
7373
}
7474

75+
#[test]
76+
fn adds_to_string_for_enum_types() {
77+
check_code_with_no_diagnostics(
78+
"
79+
package pkg is
80+
type enum_t is (alpha, beta);
81+
alias my_to_string is to_string[enum_t return string];
82+
end package;
83+
",
84+
);
85+
}
86+
7587
#[test]
7688
fn no_error_for_duplicate_alias_of_implicit() {
7789
check_code_with_no_diagnostics(

vhdl_ls/src/vhdl_server.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -854,12 +854,18 @@ end package;
854854

855855
let config_uri = write_config(
856856
&root_uri,
857-
"
857+
format!(
858+
"
858859
[libraries]
860+
std.files = [
861+
'{}/../vhdl_libraries/std/*.vhd',
862+
]
859863
lib.files = [
860864
'*.vhd'
861865
]
862866
",
867+
std::env::var("CARGO_MANIFEST_DIR").unwrap()
868+
),
863869
);
864870

865871
expect_loaded_config_messages(&mock, &config_uri);

0 commit comments

Comments
 (0)