Suggestion should contain a list of annotations (#6924)

close #6847

Add annotation names to suggestions.
This commit is contained in:
Dmitry Bushev 2023-06-02 08:26:01 +01:00 committed by GitHub
parent bd3ba26fc1
commit 4e9f02258e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 476 additions and 165 deletions

View File

@ -575,6 +575,9 @@ interface Constructor {
/** The documentation string. */
documentation?: string;
/** The list of annotations. */
annotations: string[];
}
interface Method {
@ -604,6 +607,9 @@ interface Method {
/** The documentation string. */
documentation?: string;
/** The list of annotations. */
annotations: string[];
}
interface Function {

View File

@ -135,6 +135,7 @@ object SearchProtocol {
conversion.returnType,
isStatic = false,
conversion.documentation,
Seq(),
conversion.reexport
)
}

View File

@ -45,7 +45,8 @@ object Suggestions {
name = "MyType",
arguments = Vector(Suggestion.Argument("a", "Any", false, false, None)),
returnType = "MyAtom",
documentation = Some(comment.atom)
documentation = Some(comment.atom),
annotations = Seq("a")
)
val method: Suggestion.Method = Suggestion.Method(
@ -59,7 +60,8 @@ object Suggestions {
selfType = "MyType",
returnType = "Number",
isStatic = false,
documentation = Some("Lovely")
documentation = Some("Lovely"),
annotations = Seq("foo")
)
val function: Suggestion.Function = Suggestion.Function(
@ -98,7 +100,8 @@ object Suggestions {
selfType = "Any",
returnType = "Any",
isStatic = false,
documentation = Some("Lovely")
documentation = Some("Lovely"),
annotations = Seq()
)
val methodOnNumber: Suggestion.Method = Suggestion.Method(
@ -111,7 +114,8 @@ object Suggestions {
selfType = "Number",
returnType = "Number",
isStatic = false,
documentation = None
documentation = None,
annotations = Seq()
)
val methodOnInteger: Suggestion.Method = Suggestion.Method(
@ -124,7 +128,8 @@ object Suggestions {
selfType = "Integer",
returnType = "Number",
isStatic = false,
documentation = Some("Blah, blah")
documentation = Some("Blah, blah"),
annotations = Seq()
)
val all = Seq(

View File

@ -357,7 +357,8 @@ class SuggestionsHandlerSpec
name = "Foo",
arguments = Vector(),
returnType = moduleName,
documentation = None
documentation = None,
annotations = Seq()
)
val module = Suggestion.Module(
module = moduleName,
@ -1083,7 +1084,8 @@ class SuggestionsHandlerSpec
Suggestion.Argument("b", "Any", false, false, None)
),
returnType = "Pair",
documentation = Some("Awesome")
documentation = Some("Awesome"),
annotations = Seq()
)
val method: Suggestion.Method =
@ -1095,7 +1097,8 @@ class SuggestionsHandlerSpec
selfType = "Test.Main",
returnType = "IO",
isStatic = true,
documentation = None
documentation = None,
annotations = Seq()
)
}

View File

@ -112,7 +112,8 @@ class SuggestionsHandlerEventsTest extends BaseServerTest with FlakySpec {
}
],
"returnType" : "MyAtom",
"documentation" : " PRIVATE\n\n A key-value store. This type assumes all keys are pairwise comparable,\n using the `<`, `>` and `==` operators.\n\n Arguments:\n - one: The first.\n - two_three: The *second*.\n\n ? Info\n Here is a thing."
"documentation" : " PRIVATE\n\n A key-value store. This type assumes all keys are pairwise comparable,\n using the `<`, `>` and `==` operators.\n\n Arguments:\n - one: The first.\n - two_three: The *second*.\n\n ? Info\n Here is a thing.",
"annotations" : ["a"]
}
}
],
@ -182,7 +183,8 @@ class SuggestionsHandlerEventsTest extends BaseServerTest with FlakySpec {
"selfType" : "MyType",
"returnType" : "Number",
"isStatic" : false,
"documentation" : "Lovely"
"documentation" : "Lovely",
"annotations" : ["foo"]
}
}
],

View File

