ty_ide: improve completions by using scopes
Previously, completions were based on just returning every identifier
parsed in the current Python file. In this commit, we change it to
identify an expression under the cursor and then return all symbols
available to the scope containing that expression.
This is still returning too much, and also, in some cases, not enough.
Namely, it doesn't really take the specific context into account other
than scope. But this does improve on the status quo. For example:
def foo(): ...
def bar():
def fast(): ...
def foofoo(): ...
f<CURSOR>
When asking for completions here, the LSP will no longer include `fast`
as a possible completion in this context.
Ref https://github.com/astral-sh/ty/issues/86
This commit is contained in:
committed by
Andrew Gallant
parent
a827b16ebd
commit
33ed502edb
@@ -111,6 +111,13 @@ impl From<Name> for compact_str::CompactString {
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Name> for String {
|
||||
#[inline]
|
||||
fn from(name: Name) -> Self {
|
||||
name.as_str().into()
|
||||
}
|
||||
}
|
||||
|
||||
impl FromIterator<char> for Name {
|
||||
fn from_iter<I: IntoIterator<Item = char>>(iter: I) -> Self {
|
||||
Self(iter.into_iter().collect())
|
||||
|
||||
Reference in New Issue
Block a user