[ty] Update completion eval to include modules

Our parsing and confirming of symbol names is highly suspect, but
I think it's fine for now.
This commit is contained in:
Andrew Gallant 2025-12-04 15:07:01 -05:00 committed by Andrew Gallant
parent 518d11b33f
commit 06415b1877
6 changed files with 34 additions and 1 deletions

View File

@ -1,4 +1,7 @@
name,file,index,rank
auto-import-includes-modules,main.py,0,1
auto-import-includes-modules,main.py,1,7
auto-import-includes-modules,main.py,2,1
auto-import-skips-current-module,main.py,0,1
fstring-completions,main.py,0,1
higher-level-symbols-preferred,main.py,0,
@ -25,4 +28,4 @@ scope-simple-long-identifier,main.py,0,1
tstring-completions,main.py,0,1
ty-extensions-lower-stdlib,main.py,0,9
type-var-typing-over-ast,main.py,0,3
type-var-typing-over-ast,main.py,1,239
type-var-typing-over-ast,main.py,1,251

1 name file index rank
2 auto-import-includes-modules main.py 0 1
3 auto-import-includes-modules main.py 1 7
4 auto-import-includes-modules main.py 2 1
5 auto-import-skips-current-module main.py 0 1
6 fstring-completions main.py 0 1
7 higher-level-symbols-preferred main.py 0
28 tstring-completions main.py 0 1
29 ty-extensions-lower-stdlib main.py 0 9
30 type-var-typing-over-ast main.py 0 3
31 type-var-typing-over-ast main.py 1 239 251

View File

@ -506,9 +506,21 @@ struct CompletionAnswer {
impl CompletionAnswer {
/// Returns true when this answer matches the completion given.
fn matches(&self, completion: &Completion) -> bool {
if let Some(ref qualified) = completion.qualified {
if qualified.as_str() == self.qualified() {
return true;
}
}
self.symbol == completion.name.as_str()
&& self.module.as_deref() == completion.module_name.map(ModuleName::as_str)
}
fn qualified(&self) -> String {
self.module
.as_ref()
.map(|module| format!("{module}.{}", self.symbol))
.unwrap_or_else(|| self.symbol.clone())
}
}
/// Copy the Python project from `src_dir` to `dst_dir`.

View File

@ -0,0 +1,2 @@
[settings]
auto-import = true

View File

@ -0,0 +1,3 @@
multiprocess<CURSOR: multiprocessing>
collect<CURSOR: collections>
collabc<CURSOR: collections.abc>

View File

@ -0,0 +1,5 @@
[project]
name = "test"
version = "0.1.0"
requires-python = ">=3.13"
dependencies = []

View File

@ -0,0 +1,8 @@
version = 1
revision = 3
requires-python = ">=3.13"
[[package]]
name = "test"
version = "0.1.0"
source = { virtual = "." }