Skip to content

Commit 14a4d27

Browse files
committed
Fix: Enable completion for type related attributes for objects
1 parent 950fe46 commit 14a4d27

File tree

3 files changed

+4
-20
lines changed

3 files changed

+4
-20
lines changed

vhdl_lang/src/completion/attributes.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ fn extend_attributes_of_type(
5454
Range(RangeAttribute::ReverseRange),
5555
Length,
5656
Ascending,
57+
Type(TypeAttribute::Element),
5758
]);
5859
}
5960
if typ.is_discrete() {
@@ -63,7 +64,7 @@ fn extend_attributes_of_type(
6364

6465
/// Extends applicable attributes when the attribute name is an object.
6566
fn extend_attributes_of_objects(obj: &Object<'_>, attributes: &mut Vec<AttributeDesignator>) {
66-
extend_attributes_of_type(obj.subtype.type_mark().kind(), attributes);
67+
extend_attributes_of_type(obj.subtype.type_mark().base_type().kind(), attributes);
6768
attributes.push(AttributeDesignator::Type(TypeAttribute::Subtype));
6869
if obj.class == ObjectClass::Signal {
6970
use crate::ast::SignalAttribute::*;
@@ -84,9 +85,6 @@ fn extend_attributes_of_objects(obj: &Object<'_>, attributes: &mut Vec<Attribute
8485
.map(AttributeDesignator::Signal),
8586
);
8687
}
87-
if obj.subtype.type_mark().kind().is_array() {
88-
attributes.push(AttributeDesignator::Type(TypeAttribute::Element));
89-
}
9088
}
9189

9290
#[cfg(test)]

vhdl_lang/src/syntax/expression.rs

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -316,18 +316,7 @@ pub fn name_to_type_mark(
316316
let pos = name.pos(ctx);
317317
let type_mark = name
318318
.try_map_into(|name| match name {
319-
Name::Attribute(attr) => {
320-
if attr.as_type().is_some() {
321-
Some(Name::Attribute(Box::new(AttributeName {
322-
name: attr.name.try_map_into(name_to_selected_name)?,
323-
attr: attr.attr,
324-
expr: None,
325-
signature: None,
326-
})))
327-
} else {
328-
None
329-
}
330-
}
319+
Name::Attribute(_) => Some(name),
331320
_ => Some(name_to_selected_name(name)?),
332321
})
333322
.ok_or_else(|| Diagnostic::syntax_error(&pos, "Expected type mark"))?;

vhdl_lang/src/syntax/separated_list.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -253,9 +253,6 @@ mod test {
253253
c_pos.range.start.character += 1;
254254
c_pos.range.end.character += 2;
255255

256-
assert_eq!(
257-
diag,
258-
vec![Diagnostic::syntax_error(c_pos, "Expected ','")]
259-
);
256+
assert_eq!(diag, vec![Diagnostic::syntax_error(c_pos, "Expected ','")]);
260257
}
261258
}

0 commit comments

Comments
 (0)