11package com.sourcegraph.semanticdb_kotlinc.test
22
33import org.scip_code.scip.Occurrence
4- import org.scip_code.scip.Relationship
5- import org.scip_code.scip.Signature
64import org.scip_code.scip.SymbolInformation
75import org.scip_code.scip.SymbolRole
6+ import org.scip_code.scip.occurrence
7+ import org.scip_code.scip.relationship
8+ import org.scip_code.scip.signature
9+ import org.scip_code.scip.symbolInformation
810
911/* *
1012 * Tiny DSL for building SCIP [Occurrence] / [SymbolInformation] test fixtures with the same shape
@@ -21,8 +23,8 @@ import org.scip_code.scip.SymbolRole
2123 * ```
2224 */
2325
24- internal const val REFERENCE : Int = 0
25- internal const val DEFINITION : Int = SymbolRole .Definition_VALUE
26+ internal val REFERENCE : Int = SymbolRole . UnspecifiedSymbolRole .number
27+ internal val DEFINITION : Int = SymbolRole .Definition .number
2628
2729@DslMarker annotation class ScipBuilderDsl
2830
@@ -59,11 +61,11 @@ class ScipOccurrenceBuilder {
5961 enclosingRange = ScipRangeBuilder ().apply (block).toIntList()
6062 }
6163
62- internal fun build (): Occurrence {
63- val builder = Occurrence .newBuilder().setSymbol( symbol).setSymbolRoles(role)
64- range?.forEach { builder.addRange(it) }
65- enclosingRange?.forEach { builder.addEnclosingRange(it) }
66- return builder.build()
64+ internal fun build (): Occurrence = occurrence {
65+ symbol = this @ScipOccurrenceBuilder. symbol
66+ symbolRoles = role
67+ this @ScipOccurrenceBuilder.range?. let { range + = it }
68+ this @ScipOccurrenceBuilder.enclosingRange?. let { enclosingRange + = it }
6769 }
6870}
6971
@@ -87,19 +89,24 @@ class ScipSymbolInformationBuilder {
8789 overrides.addAll(symbols)
8890 }
8991
90- internal fun build (): SymbolInformation {
91- val builder = SymbolInformation .newBuilder().setSymbol(symbol)
92- if (displayName.isNotEmpty()) builder.displayName = displayName
93- signatureText?.let {
94- builder.signatureDocumentation =
95- Signature .newBuilder().setLanguage(" kotlin" ).setText(it).build()
92+ internal fun build (): SymbolInformation = symbolInformation {
93+ symbol = this @ScipSymbolInformationBuilder.symbol
94+ if (this @ScipSymbolInformationBuilder.displayName.isNotEmpty()) {
95+ displayName = this @ScipSymbolInformationBuilder.displayName
9696 }
97- for (d in docs) builder.addDocumentation(d)
97+ signatureText?.let { sigText ->
98+ signatureDocumentation = signature {
99+ language = " kotlin"
100+ text = sigText
101+ }
102+ }
103+ for (d in docs) documentation + = d
98104 for (s in overrides) {
99- builder.addRelationships(
100- Relationship .newBuilder().setSymbol(s).setIsImplementation(true ).build())
105+ relationships + = relationship {
106+ symbol = s
107+ isImplementation = true
108+ }
101109 }
102- return builder.build()
103110 }
104111}
105112
0 commit comments