mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-04 10:48:32 +00:00
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:
parent
a827b16ebd
commit
33ed502edb
3 changed files with 893 additions and 22 deletions
|
@ -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())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue