Skip to content

Commit

Permalink
fix(projectional-editor): kernelf editor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
slisson committed Oct 21, 2024
1 parent 7a7632e commit 226580b
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,10 @@ import org.iets3.core.expr.base.N_ISingleSymbolRef
import org.modelix.aspects.behavior.buildPolymorphicFunction

val binaryExpressionSymbols by buildPolymorphicFunction().returns<String>().forConcept<CN_BinaryExpression>()
.defaultValue { ":${it.untyped().getShortName()}:" }.delegate()
.defaultValue { it.alias ?: ":${it.untyped().getShortName()}:" }.delegate()

val ISingleSymbolRef_getSymbolName by buildPolymorphicFunction().returns<String>().forNode(C_ISingleSymbolRef).delegate()
fun N_ISingleSymbolRef.getSymbolName() = ISingleSymbolRef_getSymbolName(this)

val IRef_target by buildPolymorphicFunction().returns<N_BaseConcept>().forNode(C_IRef).delegate()
fun N_IRef.target() = IRef_target(this)

val BaseConcept_alias by buildPolymorphicFunction().returns<String>().forConcept<CN_BaseConcept>().delegate()
fun CN_BaseConcept.alias() = BaseConcept_alias(this)
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ val Editor_org_iets3_core_expr_base = languageAspects(L_org_iets3_core_expr_base
binaryExpressionSymbols.implement(language.OptionOrExpression) { "?:" }
binaryExpressionSymbols.implement(L_org_iets3_core_expr_lambda.FunCompose) { ":o:" }

editor(language.BinaryExpression) {
editor(language.BinaryExpression, applicableToSubConcepts = true) {
val symbol = binaryExpressionSymbols(concept)
concept.left.cell()
symbol.constant()
Expand Down Expand Up @@ -345,7 +345,7 @@ val Editor_org_iets3_core_expr_base = languageAspects(L_org_iets3_core_expr_base
language.OrTag to "||",
language.PlusTag to "+",
)
editor(language.OperatorTag) {
editor(language.OperatorTag, applicableToSubConcepts = true) {
val symbol = operatorTagSymbols[concept]
?: "Unknown operator tag ${concept.untyped().getLongName()}"
symbol.constant()
Expand Down Expand Up @@ -395,7 +395,7 @@ val Editor_org_iets3_core_expr_base = languageAspects(L_org_iets3_core_expr_base
}
}
editor(language.PrimitiveType) {
concept.alias().constant {
(concept.alias ?: concept.untyped().getShortName()).constant {
iets3type()
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,5 @@ import org.iets3.core.expr.datetime.L_org_iets3_core_expr_datetime
import org.modelix.aspects.languageAspects

val Editor_org_iets3_core_expr_datetime = languageAspects(L_org_iets3_core_expr_datetime) {
BaseConcept_alias.implement(language.DateDeltaType) { "datedelta" }
BaseConcept_alias.implement(language.DaysDeltaType) { "days" }
BaseConcept_alias.implement(language.MonthsDeltaType) { "months" }
BaseConcept_alias.implement(language.WeeksDeltaType) { "weeks" }
BaseConcept_alias.implement(language.YearsDeltaType) { "years" }
BaseConcept_alias.implement(language.TimeDeltaType) { "timedelta" }
BaseConcept_alias.implement(language.HoursDeltaType) { "hours" }
BaseConcept_alias.implement(language.MinutesDeltaType) { "minutes" }
BaseConcept_alias.implement(language.SecondsDeltaType) { "seconds" }

}
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,6 @@ import org.modelix.aspects.languageAspects
import org.modelix.editor.editor

val Editor_org_iets3_core_expr_simpleTypes = languageAspects(L_org_iets3_core_expr_simpleTypes) {
BaseConcept_alias.implement(language.BooleanType) { "boolean" }
BaseConcept_alias.implement(language.NumberType) { "number" }
BaseConcept_alias.implement(language.IntegerType) { "int" }
BaseConcept_alias.implement(language.RealType) { "real" }
BaseConcept_alias.implement(language.StringType) { "string" }
editor(language.StringLiteral) {
horizontal {
textColor("DarkGreen")
Expand All @@ -25,6 +20,7 @@ val Editor_org_iets3_core_expr_simpleTypes = languageAspects(L_org_iets3_core_ex
editor(language.NumberLiteral) {
concept.value.cell {
textColor("DarkMagenta")
regex("""[0-9]+([.][0-9]+)?""")
validateValue { it.toDoubleOrNull() != null }
}
}
Expand Down Expand Up @@ -147,7 +143,7 @@ val Editor_org_iets3_core_expr_simpleTypes = languageAspects(L_org_iets3_core_ex
language.RoundUpRoundingMode to "round up",
language.TruncateRoundingMode to "truncate",
)
editor(language.RoundingMode) {
editor(language.RoundingMode, applicableToSubConcepts = true) {
val mode = roundingModes[concept]
?: "Unknown rounding mode ${concept.untyped().getLongName()}"
mode.constant()
Expand Down

0 comments on commit 226580b

Please sign in to comment.