Skip to content
This repository was archived by the owner on Jan 19, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
fd80b74
feat(parser): mostly finish updating parser schema
lars-reimann Jul 2, 2022
f60e877
test(parser): update tests
lars-reimann Jul 2, 2022
8b57297
feat(parser): fully migrate parser
lars-reimann Jul 2, 2022
a5224bc
feat(gui): migration from annotation store v1 to v2
lars-reimann Jul 2, 2022
a2771ea
refactor(gui): upgrade annotation store in annotation slice to new ve…
lars-reimann Jul 2, 2022
5164ca4
refactor(gui): update most of the gui code
lars-reimann Jul 2, 2022
74992d9
feat(gui): get everything running again (still needs testing)
lars-reimann Jul 2, 2022
8c3e073
fix(gui): update help button
lars-reimann Jul 2, 2022
a213ca9
fix(gui): run migration on import/startup
lars-reimann Jul 2, 2022
49feb0f
fix(gui): behavior of value form when changing type
lars-reimann Jul 2, 2022
d330783
feat(gui): improve tag for value annotation
lars-reimann Jul 2, 2022
674a637
fix(gui): allow selection of False and empty string
lars-reimann Jul 2, 2022
90f7b4d
feat(gui)!: replace attribute annotation with optional on import
lars-reimann Jul 2, 2022
5c62671
feat(gui): move value annotation to uncategorized section in dropdown
lars-reimann Jul 2, 2022
c9c986b
style: fix lint errors
lars-reimann Jul 2, 2022
ef72be3
style: fix lint errors
lars-reimann Jul 2, 2022
70abffd
fix(backend): failing tests
lars-reimann Jul 2, 2022
8b5efd8
style(backend): fix linter errors
lars-reimann Jul 2, 2022
3b4d66a
style(backend): fix linter errors
lars-reimann Jul 2, 2022
2d92a82
style: apply automatic fixes of linters
lars-reimann Jul 2, 2022
ff0cecf
fix: smoke tests
lars-reimann Jul 2, 2022
d20bcd6
feat(gui): improve labels in value form
lars-reimann Jul 2, 2022
6a1c2b0
fix(gui): make boolean value required and fix initialization
lars-reimann Jul 2, 2022
86cab63
feat(gui): polishing
lars-reimann Jul 2, 2022
c020b84
style: apply automatic fixes of linters
lars-reimann Jul 2, 2022
12cd057
chore(data): update annotation data
lars-reimann Jul 2, 2022
9d7ec5e
fix(gui): adding new annotations
lars-reimann Jul 2, 2022
852b377
refactor(gui): polishing
lars-reimann Jul 2, 2022
5c78448
fix(gui): failing test
lars-reimann Jul 2, 2022
4f0eae8
style: apply automatic fixes of linters
lars-reimann Jul 2, 2022
b11ef59
fix(backend): wrong main class
lars-reimann Jul 2, 2022
837f315
refactor(gui): rename a function
lars-reimann Jul 2, 2022
4ba87bb
style(backend): use trailing commas
lars-reimann Jul 2, 2022
97396cc
style: apply automatic fixes of linters
lars-reimann Jul 2, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,8 @@ insert_final_newline = true

[{*.yaml,*.yml}]
indent_size = 2

[*.{kt,kts}]
disabled_rules = filename
ij_kotlin_allow_trailing_comma = true
ij_kotlin_allow_trailing_comma_on_call_site = true
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ jobs:
run: poetry run parse-package usages -p package_parser -c package_parser -o out

- name: Smoke test (annotations)
run: poetry run parse-package annotations -a tests/data/removes/api_data.json -u tests/data/removes/usage_data.json -o out/annotations.json
run: poetry run parse-package annotations -a tests/data/removeAnnotations/api_data.json -u tests/data/removeAnnotations/usage_data.json -o out/annotations.json

