diff --git a/monticore-generator/src/main/java/de/monticore/codegen/cd2java/_symboltable/serialization/BITSer.java b/monticore-generator/src/main/java/de/monticore/codegen/cd2java/_symboltable/serialization/BITSer.java index f7909a672..fa8b1ba3b 100644 --- a/monticore-generator/src/main/java/de/monticore/codegen/cd2java/_symboltable/serialization/BITSer.java +++ b/monticore-generator/src/main/java/de/monticore/codegen/cd2java/_symboltable/serialization/BITSer.java @@ -3,6 +3,7 @@ package de.monticore.codegen.cd2java._symboltable.serialization; import de.monticore.generating.templateengine.HookPoint; +import de.monticore.types.check.SymTypeExpression; import java.util.LinkedHashMap; import java.util.Map; @@ -49,6 +50,9 @@ public void init() { bitsers.put("long", _long); bitsers.put("java.lang.Long", _long); bitsers.put("Long", _long); + + BITSerStrategy symTypeExpression = new SymTypeExpressionSerStrategy(); + bitsers.put(SymTypeExpression.class.getName(), symTypeExpression); } /** diff --git a/monticore-generator/src/main/java/de/monticore/codegen/cd2java/_symboltable/serialization/SymTypeExpressionSerStrategy.java b/monticore-generator/src/main/java/de/monticore/codegen/cd2java/_symboltable/serialization/SymTypeExpressionSerStrategy.java new file mode 100644 index 000000000..b761eb156 --- /dev/null +++ b/monticore-generator/src/main/java/de/monticore/codegen/cd2java/_symboltable/serialization/SymTypeExpressionSerStrategy.java @@ -0,0 +1,42 @@ +/* (c) https://github.com/MontiCore/monticore */ +package de.monticore.codegen.cd2java._symboltable.serialization; + +import de.monticore.generating.templateengine.HookPoint; +import de.monticore.generating.templateengine.StringHookPoint; +import de.monticore.types.check.SymTypeExpression; + +/** + * DeSerialization of {@link SymTypeExpression} symbol attributes. + */ +public class SymTypeExpressionSerStrategy extends BITSerStrategy { + public SymTypeExpressionSerStrategy() { + super(SymTypeExpression.class.getName(), "null"); + } + + @Override + public HookPoint getSerialHook(String attrParam) { + return new StringHookPoint(String.format("de.monticore.types.check.SymTypeExpressionDeSer.serializeMember(s2j.getJsonPrinter(), \"%s\", %s);", attrParam, attrParam)); + } + + @Override + public HookPoint getOptSerialHook(String attrParam) { + return new StringHookPoint(String.format("de.monticore.types.check.SymTypeExpressionDeSer.serializeMember(s2j.getJsonPrinter(), \"%s\", %s);", attrParam, attrParam)); + } + + @Override + public HookPoint getListSerialHook(String attrParam) { + return new StringHookPoint(String.format("de.monticore.types.check.SymTypeExpressionDeSer.serializeMember(s2j.getJsonPrinter(), \"%s\", %s);", attrParam, attrParam)); + } + + public HookPoint getDeserialHook(String jsonParam, String attrParam) { + return new StringHookPoint(String.format("return de.monticore.types.check.SymTypeExpressionDeSer.deserializeMember(\"%s\", symbolJson, scope);", attrParam)); + } + + public HookPoint getOptDeserialHook(String jsonParam, String attrParam) { + return new StringHookPoint(String.format("return de.monticore.types.check.SymTypeExpressionDeSer.deserializeOptionalMember(\"%s\", symbolJson, scope);", attrParam)); + } + + public HookPoint getListDeserialHook(String jsonParam, String attrParam) { + return new StringHookPoint(String.format("return de.monticore.types.check.SymTypeExpressionDeSer.deserializeListMember(\"%s\", symbolJson, scope);", attrParam)); + } +} diff --git a/monticore-grammar/src/main/java/de/monticore/symbols/oosymbols/_symboltable/FieldSymbolDeSer.java b/monticore-grammar/src/main/java/de/monticore/symbols/oosymbols/_symboltable/FieldSymbolDeSer.java deleted file mode 100644 index 8cd55936e..000000000 --- a/monticore-grammar/src/main/java/de/monticore/symbols/oosymbols/_symboltable/FieldSymbolDeSer.java +++ /dev/null @@ -1,26 +0,0 @@ -/* (c) https://github.com/MontiCore/monticore */ -package de.monticore.symbols.oosymbols._symboltable; - -import de.monticore.symboltable.serialization.json.JsonObject; -import de.monticore.types.check.SymTypeExpression; -import de.monticore.types.check.SymTypeExpressionDeSer; - -public class FieldSymbolDeSer extends FieldSymbolDeSerTOP { - - @Override - protected void serializeType(SymTypeExpression type, OOSymbolsSymbols2Json s2j) { - SymTypeExpressionDeSer.serializeMember(s2j.getJsonPrinter(), "type", type); - } - - @Override - public SymTypeExpression deserializeType(JsonObject symbolJson) { - // support deprecated behavior - return deserializeType(null, symbolJson); - } - - @Override - public SymTypeExpression deserializeType(IOOSymbolsScope enclosingScope, JsonObject symbolJson) { - return SymTypeExpressionDeSer.deserializeMember("type", symbolJson, enclosingScope); - } - -} diff --git a/monticore-grammar/src/main/java/de/monticore/symbols/oosymbols/_symboltable/MethodSymbolDeSer.java b/monticore-grammar/src/main/java/de/monticore/symbols/oosymbols/_symboltable/MethodSymbolDeSer.java deleted file mode 100644 index e5515c792..000000000 --- a/monticore-grammar/src/main/java/de/monticore/symbols/oosymbols/_symboltable/MethodSymbolDeSer.java +++ /dev/null @@ -1,26 +0,0 @@ -/* (c) https://github.com/MontiCore/monticore */ -package de.monticore.symbols.oosymbols._symboltable; - -import de.monticore.symboltable.serialization.json.JsonObject; -import de.monticore.types.check.SymTypeExpression; -import de.monticore.types.check.SymTypeExpressionDeSer; - -public class MethodSymbolDeSer extends MethodSymbolDeSerTOP { - - @Override - protected void serializeType(SymTypeExpression type, OOSymbolsSymbols2Json s2j) { - SymTypeExpressionDeSer.serializeMember(s2j.getJsonPrinter(), "type", type); - } - - @Override - public SymTypeExpression deserializeType(JsonObject symbolJson) { - // support deprecated behavior - return deserializeType(null, symbolJson); - } - - @Override - public SymTypeExpression deserializeType(IOOSymbolsScope enclosingScope, JsonObject symbolJson) { - return SymTypeExpressionDeSer.deserializeMember("type", symbolJson, enclosingScope); - } - -} diff --git a/monticore-grammar/src/main/java/de/monticore/symbols/oosymbols/_symboltable/OOTypeSymbolDeSer.java b/monticore-grammar/src/main/java/de/monticore/symbols/oosymbols/_symboltable/OOTypeSymbolDeSer.java deleted file mode 100644 index 91c204980..000000000 --- a/monticore-grammar/src/main/java/de/monticore/symbols/oosymbols/_symboltable/OOTypeSymbolDeSer.java +++ /dev/null @@ -1,31 +0,0 @@ -/* (c) https://github.com/MontiCore/monticore */ -package de.monticore.symbols.oosymbols._symboltable; - -import de.monticore.symboltable.serialization.json.JsonObject; -import de.monticore.types.check.SymTypeExpression; -import de.monticore.types.check.SymTypeExpressionDeSer; - -import java.util.List; - -public class OOTypeSymbolDeSer extends OOTypeSymbolDeSerTOP { - - @Override - protected void serializeSuperTypes(List superTypes, - OOSymbolsSymbols2Json s2j) { - SymTypeExpressionDeSer.serializeMember(s2j.getJsonPrinter(), "superTypes", superTypes); - } - - @Override - public List deserializeSuperTypes(JsonObject symbolJson) { - // support deprecated behavior - return deserializeSuperTypes(null, symbolJson); - } - - @Override - public List deserializeSuperTypes( - IOOSymbolsScope enclosingScope, JsonObject symbolJson) { - return SymTypeExpressionDeSer.deserializeListMember( - "superTypes", symbolJson, enclosingScope); - } - -}