@ -137,6 +137,21 @@ object Suggestion {
}
}
/** Annotations extractor. */
object Annotations {
def apply(suggestion: Suggestion): Seq[String] =
suggestion match {
case _: Module => Seq()
case _: Type => Seq()
case constructor: Constructor => constructor.annotations
case method: Method => method.annotations
case _: Conversion => Seq()
case _: Function => Seq()
case _: Local => Seq()
}
}
/** An argument of an atom or a function.
*
* @param name the argument name
@ -283,6 +298,7 @@ object Suggestion {
* @param arguments the list of arguments
* @param returnType the type of an atom
* @param documentation the documentation string
* @param annotations the list of annotations
* @param reexport the module re-exporting this atom
*/
case class Constructor(
@ -292,6 +308,7 @@ object Suggestion {
arguments: Seq[Argument],
returnType: String,
documentation: Option[String],
annotations: Seq[String],
reexport: Option[String] = None
) extends Suggestion
with ToLogString {
@ -323,6 +340,7 @@ object Suggestion {
* @param returnType the return type of a method
* @param isStatic the flag indicating whether a method is static or instance
* @param documentation the documentation string
* @param annotations the list of annotations
* @param reexport the module re-exporting this method
*/
case class Method(
@ -334,6 +352,7 @@ object Suggestion {
returnType: String,
isStatic: Boolean,
documentation: Option[String],
annotations: Seq[String],
reexport: Option[String] = None
) extends Suggestion
with ToLogString {

View File

@ -169,7 +169,8 @@ class RuntimeSuggestionUpdatesTest
"Enso_Test.Test.Main",
ConstantsGen.ANY,
true,
None
None,
Seq()
),
Api.SuggestionAction.Add()
),
@ -218,7 +219,8 @@ class RuntimeSuggestionUpdatesTest
"Enso_Test.Test.Main",
ConstantsGen.ANY,
true,
None
None,
Seq()
),
Api.SuggestionAction.Modify()
),
@ -289,7 +291,8 @@ class RuntimeSuggestionUpdatesTest
"Enso_Test.Test.Main",
ConstantsGen.ANY,
true,
None
None,
Seq()
),
Api.SuggestionAction.Modify()
),
@ -380,7 +383,8 @@ class RuntimeSuggestionUpdatesTest
"Enso_Test.Test.Main",
ConstantsGen.ANY,
true,
None
None,
Seq()
),
Api.SuggestionAction.Modify()
),
@ -479,7 +483,8 @@ class RuntimeSuggestionUpdatesTest
"Enso_Test.Test.Main",
ConstantsGen.ANY,
true,
None
None,
Seq()
),
Api.SuggestionAction.Modify()
),
@ -555,7 +560,8 @@ class RuntimeSuggestionUpdatesTest
"Enso_Test.Test.Main",
ConstantsGen.ANY,
true,
None
None,
Seq()
),
Api.SuggestionAction.Add()
),
@ -615,7 +621,8 @@ class RuntimeSuggestionUpdatesTest
"Enso_Test.Test.Main",
ConstantsGen.ANY,
true,
None
None,
Seq()
),
Api.SuggestionAction.Modify(
None,
@ -716,7 +723,8 @@ class RuntimeSuggestionUpdatesTest
"Enso_Test.Test.Main",
ConstantsGen.ANY,
true,
None
None,
Seq()
),
Api.SuggestionAction.Add()
),
@ -773,7 +781,8 @@ class RuntimeSuggestionUpdatesTest
"Enso_Test.Foo.Main",
ConstantsGen.ANY,
true,
None
None,
Seq()
),
Api.SuggestionAction.Add()
),
@ -870,7 +879,8 @@ class RuntimeSuggestionUpdatesTest
"Enso_Test.Test.Main",
ConstantsGen.ANY,
true,
None
None,
Seq()
),
Api.SuggestionAction.Add()
),
@ -914,7 +924,8 @@ class RuntimeSuggestionUpdatesTest
ConstantsGen.TEXT,
ConstantsGen.ANY,
false,
None
None,
Seq()
),
Api.SuggestionAction.Add()
),
@ -940,7 +951,8 @@ class RuntimeSuggestionUpdatesTest
ConstantsGen.NUMBER,
ConstantsGen.ANY,
false,
None
None,
Seq()
),
Api.SuggestionAction.Add()
),
@ -1059,7 +1071,8 @@ class RuntimeSuggestionUpdatesTest
.Argument("a", ConstantsGen.ANY, false, false, None)
),
"Enso_Test.Test.A.MyType",
None
None,
Seq()
),
Api.SuggestionAction.Add()
),
@ -1084,7 +1097,8 @@ class RuntimeSuggestionUpdatesTest
"Enso_Test.Test.A.MyType",
ConstantsGen.ANY,
false,
None
None,
Seq()
),
Api.SuggestionAction.Add()
),
@ -1108,7 +1122,8 @@ class RuntimeSuggestionUpdatesTest
ConstantsGen.INTEGER,
ConstantsGen.ANY,
false,
None
None,
Seq()
),
Api.SuggestionAction.Add()
),
@ -1132,7 +1147,8 @@ class RuntimeSuggestionUpdatesTest
"Enso_Test.Test.A",
ConstantsGen.ANY,
true,
None
None,
Seq()
),
Api.SuggestionAction.Add()
),
@ -1181,7 +1197,8 @@ class RuntimeSuggestionUpdatesTest
"Enso_Test.Test.Main",
ConstantsGen.ANY,
true,
None
None,
Seq()
),
Api.SuggestionAction.Add()
),

View File

