mirror of
https://github.com/enso-org/enso.git
synced 2024-11-27 06:32:30 +03:00
Do not add self arguments of static methods to suggestions database (#7074)
The `self` argument of static methods should not be visible to the user. # Important Notes ![2023-06-19-190618_1243x459_scrot](https://github.com/enso-org/enso/assets/357683/f9b32911-bf8a-4cbc-ab7a-61beaae3c98b)
This commit is contained in:
parent
20edc2dd0d
commit
8b65509415
@ -546,14 +546,6 @@ class RuntimeSuggestionUpdatesTest
|
||||
moduleName,
|
||||
"foo",
|
||||
List(
|
||||
Suggestion
|
||||
.Argument(
|
||||
"self",
|
||||
"Enso_Test.Test.Main",
|
||||
false,
|
||||
false,
|
||||
None
|
||||
),
|
||||
Suggestion
|
||||
.Argument("x", ConstantsGen.ANY, false, false, None)
|
||||
),
|
||||
@ -607,14 +599,6 @@ class RuntimeSuggestionUpdatesTest
|
||||
moduleName,
|
||||
"foo",
|
||||
List(
|
||||
Suggestion
|
||||
.Argument(
|
||||
"self",
|
||||
"Enso_Test.Test.Main",
|
||||
false,
|
||||
false,
|
||||
None
|
||||
),
|
||||
Suggestion
|
||||
.Argument("x", ConstantsGen.ANY, false, false, None)
|
||||
),
|
||||
@ -629,9 +613,9 @@ class RuntimeSuggestionUpdatesTest
|
||||
Some(
|
||||
List(
|
||||
Api.SuggestionArgumentAction
|
||||
.Modify(1, Some("a"), None, None, None, None),
|
||||
.Modify(0, Some("a"), None, None, None, None),
|
||||
Api.SuggestionArgumentAction.Add(
|
||||
2,
|
||||
1,
|
||||
Suggestion
|
||||
.Argument("b", ConstantsGen.ANY, false, false, None)
|
||||
)
|
||||
@ -1134,15 +1118,7 @@ class RuntimeSuggestionUpdatesTest
|
||||
None,
|
||||
"Enso_Test.Test.A",
|
||||
"hello",
|
||||
List(
|
||||
Suggestion.Argument(
|
||||
"self",
|
||||
"Enso_Test.Test.A",
|
||||
false,
|
||||
false,
|
||||
None
|
||||
)
|
||||
),
|
||||
Seq(),
|
||||
"Enso_Test.Test.A",
|
||||
ConstantsGen.ANY,
|
||||
true,
|
||||
|
@ -239,7 +239,7 @@ final class SuggestionBuilder[A: IndexedSource](
|
||||
): Suggestion.Method = {
|
||||
val typeSig = buildTypeSignatureFromMetadata(typeSignature)
|
||||
val (methodArgs, returnTypeDef) =
|
||||
buildMethodArguments(args, typeSig, selfType)
|
||||
buildMethodArguments(args, typeSig, selfType, isStatic)
|
||||
val annotations =
|
||||
genericAnnotations.map(buildAnnotationsFromMetadata).getOrElse(Seq())
|
||||
methodType match {
|
||||
@ -518,12 +518,14 @@ final class SuggestionBuilder[A: IndexedSource](
|
||||
* @param vargs the list of value arguments
|
||||
* @param targs the list of type arguments
|
||||
* @param selfType the self type of a method
|
||||
* @param isStatic is the method static
|
||||
* @return the list of arguments with a method return type
|
||||
*/
|
||||
private def buildMethodArguments(
|
||||
vargs: Seq[IR.DefinitionArgument],
|
||||
targs: Seq[TypeArg],
|
||||
selfType: QualifiedName
|
||||
selfType: QualifiedName,
|
||||
isStatic: Boolean
|
||||
): (Seq[Suggestion.Argument], Option[TypeArg]) = {
|
||||
@scala.annotation.tailrec
|
||||
def go(
|
||||
@ -544,14 +546,18 @@ final class SuggestionBuilder[A: IndexedSource](
|
||||
_,
|
||||
_
|
||||
) +: vtail =>
|
||||
val thisArg = Suggestion.Argument(
|
||||
name = name.name,
|
||||
reprType = selfType.toString,
|
||||
isSuspended = suspended,
|
||||
hasDefault = defaultValue.isDefined,
|
||||
defaultValue = defaultValue.flatMap(buildDefaultValue)
|
||||
)
|
||||
go(vtail, targs, acc :+ thisArg)
|
||||
if (isStatic) {
|
||||
go(vtail, targs, acc)
|
||||
} else {
|
||||
val thisArg = Suggestion.Argument(
|
||||
name = name.name,
|
||||
reprType = selfType.toString,
|
||||
isSuspended = suspended,
|
||||
hasDefault = defaultValue.isDefined,
|
||||
defaultValue = defaultValue.flatMap(buildDefaultValue)
|
||||
)
|
||||
go(vtail, targs, acc :+ thisArg)
|
||||
}
|
||||
case varg +: vtail =>
|
||||
targs match {
|
||||
case targ +: ttail =>
|
||||
|
@ -70,12 +70,10 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers {
|
||||
ModuleNode,
|
||||
Tree.Node(
|
||||
Suggestion.DefinedMethod(
|
||||
externalId = None,
|
||||
module = "Unnamed.Test",
|
||||
name = "foo",
|
||||
arguments = Seq(
|
||||
Suggestion.Argument("self", "Unnamed.Test", false, false, None)
|
||||
),
|
||||
externalId = None,
|
||||
module = "Unnamed.Test",
|
||||
name = "foo",
|
||||
arguments = Seq(),
|
||||
selfType = "Unnamed.Test",
|
||||
returnType = SuggestionBuilder.Any,
|
||||
isStatic = true,
|
||||
@ -102,12 +100,10 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers {
|
||||
DoccedModuleNode,
|
||||
Tree.Node(
|
||||
Suggestion.DefinedMethod(
|
||||
externalId = None,
|
||||
module = "Unnamed.Test",
|
||||
name = "foo",
|
||||
arguments = Seq(
|
||||
Suggestion.Argument("self", "Unnamed.Test", false, false, None)
|
||||
),
|
||||
externalId = None,
|
||||
module = "Unnamed.Test",
|
||||
name = "foo",
|
||||
arguments = Seq(),
|
||||
selfType = "Unnamed.Test",
|
||||
returnType = SuggestionBuilder.Any,
|
||||
isStatic = true,
|
||||
@ -137,7 +133,6 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers {
|
||||
module = "Unnamed.Test",
|
||||
name = "foo",
|
||||
arguments = Seq(
|
||||
Suggestion.Argument("self", "Unnamed.Test", false, false, None),
|
||||
Suggestion
|
||||
.Argument("a", SuggestionBuilder.Any, false, false, None),
|
||||
Suggestion
|
||||
@ -170,12 +165,10 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers {
|
||||
DoccedModuleNode,
|
||||
Tree.Node(
|
||||
Suggestion.DefinedMethod(
|
||||
externalId = None,
|
||||
module = "Unnamed.Test",
|
||||
name = "foo",
|
||||
arguments = Seq(
|
||||
Suggestion.Argument("self", "Unnamed.Test", false, false, None)
|
||||
),
|
||||
externalId = None,
|
||||
module = "Unnamed.Test",
|
||||
name = "foo",
|
||||
arguments = Seq(),
|
||||
selfType = "Unnamed.Test",
|
||||
returnType = "Number",
|
||||
isStatic = true,
|
||||
@ -201,12 +194,10 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers {
|
||||
ModuleNode,
|
||||
Tree.Node(
|
||||
Suggestion.DefinedMethod(
|
||||
externalId = None,
|
||||
module = "Unnamed.Test",
|
||||
name = "foo",
|
||||
arguments = Seq(
|
||||
Suggestion.Argument("self", "Unnamed.Test", false, false, None)
|
||||
),
|
||||
externalId = None,
|
||||
module = "Unnamed.Test",
|
||||
name = "foo",
|
||||
arguments = Seq(),
|
||||
selfType = "Unnamed.Test",
|
||||
returnType = "Foo.Bar",
|
||||
isStatic = true,
|
||||
@ -238,7 +229,6 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers {
|
||||
module = "Unnamed.Test",
|
||||
name = "foo",
|
||||
arguments = Seq(
|
||||
Suggestion.Argument("self", "Unnamed.Test", false, false, None),
|
||||
Suggestion.Argument(
|
||||
"a",
|
||||
"Standard.Base.Data.Text.Text",
|
||||
@ -276,7 +266,6 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers {
|
||||
module = "Unnamed.Test",
|
||||
name = "foo",
|
||||
arguments = Seq(
|
||||
Suggestion.Argument("self", "Unnamed.Test", false, false, None),
|
||||
Suggestion.Argument(
|
||||
"a",
|
||||
"Either (Vector Number) Text",
|
||||
@ -311,12 +300,10 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers {
|
||||
ModuleNode,
|
||||
Tree.Node(
|
||||
Suggestion.DefinedMethod(
|
||||
externalId = None,
|
||||
module = "Unnamed.Test",
|
||||
name = "foo",
|
||||
arguments = Seq(
|
||||
Suggestion.Argument("self", "Unnamed.Test", false, false, None)
|
||||
),
|
||||
externalId = None,
|
||||
module = "Unnamed.Test",
|
||||
name = "foo",
|
||||
arguments = Seq(),
|
||||
selfType = "Unnamed.Test",
|
||||
returnType = "Foo.Bar Baz",
|
||||
isStatic = true,
|
||||
@ -348,7 +335,6 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers {
|
||||
module = "Unnamed.Test",
|
||||
name = "foo",
|
||||
arguments = Seq(
|
||||
Suggestion.Argument("self", "Unnamed.Test", false, false, None),
|
||||
Suggestion
|
||||
.Argument("a", SuggestionBuilder.Any, false, false, None),
|
||||
Suggestion
|
||||
@ -411,7 +397,6 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers {
|
||||
module = "Unnamed.Test",
|
||||
name = "foo",
|
||||
arguments = Seq(
|
||||
Suggestion.Argument("self", "Unnamed.Test", false, false, None),
|
||||
Suggestion
|
||||
.Argument("a", SuggestionBuilder.Any, false, true, Some("0"))
|
||||
),
|
||||
@ -765,7 +750,6 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers {
|
||||
module = "Unnamed.Test",
|
||||
name = "foo",
|
||||
arguments = Seq(
|
||||
Suggestion.Argument("self", "Unnamed.Test", false, false, None),
|
||||
Suggestion.Argument(
|
||||
"a",
|
||||
"Standard.Base.Data.Text.Text | Standard.Base.Data.Boolean.Boolean | Unnamed.Test.Value | Unnamed.Test.Auto",
|
||||
@ -810,7 +794,6 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers {
|
||||
module = "Unnamed.Test",
|
||||
name = "foo",
|
||||
arguments = Seq(
|
||||
Suggestion.Argument("self", "Unnamed.Test", false, false, None),
|
||||
Suggestion
|
||||
.Argument("a", SuggestionBuilder.Any, true, false, None)
|
||||
),
|
||||
@ -856,7 +839,6 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers {
|
||||
module = "Unnamed.Test",
|
||||
name = "foo",
|
||||
arguments = Seq(
|
||||
Suggestion.Argument("self", "Unnamed.Test", false, false, None),
|
||||
Suggestion.Argument(
|
||||
"a",
|
||||
"Unnamed.Test.A",
|
||||
@ -1985,13 +1967,10 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers {
|
||||
),
|
||||
Tree.Node(
|
||||
Suggestion.DefinedMethod(
|
||||
externalId = None,
|
||||
module = "Unnamed.Test",
|
||||
name = "empty",
|
||||
arguments = Seq(
|
||||
Suggestion
|
||||
.Argument("self", "Unnamed.Test.List", false, false, None)
|
||||
),
|
||||
externalId = None,
|
||||
module = "Unnamed.Test",
|
||||
name = "empty",
|
||||
arguments = Seq(),
|
||||
selfType = "Unnamed.Test.List",
|
||||
returnType = "Unnamed.Test.List",
|
||||
isStatic = true,
|
||||
@ -2887,7 +2866,6 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers {
|
||||
module = "Unnamed.Test",
|
||||
name = "quux",
|
||||
arguments = Vector(
|
||||
Suggestion.Argument("self", "Unnamed.Test", false, false, None),
|
||||
Suggestion.Argument(
|
||||
"x",
|
||||
"Unnamed.Test.A",
|
||||
@ -2997,7 +2975,6 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers {
|
||||
module = "Unnamed.Test",
|
||||
name = "quux",
|
||||
arguments = Vector(
|
||||
Suggestion.Argument("self", "Unnamed.Test", false, false, None),
|
||||
Suggestion.Argument(
|
||||
"x",
|
||||
"Unnamed.Test.A",
|
||||
@ -3192,12 +3169,10 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers {
|
||||
),
|
||||
Tree.Node(
|
||||
Suggestion.DefinedMethod(
|
||||
externalId = None,
|
||||
module = "Unnamed.Test",
|
||||
name = "foo",
|
||||
arguments = Seq(
|
||||
Suggestion.Argument("self", "Unnamed.Test", false, false, None)
|
||||
),
|
||||
externalId = None,
|
||||
module = "Unnamed.Test",
|
||||
name = "foo",
|
||||
arguments = Seq(),
|
||||
selfType = "Unnamed.Test",
|
||||
returnType = SuggestionBuilder.Any,
|
||||
isStatic = true,
|
||||
@ -3223,7 +3198,7 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers {
|
||||
val fooSuggestion = suggestions.collectFirst {
|
||||
case s: Suggestion.DefinedMethod if s.name == "foo" => s
|
||||
}
|
||||
val fooArg = fooSuggestion.get.arguments(1)
|
||||
val fooArg = fooSuggestion.get.arguments(0)
|
||||
fooArg.reprType shouldEqual "Unnamed.Test.My_Tp"
|
||||
fooArg.tagValues shouldEqual Some(
|
||||
List("Unnamed.Test.My_Tp.Variant_A", "Unnamed.Test.My_Tp.Variant_B")
|
||||
|
Loading…
Reference in New Issue
Block a user