-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Split completions into multiple files
commit-id:9774fc9a
- Loading branch information
Showing
12 changed files
with
547 additions
and
489 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
use cairo_lang_defs::db::DefsGroup; | ||
use cairo_lang_syntax::node::TypedSyntaxNode; | ||
use cairo_lang_syntax::node::ast::Attribute; | ||
use lsp_types::{CompletionItem, CompletionItemKind}; | ||
|
||
use crate::lang::db::AnalysisDatabase; | ||
|
||
pub mod derive; | ||
|
||
pub fn attribute_completions( | ||
db: &AnalysisDatabase, | ||
attribute: Attribute, | ||
) -> Option<Vec<CompletionItem>> { | ||
let plugins = db.macro_plugins(); | ||
|
||
let attr_name = attribute.attr(db).as_syntax_node().get_text(db); | ||
|
||
Some( | ||
plugins | ||
.iter() | ||
.flat_map(|plugin| plugin.declared_attributes()) | ||
.filter(|name| { | ||
// Don't suggest already typed one. | ||
name.starts_with(&attr_name) && name != &attr_name | ||
}) | ||
.map(|name| CompletionItem { | ||
label: name, | ||
kind: Some(CompletionItemKind::FUNCTION), | ||
..Default::default() | ||
}) | ||
.collect(), | ||
) | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.