Skip to content

Commit

Permalink
Suppress event impls for zeekygen interactions
Browse files Browse the repository at this point in the history
  • Loading branch information
bbannier committed May 27, 2024
1 parent 0f09ab3 commit af1dc6f
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions src/lsp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -782,8 +782,15 @@ impl LanguageServer for Backend {
let mut x = fuzzy_search_symbol(&state, &symbol);
x.sort_by(|(r1, _), (r2, _)| r1.total_cmp(r2));

if let Some((_, decl)) = x.last() {
contents.push(MarkedString::String(decl.documentation.to_string()));
if let Some(docs) = fuzzy_search_symbol(&state, &symbol)
.iter()
// Filter out event implementations.
.filter(|(_, d)| !matches!(d.kind, DeclKind::EventDef(_)))
.sorted_by(|(r1, _), (r2, _)| r1.total_cmp(r2))
.last()
.map(|(_, d)| d.documentation.to_string())
{
contents.push(MarkedString::String(docs));
}
Some(())
};
Expand Down Expand Up @@ -976,9 +983,12 @@ impl LanguageServer for Backend {
// If we are in a zeekygen comment try to recover an
// identifier under the cursor and use it as target.
let symbol = word_at_position(&source, position)?;
let mut x = fuzzy_search_symbol(&state, &symbol);
x.sort_by(|(r1, _), (r2, _)| r1.total_cmp(r2));
x.last()
fuzzy_search_symbol(&state, &symbol)
.iter()
// Filter out event implementations.
.filter(|(_, d)| !matches!(d.kind, DeclKind::EventDef(_)))
.sorted_by(|(r1, _), (r2, _)| r1.total_cmp(r2))
.last()
.and_then(|(_, d)| d.loc.as_ref())
.map(|l| Location::new(l.uri.as_ref().clone(), l.range))
}
Expand Down

0 comments on commit af1dc6f

Please sign in to comment.