From e3a97201593636367cf09deeafd1fe676c483b71 Mon Sep 17 00:00:00 2001 From: Shunsuke Shibayama Date: Tue, 20 Aug 2024 22:10:33 +0900 Subject: [PATCH] fix: signature help not working --- README.md | 31 ++++++++++++++++++++----------- crates/py2erg/convert.rs | 14 ++++++++++---- 2 files changed, 30 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index 36284f7..3aeb19c 100644 --- a/README.md +++ b/README.md @@ -45,14 +45,14 @@ On average, pylyzer can inspect Python scripts more than __100 times faster__ th While pytype/pyright's error reports are illegible, pylyzer shows where the error occurred and provides clear error messages. +### pyright + +![pyright_report](https://raw.githubusercontent.com/mtshiba/pylyzer/main/images/pyright_report.png) + ### pylyzer 😃 ![report](https://raw.githubusercontent.com/mtshiba/pylyzer/main/images/report.png) -### pyright 🙃 - -![pyright_report](https://raw.githubusercontent.com/mtshiba/pylyzer/main/images/pyright_report.png) - * Rich LSP support 📝 pylyzer as a language server supports various features, such as completion and renaming (The language server is an adaptation of the Erg Language Server (ELS). For more information on the implemented features, please see [here](https://github.com/erg-lang/erg/tree/main/crates/els#readme)). @@ -104,6 +104,16 @@ pylyzer converts Python ASTs to Erg ASTs and passes them to Erg's type checker. * [x] builtin modules analysis * [x] local scripts analysis * [x] local packages analysis +* [x] LSP features + * [x] diagnostics + * [x] completion + * [x] rename + * [x] hover + * [x] goto definition + * [x] signature help + * [x] find references + * [x] document symbol + * [x] call hierarchy * [x] collection types * [x] `list` * [x] `dict` @@ -114,17 +124,15 @@ pylyzer converts Python ASTs to Erg ASTs and passes them to Erg's type checker. * [x] `Literal` * [x] `Callable` * [ ] `TypedDict` - * [ ] type variable - * [x] `TypeVar` - * [x] type parameter syntax - * [ ] `Generic` + * [x] `TypeVar` + * [ ] `Generic` * [ ] `Protocol` * [ ] `Final` * [ ] `Annotated` * [ ] `TypeAlias` - * [ ] type guard - * [x] type narrowing - * [ ] `TypeGuard` + * [ ] `TypeGuard` + * [x] type parameter syntax + * [x] type narrowing * [ ] others * `collections.abc` * [x] `Iterable` @@ -135,6 +143,7 @@ pylyzer converts Python ASTs to Erg ASTs and passes them to Erg's type checker. * [x] type assertion (`typing.cast`) * [x] type narrowing (`is`, `isinstance`) * [ ] `pyi` (stub) files support +* [ ] glob pattern file check --- diff --git a/crates/py2erg/convert.rs b/crates/py2erg/convert.rs index 57bbb31..83bda6d 100644 --- a/crates/py2erg/convert.rs +++ b/crates/py2erg/convert.rs @@ -1166,6 +1166,7 @@ impl ASTConverter { } py_ast::Expr::Call(call) => { let loc = call.location(); + let end_loc = call.end_location(); let function = self.convert_expr(*call.func); let (pos_args, var_args): (Vec<_>, _) = call .args @@ -1201,10 +1202,15 @@ impl ASTConverter { .into_iter() .map(|Keyword { value, .. }| PosArg::new(self.convert_expr(value))) .next(); - let last_col = pos_args - .last() - .and_then(|last| last.col_end()) - .unwrap_or(function.col_end().unwrap_or(0) + 1); + let last_col = end_loc.map_or_else( + || { + pos_args + .last() + .and_then(|last| last.col_end()) + .unwrap_or(function.col_end().unwrap_or(0) + 1) + }, + |loc| loc.row.get(), + ); let paren = { let lp = Token::new( TokenKind::LParen,