Add ascription type information to suggestions database (#9267)

close #9258

Changelog:
- fix: add information about the type descriptions to the suggestion database
This commit is contained in:
Dmitry Bushev 2024-03-05 09:02:41 +00:00 committed by GitHub
parent ba9b7f199a
commit 02bd863c29
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 75 additions and 1 deletions

View File

@ -702,7 +702,7 @@ final class SuggestionBuilder[A: IndexedSource](
* @return the suggestion argument
*/
private def buildArgument(arg: DefinitionArgument): Suggestion.Argument = {
buildTypeSignatureFromMetadata(arg.name.getMetadata(TypeSignatures)) match {
buildTypeSignatureFromMetadata(arg.getMetadata(TypeSignatures)) match {
case Vector(targ) =>
buildTypedArgument(arg, targ)
case _ =>

View File

@ -245,6 +245,80 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers {
)
}
"build method with an ascribed argument" in {
val code =
"""import Standard.Base.Data.Text.Text
|
|foo (a : Text) = 42""".stripMargin
val module = code.preprocessModule
build(code, module) shouldEqual Tree.Root(
Vector(
ModuleNode,
Tree.Node(
Suggestion.DefinedMethod(
externalId = None,
module = "Unnamed.Test",
name = "foo",
arguments = Seq(
Suggestion.Argument(
"a",
"Standard.Base.Data.Text.Text",
false,
false,
None
)
),
selfType = "Unnamed.Test",
returnType = SuggestionBuilder.Any,
isStatic = true,
documentation = None,
annotations = Seq()
),
Vector()
)
)
)
}
"build method with an ascribed and default argument" in {
val code =
"""import Standard.Base.Data.Text.Text
|
|foo (a : Text = "42") = a""".stripMargin
val module = code.preprocessModule
build(code, module) shouldEqual Tree.Root(
Vector(
ModuleNode,
Tree.Node(
Suggestion.DefinedMethod(
externalId = None,
module = "Unnamed.Test",
name = "foo",
arguments = Seq(
Suggestion.Argument(
"a",
"Standard.Base.Data.Text.Text",
false,
true,
Some("\"42\"")
)
),
selfType = "Unnamed.Test",
returnType = SuggestionBuilder.Any,
isStatic = true,
documentation = None,
annotations = Seq()
),
Vector()
)
)
)
}
"build method with a type containing higher kinds" in {
val code =