- name: Smoke test (all)
run: poetry run parse-package all -p package_parser -s package_parser -c package_parser -o out
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ jobs:
run: poetry run parse-package usages -p package_parser -c package_parser -o out

- name: Smoke test (annotations)
run: poetry run parse-package annotations -a tests/data/removes/api_data.json -u tests/data/removes/usage_data.json -o out/annotations.json
run: poetry run parse-package annotations -a tests/data/removeAnnotations/api_data.json -u tests/data/removeAnnotations/usage_data.json -o out/annotations.json

- name: Smoke test (all)
run: poetry run parse-package all -p package_parser -s package_parser -c package_parser -o out
Expand Down
4 changes: 2 additions & 2 deletions api-editor/backend/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ plugins {
}

application {
mainClass.set("com.larsreimann.api_editor.server.ApplicationKt")
mainClass.set("com.larsreimann.apiEditor.server.ApplicationKt")
}

java {
Expand Down Expand Up @@ -81,7 +81,7 @@ tasks {
val winFileText = winScriptFile.readText()
.replace(
Regex("set CLASSPATH=.*"),
"rem original CLASSPATH declaration replaced by:\nset CLASSPATH=%APP_HOME%\\\\lib\\\\*"
"rem original CLASSPATH declaration replaced by:\nset CLASSPATH=%APP_HOME%\\\\lib\\\\*",
)

winScriptFile.writeText(winFileText)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.larsreimann.api_editor.codegen
package com.larsreimann.apiEditor.codegen

import com.larsreimann.api_editor.mutable_model.PythonModule
import com.larsreimann.api_editor.mutable_model.PythonPackage
import com.larsreimann.apiEditor.mutableModel.PythonModule
import com.larsreimann.apiEditor.mutableModel.PythonPackage
import com.larsreimann.safeds.constant.SdsFileExtension
import java.io.BufferedInputStream
import java.io.BufferedOutputStream
Expand Down
Original file line number Diff line number Diff line change
@@ -1,40 +1,40 @@
package com.larsreimann.api_editor.codegen

import com.larsreimann.api_editor.model.Boundary
import com.larsreimann.api_editor.model.ComparisonOperator.LESS_THAN
import com.larsreimann.api_editor.model.ComparisonOperator.LESS_THAN_OR_EQUALS
import com.larsreimann.api_editor.model.ComparisonOperator.UNRESTRICTED
import com.larsreimann.api_editor.model.PythonParameterAssignment.IMPLICIT
import com.larsreimann.api_editor.model.PythonParameterAssignment.NAMED_VARARG
import com.larsreimann.api_editor.model.PythonParameterAssignment.NAME_ONLY
import com.larsreimann.api_editor.model.PythonParameterAssignment.POSITIONAL_VARARG
import com.larsreimann.api_editor.model.PythonParameterAssignment.POSITION_ONLY
import com.larsreimann.api_editor.model.PythonParameterAssignment.POSITION_OR_NAME
import com.larsreimann.api_editor.mutable_model.PythonArgument
import com.larsreimann.api_editor.mutable_model.PythonAttribute
import com.larsreimann.api_editor.mutable_model.PythonBoolean
import com.larsreimann.api_editor.mutable_model.PythonCall
import com.larsreimann.api_editor.mutable_model.PythonClass
import com.larsreimann.api_editor.mutable_model.PythonConstructor
import com.larsreimann.api_editor.mutable_model.PythonDeclaration
import com.larsreimann.api_editor.mutable_model.PythonEnum
import com.larsreimann.api_editor.mutable_model.PythonEnumInstance
import com.larsreimann.api_editor.mutable_model.PythonExpression
import com.larsreimann.api_editor.mutable_model.PythonFloat
import com.larsreimann.api_editor.mutable_model.PythonFunction
import com.larsreimann.api_editor.mutable_model.PythonInt
import com.larsreimann.api_editor.mutable_model.PythonMemberAccess
import com.larsreimann.api_editor.mutable_model.PythonModule
import com.larsreimann.api_editor.mutable_model.PythonNamedSpread
import com.larsreimann.api_editor.mutable_model.PythonNamedType
import com.larsreimann.api_editor.mutable_model.PythonNone
import com.larsreimann.api_editor.mutable_model.PythonParameter
import com.larsreimann.api_editor.mutable_model.PythonPositionalSpread
import com.larsreimann.api_editor.mutable_model.PythonReference
import com.larsreimann.api_editor.mutable_model.PythonString
import com.larsreimann.api_editor.mutable_model.PythonStringifiedExpression
import com.larsreimann.api_editor.mutable_model.PythonStringifiedType
import com.larsreimann.api_editor.mutable_model.PythonType
package com.larsreimann.apiEditor.codegen

import com.larsreimann.apiEditor.model.Boundary
import com.larsreimann.apiEditor.model.ComparisonOperator.LESS_THAN
import com.larsreimann.apiEditor.model.ComparisonOperator.LESS_THAN_OR_EQUALS
import com.larsreimann.apiEditor.model.ComparisonOperator.UNRESTRICTED
import com.larsreimann.apiEditor.model.PythonParameterAssignment.IMPLICIT
import com.larsreimann.apiEditor.model.PythonParameterAssignment.NAMED_VARARG
import com.larsreimann.apiEditor.model.PythonParameterAssignment.NAME_ONLY
import com.larsreimann.apiEditor.model.PythonParameterAssignment.POSITIONAL_VARARG
import com.larsreimann.apiEditor.model.PythonParameterAssignment.POSITION_ONLY
import com.larsreimann.apiEditor.model.PythonParameterAssignment.POSITION_OR_NAME
import com.larsreimann.apiEditor.mutableModel.PythonArgument
import com.larsreimann.apiEditor.mutableModel.PythonAttribute
import com.larsreimann.apiEditor.mutableModel.PythonBoolean
import com.larsreimann.apiEditor.mutableModel.PythonCall
import com.larsreimann.apiEditor.mutableModel.PythonClass
import com.larsreimann.apiEditor.mutableModel.PythonConstructor
import com.larsreimann.apiEditor.mutableModel.PythonDeclaration
import com.larsreimann.apiEditor.mutableModel.PythonEnum
import com.larsreimann.apiEditor.mutableModel.PythonEnumInstance
import com.larsreimann.apiEditor.mutableModel.PythonExpression
import com.larsreimann.apiEditor.mutableModel.PythonFloat
import com.larsreimann.apiEditor.mutableModel.PythonFunction
import com.larsreimann.apiEditor.mutableModel.PythonInt
import com.larsreimann.apiEditor.mutableModel.PythonMemberAccess
import com.larsreimann.apiEditor.mutableModel.PythonModule
import com.larsreimann.apiEditor.mutableModel.PythonNamedSpread
import com.larsreimann.apiEditor.mutableModel.PythonNamedType
import com.larsreimann.apiEditor.mutableModel.PythonNone
import com.larsreimann.apiEditor.mutableModel.PythonParameter
import com.larsreimann.apiEditor.mutableModel.PythonPositionalSpread
import com.larsreimann.apiEditor.mutableModel.PythonReference
import com.larsreimann.apiEditor.mutableModel.PythonString
import com.larsreimann.apiEditor.mutableModel.PythonStringifiedExpression
import com.larsreimann.apiEditor.mutableModel.PythonStringifiedType
import com.larsreimann.apiEditor.mutableModel.PythonType
import com.larsreimann.modeling.closest
import com.larsreimann.modeling.descendants

Expand All @@ -47,7 +47,7 @@ fun PythonModule.toPythonCode(): String {
importsToPythonCode(),
classes.joinToString("\n\n") { it.toPythonCode() },
functions.joinToString("\n\n") { it.toPythonCode() },
enums.joinToString("\n\n") { it.toPythonCode() }
enums.joinToString("\n\n") { it.toPythonCode() },
)

val joinedStrings = strings
Expand All @@ -59,7 +59,6 @@ fun PythonModule.toPythonCode(): String {

private fun PythonModule.importsToPythonCode() = buildString {
val imports = buildSet<String> {

// Functions
this += descendants { it !is PythonDeclaration }
.filterIsInstance<PythonFunction>()
Expand Down Expand Up @@ -292,7 +291,7 @@ fun List<PythonParameter>.toPythonCode(): String {
positionOrNameParametersString,
positionalVarargParametersString,
nameOnlyParametersString,
namedVarargsParametersString
namedVarargsParametersString,
)

return parameterStrings
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package com.larsreimann.api_editor.codegen
package com.larsreimann.apiEditor.codegen

import com.larsreimann.api_editor.model.PythonParameterAssignment
import com.larsreimann.api_editor.mutable_model.PythonAttribute
import com.larsreimann.api_editor.mutable_model.PythonClass
import com.larsreimann.api_editor.mutable_model.PythonFunction
import com.larsreimann.api_editor.mutable_model.PythonParameter
import com.larsreimann.apiEditor.model.PythonParameterAssignment
import com.larsreimann.apiEditor.mutableModel.PythonAttribute
import com.larsreimann.apiEditor.mutableModel.PythonClass
import com.larsreimann.apiEditor.mutableModel.PythonFunction
import com.larsreimann.apiEditor.mutableModel.PythonParameter

private fun attributesDocstring(attributes: List<PythonAttribute>) = buildString {
if (attributes.all { it.description.isBlank() }) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
package com.larsreimann.api_editor.codegen

import com.larsreimann.api_editor.model.PythonParameterAssignment.IMPLICIT
import com.larsreimann.api_editor.mutable_model.PythonAttribute
import com.larsreimann.api_editor.mutable_model.PythonClass
import com.larsreimann.api_editor.mutable_model.PythonEnum
import com.larsreimann.api_editor.mutable_model.PythonEnumInstance
import com.larsreimann.api_editor.mutable_model.PythonExpression
import com.larsreimann.api_editor.mutable_model.PythonFunction
import com.larsreimann.api_editor.mutable_model.PythonModule
import com.larsreimann.api_editor.mutable_model.PythonNamedType
import com.larsreimann.api_editor.mutable_model.PythonParameter
import com.larsreimann.api_editor.mutable_model.PythonResult
import com.larsreimann.api_editor.mutable_model.PythonStringifiedExpression
import com.larsreimann.api_editor.mutable_model.PythonStringifiedType
import com.larsreimann.api_editor.mutable_model.PythonType
package com.larsreimann.apiEditor.codegen

import com.larsreimann.apiEditor.model.PythonParameterAssignment.IMPLICIT
import com.larsreimann.apiEditor.mutableModel.PythonAttribute
import com.larsreimann.apiEditor.mutableModel.PythonClass
import com.larsreimann.apiEditor.mutableModel.PythonEnum
import com.larsreimann.apiEditor.mutableModel.PythonEnumInstance
import com.larsreimann.apiEditor.mutableModel.PythonExpression
import com.larsreimann.apiEditor.mutableModel.PythonFunction
import com.larsreimann.apiEditor.mutableModel.PythonModule
import com.larsreimann.apiEditor.mutableModel.PythonNamedType
import com.larsreimann.apiEditor.mutableModel.PythonParameter
import com.larsreimann.apiEditor.mutableModel.PythonResult
import com.larsreimann.apiEditor.mutableModel.PythonStringifiedExpression
import com.larsreimann.apiEditor.mutableModel.PythonStringifiedType
import com.larsreimann.apiEditor.mutableModel.PythonType
import com.larsreimann.safeds.constant.SdsFileExtension
import com.larsreimann.safeds.emf.createSdsAnnotationCall
import com.larsreimann.safeds.emf.createSdsArgument
Expand Down Expand Up @@ -56,7 +56,7 @@ fun PythonModule.toStubCode(): String {
createSdsDummyResource(
"compilationUnitStub",
SdsFileExtension.Stub,
compilationUnit
compilationUnit,
)

return when (val result = compilationUnit.serializeToFormattedString()) {
Expand All @@ -75,7 +75,7 @@ fun PythonModule.toSdsCompilationUnit(): SdsCompilationUnit {

return createSdsCompilationUnit(
packageName = name,
members = classes + functions + enums
members = classes + functions + enums,
)
}

Expand All @@ -99,7 +99,7 @@ fun PythonClass.toSdsClass(): SdsClass {
}
},
parameters = buildConstructor(),
members = attributes + methods
members = attributes + methods,
)
}

Expand All @@ -126,7 +126,7 @@ fun PythonAttribute.toSdsAttribute(): SdsAttribute {
add(createSdsDescriptionAnnotationUse(description))
}
},
type = type.toSdsType()
type = type.toSdsType(),
)
}

Expand All @@ -148,21 +148,21 @@ fun PythonFunction.toSdsFunction(): SdsFunction {
}
},
parameters = parameters.mapNotNull { it.toSdsParameterOrNull() },
results = results.map { it.toSdsResult() }
results = results.map { it.toSdsResult() },
)
}

