Skip to content

Commit

Permalink
fix: missing menuitem groups completions
Browse files Browse the repository at this point in the history
  • Loading branch information
Desdaemon committed Mar 20, 2024
1 parent 675e79d commit 4f43c62
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 18 deletions.
2 changes: 1 addition & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ impl LanguageServer for Backend {
})),
completion_provider: Some(CompletionOptions {
resolve_provider: Some(true),
trigger_characters: Some(['"', '\'', '.', '_'].iter().map(char::to_string).collect()),
trigger_characters: Some(['"', '\'', '.', '_', ',', ' '].iter().map(char::to_string).collect()),
all_commit_characters: None,
completion_item: None,
work_done_progress_options: Default::default(),
Expand Down
42 changes: 25 additions & 17 deletions src/xml.rs
Original file line number Diff line number Diff line change
Expand Up @@ -529,23 +529,28 @@ fn gather_refs<'read>(
model_filter = Some(value.as_str().to_string());
}
}
// <record id=.. /> or <template id=.. />
Ok(Token::Attribute { local, value, .. })
if matches!(tag, Some(Tag::Record | Tag::Template))
&& local == "id" && value.range().contains(&offset_at_cursor) =>
if matches!(tag, Some(Tag::Record | Tag::Template | Tag::Menuitem))
&& local == "id" && value.range().contains_end(offset_at_cursor) =>
{
ref_at_cursor = Some((value.as_str(), value.range()));
ref_kind = Some(RefKind::Id);
arch_model = None;
match tag {
Some(Tag::Template) => {
model_filter = Some("ir.ui.view".to_string());
}
Some(Tag::Menuitem) => {
model_filter = Some("ir.ui.menu".to_string());
}
_ => {}
}
}
// <menuitem parent=.. action=.. />
Ok(Token::Attribute { local, value, .. })
if matches!(tag, Some(Tag::Menuitem)) && value.range().contains_end(offset_at_cursor) =>
{
match local.as_str() {
"id" => {
ref_at_cursor = Some((value.as_str(), value.range()));
ref_kind = Some(RefKind::Id);
}
"parent" => {
ref_at_cursor = Some((value.as_str(), value.range()));
ref_kind = Some(RefKind::Ref(interner.get_or_intern_static("parent_id")));
Expand All @@ -556,6 +561,12 @@ fn gather_refs<'read>(
ref_kind = Some(RefKind::Ref(interner.get_or_intern_static("action")));
model_filter = Some("ir.ui.menu".to_string());
}
"groups" => {
ref_kind = Some(RefKind::Id);
arch_model = None;
model_filter = Some("res.groups".to_string());
determine_csv_xmlid_subgroup(&mut ref_at_cursor, value, offset_at_cursor);
}
_ => {}
}
}
Expand All @@ -569,16 +580,7 @@ fn gather_refs<'read>(
ref_at_cursor = Some((local.as_str(), local.range()));
ref_kind = Some(RefKind::PropOf(component));
}
// catchall groups=
Ok(Token::Attribute { local, value, .. })
if local.as_str() == "groups" && value.range().contains_end(offset_at_cursor) =>
{
ref_kind = Some(RefKind::Id);
model_filter = Some("res.groups".to_string());
arch_model = None;
determine_csv_xmlid_subgroup(&mut ref_at_cursor, value, offset_at_cursor);
}
// on-hover cases
// catchall cases
Ok(Token::Attribute { local, value, .. }) if value.range().contains_end(offset_at_cursor) => {
match local.as_str() {
"t-name" => {
Expand All @@ -593,6 +595,12 @@ fn gather_refs<'read>(
ref_at_cursor = Some((value.as_str(), value.range()));
ref_kind = Some(RefKind::TCall);
}
"groups" => {
ref_kind = Some(RefKind::Id);
model_filter = Some("res.groups".to_string());
arch_model = None;
determine_csv_xmlid_subgroup(&mut ref_at_cursor, value, offset_at_cursor);
}
_ => {}
}
}
Expand Down

0 comments on commit 4f43c62

Please sign in to comment.