mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-30 13:51:16 +00:00
[ty] Add type information to all_members
API
Since we generally need (so far) to get the type information of each suggestion to figure out its boundness anyway, we might as well expose it here. Completions want to use this information to enhance the metadata on each suggestion for a more pleasant user experience. For the most part, this was pretty straight-forward. The most exciting part was in computing the types for instance attributes. I'm not 100% sure it's correct or is the best way to do it.
This commit is contained in:
parent
79fe538458
commit
fea84e8777
4 changed files with 269 additions and 102 deletions
|
@ -73,7 +73,7 @@ impl<'db> SemanticModel<'db> {
|
|||
.into_iter()
|
||||
.map(|member| Completion {
|
||||
name: member.name,
|
||||
ty: None,
|
||||
ty: member.ty,
|
||||
builtin,
|
||||
})
|
||||
.collect()
|
||||
|
@ -86,7 +86,7 @@ impl<'db> SemanticModel<'db> {
|
|||
.into_iter()
|
||||
.map(|member| Completion {
|
||||
name: member.name,
|
||||
ty: None,
|
||||
ty: member.ty,
|
||||
builtin: false,
|
||||
})
|
||||
.collect()
|
||||
|
@ -122,7 +122,7 @@ impl<'db> SemanticModel<'db> {
|
|||
all_declarations_and_bindings(self.db, file_scope.to_scope_id(self.db, self.file))
|
||||
.map(|member| Completion {
|
||||
name: member.name,
|
||||
ty: None,
|
||||
ty: member.ty,
|
||||
builtin: false,
|
||||
}),
|
||||
);
|
||||
|
@ -172,8 +172,8 @@ impl NameKind {
|
|||
pub struct Completion<'db> {
|
||||
/// The label shown to the user for this suggestion.
|
||||
pub name: Name,
|
||||
/// The type of this completion, if available.
|
||||
pub ty: Option<Type<'db>>,
|
||||
/// The type of this completion.
|
||||
pub ty: Type<'db>,
|
||||
/// Whether this suggestion came from builtins or not.
|
||||
///
|
||||
/// At time of writing (2025-06-26), this information
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue