Skip to content

Commit b0b65c2

Browse files
UnboundVariableUnboundVariableMichaReiser
authored
[ty] Initial implementation of signature help provider (#19194)
This PR includes: * Implemented core signature help logic * Added new docstring method on Definition that returns a docstring for function and class definitions * Modified the display code for Signature that allows a signature string to be broken into text ranges that correspond to each parameter in the signature * Augmented Signature struct so it can track the Definition for a signature when available; this allows us to find the docstring associated with the signature * Added utility functions for parsing parameter documentation from three popular docstring formats (Google, NumPy and reST) * Implemented tests for all of the above "Signature help" is displayed by an editor when you are typing a function call expression. It is typically triggered when you type an open parenthesis. The language server provides information about the target function's signature (or multiple signatures), documentation, and parameters. Here is how this appears: ![image](https://github.com/user-attachments/assets/40dce616-ed74-4810-be62-42a5b5e4b334) --------- Co-authored-by: UnboundVariable <[email protected]> Co-authored-by: Micha Reiser <[email protected]>
1 parent 08bc6d2 commit b0b65c2

File tree

20 files changed

+1914
-51
lines changed

20 files changed

+1914
-51
lines changed

Cargo.lock

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/ty_ide/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,12 @@ bitflags = { workspace = true }
1515
ruff_db = { workspace = true }
1616
ruff_python_ast = { workspace = true }
1717
ruff_python_parser = { workspace = true }
18+
ruff_python_trivia = { workspace = true }
19+
ruff_source_file = { workspace = true }
1820
ruff_text_size = { workspace = true }
1921
ty_python_semantic = { workspace = true }
2022

23+
regex = { workspace = true }
2124
rustc-hash = { workspace = true }
2225
salsa = { workspace = true }
2326
smallvec = { workspace = true }

crates/ty_ide/src/docstring.rs

Lines changed: 664 additions & 0 deletions
Large diffs are not rendered by default.

crates/ty_ide/src/lib.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,25 @@
11
mod completion;
22
mod db;
3+
mod docstring;
34
mod find_node;
45
mod goto;
56
mod hover;
67
mod inlay_hints;
78
mod markup;
89
mod semantic_tokens;
10+
mod signature_help;
911

1012
pub use completion::completion;
1113
pub use db::Db;
14+
pub use docstring::get_parameter_documentation;
1215
pub use goto::goto_type_definition;
1316
pub use hover::hover;
1417
pub use inlay_hints::inlay_hints;
1518
pub use markup::MarkupKind;
1619
pub use semantic_tokens::{
1720
SemanticToken, SemanticTokenModifier, SemanticTokenType, SemanticTokens, semantic_tokens,
1821
};
22+
pub use signature_help::{ParameterDetails, SignatureDetails, SignatureHelpInfo, signature_help};
1923

2024
use ruff_db::files::{File, FileRange};
2125
use ruff_text_size::{Ranged, TextRange};

0 commit comments

Comments
 (0)