Skip to content

Commit

Permalink
Fix: Enable completion for type related attributes for objects
Browse files Browse the repository at this point in the history
  • Loading branch information
Schottky-spi committed Aug 14, 2024
1 parent 950fe46 commit 14a4d27
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 20 deletions.
6 changes: 2 additions & 4 deletions vhdl_lang/src/completion/attributes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ fn extend_attributes_of_type(
Range(RangeAttribute::ReverseRange),
Length,
Ascending,
Type(TypeAttribute::Element),
]);
}
if typ.is_discrete() {
Expand All @@ -63,7 +64,7 @@ fn extend_attributes_of_type(

/// Extends applicable attributes when the attribute name is an object.
fn extend_attributes_of_objects(obj: &Object<'_>, attributes: &mut Vec<AttributeDesignator>) {
extend_attributes_of_type(obj.subtype.type_mark().kind(), attributes);
extend_attributes_of_type(obj.subtype.type_mark().base_type().kind(), attributes);
attributes.push(AttributeDesignator::Type(TypeAttribute::Subtype));
if obj.class == ObjectClass::Signal {
use crate::ast::SignalAttribute::*;
Expand All @@ -84,9 +85,6 @@ fn extend_attributes_of_objects(obj: &Object<'_>, attributes: &mut Vec<Attribute
.map(AttributeDesignator::Signal),
);
}
if obj.subtype.type_mark().kind().is_array() {
attributes.push(AttributeDesignator::Type(TypeAttribute::Element));
}
}

#[cfg(test)]
Expand Down
13 changes: 1 addition & 12 deletions vhdl_lang/src/syntax/expression.rs
Original file line number Diff line number Diff line change
Expand Up @@ -316,18 +316,7 @@ pub fn name_to_type_mark(
let pos = name.pos(ctx);
let type_mark = name
.try_map_into(|name| match name {
Name::Attribute(attr) => {
if attr.as_type().is_some() {
Some(Name::Attribute(Box::new(AttributeName {
name: attr.name.try_map_into(name_to_selected_name)?,
attr: attr.attr,
expr: None,
signature: None,
})))
} else {
None
}
}
Name::Attribute(_) => Some(name),
_ => Some(name_to_selected_name(name)?),
})
.ok_or_else(|| Diagnostic::syntax_error(&pos, "Expected type mark"))?;
Expand Down
5 changes: 1 addition & 4 deletions vhdl_lang/src/syntax/separated_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -253,9 +253,6 @@ mod test {
c_pos.range.start.character += 1;
c_pos.range.end.character += 2;

assert_eq!(
diag,
vec![Diagnostic::syntax_error(c_pos, "Expected ','")]
);
assert_eq!(diag, vec![Diagnostic::syntax_error(c_pos, "Expected ','")]);
}
}

0 comments on commit 14a4d27

Please sign in to comment.