@ -5,6 +5,7 @@ import org.enso.compiler.core.IR
import org.enso.compiler.data.BindingsMap
import org.enso.compiler.pass.resolve.{
DocumentationComments,
GenericAnnotations,
MethodDefinitions,
TypeNames,
TypeSignatures
@ -77,7 +78,7 @@ final class SuggestionBuilder[A: IndexedSource](
case data @ IR.Module.Scope.Definition.Data(
name,
arguments,
_,
annotations,
_,
_,
_
@ -87,6 +88,7 @@ final class SuggestionBuilder[A: IndexedSource](
tpName.name,
name.name,
arguments,
annotations,
data.getMetadata(DocumentationComments).map(_.documentation)
)
}
@ -108,6 +110,7 @@ final class SuggestionBuilder[A: IndexedSource](
_
) if !m.isStaticWrapperForInstanceMethod =>
val typeSignature = ir.getMetadata(TypeSignatures)
val annotations = ir.getMetadata(GenericAnnotations)
val (selfTypeOpt, isStatic) = typePtr match {
case Some(typePtr) =>
val selfType = typePtr
@ -126,7 +129,8 @@ final class SuggestionBuilder[A: IndexedSource](
isStatic,
args,
doc,
typeSignature
typeSignature,
annotations
)
}
val subforest = go(
@ -224,11 +228,14 @@ final class SuggestionBuilder[A: IndexedSource](
isStatic: Boolean,
args: Seq[IR.DefinitionArgument],
doc: Option[String],
typeSignature: Option[TypeSignatures.Metadata]
typeSignature: Option[TypeSignatures.Metadata],
genericAnnotations: Option[GenericAnnotations.Metadata]
): Suggestion.Method = {
val typeSig = buildTypeSignatureFromMetadata(typeSignature)
val (methodArgs, returnTypeDef) =
buildMethodArguments(args, typeSig, selfType)
val annotations =
genericAnnotations.map(buildAnnotationsFromMetadata).getOrElse(Seq())
Suggestion.Method(
externalId = externalId,
module = module.toString,
@ -237,7 +244,8 @@ final class SuggestionBuilder[A: IndexedSource](
selfType = selfType.toString,
returnType = buildReturnType(returnTypeDef),
isStatic = isStatic,
documentation = doc
documentation = doc,
annotations = annotations
)
}
@ -345,6 +353,7 @@ final class SuggestionBuilder[A: IndexedSource](
tp: String,
name: String,
arguments: Seq[IR.DefinitionArgument],
genericAnnotations: Seq[IR.Name.GenericAnnotation],
doc: Option[String]
): Suggestion.Constructor =
Suggestion.Constructor(
@ -353,7 +362,8 @@ final class SuggestionBuilder[A: IndexedSource](
name = name,
arguments = arguments.map(buildArgument),
returnType = module.createChild(tp).toString,
documentation = doc
documentation = doc,
annotations = genericAnnotations.map(_.name)
)
/** Build getter methods from atom arguments. */
@ -371,14 +381,15 @@ final class SuggestionBuilder[A: IndexedSource](
location = None
)
buildMethod(
externalId = None,
module = module,
name = getterName,
selfType = module.createChild(typeName),
isStatic = false,
args = Seq(thisArg),
doc = None,
typeSignature = argument.name.getMetadata(TypeSignatures)
externalId = None,
module = module,
name = getterName,
selfType = module.createChild(typeName),
isStatic = false,
args = Seq(thisArg),
doc = None,
typeSignature = argument.name.getMetadata(TypeSignatures),
genericAnnotations = None
)
}
@ -420,6 +431,12 @@ final class SuggestionBuilder[A: IndexedSource](
TypeArg.Value(resolvedName.qualifiedName)
}
/** Build annotations from metadata. */
private def buildAnnotationsFromMetadata(
genericAnnotations: GenericAnnotations.Metadata
): Seq[String] =
genericAnnotations.annotations.map(_.name)
/** Build type signature from the ir metadata.
*
* @param typeSignature the type signature metadata

View File

@ -79,7 +79,8 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers {
selfType = "Unnamed.Test",
returnType = SuggestionBuilder.Any,
isStatic = true,
documentation = None
documentation = None,
annotations = Seq()
),
Vector()
)
@ -110,7 +111,43 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers {
selfType = "Unnamed.Test",
returnType = SuggestionBuilder.Any,
isStatic = true,
documentation = Some(" The foo")
documentation = Some(" The foo"),
annotations = Seq()
),
Vector()
)
)
)
}
"build method with annotations" in {
val code =
"""@a foo
|@b bar
|foo a b = a + b""".stripMargin
val module = code.preprocessModule
build(code, module) shouldEqual Tree.Root(
Vector(
ModuleNode,
Tree.Node(
Suggestion.Method(
externalId = None,
module = "Unnamed.Test",
name = "foo",
arguments = Seq(
Suggestion.Argument("self", "Unnamed.Test", false, false, None),
Suggestion
.Argument("a", SuggestionBuilder.Any, false, false, None),
Suggestion
.Argument("b", SuggestionBuilder.Any, false, false, None)
),
selfType = "Unnamed.Test",
returnType = SuggestionBuilder.Any,
isStatic = true,
documentation = None,
annotations = Seq("a", "b")
),
Vector()
)
@ -142,7 +179,8 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers {
selfType = "Unnamed.Test",
returnType = "Number",
isStatic = true,
documentation = Some(" The foo")
documentation = Some(" The foo"),
annotations = Seq()
),
Vector()
)
@ -172,7 +210,8 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers {
selfType = "Unnamed.Test",
returnType = "Foo.Bar",
isStatic = true,
documentation = None
documentation = None,
annotations = Seq()
),
Vector()
)
@ -211,7 +250,8 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers {
selfType = "Unnamed.Test",
returnType = "Standard.Base.Data.Numbers.Number",
isStatic = true,
documentation = None
documentation = None,
annotations = Seq()
),
Vector()
)
@ -248,7 +288,8 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers {
selfType = "Unnamed.Test",
returnType = "Number",
isStatic = true,
documentation = None
documentation = None,
annotations = Seq()
),
Vector()
)
@ -279,7 +320,8 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers {
selfType = "Unnamed.Test",
returnType = "Foo.Bar Baz",
isStatic = true,
documentation = None
documentation = None,
annotations = Seq()
),
Vector()
)
@ -315,7 +357,8 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers {
selfType = "Unnamed.Test",
returnType = SuggestionBuilder.Any,
isStatic = true,
documentation = None
documentation = None,
annotations = Seq()
),
Vector(
Tree.Node(
@ -375,7 +418,8 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers {
selfType = "Unnamed.Test",
returnType = SuggestionBuilder.Any,
isStatic = true,
documentation = None
documentation = None,
annotations = Seq()
),
Vector()
)
@ -423,7 +467,8 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers {
selfType = "Unnamed.Test.MyType",
returnType = SuggestionBuilder.Any,
isStatic = false,
documentation = None
documentation = None,
annotations = Seq()
),
Vector()
)
@ -483,7 +528,8 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers {
selfType = "Unnamed.Test.MyAtom",
returnType = "Number",
isStatic = false,
documentation = Some(" My bar")
documentation = Some(" My bar"),
annotations = Seq()
),
Vector()
)
@ -529,7 +575,8 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers {
selfType = "Unnamed.Test.MyAtom",
returnType = "Number",
isStatic = false,
documentation = None
documentation = None,
annotations = Seq()
),
Vector()
)
@ -573,7 +620,8 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers {
name = "Variant_1",
arguments = Seq(),
returnType = "Unnamed.Test.My_Atom",
documentation = None
documentation = None,
annotations = Seq()
),
Vector()
),
@ -584,7 +632,8 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers {
name = "Variant_2",
arguments = Seq(),
returnType = "Unnamed.Test.My_Atom",
documentation = None
documentation = None,
annotations = Seq()
),
Vector()
),
@ -633,7 +682,8 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers {
selfType = "Unnamed.Test.Other_Atom",
returnType = "Number",
isStatic = false,
documentation = None
documentation = None,
annotations = Seq()
),
Vector()
)
@ -680,7 +730,8 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers {
name = "A",
arguments = Seq(),
returnType = "Unnamed.Test.Value",
documentation = None
documentation = None,
annotations = Seq()
),
Vector()
),
@ -691,7 +742,8 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers {
name = "B",
arguments = Seq(),
returnType = "Unnamed.Test.Value",
documentation = None
documentation = None,
annotations = Seq()
),
Vector()
),
@ -734,7 +786,8 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers {
selfType = "Unnamed.Test",
returnType = "Any",
isStatic = true,
documentation = None
documentation = None,
annotations = Seq()
),
Vector()
)
@ -764,7 +817,8 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers {
selfType = "Unnamed.Test",
returnType = SuggestionBuilder.Any,
isStatic = true,
documentation = None
documentation = None,
annotations = Seq()
),
Vector()
)
@ -815,7 +869,8 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers {
selfType = "Unnamed.Test",
returnType = "Unnamed.Test.A",
isStatic = true,
documentation = None
documentation = None,
annotations = Seq()
),
Vector()
)
@ -865,7 +920,8 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers {
selfType = "Unnamed.Test.MyType",
returnType = SuggestionBuilder.Any,
isStatic = false,
documentation = None
documentation = None,
annotations = Seq()
),
Vector()
),
@ -929,7 +985,8 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers {
.Argument("a", SuggestionBuilder.Any, false, false, None)
),
returnType = "Unnamed.Test.MyMaybe",
documentation = None
documentation = None,
annotations = Seq()
),
Vector()
),
@ -945,7 +1002,8 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers {
selfType = "Unnamed.Test.MyMaybe",
returnType = SuggestionBuilder.Any,
isStatic = false,
documentation = None
documentation = None,
annotations = Seq()
),
Vector()
),
@ -956,7 +1014,8 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers {
name = "None",
arguments = Seq(),
returnType = "Unnamed.Test.None",
documentation = None
documentation = None,
annotations = Seq()
),
Vector()
),
@ -982,7 +1041,8 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers {
.Argument("x", SuggestionBuilder.Any, false, false, None)
),
returnType = "Unnamed.Test.New",
documentation = None
documentation = None,
annotations = Seq()
),
Vector()
),
@ -998,7 +1058,8 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers {
selfType = "Unnamed.Test.New",
returnType = SuggestionBuilder.Any,
isStatic = false,
documentation = None
documentation = None,
annotations = Seq()
),
Vector()
),
@ -1041,7 +1102,8 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers {
selfType = "Unnamed.Test",
returnType = SuggestionBuilder.Any,
isStatic = true,
documentation = None
documentation = None,
annotations = Seq()
),
Vector(
Tree.Node(
@ -1091,7 +1153,8 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers {
selfType = "Unnamed.Test",
returnType = SuggestionBuilder.Any,
isStatic = true,
documentation = None
documentation = None,
annotations = Seq()
),
Vector(
Tree.Node(
@ -1155,7 +1218,8 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers {
selfType = "Unnamed.Test",
returnType = SuggestionBuilder.Any,
isStatic = true,
documentation = None
documentation = None,
annotations = Seq()
),
Vector(
Tree.Node(
@ -1217,7 +1281,8 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers {
selfType = "Unnamed.Test",
returnType = SuggestionBuilder.Any,
isStatic = true,
documentation = None
documentation = None,
annotations = Seq()
),
Vector(
Tree.Node(
@ -1273,7 +1338,8 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers {
selfType = "Unnamed.Test",
returnType = SuggestionBuilder.Any,
isStatic = true,
documentation = None
documentation = None,
annotations = Seq()
),
Vector(
Tree.Node(
@ -1327,7 +1393,8 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers {
selfType = "Unnamed.Test",
returnType = SuggestionBuilder.Any,
isStatic = true,
documentation = None
documentation = None,
annotations = Seq()
),
Vector(
Tree.Node(
@ -1373,7 +1440,8 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers {
selfType = "Unnamed.Test",
returnType = SuggestionBuilder.Any,
isStatic = true,
documentation = None
documentation = None,
annotations = Seq()
),
Vector(
Tree.Node(
@ -1433,7 +1501,8 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers {
selfType = "Unnamed.Test",
returnType = SuggestionBuilder.Any,
isStatic = true,
documentation = None
documentation = None,
annotations = Seq()
),
Vector(
Tree.Node(
@ -1492,7 +1561,8 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers {
selfType = "Unnamed.Test",
returnType = SuggestionBuilder.Any,
isStatic = true,
documentation = None
documentation = None,
annotations = Seq()
),
Vector(
Tree.Node(
@ -1537,7 +1607,8 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers {
selfType = "Unnamed.Test",
returnType = SuggestionBuilder.Any,
isStatic = true,
documentation = None
documentation = None,
annotations = Seq()
),
Vector(
Tree.Node(
@ -1594,7 +1665,8 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers {
.Argument("b", SuggestionBuilder.Any, false, false, None)
),
returnType = "Unnamed.Test.MyType",
documentation = None
documentation = None,
annotations = Seq()
),
Vector()
),
@ -1610,7 +1682,8 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers {
selfType = "Unnamed.Test.MyType",
returnType = SuggestionBuilder.Any,
isStatic = false,
documentation = None
documentation = None,
annotations = Seq()
),
Vector()
),
@ -1626,7 +1699,8 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers {
selfType = "Unnamed.Test.MyType",
returnType = SuggestionBuilder.Any,
isStatic = false,
documentation = None
documentation = None,
annotations = Seq()
),
Vector()
)
@ -1672,7 +1746,8 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers {
.Argument("b", SuggestionBuilder.Any, false, false, None)
),
returnType = "Unnamed.Test.Mtp",
documentation = Some(" My sweet atom")
documentation = Some(" My sweet atom"),
annotations = Seq()
),
Vector()
),
@ -1688,7 +1763,8 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers {
selfType = "Unnamed.Test.Mtp",
returnType = SuggestionBuilder.Any,
isStatic = false,
documentation = None
documentation = None,
annotations = Seq()
),
Vector()
),
@ -1704,7 +1780,8 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers {
selfType = "Unnamed.Test.Mtp",
returnType = SuggestionBuilder.Any,
isStatic = false,
documentation = None
documentation = None,
annotations = Seq()
),
Vector()
)
@ -1742,7 +1819,8 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers {
name = "Nothing",
arguments = Seq(),
returnType = "Unnamed.Test.Maybe",
documentation = None
documentation = None,
annotations = Seq()
),
Vector()
),
@ -1756,7 +1834,8 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers {
.Argument("a", SuggestionBuilder.Any, false, false, None)
),
returnType = "Unnamed.Test.Maybe",
documentation = None
documentation = None,
annotations = Seq()
),
Vector()
),
@ -1772,7 +1851,8 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers {
selfType = "Unnamed.Test.Maybe",
returnType = SuggestionBuilder.Any,
isStatic = false,
documentation = None
documentation = None,
annotations = Seq()
),
Vector()
)
@ -1815,7 +1895,8 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers {
name = "Nothing",
arguments = Seq(),
returnType = "Unnamed.Test.Maybe",
documentation = Some(" Nothing here")
documentation = Some(" Nothing here"),
annotations = Seq()
),
Vector()
),
@ -1829,7 +1910,8 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers {
.Argument("a", SuggestionBuilder.Any, false, false, None)
),
returnType = "Unnamed.Test.Maybe",
documentation = Some(" Something there")
documentation = Some(" Something there"),
annotations = Seq()
),
Vector()
),
@ -1845,7 +1927,8 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers {
selfType = "Unnamed.Test.Maybe",
returnType = SuggestionBuilder.Any,
isStatic = false,
documentation = None
documentation = None,
annotations = Seq()
),
Vector()
)
@ -1889,7 +1972,8 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers {
name = "Cons",
arguments = Seq(),
returnType = "Unnamed.Test.List",
documentation = Some(" And more")
documentation = Some(" And more"),
annotations = Seq()
),
Vector()
),
@ -1900,7 +1984,8 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers {
name = "Nil",
arguments = Seq(),
returnType = "Unnamed.Test.List",
documentation = Some(" End")
documentation = Some(" End"),
annotations = Seq()
),
Vector()
),
@ -1916,7 +2001,8 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers {
selfType = "Unnamed.Test.List",
returnType = "Unnamed.Test.List",
isStatic = true,
documentation = Some(" a method")
documentation = Some(" a method"),
annotations = Seq()
),
Vector()
)
@ -1957,7 +2043,8 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers {
name = "Nothing",
arguments = Seq(),
returnType = "Unnamed.Test.Maybe",
documentation = None
documentation = None,
annotations = Seq()
),
Vector()
),
@ -1971,7 +2058,8 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers {
.Argument("a", SuggestionBuilder.Any, false, false, None)
),
returnType = "Unnamed.Test.Maybe",
documentation = None
documentation = None,
annotations = Seq()
),
Vector()
),
@ -1987,7 +2075,8 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers {
selfType = "Unnamed.Test.Maybe",
returnType = SuggestionBuilder.Any,
isStatic = false,
documentation = None
documentation = None,
annotations = Seq()
),
Vector()
),
@ -2005,7 +2094,8 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers {
selfType = "Unnamed.Test.Maybe",
returnType = SuggestionBuilder.Any,
isStatic = false,
documentation = None
documentation = None,
annotations = Seq()
),
Vector()
)
@ -2047,7 +2137,8 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers {
name = "X",
arguments = Seq(),
returnType = "Unnamed.Test.S",
documentation = None
documentation = None,
annotations = Seq()
),
Vector()
),
@ -2058,7 +2149,8 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers {
name = "Y",
arguments = Seq(),
returnType = "Unnamed.Test.S",
documentation = None
documentation = None,
annotations = Seq()
),
Vector()
),
@ -2090,7 +2182,8 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers {
)
),
returnType = "Unnamed.Test.T",
documentation = None
documentation = None,
annotations = Seq()
),
Vector()
),
@ -2106,9 +2199,123 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers {
selfType = "Unnamed.Test.T",
returnType = "Unnamed.Test.S",
isStatic = false,
documentation = None,
annotations = Seq()
),
Vector()
)
)
)
}
"build type with constructors with annotations" in {
val code =
"""type S
| @a foo
| @b bar
| X a b
| Y c
|""".stripMargin
val module = code.preprocessModule
build(code, module) shouldEqual Tree.Root(
Vector(
ModuleNode,
Tree.Node(
Suggestion.Type(
externalId = None,
module = "Unnamed.Test",
name = "S",
params = Seq(),
returnType = "Unnamed.Test.S",
parentType = Some(SuggestionBuilder.Any),
documentation = None
),
Vector()
),
Tree.Node(
Suggestion.Constructor(
externalId = None,
module = "Unnamed.Test",
name = "X",
arguments = Seq(
Suggestion
.Argument("a", SuggestionBuilder.Any, false, false, None),
Suggestion
.Argument("b", SuggestionBuilder.Any, false, false, None)
),
returnType = "Unnamed.Test.S",
documentation = None,
annotations = Seq("a", "b")
),
Vector()
),
Tree.Node(
Suggestion.Constructor(
externalId = None,
module = "Unnamed.Test",
name = "Y",
arguments = Seq(
Suggestion
.Argument("c", SuggestionBuilder.Any, false, false, None)
),
returnType = "Unnamed.Test.S",
documentation = None,
annotations = Seq()
),
Vector()
),
Tree.Node(
Suggestion.Method(
externalId = None,
module = "Unnamed.Test",
name = "a",
arguments = Seq(
Suggestion
.Argument("self", "Unnamed.Test.S", false, false, None)
),
selfType = "Unnamed.Test.S",
returnType = SuggestionBuilder.Any,
isStatic = false,
documentation = None,
annotations = Seq()
),
Vector()
),
Tree.Node(
Suggestion.Method(
externalId = None,
module = "Unnamed.Test",
name = "b",
arguments = Seq(
Suggestion
.Argument("self", "Unnamed.Test.S", false, false, None)
),
selfType = "Unnamed.Test.S",
returnType = SuggestionBuilder.Any,
isStatic = false,
documentation = None,
annotations = Seq()
),
Vector()
),
Tree.Node(
Suggestion.Method(
externalId = None,
module = "Unnamed.Test",
name = "c",
arguments = Seq(
Suggestion
.Argument("self", "Unnamed.Test.S", false, false, None)
),
selfType = "Unnamed.Test.S",
returnType = SuggestionBuilder.Any,
isStatic = false,
documentation = None,
annotations = Seq()
),
Vector()
)
)
)
@ -2155,7 +2362,8 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers {
)
),
returnType = "Unnamed.Test.T",
documentation = None
documentation = None,
annotations = Seq()
),
Vector()
),
@ -2171,7 +2379,8 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers {
selfType = "Unnamed.Test.T",
returnType = "Standard.Base.Data.Numbers.Number",
isStatic = false,
documentation = None
documentation = None,
annotations = Seq()
),
Vector()
)
@ -2218,7 +2427,8 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers {
Suggestion.Argument("x", "a", false, false, None)
),
returnType = "Unnamed.Test.E",
documentation = None
documentation = None,
annotations = Seq()
),
Vector()
),
@ -2231,7 +2441,8 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers {
Suggestion.Argument("y", "b", false, false, None)
),
returnType = "Unnamed.Test.E",
documentation = None
documentation = None,
annotations = Seq()
),
Vector()
),
@ -2247,7 +2458,8 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers {
selfType = "Unnamed.Test.E",
returnType = "a",
isStatic = false,
documentation = None
documentation = None,
annotations = Seq()
),
Vector()
),
@ -2263,7 +2475,8 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers {
selfType = "Unnamed.Test.E",
returnType = "b",
isStatic = false,
documentation = None
documentation = None,
annotations = Seq()
),
Vector()
)
@ -2370,7 +2583,8 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers {
.Argument("b", SuggestionBuilder.Any, false, false, None)
),
returnType = "Unnamed.Test.MyType",
documentation = None
documentation = None,
annotations = Seq()
),
Vector()
),
@ -2386,7 +2600,8 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers {
selfType = "Unnamed.Test.MyType",
returnType = SuggestionBuilder.Any,
isStatic = false,
documentation = None
documentation = None,
annotations = Seq()
),
Vector()
),
@ -2402,7 +2617,8 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers {
selfType = "Unnamed.Test.MyType",
returnType = SuggestionBuilder.Any,
isStatic = false,
documentation = None
documentation = None,
annotations = Seq()
),
Vector()
),
@ -2415,7 +2631,8 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers {
selfType = "Unnamed.Test",
returnType = SuggestionBuilder.Any,
isStatic = true,
documentation = None
documentation = None,
annotations = Seq()
),
Vector()
)
@ -2456,7 +2673,8 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers {
.Argument("a", SuggestionBuilder.Any, false, false, None)
),
returnType = "Unnamed.Test.Test",
documentation = None
documentation = None,
annotations = Seq()
),
Vector()
),
@ -2472,7 +2690,8 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers {
selfType = "Unnamed.Test.Test",
returnType = SuggestionBuilder.Any,
isStatic = false,
documentation = None
documentation = None,
annotations = Seq()
),
Vector()
),
@ -2485,7 +2704,8 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers {
selfType = "Unnamed.Test",
returnType = SuggestionBuilder.Any,
isStatic = true,
documentation = None
documentation = None,
annotations = Seq()
),
Vector()
)
@ -2532,16 +2752,17 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers {
name = "Mk_A",
arguments = List(),
returnType = "Unnamed.Test.A",
documentation = None
documentation = None,
annotations = Seq()
),
Vector()
),
Tree.Node(
Suggestion.Constructor(
None,
"Unnamed.Test",
"Mk_A_Plus",
List(
externalId = None,
module = "Unnamed.Test",
name = "Mk_A_Plus",
arguments = List(
Suggestion.Argument(
"a",
"Standard.Base.Any.Any",
@ -2551,26 +2772,26 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers {
None
)
),
"Unnamed.Test.A",
None,
None
returnType = "Unnamed.Test.A",
documentation = None,
annotations = Seq()
),
Vector()
),
Tree.Node(
Suggestion.Method(
None,
"Unnamed.Test",
"a",
Vector(
externalId = None,
module = "Unnamed.Test",
name = "a",
arguments = Vector(
Suggestion
.Argument("self", "Unnamed.Test.A", false, false, None, None)
),
"Unnamed.Test.A",
"Standard.Base.Any.Any",
false,
None,
None
selfType = "Unnamed.Test.A",
returnType = "Standard.Base.Any.Any",
isStatic = false,
documentation = None,
annotations = Seq()
),
Vector()
),
@ -2594,7 +2815,8 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers {
selfType = "Unnamed.Test.A",
returnType = "Unnamed.Test.A",
isStatic = false,
documentation = None
documentation = None,
annotations = Seq()
),
Vector()
),
@ -2617,7 +2839,8 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers {
selfType = "Unnamed.Test",
returnType = "Unnamed.Test.A",
isStatic = true,
documentation = None
documentation = None,
annotations = Seq()
),
Vector()
),
@ -2630,7 +2853,8 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers {
selfType = "Unnamed.Test",
returnType = SuggestionBuilder.Any,
isStatic = true,
documentation = None
documentation = None,
annotations = Seq()
),
Vector()
)
@ -2676,7 +2900,8 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers {
name = "Mk_A",
arguments = List(),
returnType = "Unnamed.Test.A",
documentation = None
documentation = None,
annotations = Seq()
),
Vector()
),
@ -2700,7 +2925,8 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers {
selfType = "Unnamed.Test.A",
returnType = "Unnamed.Test.A",
isStatic = false,
documentation = None
documentation = None,
annotations = Seq()
),
Vector()
),
@ -2723,7 +2949,8 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers {
selfType = "Unnamed.Test",
returnType = "Unnamed.Test.A",
isStatic = true,
documentation = None
documentation = None,
annotations = Seq()
),
Vector()
),
@ -2736,7 +2963,8 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers {
selfType = "Unnamed.Test",
returnType = SuggestionBuilder.Any,
isStatic = true,
documentation = None
documentation = None,
annotations = Seq()
),
Vector()
)
@ -2768,7 +2996,8 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers {
selfType = "Unnamed.Test",
returnType = SuggestionBuilder.Any,
isStatic = true,
documentation = None
documentation = None,
annotations = Seq()
),
Vector()
)
@ -2801,7 +3030,8 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers {
selfType = "Unnamed.Test",
returnType = SuggestionBuilder.Any,
isStatic = true,
documentation = None
documentation = None,
annotations = Seq()
),
Vector(
Tree.Node(
@ -2855,7 +3085,8 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers {
selfType = "Unnamed.Test",
returnType = SuggestionBuilder.Any,
isStatic = true,
documentation = None
documentation = None,
annotations = Seq()
),
Vector(
Tree.Node(
@ -2909,7 +3140,8 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers {
selfType = "Unnamed.Test",
returnType = SuggestionBuilder.Any,
isStatic = true,
documentation = Some(" The foo")
documentation = Some(" The foo"),
annotations = Seq()
),
Vector()
)

View File

@ -28,41 +28,43 @@ object SuggestionRandom {
def nextSuggestionModule(): Suggestion.Module =
Suggestion.Module(
module = nextString(),
documentation = optional(nextString())
module = nextString(),
documentation = optional(nextString())
)
def nextSuggestionType(): Suggestion.Type =
Suggestion.Type(
externalId = optional(UUID.randomUUID()),
module = "Test.Main",
name = nextString(),
params = Seq(),
returnType = nextString(),
parentType = optional(nextString()),
documentation = optional(nextString())
externalId = optional(UUID.randomUUID()),
module = "Test.Main",
name = nextString(),
params = Seq(),
returnType = nextString(),
parentType = optional(nextString()),
documentation = optional(nextString())
)
def nextSuggestionConstructor(): Suggestion.Constructor =
Suggestion.Constructor(
externalId = optional(UUID.randomUUID()),
module = "Test.Main",
name = nextString(),
arguments = Seq(),
returnType = nextString(),
documentation = optional(nextString())
externalId = optional(UUID.randomUUID()),
module = "Test.Main",
name = nextString(),
arguments = Seq(),
returnType = nextString(),
documentation = optional(nextString()),
annotations = Seq()
)
def nextSuggestionMethod(): Suggestion.Method =
Suggestion.Method(
externalId = optional(UUID.randomUUID()),
module = "Test.Main",
name = nextString(),
arguments = Seq(),
selfType = nextString(),
returnType = nextString(),
isStatic = Random.nextBoolean(),
documentation = optional(nextString())
externalId = optional(UUID.randomUUID()),
module = "Test.Main",
name = nextString(),
arguments = Seq(),
selfType = nextString(),
returnType = nextString(),
isStatic = Random.nextBoolean(),
documentation = optional(nextString()),
annotations = Seq()
)
def nextSuggestionFunction(): Suggestion.Function =

View File

@ -823,6 +823,7 @@ final class SqlSuggestionsRepo(val db: SqlDatabase)(implicit
_,
returnType,
doc,
_,
reexport
) =>
SuggestionRow(
@ -852,6 +853,7 @@ final class SqlSuggestionsRepo(val db: SqlDatabase)(implicit
returnType,
isStatic,
doc,
_,
reexport
) =>
SuggestionRow(
@ -981,6 +983,7 @@ final class SqlSuggestionsRepo(val db: SqlDatabase)(implicit
arguments = Seq(),
returnType = suggestion.returnType,
documentation = suggestion.documentation,
annotations = Seq(),
reexport = suggestion.reexport
)
case SuggestionKind.METHOD =>
@ -994,6 +997,7 @@ final class SqlSuggestionsRepo(val db: SqlDatabase)(implicit
returnType = suggestion.returnType,
isStatic = suggestion.isStatic,
documentation = suggestion.documentation,
annotations = Seq(),
reexport = suggestion.reexport
)
case SuggestionKind.CONVERSION =>

View File

@ -1490,7 +1490,8 @@ class SuggestionsRepoTest
Suggestion.Argument("b", "Any", false, false, None)
),
returnType = "Standard.Builtins.Pair",
documentation = Some("Awesome")
documentation = Some("Awesome"),
annotations = Seq()
)
val method: Suggestion.Method =
@ -1502,7 +1503,8 @@ class SuggestionsRepoTest
selfType = "local.Test.Main",
returnType = "Standard.Builtins.IO",
isStatic = true,
documentation = None
documentation = None,
annotations = Seq()
)
val instanceMethod: Suggestion.Method =
@ -1514,7 +1516,8 @@ class SuggestionsRepoTest
selfType = "local.Test.Main.A",
returnType = "Standard.Builtins.Nothing",
isStatic = false,
documentation = None
documentation = None,
annotations = Seq()
)
val conversion: Suggestion.Conversion =