Commit c74789fc authored by Christoph Richter's avatar Christoph Richter
Browse files

Upgraded to MontiCore 5.0.0

parent 82306716
Pipeline #55142 passed with stage
in 1 minute and 2 seconds
......@@ -34,7 +34,7 @@
<properties>
<!-- .. SE-Libraries .................................................. -->
<monticore.version>4.5.4.08.11.2017</monticore.version>
<monticore.version>5.0.0</monticore.version>
<se-commons.version>1.7.7</se-commons.version>
<mc.grammars.assembly.version>0.0.6-SNAPSHOT</mc.grammars.assembly.version>
......@@ -45,7 +45,7 @@
<jscience.version>4.3.1</jscience.version>
<!-- .. Plugins ....................................................... -->
<monticore.plugin>4.5.3-SNAPSHOT</monticore.plugin>
<monticore.plugin>5.0.0</monticore.plugin>
<assembly.plugin>2.5.4</assembly.plugin>
<compiler.plugin>3.3</compiler.plugin>
<source.plugin>2.4</source.plugin>
......
......@@ -37,9 +37,9 @@ grammar Tagging extends de.monticore.common.Common {
method public String toString(){
String arrayPart = "";
arrayPart += start.isPresent() ? "" + start.get().getValue() : "";
arrayPart += step.isPresent() ? ":" + step.get().getValue() : "";
arrayPart += end.isPresent() ? ":" + end.get().getValue() : "";
arrayPart += getStartOpt().isPresent() ? "" + getStartOpt().get().getValue() : "";
arrayPart += getStepOpt().isPresent() ? ":" + getStepOpt().get().getValue() : "";
arrayPart += getEndOpt().isPresent() ? ":" + getEndOpt().get().getValue() : "";
return name + (arrayPart.equals("") ? "" : "[" + arrayPart + "]");
};
......@@ -47,7 +47,7 @@ grammar Tagging extends de.monticore.common.Common {
QualifiedNameWithArray = parts:( NameWithArray || ".")+;
ast QualifiedNameWithArray =
method public String toString(){
return de.se_rwth.commons.Joiners.DOT.join(getParts());
return de.se_rwth.commons.Joiners.DOT.join(getPartsList());
};
......
......@@ -20,8 +20,11 @@
*/
package de.monticore.lang.tagging._ast;
import java.util.Optional;
public class ASTTagElement extends ASTTagElementTOP {
protected ASTTagElement (String name, String tagValue) {
protected ASTTagElement(String name, Optional<String> tagValue) {
super(name, tagValue);
}
......
......@@ -222,11 +222,6 @@ public class TaggingResolver implements Scope {
return globalScope.resolveLocally(symbolKind);
}
@Override
public Optional<? extends Symbol> resolve(SymbolPredicate symbolPredicate) {
return globalScope.resolve(symbolPredicate);
}
@Override
public <T extends Symbol> Optional<T> resolveDown(String s, SymbolKind symbolKind) {
return globalScope.resolveDown(s, symbolKind);
......@@ -262,12 +257,6 @@ public class TaggingResolver implements Scope {
return globalScope.getLocalSymbols();
}
/** @deprecated */
@Override
public Map<String, Collection<Symbol>> getSymbols() {
return globalScope.getSymbols();
}
@Override
public int getSymbolsSize() {
return globalScope.getSymbolsSize();
......
......@@ -101,8 +101,8 @@ public class TagSchemaGenerator extends GeneratorEngine {
String.format("Could not load tagschema '%s'", tagSchemaLocation.toString()));
List<String> tagTypeNames = new ArrayList<>();
String packageName = Joiners.DOT.join(tagSchemaUnit.getPackage());
List<ASTTagType> tagTypes = tagSchemaUnit.getTagTypes();
String packageName = Joiners.DOT.join(tagSchemaUnit.getPackageList());
List<ASTTagType> tagTypes = tagSchemaUnit.getTagTypeList();
for (ASTTagType tagType : tagTypes) {
generateTagType(tagType, tagSchemaUnit, packageName, symbolScopeMap);
tagTypeNames.add(tagType.getName());
......@@ -129,18 +129,18 @@ public class TagSchemaGenerator extends GeneratorEngine {
protected void generateValuedTagType(ASTValuedTagType valuedTagType, ASTTagSchemaUnit tagSchemaUnit, String packageName, Map<String, String> symbolScopeMap) {
String dataType = null;
boolean isUnit = false;
if (valuedTagType.getBoolean().isPresent()) {
if (valuedTagType.getBooleanOpt().isPresent()) {
dataType = "Boolean";
}
else if (valuedTagType.getNumber().isPresent()) {
else if (valuedTagType.getNumberOpt().isPresent()) {
dataType = "Number";
}
else if (valuedTagType.getString().isPresent()) {
else if (valuedTagType.getStringOpt().isPresent()) {
dataType = "String";
}
else if (valuedTagType.getUnitKind().isPresent()) {
else if (valuedTagType.getUnitKindOpt().isPresent()) {
isUnit = true;
dataType = valuedTagType.getUnitKind().get();
dataType = valuedTagType.getUnitKindOpt().get();
if (!UnitKinds.contains(dataType)) {
Log.error(String.format("Unit kind '%s' is not supported. Currently the following unit kinds are available '%s'",
dataType, UnitKinds.available()), valuedTagType.get_SourcePositionStart());
......@@ -152,7 +152,7 @@ public class TagSchemaGenerator extends GeneratorEngine {
Paths.get(createPackagePath(packageName).toString(), tagSchemaUnit.getName(), valuedTagType.getName() + "Symbol.java"),
tagSchemaUnit, packageName, tagSchemaUnit.getName(), valuedTagType.getName(), dataType, isUnit);
String importSymbols = "de.monticore.lang.montiarc._symboltable.*";
String scopeSymbol = valuedTagType.getScope().get().getScopeIdentifiers().get(0).getScopeName();
String scopeSymbol = valuedTagType.getScopeOpt().get().getScopeIdentifierList().get(0).getScopeName();
String nameScopeType = Log.errorIfNull(symbolScopeMap.get(scopeSymbol), String.format("For the scope symbol '%s' is no scope type defined.", scopeSymbol));
generate("templates.de.monticore.lang.tagschema.ValuedTagTypeCreator",
Paths.get(createPackagePath(packageName).toString(),tagSchemaUnit.getName(), valuedTagType.getName() + "SymbolCreator.java"),
......@@ -174,7 +174,7 @@ public class TagSchemaGenerator extends GeneratorEngine {
Paths.get(createPackagePath(packageName).toString(), tagSchemaUnit.getName(), simpleTagType.getName() + "Symbol.java"),
tagSchemaUnit, packageName, tagSchemaUnit.getName(), simpleTagType.getName());
String importSymbols = "de.monticore.lang.montiarc._symboltable.*";
String scopeSymbol = simpleTagType.getScope().get().getScopeIdentifiers().get(0).getScopeName();
String scopeSymbol = simpleTagType.getScopeOpt().get().getScopeIdentifierList().get(0).getScopeName();
String nameScopeType = Log.errorIfNull(symbolScopeMap.get(scopeSymbol), String.format("For the scope symbol '%s' is no scope type defined.", scopeSymbol));
generate("templates.de.monticore.lang.tagschema.SimpleTagTypeCreator",
Paths.get(createPackagePath(packageName).toString(), tagSchemaUnit.getName(), simpleTagType.getName() + "SymbolCreator.java"),
......
......@@ -22,7 +22,6 @@ package de.monticore.lang.tagging.helper;
import com.google.common.collect.Lists;
import de.monticore.lang.tagging._ast.*;
import de.monticore.literals.literals._ast.ASTIntLiteral;
import java.util.ArrayList;
import java.util.Collection;
......@@ -36,14 +35,14 @@ public class RangeFixer {
public static void fixTaggingUnit(ASTTaggingUnit astTaggingUnit) {
//Replace all range syntax scopes with expanded versions
astTaggingUnit.getTagBody().getTags()
astTaggingUnit.getTagBody().getTagList()
.forEach(tag -> {
List<ASTScope> fixedScopes = tag.getScopes().stream()
List<ASTScope> fixedScopes = tag.getScopeList().stream()
.map(RangeFixer::expandScopeWithRange)
.flatMap(Collection::stream)
.collect(Collectors.toList());
tag.setScopes(fixedScopes);
tag.setScopeList(fixedScopes);
});
}
......@@ -52,22 +51,22 @@ public class RangeFixer {
ASTNameScope nameScope = (ASTNameScope) scope;
List<ASTQualifiedNameWithArray> qualifiedNames = new ArrayList<>();
//add empty start name
qualifiedNames.add(ASTQualifiedNameWithArray.getBuilder().build());
qualifiedNames.add(TaggingMill.qualifiedNameWithArrayBuilder().build());
for (ASTNameWithArray part : nameScope.getQualifiedName().getParts()) {
for (ASTNameWithArray part : nameScope.getQualifiedName().getPartsList()) {
List<ASTNameWithArray> expandedParts = expandRangeInPart(part);
List<ASTQualifiedNameWithArray> expandedNames = new ArrayList<>();
for (ASTNameWithArray ep : expandedParts) {
for (ASTQualifiedNameWithArray name : qualifiedNames) {
ASTQualifiedNameWithArray tmpName = name.deepClone();
tmpName.getParts().add(ep);
tmpName.getPartsList().add(ep);
expandedNames.add(tmpName);
}
}
qualifiedNames = expandedNames;
}
return qualifiedNames.stream().map(name -> ASTNameScope.getBuilder().qualifiedName(name).build()).collect(Collectors.toList());
return qualifiedNames.stream().map(name -> TaggingMill.nameScopeBuilder().setQualifiedName(name).build()).collect(Collectors.toList());
} else {
return Lists.newArrayList(scope);
......@@ -76,20 +75,20 @@ public class RangeFixer {
public static List<ASTNameWithArray> expandRangeInPart(ASTNameWithArray part) {
//Not a range
if (!part.getStart().isPresent() || !part.getEnd().isPresent()) {
if (!part.getStartOpt().isPresent() || !part.getEndOpt().isPresent()) {
return Lists.newArrayList(part);
}
List<ASTNameWithArray> result = new ArrayList<>();
int step = part.getStep().isPresent() ? part.getStep().get().getValue() : 1;
int start = part.getStart().get().getValue();
int end = part.getEnd().get().getValue();
int step = part.getStepOpt().isPresent() ? part.getStepOpt().get().getValue() : 1;
int start = part.getStartOpt().get().getValue();
int end = part.getEndOpt().get().getValue();
for (int i = start; i <= end; i += step) {
ASTNameWithArray tmpNameWithArray = ASTNameWithArray.getBuilder()
.name(part.getName())
.start(ASTIntLiteral.getBuilder().source("" + i).build())
ASTNameWithArray tmpNameWithArray = TaggingMill.nameWithArrayBuilder()
.setName(part.getName())
.setStart(TaggingMill.intLiteralBuilder().setSource("" + i).build())
.build();
result.add(tmpNameWithArray);
}
......
......@@ -20,6 +20,8 @@
*/
package de.monticore.lang.tagschema._ast;
import java.util.Optional;
/**
* Created by MichaelvonWenckstern on 28.06.2016.
*/
......@@ -28,8 +30,8 @@ public class ASTComplexTagType extends ASTComplexTagTypeTOP {
super();
}
public ASTComplexTagType (String name, ASTScope scope, String complexTagDef) {
super(name, scope, complexTagDef);
public ASTComplexTagType(String name, Optional<ASTScope> scope, String complexTag) {
super(name, scope, complexTag);
}
public void setComplexTag(String complexTag) {
......
......@@ -20,44 +20,44 @@
*/
package de.monticore.lang.tagschema._ast;
import java.util.ArrayList;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Optional;
import java.util.Set;
/**
* Created by MichaelvonWenckstern on 15.06.2016.
*/
public class ASTEnumeratedTagType extends ASTEnumeratedTagTypeTOP {
protected ASTEnumeratedTagType() {
super();
}
protected ASTEnumeratedTagType() {
super();
}
protected Set<String> enumValues = new LinkedHashSet<>();
protected Set<String> enumValues = new LinkedHashSet<>();
protected ASTEnumeratedTagType (String name, String enumText, ASTScope scope) {
super(name, enumText, scope);
}
protected ASTEnumeratedTagType(String name, String enumText, Optional<ASTScope> scope) {
super(name, enumText, scope);
this.enumValues = enumValues;
}
public void setEnumText(String enumText) {
if (enumText != null) {
if (enumText.startsWith("[")) {
enumText = enumText.substring(1);
}
if (enumText.endsWith("]")) {
enumText = enumText.substring(0, enumText.length() - 1);
}
enumText = enumText.trim();
// TODO fix: now it also splits BC and D in A | "BC|D" | X
String vs[] = enumText.split("\\|");
for (String v : vs) {
enumValues.add(v.trim());
}
public void setEnumText(String enumText) {
if (enumText != null) {
if (enumText.startsWith("[")) {
enumText = enumText.substring(1);
}
if (enumText.endsWith("]")) {
enumText = enumText.substring(0, enumText.length() - 1);
}
enumText = enumText.trim();
// TODO fix: now it also splits BC and D in A | "BC|D" | X
String vs[] = enumText.split("\\|");
for (String v : vs) {
enumValues.add(v.trim());
}
}
super.setEnumText(enumText);
}
super.setEnumText(enumText);
}
public Set<String> getEnumValues() {
return enumValues;
}
public Set<String> getEnumValues() {
return enumValues;
}
}
......@@ -55,14 +55,14 @@ public class ${tagTypeName}SymbolCreator implements TagSymbolCreator {
.getQualifiedName().toString()) :
packageName;
for (ASTTag element : unit.getTagBody().getTags()) {
for (ASTTag element : unit.getTagBody().getTagList()) {
element.getTagElements().stream()
.filter(t -> t.getName().equals("${tagTypeName}"))
.filter(t -> !t.getTagValue().isPresent())
.map(t -> matchRegexPattern(t.getTagValue().get()))
.filter(r -> r != null)
.forEachOrdered(m ->
element.getScopes().stream()
element.getScopeList().stream()
.filter(this::checkScope)
.map(s -> (ASTNameScope) s)
.map(s -> getGlobalScope(gs).<${scopeSymbol}>resolveDown(
......
......@@ -45,12 +45,12 @@ public class ${tagTypeName}SymbolCreator implements TagSymbolCreator {
.getQualifiedName().toString()) :
packageName;
for (ASTTag element : unit.getTagBody().getTags()) {
for (ASTTag element : unit.getTagBody().getTagList()) {
element.getTagElements().stream()
.filter(t -> t.getName().equals("${tagTypeName}"))
.filter(t -> !t.getTagValue().isPresent()) // only marker tag with no value
.forEachOrdered(t ->
element.getScopes().stream()
element.getScopeList().stream()
.filter(this::checkScope)
.map(s -> (ASTNameScope) s)
.map(s -> getGlobalScope(gs).<Symbol>resolveDownMany(
......
......@@ -62,7 +62,7 @@ public class ${tagTypeName}SymbolCreator implements TagSymbolCreator {
.getQualifiedNameString()) :
packageName;
for (ASTTag element : unit.getTagBody().getTags()) {
for (ASTTag element : unit.getTagBody().getTagList()) {
element.getTagElements().stream()
.filter(t -> t.getName().equals("${tagTypeName}"))
.filter(t -> t.getTagValue().isPresent())
......@@ -72,7 +72,7 @@ public class ${tagTypeName}SymbolCreator implements TagSymbolCreator {
.filter(this::checkUnit)
</#if>
.forEachOrdered(v ->
element.getScopes().stream()
element.getScopeList().stream()
.filter(this::checkScope)
.map(s -> (ASTNameScope) s)
.map(s -> getGlobalScope(gs).<Symbol>resolveDownMany(
......
......@@ -97,7 +97,7 @@ public class ${tagTypeName}SymbolCreator implements TagSymbolCreator {
for (ASTTagElement element : unit.getTagBody().getTagElements()) {
if (element instanceof ASTTargetElement) {
((ASTTargetElement) element).getTags().stream()
((ASTTargetElement) element).getTagList().stream()
.filter(t -> t.getName().equals("${tagTypeName}"))
.filter(this::checkASTTagKind)
.map(t -> (ASTValuedTag) t)
......@@ -113,7 +113,7 @@ public class ${tagTypeName}SymbolCreator implements TagSymbolCreator {
.map(v -> (ASTNumericTagValue)v.getTagValue())
</#if>
.forEachOrdered(v ->
((ASTTargetElement) element).getScopes().stream()
((ASTTargetElement) element).getScopeList().stream()
.filter(this::checkScope)
.map(s -> (ASTNameScope) s)
.map(s -> getGlobalScope(gs).<${scopeSymbol}>resolveDown(
......
......@@ -65,10 +65,10 @@ public class ParserTagValueTest {
// public void testTags() throws Exception {
// TagsParser parser = new TagsParser();
// ASTTags tags = parser.parse("C:\\Users\\MichaelvonWenckstern\\Documents\\MontiArc4\\01.code\\tagging\\src\\test\\resources\\windTurbine\\PowerConsumptionTags.tag").get();
// System.out.println(tags.getTags().size());
// tags.getTags().stream().filter(t -> t.getTagValue().isPresent())
// System.out.println(tags.getTagList().size());
// tags.getTagList().stream().filter(t -> t.getTagValue().isPresent())
// .forEachOrdered(t -> System.out.println(t.getTagValue().get()));
//// System.out.println(tags.getTags().get(0).getTagValue().length());
//// System.out.println(tags.getTagList().get(0).getTagValue().length());
// }
/* @Ignore
......@@ -76,8 +76,8 @@ public class ParserTagValueTest {
public void testTagschema2() throws Exception {
TaggingParser parser = new TaggingParser();
ASTTaggingUnit tags = parser.parse("C:\\Users\\MichaelvonWenckstern\\Documents\\MontiArc4\\01.code\\tagging\\src\\test\\resources\\windTurbine\\PowerConsumption.tag").get();
tags.getTagBody().getTags().forEach(t -> t.getTagElements().forEach(e -> System.out.println(e.getName() + ": " + e.getTagValue().orElse(""))));
// System.out.println(tags.getTags().size());
// System.out.println(tags.getTags().get(0).getTagValue().length());
tags.getTagBody().getTagList().forEach(t -> t.getTagElements().forEach(e -> System.out.println(e.getName() + ": " + e.getTagValue().orElse(""))));
// System.out.println(tags.getTagList().size());
// System.out.println(tags.getTagList().get(0).getTagValue().length());
}*/
}
......@@ -43,12 +43,12 @@ public class IsTraceableSymbolCreator implements TagSymbolCreator {
.getQualifiedName().toString()) :
packageName;
for (ASTTag element : unit.getTagBody().getTags()) {
for (ASTTag element : unit.getTagBody().getTagList()) {
element.getTagElements().stream()
.filter(t -> t.getName().equals("IsTraceable"))
.filter(t -> !t.getTagValue().isPresent()) // only marker tag with no value
.forEachOrdered(t ->
element.getScopes().stream()
element.getScopeList().stream()
.filter(this::checkScope)
.map(s -> (ASTNameScope) s)
.map(s -> getGlobalScope(gs).<ComponentSymbol>resolveDown(
......
......@@ -46,12 +46,12 @@ public class IsTraceableSymbolCreator implements TagSymbolCreator {
.getQualifiedName().toString()) :
packageName;
for (ASTTag element : unit.getTagBody().getTags()) {
for (ASTTag element : unit.getTagBody().getTagList()) {
element.getTagElements().stream()
.filter(t -> t.getName().equals("IsTraceable"))
.filter(t -> !t.getTagValue().isPresent()) // only marker tag with no value
.forEachOrdered(t ->
element.getScopes().stream()
element.getScopeList().stream()
.filter(this::checkScope)
.map(s -> (ASTNameScope) s)
.map(s -> getGlobalScope(gs).<Symbol>resolveDownMany(
......
......@@ -46,12 +46,12 @@ public class TraceableSymbolCreator implements TagSymbolCreator {
.getQualifiedName().toString()) :
packageName;
for (ASTTag element : unit.getTagBody().getTags()) {
for (ASTTag element : unit.getTagBody().getTagList()) {
element.getTagElements().stream()
.filter(t -> t.getName().equals("Traceable"))
.filter(t -> !t.getTagValue().isPresent()) // only marker tag with no value
.forEachOrdered(t ->
element.getScopes().stream()
element.getScopeList().stream()
.filter(this::checkScope)
.map(s -> (ASTNameScope) s)
.map(s -> getGlobalScope(gs).<Symbol>resolveDownMany(
......
......@@ -43,12 +43,12 @@ public class TraceableSymbolCreator implements TagSymbolCreator {
.getQualifiedName().toString()) :
packageName;
for (ASTTag element : unit.getTagBody().getTags()) {
for (ASTTag element : unit.getTagBody().getTagList()) {
element.getTagElements().stream()
.filter(t -> t.getName().equals("Traceable"))
.filter(t -> !t.getTagValue().isPresent()) // only marker tag with no value
.forEachOrdered(t ->
element.getScopes().stream()
element.getScopeList().stream()
.filter(this::checkScope)
.map(s -> (ASTNameScope) s)
.map(s -> getGlobalScope(gs).<ExpandedComponentInstanceSymbol>resolveDown(
......
......@@ -54,7 +54,7 @@ public class CompPowerInstSymbolCreator implements TagSymbolCreator {
.getQualifiedNameString()) :
packageName;
for (ASTTag element : unit.getTagBody().getTags()) {
for (ASTTag element : unit.getTagBody().getTagList()) {
element.getTagElements().stream()
.filter(t -> t.getName().equals("CompPowerInst"))
.filter(t -> t.getTagValue().isPresent())
......@@ -62,7 +62,7 @@ public class CompPowerInstSymbolCreator implements TagSymbolCreator {
.filter(v -> v != null)
.filter(this::checkUnit)
.forEachOrdered(v ->
element.getScopes().stream()
element.getScopeList().stream()
.filter(this::checkScope)
.map(s -> (ASTNameScope) s)
.map(s -> getGlobalScope(gs).<Symbol>resolveDownMany(
......
......@@ -54,7 +54,7 @@ public class CompPowerSymbolCreator implements TagSymbolCreator {
.getQualifiedNameString()) :
packageName;
for (ASTTag element : unit.getTagBody().getTags()) {
for (ASTTag element : unit.getTagBody().getTagList()) {
element.getTagElements().stream()
.filter(t -> t.getName().equals("CompPower"))
.filter(t -> t.getTagValue().isPresent())
......@@ -62,7 +62,7 @@ public class CompPowerSymbolCreator implements TagSymbolCreator {
.filter(v -> v != null)
.filter(this::checkUnit)
.forEachOrdered(v ->
element.getScopes().stream()
element.getScopeList().stream()
.filter(this::checkScope)
.map(s -> (ASTNameScope) s)
.map(s -> getGlobalScope(gs).<Symbol>resolveDownMany(
......
......@@ -54,7 +54,7 @@ public class LatencyCmpInstSymbolCreator implements TagSymbolCreator {
.getQualifiedNameString()) :
packageName;
for (ASTTag element : unit.getTagBody().getTags()) {
for (ASTTag element : unit.getTagBody().getTagList()) {
element.getTagElements().stream()
.filter(t -> t.getName().equals("LatencyCmpInst"))
.filter(t -> t.getTagValue().isPresent())
......@@ -62,7 +62,7 @@ public class LatencyCmpInstSymbolCreator implements TagSymbolCreator {
.filter(v -> v != null)
.filter(this::checkUnit)
.forEachOrdered(v ->
element.getScopes().stream()
element.getScopeList().stream()
.filter(this::checkScope)
.map(s -> (ASTNameScope) s)
.map(s -> getGlobalScope(gs).<Symbol>resolveDownMany(
......
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