From ba7b35069d3ad312b5ad07fd587f6f2dcf559418 Mon Sep 17 00:00:00 2001 From: Alexander Koval Date: Thu, 4 Jan 2024 18:30:31 +0200 Subject: [PATCH] Add space before colon when bounding generic parameter --- .../dev/evo/elasticmagic/SearchQuery.kt | 8 ++--- .../kotlin/dev/evo/elasticmagic/Version.kt | 2 +- .../dev/evo/elasticmagic/aggs/Aggregations.kt | 2 +- .../dev/evo/elasticmagic/aggs/Bucket.kt | 4 +-- .../dev/evo/elasticmagic/aggs/Histogram.kt | 4 +-- .../kotlin/dev/evo/elasticmagic/aggs/Range.kt | 6 ++-- .../kotlin/dev/evo/elasticmagic/aggs/Terms.kt | 2 +- .../dev/evo/elasticmagic/bulk/Actions.kt | 12 +++---- .../dev/evo/elasticmagic/compile/Compiler.kt | 2 +- .../compile/SearchQueryCompiler.kt | 2 +- .../dev/evo/elasticmagic/doc/Document.kt | 34 +++++++++---------- .../dev/evo/elasticmagic/query/Expressions.kt | 2 +- .../evo/elasticmagic/query/FunctionScore.kt | 2 +- .../dev/evo/elasticmagic/types/FieldType.kt | 16 ++++----- .../evo/elasticmagic/aggs/TestAggregation.kt | 2 +- .../elasticmagic/compile/BaseCompilerTest.kt | 2 +- 16 files changed, 51 insertions(+), 51 deletions(-) diff --git a/elasticmagic/src/commonMain/kotlin/dev/evo/elasticmagic/SearchQuery.kt b/elasticmagic/src/commonMain/kotlin/dev/evo/elasticmagic/SearchQuery.kt index 3f0632c307..d04987e0be 100644 --- a/elasticmagic/src/commonMain/kotlin/dev/evo/elasticmagic/SearchQuery.kt +++ b/elasticmagic/src/commonMain/kotlin/dev/evo/elasticmagic/SearchQuery.kt @@ -29,7 +29,7 @@ enum class SearchType : ToValue { * suspendable or blocking. */ @Suppress("UnnecessaryAbstractClass") -abstract class BaseSearchQuery>( +abstract class BaseSearchQuery>( protected val docSourceFactory: (obj: Deserializer.ObjectCtx) -> S, protected var query: QueryExpression? = null, params: Params = Params(), @@ -147,7 +147,7 @@ abstract class BaseSearchQuery>( * * @sample samples.code.SearchQuery.queryNode */ - inline fun queryNode( + inline fun queryNode( handle: NodeHandle, block: (N) -> N ): T { @@ -776,7 +776,7 @@ abstract class BaseSearchQuery>( /** * An asynchronous version of search query. */ -open class SearchQuery( +open class SearchQuery( docSourceFactory: (obj: Deserializer.ObjectCtx) -> S, query: QueryExpression? = null, params: Params = Params(), @@ -927,7 +927,7 @@ open class SearchQuery( * A prepared search query is a public read-only view to a search query. * Mainly it is used to compile a search query. */ - data class Search( + data class Search( val docSourceFactory: (obj: Deserializer.ObjectCtx) -> S, override val query: QueryExpression?, override val filters: List, diff --git a/elasticmagic/src/commonMain/kotlin/dev/evo/elasticmagic/Version.kt b/elasticmagic/src/commonMain/kotlin/dev/evo/elasticmagic/Version.kt index ce61218bbb..1b1568c24a 100644 --- a/elasticmagic/src/commonMain/kotlin/dev/evo/elasticmagic/Version.kt +++ b/elasticmagic/src/commonMain/kotlin/dev/evo/elasticmagic/Version.kt @@ -1,6 +1,6 @@ package dev.evo.elasticmagic -sealed class Version> : Comparable { +sealed class Version> : Comparable { companion object { fun compareVersions( major: Int, minor: Int, patch: Int, diff --git a/elasticmagic/src/commonMain/kotlin/dev/evo/elasticmagic/aggs/Aggregations.kt b/elasticmagic/src/commonMain/kotlin/dev/evo/elasticmagic/aggs/Aggregations.kt index c120e40ab7..a83fd2d863 100644 --- a/elasticmagic/src/commonMain/kotlin/dev/evo/elasticmagic/aggs/Aggregations.kt +++ b/elasticmagic/src/commonMain/kotlin/dev/evo/elasticmagic/aggs/Aggregations.kt @@ -61,7 +61,7 @@ sealed class AggValue : ObjExpression { * Base aggregation expression. * @param R an aggregation result type for this aggregation */ -interface Aggregation : NamedExpression { +interface Aggregation : NamedExpression { /** * Processes corresponding aggregation response. */ diff --git a/elasticmagic/src/commonMain/kotlin/dev/evo/elasticmagic/aggs/Bucket.kt b/elasticmagic/src/commonMain/kotlin/dev/evo/elasticmagic/aggs/Bucket.kt index 5fd4bded5f..e505bd178e 100644 --- a/elasticmagic/src/commonMain/kotlin/dev/evo/elasticmagic/aggs/Bucket.kt +++ b/elasticmagic/src/commonMain/kotlin/dev/evo/elasticmagic/aggs/Bucket.kt @@ -10,7 +10,7 @@ import dev.evo.elasticmagic.serde.Deserializer import dev.evo.elasticmagic.serde.Serializer import dev.evo.elasticmagic.serde.forEachObj -abstract class BucketAggregation : Aggregation { +abstract class BucketAggregation : Aggregation { abstract val aggs: Map> override fun accept(ctx: Serializer.ObjectCtx, compiler: BaseSearchQueryCompiler) { @@ -41,7 +41,7 @@ abstract class SingleBucketAggregation : BucketAggregation : AggregationResult { +abstract class BucketAggResult : AggregationResult { abstract val buckets: List } diff --git a/elasticmagic/src/commonMain/kotlin/dev/evo/elasticmagic/aggs/Histogram.kt b/elasticmagic/src/commonMain/kotlin/dev/evo/elasticmagic/aggs/Histogram.kt index be05db2349..66d3c6d41b 100644 --- a/elasticmagic/src/commonMain/kotlin/dev/evo/elasticmagic/aggs/Histogram.kt +++ b/elasticmagic/src/commonMain/kotlin/dev/evo/elasticmagic/aggs/Histogram.kt @@ -19,7 +19,7 @@ data class HistogramBounds( } } -abstract class BaseHistogramAgg : BucketAggregation() { +abstract class BaseHistogramAgg : BucketAggregation() { abstract val value: AggValue abstract val minDocCount: Long? abstract val missing: T? @@ -97,7 +97,7 @@ abstract class BaseHistogramAgg : BucketAggregation< protected abstract val makeHistogramResult: (List) -> R } -data class HistogramAgg( +data class HistogramAgg( override val value: AggValue, val interval: T, val offset: T? = null, diff --git a/elasticmagic/src/commonMain/kotlin/dev/evo/elasticmagic/aggs/Range.kt b/elasticmagic/src/commonMain/kotlin/dev/evo/elasticmagic/aggs/Range.kt index 2e85b67adc..072a825cb4 100644 --- a/elasticmagic/src/commonMain/kotlin/dev/evo/elasticmagic/aggs/Range.kt +++ b/elasticmagic/src/commonMain/kotlin/dev/evo/elasticmagic/aggs/Range.kt @@ -18,7 +18,7 @@ data class AggRange( } } -abstract class BaseRangeAgg : BucketAggregation() { +abstract class BaseRangeAgg : BucketAggregation() { abstract val value: AggValue abstract val ranges: List> abstract val format: String? @@ -94,7 +94,7 @@ data class RangeBucket( override val aggs: Map = emptyMap(), ) : KeyedBucket() -data class RangeAgg( +data class RangeAgg( override val value: AggValue, override val ranges: List>, override val format: String? = null, @@ -121,7 +121,7 @@ data class RangeAgg( ) companion object { - fun simpleRanges( + fun simpleRanges( field: FieldOperations, ranges: List>, format: String? = null, diff --git a/elasticmagic/src/commonMain/kotlin/dev/evo/elasticmagic/aggs/Terms.kt b/elasticmagic/src/commonMain/kotlin/dev/evo/elasticmagic/aggs/Terms.kt index 038b4938e9..9430309077 100644 --- a/elasticmagic/src/commonMain/kotlin/dev/evo/elasticmagic/aggs/Terms.kt +++ b/elasticmagic/src/commonMain/kotlin/dev/evo/elasticmagic/aggs/Terms.kt @@ -9,7 +9,7 @@ import dev.evo.elasticmagic.serde.Deserializer import dev.evo.elasticmagic.serde.Serializer import dev.evo.elasticmagic.serde.forEachObj -abstract class BaseTermsAgg : BucketAggregation() { +abstract class BaseTermsAgg : BucketAggregation() { abstract val value: AggValue abstract val size: Int? abstract val shardSize: Int? diff --git a/elasticmagic/src/commonMain/kotlin/dev/evo/elasticmagic/bulk/Actions.kt b/elasticmagic/src/commonMain/kotlin/dev/evo/elasticmagic/bulk/Actions.kt index d159ade7d9..d0b5c114f2 100644 --- a/elasticmagic/src/commonMain/kotlin/dev/evo/elasticmagic/bulk/Actions.kt +++ b/elasticmagic/src/commonMain/kotlin/dev/evo/elasticmagic/bulk/Actions.kt @@ -121,7 +121,7 @@ interface IdActionMeta : ActionMeta { * * @see */ -open class IndexAction( +open class IndexAction( override val meta: ActionMeta, override val source: S, override val concurrencyControl: ConcurrencyControl? = null, @@ -136,7 +136,7 @@ open class IndexAction( * * @see */ -class CreateAction( +class CreateAction( meta: ActionMeta, source: S, pipeline: String? = null, @@ -168,7 +168,7 @@ class DeleteAction( * * @see */ -class UpdateAction( +class UpdateAction( override val meta: IdActionMeta, override val source: UpdateSource, val retryOnConflict: Int? = null, @@ -185,7 +185,7 @@ class UpdateAction( * - [WithDoc] makes a partial update of the existing document. * - [WithScript] runs the specified script and indexes its result. */ -sealed class UpdateSource( +sealed class UpdateSource( val upsert: S?, val detectNoop: Boolean?, ) { @@ -199,7 +199,7 @@ sealed class UpdateSource( detectNoop = detectNoop, ) - class WithScript( + class WithScript( val script: Script, val scriptedUpsert: Boolean? = null, upsert: S? = null, @@ -213,7 +213,7 @@ sealed class UpdateSource( /** * Combines a document source with its action metadata. */ -class DocSourceAndMeta( +class DocSourceAndMeta( val meta: M, val doc: BaseDocSource ) diff --git a/elasticmagic/src/commonMain/kotlin/dev/evo/elasticmagic/compile/Compiler.kt b/elasticmagic/src/commonMain/kotlin/dev/evo/elasticmagic/compile/Compiler.kt index 822e0a1cd6..0ef1035b03 100644 --- a/elasticmagic/src/commonMain/kotlin/dev/evo/elasticmagic/compile/Compiler.kt +++ b/elasticmagic/src/commonMain/kotlin/dev/evo/elasticmagic/compile/Compiler.kt @@ -100,7 +100,7 @@ enum class ElasticsearchFeatures( } } - private fun > findFeatures( + private fun > findFeatures( esVersion: T, features: List> ): ElasticsearchFeatures { for (versionToFeature in features.reversed()) { diff --git a/elasticmagic/src/commonMain/kotlin/dev/evo/elasticmagic/compile/SearchQueryCompiler.kt b/elasticmagic/src/commonMain/kotlin/dev/evo/elasticmagic/compile/SearchQueryCompiler.kt index 42a5a0cb6d..98eaed4e88 100644 --- a/elasticmagic/src/commonMain/kotlin/dev/evo/elasticmagic/compile/SearchQueryCompiler.kt +++ b/elasticmagic/src/commonMain/kotlin/dev/evo/elasticmagic/compile/SearchQueryCompiler.kt @@ -201,7 +201,7 @@ open class SearchQueryCompiler( } } - fun compile( + fun compile( serde: Serde, searchQuery: WithIndex> ): ApiRequest> { val body = serde.serializer.obj { diff --git a/elasticmagic/src/commonMain/kotlin/dev/evo/elasticmagic/doc/Document.kt b/elasticmagic/src/commonMain/kotlin/dev/evo/elasticmagic/doc/Document.kt index a88a390f4d..ccbbf74f2f 100644 --- a/elasticmagic/src/commonMain/kotlin/dev/evo/elasticmagic/doc/Document.kt +++ b/elasticmagic/src/commonMain/kotlin/dev/evo/elasticmagic/doc/Document.kt @@ -433,7 +433,7 @@ abstract class FieldSet : FieldSetShortcuts(), Named { * It is not recommended to use [Enum.ordinal] property for field value as it can change * when new variant is added. */ -inline fun > FieldSet.Field.enum( +inline fun > FieldSet.Field.enum( fieldValue: IntEnumValue, ): FieldSet.Field { return FieldSet.Field( @@ -454,7 +454,7 @@ inline fun > FieldSet.Field.enum( * @param fieldValue function that provides field value of an enum variant. * [Enum.name] property will be used if [fieldValue] is not provided. */ -inline fun > FieldSet.Field.enum( +inline fun > FieldSet.Field.enum( fieldValue: KeywordEnumValue? = null, ): FieldSet.Field { return FieldSet.Field( @@ -482,7 +482,7 @@ open class SubFields(private val field: BoundField) : FieldSet(), Field override fun getQualifiedFieldName(): String = field.getQualifiedFieldName() - class UnboundSubFields>( + class UnboundSubFields>( internal val unboundField: Field, internal val subFieldsFactory: (BoundField) -> F, ) { @@ -520,12 +520,12 @@ internal class SubFieldsField( ) : WrapperField(field) abstract class BaseDocument : FieldSet() { - fun > Field.subFields( + fun > Field.subFields( factory: (BoundField) -> F): SubFields.UnboundSubFields { return SubFields.UnboundSubFields(this, factory) } - fun `object`( + fun `object`( name: String?, factory: (DocSourceField) -> T, enabled: Boolean? = null, @@ -541,7 +541,7 @@ abstract class BaseDocument : FieldSet() { return SubDocument.UnboundSubDocument(name, ObjectType(), params, factory) } - fun `object`( + fun `object`( factory: (DocSourceField) -> T, enabled: Boolean? = null, dynamic: Dynamic? = null, @@ -550,7 +550,7 @@ abstract class BaseDocument : FieldSet() { return `object`(null, factory, enabled, dynamic, params) } - fun obj( + fun obj( name: String?, factory: (DocSourceField) -> T, enabled: Boolean? = null, @@ -560,7 +560,7 @@ abstract class BaseDocument : FieldSet() { return `object`(name, factory, enabled, dynamic, params) } - fun obj( + fun obj( factory: (DocSourceField) -> T, enabled: Boolean? = null, dynamic: Dynamic? = null, @@ -569,7 +569,7 @@ abstract class BaseDocument : FieldSet() { return `object`(factory, enabled, dynamic, params) } - fun nested( + fun nested( name: String?, factory: (DocSourceField) -> T, dynamic: Dynamic? = null, @@ -583,7 +583,7 @@ abstract class BaseDocument : FieldSet() { return SubDocument.UnboundSubDocument(name, NestedType(), params, factory) } - fun nested( + fun nested( factory: (DocSourceField) -> T, dynamic: Dynamic? = null, params: Params = Params() @@ -616,7 +616,7 @@ abstract class SubDocument( fun getParent(): FieldSet = field.getParent() - class UnboundSubDocument( + class UnboundSubDocument( private val name: String?, internal val type: ObjectType, internal val params: Params, @@ -667,7 +667,7 @@ open class MetaFields : RootFieldSet() { open val size by SizeField() @Suppress("UnnecessaryAbstractClass") - abstract class BaseMetaField>( + abstract class BaseMetaField>( name: String, type: FieldType, params: Params = Params(), private val boundFieldFactory: (String, Params, MetaFields) -> B ) : Field(name, type, params) { @@ -938,7 +938,7 @@ abstract class DynamicTemplates : RootFieldSet() { /** * Template for a field with sub-fields. */ - fun > template( + fun > template( name: String? = null, mapping: SubFields.UnboundSubFields, matchMappingType: MatchMappingType<*, *>? = null, @@ -967,7 +967,7 @@ abstract class DynamicTemplates : RootFieldSet() { /** * Template for a sub-document field. */ - fun template( + fun template( name: String? = null, mapping: SubDocument.UnboundSubDocument, matchMappingType: MatchMappingType<*, *>? = null, @@ -1202,7 +1202,7 @@ abstract class DynamicTemplates : RootFieldSet() { } } - class FromSubFields>( + class FromSubFields>( val subFields: SubFields.UnboundSubFields ) : DynamicField() { override fun field(fieldPath: String): F { @@ -1212,7 +1212,7 @@ abstract class DynamicTemplates : RootFieldSet() { } } - class FromSubDocument( + class FromSubDocument( val subDocument: SubDocument.UnboundSubDocument ) : DynamicField() { override fun field(fieldPath: String): F { @@ -1254,7 +1254,7 @@ abstract class DynamicTemplates : RootFieldSet() { data class Date(override val fieldType: FieldType) : MatchMappingType() - data class Object(override val fieldType: FieldType) : MatchMappingType() + data class Object(override val fieldType: FieldType) : MatchMappingType() } enum class MatchPattern : ToValue { diff --git a/elasticmagic/src/commonMain/kotlin/dev/evo/elasticmagic/query/Expressions.kt b/elasticmagic/src/commonMain/kotlin/dev/evo/elasticmagic/query/Expressions.kt index acfe55e51b..3d164da55c 100644 --- a/elasticmagic/src/commonMain/kotlin/dev/evo/elasticmagic/query/Expressions.kt +++ b/elasticmagic/src/commonMain/kotlin/dev/evo/elasticmagic/query/Expressions.kt @@ -14,7 +14,7 @@ interface Named : ToValue { } } -interface Expression : BaseSearchQueryCompiler.Visitable { +interface Expression : BaseSearchQueryCompiler.Visitable { fun clone(): Expression fun children(): Iterator>? { diff --git a/elasticmagic/src/commonMain/kotlin/dev/evo/elasticmagic/query/FunctionScore.kt b/elasticmagic/src/commonMain/kotlin/dev/evo/elasticmagic/query/FunctionScore.kt index c2b7132af9..2afdb48c41 100644 --- a/elasticmagic/src/commonMain/kotlin/dev/evo/elasticmagic/query/FunctionScore.kt +++ b/elasticmagic/src/commonMain/kotlin/dev/evo/elasticmagic/query/FunctionScore.kt @@ -144,7 +144,7 @@ data class FunctionScore( } } - data class FieldValueFactor( + data class FieldValueFactor( val field: FieldOperations, val factor: Float? = null, val missing: T? = null, diff --git a/elasticmagic/src/commonMain/kotlin/dev/evo/elasticmagic/types/FieldType.kt b/elasticmagic/src/commonMain/kotlin/dev/evo/elasticmagic/types/FieldType.kt index a23ed9995f..5c6615018e 100644 --- a/elasticmagic/src/commonMain/kotlin/dev/evo/elasticmagic/types/FieldType.kt +++ b/elasticmagic/src/commonMain/kotlin/dev/evo/elasticmagic/types/FieldType.kt @@ -99,7 +99,7 @@ abstract class SimpleFieldType : FieldType { * See: */ @Suppress("UnnecessaryAbstractClass") -abstract class NumberType : SimpleFieldType() +abstract class NumberType : SimpleFieldType() /** * Integer field type represents signed integer value from [Byte.MIN_VALUE] to [Byte.MAX_VALUE]. @@ -445,19 +445,19 @@ object DoubleRangeType : RangeType(DoubleType) * We need this interface hierarchy to be able to make multiple [enum] extension functions * without signature clashing. */ -fun interface EnumValue, T> { +fun interface EnumValue, T> { fun get(v: V): T } /** * An interface that provides integer field value for an enum. */ -fun interface IntEnumValue> : EnumValue +fun interface IntEnumValue> : EnumValue /** * An interface that provides string field value for an enum. */ -fun interface KeywordEnumValue> : EnumValue +fun interface KeywordEnumValue> : EnumValue /** * A field type that transforms enum variants to field values and vice verse. @@ -468,7 +468,7 @@ fun interface KeywordEnumValue> : EnumValue * @param type original field type * @param termType should be `V::class` */ -class EnumFieldType>( +class EnumFieldType>( enumValues: Array, private val fieldValue: EnumValue, private val type: FieldType<*, *>, @@ -546,7 +546,7 @@ object JoinType : FieldType { * * See: */ -open class ObjectType : FieldType { +open class ObjectType : FieldType { override val name = "object" override val termType = Nothing::class @@ -584,7 +584,7 @@ open class ObjectType : FieldType { * * See: */ -class NestedType : ObjectType() { +class NestedType : ObjectType() { override val name = "nested" } @@ -592,7 +592,7 @@ class NestedType : ObjectType() { * Needed to bind specific document source to [ObjectType] at runtime. * Used by [dev.evo.elasticmagic.doc.DocSource]. */ -internal class SourceType( +internal class SourceType( val type: FieldType, private val sourceFactory: () -> V ) : FieldType { diff --git a/elasticmagic/src/commonTest/kotlin/dev/evo/elasticmagic/aggs/TestAggregation.kt b/elasticmagic/src/commonTest/kotlin/dev/evo/elasticmagic/aggs/TestAggregation.kt index 4ea2782a00..e1587e6b22 100644 --- a/elasticmagic/src/commonTest/kotlin/dev/evo/elasticmagic/aggs/TestAggregation.kt +++ b/elasticmagic/src/commonTest/kotlin/dev/evo/elasticmagic/aggs/TestAggregation.kt @@ -4,7 +4,7 @@ import dev.evo.elasticmagic.query.BaseExpressionTest @Suppress("UnnecessaryAbstractClass") abstract class TestAggregation : BaseExpressionTest() { - protected fun , R: AggregationResult> process( + protected fun , R: AggregationResult> process( agg: A, rawResult: Map ): R { return agg.processResult(deserializer.wrapObj(rawResult)) diff --git a/test-utils/src/commonMain/kotlin/dev/evo/elasticmagic/compile/BaseCompilerTest.kt b/test-utils/src/commonMain/kotlin/dev/evo/elasticmagic/compile/BaseCompilerTest.kt index be5f4de305..d3efaf11fa 100644 --- a/test-utils/src/commonMain/kotlin/dev/evo/elasticmagic/compile/BaseCompilerTest.kt +++ b/test-utils/src/commonMain/kotlin/dev/evo/elasticmagic/compile/BaseCompilerTest.kt @@ -7,7 +7,7 @@ import dev.evo.elasticmagic.withIndex import io.kotest.matchers.types.shouldBeInstanceOf @Suppress("UnnecessaryAbstractClass") -abstract class BaseCompilerTest( +abstract class BaseCompilerTest( compilerFactory: (ElasticsearchFeatures) -> T ) : BaseTest() { protected open val compilers: List = ElasticsearchFeatures.values()