private fun createSdsDescriptionAnnotationUse(description: String): SdsAnnotationCall {
return createSdsAnnotationCall(
"Description",
listOf(createSdsArgument(createSdsString(description)))
listOf(createSdsArgument(createSdsString(description))),
)
}

private fun createSdsPythonNameAnnotationUse(name: String): SdsAnnotationCall {
return createSdsAnnotationCall(
"PythonName",
listOf(createSdsArgument(createSdsString(name)))
listOf(createSdsArgument(createSdsString(name))),
)
}

Expand All @@ -184,7 +184,7 @@ fun PythonParameter.toSdsParameterOrNull(): SdsParameter? {
}
},
type = type.toSdsType(),
defaultValue = defaultValue?.toSdsExpression()
defaultValue = defaultValue?.toSdsExpression(),
)
}

Expand All @@ -201,7 +201,7 @@ fun PythonResult.toSdsResult(): SdsResult {
add(createSdsDescriptionAnnotationUse(description))
}
},
type = type.toSdsType()
type = type.toSdsType(),
)
}

Expand Down Expand Up @@ -240,7 +240,7 @@ fun PythonEnumInstance.toSdsEnumVariant(): SdsEnumVariant {
if (description.isNotBlank()) {
add(createSdsDescriptionAnnotationUse(description))
}
}
},
)
}

