From 7c50dfd7d12f5cb60e13df303b5d96779d3ce44e Mon Sep 17 00:00:00 2001 From: Tony Tkacik Date: Fri, 29 May 2020 08:45:41 +0200 Subject: [PATCH] Axiom: Added support for mixins Signed-off-by: Tony Tkacik --- .../evolveum/axiom/lang/api/AxiomBuiltIn.java | 1 + .../axiom/lang/impl/BasicStatementRule.java | 15 +++++++++++-- .../axiom/src/main/resources/axiom-lang.axiom | 22 ++++++++++--------- 3 files changed, 26 insertions(+), 12 deletions(-) diff --git a/infra/axiom/src/main/java/com/evolveum/axiom/lang/api/AxiomBuiltIn.java b/infra/axiom/src/main/java/com/evolveum/axiom/lang/api/AxiomBuiltIn.java index 62770262611..854f7ca8fc9 100644 --- a/infra/axiom/src/main/java/com/evolveum/axiom/lang/api/AxiomBuiltIn.java +++ b/infra/axiom/src/main/java/com/evolveum/axiom/lang/api/AxiomBuiltIn.java @@ -55,6 +55,7 @@ public static class Item implements AxiomItemDefinition { public static final AxiomItemDefinition TARGET = new Item("target", Type.TYPE_REFERENCE, true); public static final AxiomItemDefinition REF_TARGET = new Item("target", Type.TYPE_DEFINITION, true); + public static final AxiomItemDefinition USES = new Item("uses", Type.TYPE_REFERENCE, true); private final AxiomIdentifier identifier; diff --git a/infra/axiom/src/main/java/com/evolveum/axiom/lang/impl/BasicStatementRule.java b/infra/axiom/src/main/java/com/evolveum/axiom/lang/impl/BasicStatementRule.java index b1eaf4389d3..7de2d74e3cf 100644 --- a/infra/axiom/src/main/java/com/evolveum/axiom/lang/impl/BasicStatementRule.java +++ b/infra/axiom/src/main/java/com/evolveum/axiom/lang/impl/BasicStatementRule.java @@ -132,10 +132,21 @@ public void apply(Lookup context, ActionBuilder context, ActionBuilder action) throws AxiomSemanticException { + Dependency typeDef = + action.require( + context.onlyItemValue(Item.REF_TARGET, AxiomTypeDefinition.class) + .map(v -> v.get())); + typeDef.unsatisfied(() -> action.error("Supertype is not complete.")); + action.apply(superTypeValue -> { + addFromType(typeDef.get(), superTypeValue.parentValue(), typeDef.get().name()); + }); + } + }, IMPORT_DEFAULT_TYPES(all(), types(Type.MODEL)) { @Override public void apply(Lookup context, ActionBuilder action) throws AxiomSemanticException { diff --git a/infra/axiom/src/main/resources/axiom-lang.axiom b/infra/axiom/src/main/resources/axiom-lang.axiom index aaa2beb70c9..a09154c370a 100644 --- a/infra/axiom/src/main/resources/axiom-lang.axiom +++ b/infra/axiom/src/main/resources/axiom-lang.axiom @@ -4,10 +4,8 @@ model axiom-lang { root model { documentation """ - Axiom Model - Declares a new axiom model. - """; + """; type AxiomModel; } @@ -28,10 +26,8 @@ model axiom-lang { item root { documentation """ - Root Definition - - Root Definition defines allowed root for serialized documents - modeled by Axiom language. + Defines allowed root for serialized documents + modeled by Axiom language. """; type AxiomRootDefinition; } @@ -49,7 +45,7 @@ model axiom-lang { item mixin { type AxiomMixinDefinition; documentation """ - Mixin Declaration, declares a new global mixin, aset of reusable item + Declares a new global mixin, a set of reusable item definitions, which can be used in type definitions. """; } @@ -190,12 +186,20 @@ model axiom-lang { } type AxiomTypeReference { + documentation "Type Reference"; argument name; + item name { + documentation "Name of referenced type"; type AxiomIdentifier; + minOccurs 1; + maxOccurs 1; } item target { + documentation "Definition of referenced type"; type AxiomTypeDefinition; + minOccurs 1; + maxOccurs 1; operational true; } } @@ -213,8 +217,6 @@ model axiom-lang { // "Type library" (temporary) - - type SemanticVersion { extends string; }