Commit 0b0fac3d authored by Ferdinand Alexander Mehlan's avatar Ferdinand Alexander Mehlan
Browse files

change templates for tagschema and complextagtypecreator to new tagging method

parent 9693a8e9
Pipeline #62977 passed with stage
in 50 seconds
/**
*
* ******************************************************************************
* MontiCAR Modeling Family, www.se-rwth.de
* Copyright (c) 2017, Software Engineering Group at RWTH Aachen,
* All rights reserved.
*
* This project is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this project. If not, see <http://www.gnu.org/licenses/>.
* *******************************************************************************
*/
package de.monticore.lang.tagging._symboltable;
import de.monticore.ModelingLanguage;
public interface TagableModelingLanguage extends ModelingLanguage {
default void addTagSymbolCreator(TagSymbolCreator tagSymbolCreator) {
}
}
......@@ -16,6 +16,7 @@ import de.monticore.lang.tagging._ast.ASTScope;
import de.monticore.lang.tagging._ast.ASTTag;
import de.monticore.lang.tagging._ast.ASTTaggingUnit;
import de.monticore.lang.tagging._symboltable.TagSymbolCreator;
import de.monticore.lang.tagging._symboltable.TaggingResolver;
import de.monticore.symboltable.Scope;
import de.se_rwth.commons.Joiners;
import de.se_rwth.commons.logging.Log;
......@@ -45,7 +46,7 @@ public class ${tagTypeName}SymbolCreator implements TagSymbolCreator {
return s;
}
public void create(ASTTaggingUnit unit, Scope gs) {
public void create(ASTTaggingUnit unit, TaggingResolver tagging) {
if (unit.getQualifiedNameList().stream()
.map(q -> q.toString())
.filter(n -> n.endsWith("${schemaName}"))
......@@ -69,12 +70,11 @@ public class ${tagTypeName}SymbolCreator implements TagSymbolCreator {
element.getScopeList().stream()
.filter(this::checkScope)
.map(s -> (ASTNameScope) s)
.map(s -> getGlobalScope(gs).<${scopeSymbol}>resolveDown(
Joiners.DOT.join(rootCmp, s.getQualifiedName().toString()),
${scopeSymbol}.KIND))
.map(s -> tagging.resolve(Joiners.DOT.join(rootCmp, // resolve down does not try to reload symbol
s.getQualifiedName().toString()), ${scopeSymbol}.KIND))
.filter(Optional::isPresent)
.map(Optional::get)
.forEachOrdered(s -> s.addTag(
.forEachOrdered(s -> tagging.addTag(s,
new ${tagTypeName}Symbol(
${symbolParams}
))));
......
......@@ -2,8 +2,7 @@ ${tc.signature("packageName", "schemaName", "tagTypeNames")}
package ${packageName}.${schemaName};
import de.monticore.CommonModelingLanguage;
import de.monticore.lang.tagging._symboltable.TagableModelingLanguage;
import de.monticore.lang.tagging._symboltable.TaggingResolver;
import de.monticore.symboltable.resolving.CommonResolvingFilter;
/**
......@@ -22,19 +21,15 @@ public class ${schemaName} {
return instance;
}
protected void doRegisterTagTypes(TagableModelingLanguage modelingLanguage) {
// all ModelingLanguage instances are actually instances of CommonModelingLanguage
if(modelingLanguage instanceof CommonModelingLanguage) {
CommonModelingLanguage commonModelingLanguage = (CommonModelingLanguage)modelingLanguage;
<#list tagTypeNames as tagTypeName>
modelingLanguage.addTagSymbolCreator(new ${tagTypeName}SymbolCreator());
commonModelingLanguage.addResolvingFilter(CommonResolvingFilter.create(${tagTypeName}Symbol.KIND));
</#list>
}
protected void doRegisterTagTypes(TaggingResolver tagging) {
<#list tagTypeNames as tagTypeName>
tagging.addTagSymbolCreator(new ${tagTypeName}SymbolCreator());
tagging.addTagSymbolResolvingFilter(CommonResolvingFilter.create(${tagTypeName}Symbol.KIND));
</#list>
}
public static void registerTagTypes(TagableModelingLanguage modelingLanguage) {
getInstance().doRegisterTagTypes(modelingLanguage);
public static void registerTagTypes(TaggingResolver tagging) {
getInstance().doRegisterTagTypes(tagging);
}
}
\ No newline at end of file
......@@ -129,7 +129,8 @@ public class GeneratorTest {
@Test
public void testSizeTag() throws Exception {
GeneratorSetup setup = new GeneratorSetup();
setup.setOutputDirectory(getPathFromRelativePath("src/test/resources/generator/").toFile());
//setup.setOutputDirectory(getPathFromRelativePath("src/test/java/").toFile());
setup.setOutputDirectory(getPathFromRelativePath("src/test/resources/generator").toFile());
setup.setTracing(true);
TagSchemaGenerator generator = new TagSchemaGenerator(setup);
Map<String, String> symbolScopeMap = new LinkedHashMap<>();
......
......@@ -3,8 +3,7 @@
package de.monticore.lang.montiarc.tag.drawing.TraceabilityTagSchema;
import de.monticore.CommonModelingLanguage;
import de.monticore.lang.tagging._symboltable.TagableModelingLanguage;
import de.monticore.lang.tagging._symboltable.TaggingResolver;
import de.monticore.symboltable.resolving.CommonResolvingFilter;
/**
......@@ -23,19 +22,15 @@ public class TraceabilityTagSchema {
return instance;
}
protected void doRegisterTagTypes(TagableModelingLanguage modelingLanguage) {
// all ModelingLanguage instances are actually instances of CommonModelingLanguage
if(modelingLanguage instanceof CommonModelingLanguage) {
CommonModelingLanguage commonModelingLanguage = (CommonModelingLanguage)modelingLanguage;
modelingLanguage.addTagSymbolCreator(new IsTraceableSymbolCreator());
commonModelingLanguage.addResolvingFilter(CommonResolvingFilter.create(IsTraceableSymbol.KIND));
modelingLanguage.addTagSymbolCreator(new TraceableSymbolCreator());
commonModelingLanguage.addResolvingFilter(CommonResolvingFilter.create(TraceableSymbol.KIND));
}
protected void doRegisterTagTypes(TaggingResolver tagging) {
tagging.addTagSymbolCreator(new IsTraceableSymbolCreator());
tagging.addTagSymbolResolvingFilter(CommonResolvingFilter.create(IsTraceableSymbol.KIND));
tagging.addTagSymbolCreator(new TraceableSymbolCreator());
tagging.addTagSymbolResolvingFilter(CommonResolvingFilter.create(TraceableSymbol.KIND));
}
public static void registerTagTypes(TagableModelingLanguage modelingLanguage) {
getInstance().doRegisterTagTypes(modelingLanguage);
public static void registerTagTypes(TaggingResolver tagging) {
getInstance().doRegisterTagTypes(tagging);
}
}
\ No newline at end of file
......@@ -3,8 +3,7 @@
package nfp.CompPower;
import de.monticore.CommonModelingLanguage;
import de.monticore.lang.tagging._symboltable.TagableModelingLanguage;
import de.monticore.lang.tagging._symboltable.TaggingResolver;
import de.monticore.symboltable.resolving.CommonResolvingFilter;
/**
......@@ -23,19 +22,15 @@ public class CompPower {
return instance;
}
protected void doRegisterTagTypes(TagableModelingLanguage modelingLanguage) {
// all ModelingLanguage instances are actually instances of CommonModelingLanguage
if(modelingLanguage instanceof CommonModelingLanguage) {
CommonModelingLanguage commonModelingLanguage = (CommonModelingLanguage)modelingLanguage;
modelingLanguage.addTagSymbolCreator(new CompPowerInstSymbolCreator());
commonModelingLanguage.addResolvingFilter(CommonResolvingFilter.create(CompPowerInstSymbol.KIND));
modelingLanguage.addTagSymbolCreator(new CompPowerSymbolCreator());
commonModelingLanguage.addResolvingFilter(CommonResolvingFilter.create(CompPowerSymbol.KIND));
}
protected void doRegisterTagTypes(TaggingResolver tagging) {
tagging.addTagSymbolCreator(new CompPowerInstSymbolCreator());
tagging.addTagSymbolResolvingFilter(CommonResolvingFilter.create(CompPowerInstSymbol.KIND));
tagging.addTagSymbolCreator(new CompPowerSymbolCreator());
tagging.addTagSymbolResolvingFilter(CommonResolvingFilter.create(CompPowerSymbol.KIND));
}
public static void registerTagTypes(TagableModelingLanguage modelingLanguage) {
getInstance().doRegisterTagTypes(modelingLanguage);
public static void registerTagTypes(TaggingResolver tagging) {
getInstance().doRegisterTagTypes(tagging);
}
}
\ No newline at end of file
......@@ -3,8 +3,7 @@
package nfp.LatencyTagSchema;
import de.monticore.CommonModelingLanguage;
import de.monticore.lang.tagging._symboltable.TagableModelingLanguage;
import de.monticore.lang.tagging._symboltable.TaggingResolver;
import de.monticore.symboltable.resolving.CommonResolvingFilter;
/**
......@@ -23,23 +22,19 @@ public class LatencyTagSchema {
return instance;
}
protected void doRegisterTagTypes(TagableModelingLanguage modelingLanguage) {
// all ModelingLanguage instances are actually instances of CommonModelingLanguage
if(modelingLanguage instanceof CommonModelingLanguage) {
CommonModelingLanguage commonModelingLanguage = (CommonModelingLanguage)modelingLanguage;
modelingLanguage.addTagSymbolCreator(new LatencyCmpInstSymbolCreator());
commonModelingLanguage.addResolvingFilter(CommonResolvingFilter.create(LatencyCmpInstSymbol.KIND));
modelingLanguage.addTagSymbolCreator(new LatencyCmpSymbolCreator());
commonModelingLanguage.addResolvingFilter(CommonResolvingFilter.create(LatencyCmpSymbol.KIND));
modelingLanguage.addTagSymbolCreator(new LatencyConnSymbolCreator());
commonModelingLanguage.addResolvingFilter(CommonResolvingFilter.create(LatencyConnSymbol.KIND));
modelingLanguage.addTagSymbolCreator(new LatencyPortSymbolCreator());
commonModelingLanguage.addResolvingFilter(CommonResolvingFilter.create(LatencyPortSymbol.KIND));
}
protected void doRegisterTagTypes(TaggingResolver tagging) {
tagging.addTagSymbolCreator(new LatencyCmpInstSymbolCreator());
tagging.addTagSymbolResolvingFilter(CommonResolvingFilter.create(LatencyCmpInstSymbol.KIND));
tagging.addTagSymbolCreator(new LatencyCmpSymbolCreator());
tagging.addTagSymbolResolvingFilter(CommonResolvingFilter.create(LatencyCmpSymbol.KIND));
tagging.addTagSymbolCreator(new LatencyConnSymbolCreator());
tagging.addTagSymbolResolvingFilter(CommonResolvingFilter.create(LatencyConnSymbol.KIND));
tagging.addTagSymbolCreator(new LatencyPortSymbolCreator());
tagging.addTagSymbolResolvingFilter(CommonResolvingFilter.create(LatencyPortSymbol.KIND));
}
public static void registerTagTypes(TagableModelingLanguage modelingLanguage) {
getInstance().doRegisterTagTypes(modelingLanguage);
public static void registerTagTypes(TaggingResolver tagging) {
getInstance().doRegisterTagTypes(tagging);
}
}
\ No newline at end of file
......@@ -3,8 +3,7 @@
package nfp.PhysicalTags;
import de.monticore.CommonModelingLanguage;
import de.monticore.lang.tagging._symboltable.TagableModelingLanguage;
import de.monticore.lang.tagging._symboltable.TaggingResolver;
import de.monticore.symboltable.resolving.CommonResolvingFilter;
/**
......@@ -23,19 +22,15 @@ public class PhysicalTags {
return instance;
}
protected void doRegisterTagTypes(TagableModelingLanguage modelingLanguage) {
// all ModelingLanguage instances are actually instances of CommonModelingLanguage
if(modelingLanguage instanceof CommonModelingLanguage) {
CommonModelingLanguage commonModelingLanguage = (CommonModelingLanguage)modelingLanguage;
modelingLanguage.addTagSymbolCreator(new WeightSymbolCreator());
commonModelingLanguage.addResolvingFilter(CommonResolvingFilter.create(WeightSymbol.KIND));
modelingLanguage.addTagSymbolCreator(new SizeSymbolCreator());
commonModelingLanguage.addResolvingFilter(CommonResolvingFilter.create(SizeSymbol.KIND));
}
protected void doRegisterTagTypes(TaggingResolver tagging) {
tagging.addTagSymbolCreator(new WeightSymbolCreator());
tagging.addTagSymbolResolvingFilter(CommonResolvingFilter.create(WeightSymbol.KIND));
tagging.addTagSymbolCreator(new SizeSymbolCreator());
tagging.addTagSymbolResolvingFilter(CommonResolvingFilter.create(SizeSymbol.KIND));
}
public static void registerTagTypes(TagableModelingLanguage modelingLanguage) {
getInstance().doRegisterTagTypes(modelingLanguage);
public static void registerTagTypes(TaggingResolver tagging) {
getInstance().doRegisterTagTypes(tagging);
}
}
\ No newline at end of file
......@@ -15,6 +15,7 @@ import de.monticore.lang.tagging._ast.ASTScope;
import de.monticore.lang.tagging._ast.ASTTag;
import de.monticore.lang.tagging._ast.ASTTaggingUnit;
import de.monticore.lang.tagging._symboltable.TagSymbolCreator;
import de.monticore.lang.tagging._symboltable.TaggingResolver;
import de.monticore.symboltable.Scope;
import de.se_rwth.commons.Joiners;
import de.se_rwth.commons.logging.Log;
......@@ -44,7 +45,7 @@ public class SizeSymbolCreator implements TagSymbolCreator {
return s;
}
public void create(ASTTaggingUnit unit, Scope gs) {
public void create(ASTTaggingUnit unit, TaggingResolver tagging) {
if (unit.getQualifiedNameList().stream()
.map(q -> q.toString())
.filter(n -> n.endsWith("PhysicalTags"))
......@@ -68,12 +69,11 @@ public class SizeSymbolCreator implements TagSymbolCreator {
element.getScopeList().stream()
.filter(this::checkScope)
.map(s -> (ASTNameScope) s)
.map(s -> getGlobalScope(gs).<EMAComponentInstanceSymbol>resolveDown(
Joiners.DOT.join(rootCmp, s.getQualifiedName().toString()),
EMAComponentInstanceSymbol.KIND))
.map(s -> tagging.resolve(Joiners.DOT.join(rootCmp, // resolve down does not try to reload symbol
s.getQualifiedName().toString()), EMAComponentInstanceSymbol.KIND))
.filter(Optional::isPresent)
.map(Optional::get)
.forEachOrdered(s -> s.addTag(
.forEachOrdered(s -> tagging.addTag(s,
new SizeSymbol(
Amount.valueOf(m.group(1)), Amount.valueOf(m.group(2)), Amount.valueOf(m.group(3))
))));
......
......@@ -3,8 +3,7 @@
package nfp.PowerConsumptionTagSchema;
import de.monticore.CommonModelingLanguage;
import de.monticore.lang.tagging._symboltable.TagableModelingLanguage;
import de.monticore.lang.tagging._symboltable.TaggingResolver;
import de.monticore.symboltable.resolving.CommonResolvingFilter;
/**
......@@ -23,23 +22,19 @@ public class PowerConsumptionTagSchema {
return instance;
}
protected void doRegisterTagTypes(TagableModelingLanguage modelingLanguage) {
// all ModelingLanguage instances are actually instances of CommonModelingLanguage
if(modelingLanguage instanceof CommonModelingLanguage) {
CommonModelingLanguage commonModelingLanguage = (CommonModelingLanguage)modelingLanguage;
modelingLanguage.addTagSymbolCreator(new PowerConsumptionSymbolCreator());
commonModelingLanguage.addResolvingFilter(CommonResolvingFilter.create(PowerConsumptionSymbol.KIND));
modelingLanguage.addTagSymbolCreator(new PowerTesterSymbolCreator());
commonModelingLanguage.addResolvingFilter(CommonResolvingFilter.create(PowerTesterSymbol.KIND));
modelingLanguage.addTagSymbolCreator(new PowerIdSymbolCreator());
commonModelingLanguage.addResolvingFilter(CommonResolvingFilter.create(PowerIdSymbol.KIND));
modelingLanguage.addTagSymbolCreator(new PowerBooleanSymbolCreator());
commonModelingLanguage.addResolvingFilter(CommonResolvingFilter.create(PowerBooleanSymbol.KIND));
}
protected void doRegisterTagTypes(TaggingResolver tagging) {
tagging.addTagSymbolCreator(new PowerConsumptionSymbolCreator());
tagging.addTagSymbolResolvingFilter(CommonResolvingFilter.create(PowerConsumptionSymbol.KIND));
tagging.addTagSymbolCreator(new PowerTesterSymbolCreator());
tagging.addTagSymbolResolvingFilter(CommonResolvingFilter.create(PowerTesterSymbol.KIND));
tagging.addTagSymbolCreator(new PowerIdSymbolCreator());
tagging.addTagSymbolResolvingFilter(CommonResolvingFilter.create(PowerIdSymbol.KIND));
tagging.addTagSymbolCreator(new PowerBooleanSymbolCreator());
tagging.addTagSymbolResolvingFilter(CommonResolvingFilter.create(PowerBooleanSymbol.KIND));
}
public static void registerTagTypes(TagableModelingLanguage modelingLanguage) {
getInstance().doRegisterTagTypes(modelingLanguage);
public static void registerTagTypes(TaggingResolver tagging) {
getInstance().doRegisterTagTypes(tagging);
}
}
\ No newline at end of file
......@@ -3,8 +3,7 @@
package nfp.TransmissionCostsTagSchema;
import de.monticore.CommonModelingLanguage;
import de.monticore.lang.tagging._symboltable.TagableModelingLanguage;
import de.monticore.lang.tagging._symboltable.TaggingResolver;
import de.monticore.symboltable.resolving.CommonResolvingFilter;
/**
......@@ -23,23 +22,19 @@ public class TransmissionCostsTagSchema {
return instance;
}
protected void doRegisterTagTypes(TagableModelingLanguage modelingLanguage) {
// all ModelingLanguage instances are actually instances of CommonModelingLanguage
if(modelingLanguage instanceof CommonModelingLanguage) {
CommonModelingLanguage commonModelingLanguage = (CommonModelingLanguage)modelingLanguage;
modelingLanguage.addTagSymbolCreator(new TransCostCmpInstSymbolCreator());
commonModelingLanguage.addResolvingFilter(CommonResolvingFilter.create(TransCostCmpInstSymbol.KIND));
modelingLanguage.addTagSymbolCreator(new TransCostCmpSymbolCreator());
commonModelingLanguage.addResolvingFilter(CommonResolvingFilter.create(TransCostCmpSymbol.KIND));
modelingLanguage.addTagSymbolCreator(new TransCostConnSymbolCreator());
commonModelingLanguage.addResolvingFilter(CommonResolvingFilter.create(TransCostConnSymbol.KIND));
modelingLanguage.addTagSymbolCreator(new TransCostPortSymbolCreator());
commonModelingLanguage.addResolvingFilter(CommonResolvingFilter.create(TransCostPortSymbol.KIND));
}
protected void doRegisterTagTypes(TaggingResolver tagging) {
tagging.addTagSymbolCreator(new TransCostCmpInstSymbolCreator());
tagging.addTagSymbolResolvingFilter(CommonResolvingFilter.create(TransCostCmpInstSymbol.KIND));
tagging.addTagSymbolCreator(new TransCostCmpSymbolCreator());
tagging.addTagSymbolResolvingFilter(CommonResolvingFilter.create(TransCostCmpSymbol.KIND));
tagging.addTagSymbolCreator(new TransCostConnSymbolCreator());
tagging.addTagSymbolResolvingFilter(CommonResolvingFilter.create(TransCostConnSymbol.KIND));
tagging.addTagSymbolCreator(new TransCostPortSymbolCreator());
tagging.addTagSymbolResolvingFilter(CommonResolvingFilter.create(TransCostPortSymbol.KIND));
}
public static void registerTagTypes(TagableModelingLanguage modelingLanguage) {
getInstance().doRegisterTagTypes(modelingLanguage);
public static void registerTagTypes(TaggingResolver tagging) {
getInstance().doRegisterTagTypes(tagging);
}
}
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment