diff --git a/src/compiler/core/src/commonMain/kotlin/community/flock/wirespec/compiler/core/emit/JavaEmitter.kt b/src/compiler/core/src/commonMain/kotlin/community/flock/wirespec/compiler/core/emit/JavaEmitter.kt index fb23bdb6..7a2433e0 100644 --- a/src/compiler/core/src/commonMain/kotlin/community/flock/wirespec/compiler/core/emit/JavaEmitter.kt +++ b/src/compiler/core/src/commonMain/kotlin/community/flock/wirespec/compiler/core/emit/JavaEmitter.kt @@ -81,6 +81,7 @@ class JavaEmitter( is Reference.Primitive -> when (type) { Reference.Primitive.Type.String -> "String" Reference.Primitive.Type.Integer -> "Integer" + Reference.Primitive.Type.Number -> "Double" Reference.Primitive.Type.Boolean -> "Boolean" } }.sanitizeSymbol() diff --git a/src/compiler/core/src/commonMain/kotlin/community/flock/wirespec/compiler/core/emit/KotlinEmitter.kt b/src/compiler/core/src/commonMain/kotlin/community/flock/wirespec/compiler/core/emit/KotlinEmitter.kt index f2d9e390..5cbecd5a 100644 --- a/src/compiler/core/src/commonMain/kotlin/community/flock/wirespec/compiler/core/emit/KotlinEmitter.kt +++ b/src/compiler/core/src/commonMain/kotlin/community/flock/wirespec/compiler/core/emit/KotlinEmitter.kt @@ -92,6 +92,7 @@ class KotlinEmitter( is Reference.Primitive -> when (type) { Reference.Primitive.Type.String -> "String" Reference.Primitive.Type.Integer -> "Int" + Reference.Primitive.Type.Number -> "Double" Reference.Primitive.Type.Boolean -> "Boolean" } }.sanitizeSymbol() diff --git a/src/compiler/core/src/commonMain/kotlin/community/flock/wirespec/compiler/core/emit/ScalaEmitter.kt b/src/compiler/core/src/commonMain/kotlin/community/flock/wirespec/compiler/core/emit/ScalaEmitter.kt index 208b0248..2eb669f4 100644 --- a/src/compiler/core/src/commonMain/kotlin/community/flock/wirespec/compiler/core/emit/ScalaEmitter.kt +++ b/src/compiler/core/src/commonMain/kotlin/community/flock/wirespec/compiler/core/emit/ScalaEmitter.kt @@ -48,6 +48,7 @@ class ScalaEmitter( is Reference.Primitive -> when (type) { Reference.Primitive.Type.String -> "String" Reference.Primitive.Type.Integer -> "Int" + Reference.Primitive.Type.Number -> "Double" Reference.Primitive.Type.Boolean -> "Boolean" } }.let { if (isIterable) "List[$it]" else it } diff --git a/src/compiler/core/src/commonMain/kotlin/community/flock/wirespec/compiler/core/emit/TypeScriptEmitter.kt b/src/compiler/core/src/commonMain/kotlin/community/flock/wirespec/compiler/core/emit/TypeScriptEmitter.kt index 0e83d247..9d56a709 100644 --- a/src/compiler/core/src/commonMain/kotlin/community/flock/wirespec/compiler/core/emit/TypeScriptEmitter.kt +++ b/src/compiler/core/src/commonMain/kotlin/community/flock/wirespec/compiler/core/emit/TypeScriptEmitter.kt @@ -56,6 +56,7 @@ class TypeScriptEmitter(logger: Logger = noLogger) : Emitter(logger) { is Reference.Primitive -> when (type) { Reference.Primitive.Type.String -> "string" Reference.Primitive.Type.Integer -> "number" + Reference.Primitive.Type.Number -> "number" Reference.Primitive.Type.Boolean -> "boolean" } } diff --git a/src/compiler/core/src/commonMain/kotlin/community/flock/wirespec/compiler/core/emit/WirespecEmitter.kt b/src/compiler/core/src/commonMain/kotlin/community/flock/wirespec/compiler/core/emit/WirespecEmitter.kt index 6cf3b102..c6e6a9dc 100644 --- a/src/compiler/core/src/commonMain/kotlin/community/flock/wirespec/compiler/core/emit/WirespecEmitter.kt +++ b/src/compiler/core/src/commonMain/kotlin/community/flock/wirespec/compiler/core/emit/WirespecEmitter.kt @@ -37,6 +37,7 @@ class WirespecEmitter(logger: Logger = noLogger) : Emitter(logger) { is Reference.Primitive -> when (type) { Reference.Primitive.Type.String -> "String" Reference.Primitive.Type.Integer -> "Integer" + Reference.Primitive.Type.Number -> "Number" Reference.Primitive.Type.Boolean -> "Boolean" } }.let { if (isIterable) "$it[]" else it } diff --git a/src/compiler/core/src/commonMain/kotlin/community/flock/wirespec/compiler/core/parse/EndpointParser.kt b/src/compiler/core/src/commonMain/kotlin/community/flock/wirespec/compiler/core/parse/EndpointParser.kt index 8a4911b3..1ce70521 100644 --- a/src/compiler/core/src/commonMain/kotlin/community/flock/wirespec/compiler/core/parse/EndpointParser.kt +++ b/src/compiler/core/src/commonMain/kotlin/community/flock/wirespec/compiler/core/parse/EndpointParser.kt @@ -27,6 +27,7 @@ import community.flock.wirespec.compiler.core.tokenize.types.TRACE import community.flock.wirespec.compiler.core.tokenize.types.WirespecType import community.flock.wirespec.compiler.core.tokenize.types.WsBoolean import community.flock.wirespec.compiler.core.tokenize.types.WsInteger +import community.flock.wirespec.compiler.core.tokenize.types.WsNumber import community.flock.wirespec.compiler.core.tokenize.types.WsString import community.flock.wirespec.compiler.utils.Logger @@ -131,6 +132,7 @@ class EndpointParser(logger: Logger) : AbstractParser(logger) { is WsString -> Primitive(Primitive.Type.String, isIterable) is WsInteger -> Primitive(Primitive.Type.Integer, isIterable) + is WsNumber -> Primitive(Primitive.Type.Number, isIterable) is WsBoolean -> Primitive(Primitive.Type.Boolean, isIterable) diff --git a/src/compiler/core/src/commonMain/kotlin/community/flock/wirespec/compiler/core/parse/TypeParser.kt b/src/compiler/core/src/commonMain/kotlin/community/flock/wirespec/compiler/core/parse/TypeParser.kt index ec075ec3..85e11a99 100644 --- a/src/compiler/core/src/commonMain/kotlin/community/flock/wirespec/compiler/core/parse/TypeParser.kt +++ b/src/compiler/core/src/commonMain/kotlin/community/flock/wirespec/compiler/core/parse/TypeParser.kt @@ -16,6 +16,7 @@ import community.flock.wirespec.compiler.core.tokenize.types.RightCurly import community.flock.wirespec.compiler.core.tokenize.types.WirespecType import community.flock.wirespec.compiler.core.tokenize.types.WsBoolean import community.flock.wirespec.compiler.core.tokenize.types.WsInteger +import community.flock.wirespec.compiler.core.tokenize.types.WsNumber import community.flock.wirespec.compiler.core.tokenize.types.WsString import community.flock.wirespec.compiler.utils.Logger @@ -96,6 +97,11 @@ class TypeParser(logger: Logger) : AbstractParser(logger) { isIterable ) + is WsNumber -> Type.Shape.Field.Reference.Primitive( + Type.Shape.Field.Reference.Primitive.Type.Number, + isIterable + ) + is WsBoolean -> Type.Shape.Field.Reference.Primitive( Type.Shape.Field.Reference.Primitive.Type.Boolean, isIterable diff --git a/src/compiler/core/src/commonMain/kotlin/community/flock/wirespec/compiler/core/parse/nodes/Type.kt b/src/compiler/core/src/commonMain/kotlin/community/flock/wirespec/compiler/core/parse/nodes/Type.kt index 997034ae..3fa06d4f 100644 --- a/src/compiler/core/src/commonMain/kotlin/community/flock/wirespec/compiler/core/parse/nodes/Type.kt +++ b/src/compiler/core/src/commonMain/kotlin/community/flock/wirespec/compiler/core/parse/nodes/Type.kt @@ -20,7 +20,7 @@ data class Type(val name: String, val shape: Shape) : Definition { override val isIterable: Boolean, override val isMap: Boolean = false ) : Reference { - enum class Type { String, Integer, Boolean } + enum class Type { String, Integer, Number, Boolean } } } } diff --git a/src/compiler/core/src/commonMain/kotlin/community/flock/wirespec/compiler/core/tokenize/types/TokenTypes.kt b/src/compiler/core/src/commonMain/kotlin/community/flock/wirespec/compiler/core/tokenize/types/TokenTypes.kt index 93de0136..bb92ac4f 100644 --- a/src/compiler/core/src/commonMain/kotlin/community/flock/wirespec/compiler/core/tokenize/types/TokenTypes.kt +++ b/src/compiler/core/src/commonMain/kotlin/community/flock/wirespec/compiler/core/tokenize/types/TokenTypes.kt @@ -31,6 +31,7 @@ data object WsEndpointDef : WirespecDefinition sealed interface WirespecType : Keyword data object WsString : WirespecType data object WsInteger : WirespecType +data object WsNumber : WirespecType data object WsBoolean : WirespecType data object CustomType : WirespecType diff --git a/src/lsp/intellij-plugin/src/main/kotlin/Lexer.kt b/src/lsp/intellij-plugin/src/main/kotlin/Lexer.kt index b44d7804..95a47fa0 100644 --- a/src/lsp/intellij-plugin/src/main/kotlin/Lexer.kt +++ b/src/lsp/intellij-plugin/src/main/kotlin/Lexer.kt @@ -23,6 +23,7 @@ import community.flock.wirespec.compiler.core.tokenize.types.WsBoolean import community.flock.wirespec.compiler.core.tokenize.types.WsEndpointDef import community.flock.wirespec.compiler.core.tokenize.types.WsEnumTypeDef import community.flock.wirespec.compiler.core.tokenize.types.WsInteger +import community.flock.wirespec.compiler.core.tokenize.types.WsNumber import community.flock.wirespec.compiler.core.tokenize.types.WsRefinedTypeDef import community.flock.wirespec.compiler.core.tokenize.types.WsString import community.flock.wirespec.compiler.core.tokenize.types.WsTypeDef @@ -59,6 +60,7 @@ class Lexer : IntellijLexer() { is CustomType -> Types.CUSTOM_TYPE is WsBoolean -> Types.BOOLEAN is WsInteger -> Types.INTEGER + is WsNumber -> Types.NUMBER is WsString -> Types.STRING is LeftCurly -> Types.LEFT_CURLY is QuestionMark -> Types.QUESTION_MARK diff --git a/src/lsp/intellij-plugin/src/main/kotlin/Types.kt b/src/lsp/intellij-plugin/src/main/kotlin/Types.kt index 1441cb58..3d5d8873 100644 --- a/src/lsp/intellij-plugin/src/main/kotlin/Types.kt +++ b/src/lsp/intellij-plugin/src/main/kotlin/Types.kt @@ -12,6 +12,7 @@ interface Types { val CUSTOM_TYPE = ElementType("CUSTOM_TYPE") val BOOLEAN = ElementType("BOOLEAN") val INTEGER = ElementType("INTEGER") + val NUMBER = ElementType("NUMBER") val STRING = ElementType("STRING") val TYPE_DEF = ElementType("TYPE_DEF") val ENUM_DEF = ElementType("ENUM_DEF") diff --git a/src/lsp/node/server/package-lock.json b/src/lsp/node/server/package-lock.json index d617c849..9e87a68d 100644 --- a/src/lsp/node/server/package-lock.json +++ b/src/lsp/node/server/package-lock.json @@ -44,10 +44,7 @@ "bin": { "wirespec": "wirespec-bin.js" }, - "devDependencies": { - "source-map-support": "0.5.21", - "typescript": "5.0.4" - } + "devDependencies": {} }, "../../../build/js/packages/wirespec-core": { "version": "0.0.1-SNAPSHOT", @@ -954,9 +951,7 @@ "wirespec": { "version": "file:../../../../build/js/packages/wirespec-src-compiler-lib", "requires": { - "format-util": "^1.0.5", - "source-map-support": "0.5.21", - "typescript": "5.0.4" + "format-util": "^1.0.5" } }, "wrappy": { diff --git a/src/openapi/src/commonMain/kotlin/community/flock/wirespec/openapi/v2/OpenApiParser.kt b/src/openapi/src/commonMain/kotlin/community/flock/wirespec/openapi/v2/OpenApiParser.kt index cb91872f..f978e2a0 100644 --- a/src/openapi/src/commonMain/kotlin/community/flock/wirespec/openapi/v2/OpenApiParser.kt +++ b/src/openapi/src/commonMain/kotlin/community/flock/wirespec/openapi/v2/OpenApiParser.kt @@ -369,7 +369,7 @@ class OpenApiParser(private val openApi: SwaggerObject) { private fun OpenapiType.toPrimitive() = when (this) { OpenapiType.STRING -> Reference.Primitive.Type.String OpenapiType.INTEGER -> Reference.Primitive.Type.Integer - OpenapiType.NUMBER -> Reference.Primitive.Type.Integer + OpenapiType.NUMBER -> Reference.Primitive.Type.Number OpenapiType.BOOLEAN -> Reference.Primitive.Type.Boolean else -> error("Type is not a primitive") } diff --git a/src/openapi/src/commonMain/kotlin/community/flock/wirespec/openapi/v3/OpenApiParser.kt b/src/openapi/src/commonMain/kotlin/community/flock/wirespec/openapi/v3/OpenApiParser.kt index c47a78e3..4852b876 100644 --- a/src/openapi/src/commonMain/kotlin/community/flock/wirespec/openapi/v3/OpenApiParser.kt +++ b/src/openapi/src/commonMain/kotlin/community/flock/wirespec/openapi/v3/OpenApiParser.kt @@ -457,7 +457,7 @@ class OpenApiParser(private val openApi: OpenAPIObject) { private fun OpenapiType.toPrimitive() = when (this) { OpenapiType.STRING -> Primitive.Type.String OpenapiType.INTEGER -> Primitive.Type.Integer - OpenapiType.NUMBER -> Primitive.Type.Integer + OpenapiType.NUMBER -> Primitive.Type.Number OpenapiType.BOOLEAN -> Primitive.Type.Boolean else -> error("Type is not a primitive") }