fix: signature help not working

This commit is contained in:
Shunsuke Shibayama 2024-08-20 22:10:33 +09:00
parent b6a368257f
commit e3a9720159
2 changed files with 30 additions and 15 deletions

View File

@ -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. 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 😃 ### pylyzer 😃
![report](https://raw.githubusercontent.com/mtshiba/pylyzer/main/images/report.png) ![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 📝 * 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)). 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] builtin modules analysis
* [x] local scripts analysis * [x] local scripts analysis
* [x] local packages 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] collection types
* [x] `list` * [x] `list`
* [x] `dict` * [x] `dict`
@ -114,17 +124,15 @@ pylyzer converts Python ASTs to Erg ASTs and passes them to Erg's type checker.
* [x] `Literal` * [x] `Literal`
* [x] `Callable` * [x] `Callable`
* [ ] `TypedDict` * [ ] `TypedDict`
* [ ] type variable
* [x] `TypeVar` * [x] `TypeVar`
* [x] type parameter syntax
* [ ] `Generic` * [ ] `Generic`
* [ ] `Protocol` * [ ] `Protocol`
* [ ] `Final` * [ ] `Final`
* [ ] `Annotated` * [ ] `Annotated`
* [ ] `TypeAlias` * [ ] `TypeAlias`
* [ ] type guard
* [x] type narrowing
* [ ] `TypeGuard` * [ ] `TypeGuard`
* [x] type parameter syntax
* [x] type narrowing
* [ ] others * [ ] others
* `collections.abc` * `collections.abc`
* [x] `Iterable` * [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 assertion (`typing.cast`)
* [x] type narrowing (`is`, `isinstance`) * [x] type narrowing (`is`, `isinstance`)
* [ ] `pyi` (stub) files support * [ ] `pyi` (stub) files support
* [ ] glob pattern file check
--- ---

View File

@ -1166,6 +1166,7 @@ impl ASTConverter {
} }
py_ast::Expr::Call(call) => { py_ast::Expr::Call(call) => {
let loc = call.location(); let loc = call.location();
let end_loc = call.end_location();
let function = self.convert_expr(*call.func); let function = self.convert_expr(*call.func);
let (pos_args, var_args): (Vec<_>, _) = call let (pos_args, var_args): (Vec<_>, _) = call
.args .args
@ -1201,10 +1202,15 @@ impl ASTConverter {
.into_iter() .into_iter()
.map(|Keyword { value, .. }| PosArg::new(self.convert_expr(value))) .map(|Keyword { value, .. }| PosArg::new(self.convert_expr(value)))
.next(); .next();
let last_col = pos_args let last_col = end_loc.map_or_else(
|| {
pos_args
.last() .last()
.and_then(|last| last.col_end()) .and_then(|last| last.col_end())
.unwrap_or(function.col_end().unwrap_or(0) + 1); .unwrap_or(function.col_end().unwrap_or(0) + 1)
},
|loc| loc.row.get(),
);
let paren = { let paren = {
let lp = Token::new( let lp = Token::new(
TokenKind::LParen, TokenKind::LParen,