Expand All @@ -264,32 +264,32 @@ fun PythonType?.toSdsType(): SdsAbstractType {
return when (this) {
is PythonNamedType -> {
createSdsNamedType(
declaration = createSdsClass(this.declaration!!.name)
declaration = createSdsClass(this.declaration!!.name),
)
}
is PythonStringifiedType -> {
when (this.string) {
"bool" -> createSdsNamedType(
declaration = createSdsClass("Boolean")
declaration = createSdsClass("Boolean"),
)
"float" -> createSdsNamedType(
declaration = createSdsClass("Float")
declaration = createSdsClass("Float"),
)
"int" -> createSdsNamedType(
declaration = createSdsClass("Int")
declaration = createSdsClass("Int"),
)
"str" -> createSdsNamedType(
declaration = createSdsClass("String")
declaration = createSdsClass("String"),
)
else -> createSdsNamedType(
declaration = createSdsClass("Any"),
isNullable = true
isNullable = true,
)
}
}
null -> createSdsNamedType(
declaration = createSdsClass("Any"),
isNullable = true
isNullable = true,
)
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.larsreimann.api_editor.codegen
package com.larsreimann.apiEditor.codegen

internal fun String.prependIndentUnlessBlank(indent: String = " "): String {
return lineSequence()
Expand Down
Loading