Commit fe0776ae authored by vonWenckstern's avatar vonWenckstern
Browse files

removed tagging tests

parent 2c0935b5
......@@ -22,14 +22,13 @@ package de.monticore.lang.embeddedmontiarc.helper;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.*;
import de.monticore.lang.monticar.ValueSymbol;
import de.monticore.lang.montiarc.tagging._symboltable.IsTaggable;
import de.monticore.lang.monticar.helper.IndentPrinter;
import de.monticore.lang.monticar.ts.MCTypeSymbol;
import de.monticore.symboltable.Symbol;
import de.monticore.symboltable.types.TypeSymbol;
import de.monticore.symboltable.types.references.ActualTypeArgument;
import de.monticore.lang.monticar.ts.references.MCTypeReference;
import de.monticore.symboltable.types.references.TypeReference;
import de.se_rwth.commons.logging.Log;
import java.util.Collection;
import java.util.List;
......@@ -41,6 +40,7 @@ import java.util.stream.Collectors;
*/
public class SymbolPrinter {
/**
* help function for nested type arguments such as List<NewType<String, List<String>>>
*/
......@@ -228,18 +228,19 @@ public class SymbolPrinter {
return ip.getContent();
}
public static void printTags(IsTaggable hasTags, IndentPrinter ip) {
if (!hasTags.getTags().isEmpty()) {
ip.println("/* tags: ");
ip.indent();
ip.indent();
ip.print(hasTags.getTags().stream().map(t -> t.toString()).
collect(Collectors.joining("\n")));
ip.print(" */");
ip.unindent();
ip.unindent();
ip.println();
}
public static void printTags(Symbol hasTags, IndentPrinter ip) {
// needs to be changed so that this method can be overwritten --> remove static
// if (!hasTags.getTags().isEmpty()) {
// ip.println("/* tags: ");
// ip.indent();
// ip.indent();
// ip.print(hasTags.getTags().stream().map(t -> t.toString()).
// collect(Collectors.joining("\n")));
// ip.print(" */");
// ip.unindent();
// ip.unindent();
// ip.println();
// }
}
public static void printPackageInfo(ComponentSymbol cmp, IndentPrinter ip, boolean skipPackageImport) {
......
/**
*
* ******************************************************************************
* 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.embeddedmontiarc.tag;//package de.monticore.lang.montiarc.tag;
//
//import de.monticore.lang.montiarc.tagging._symboltable.TagKind;
//import de.monticore.lang.montiarc.tagging._symboltable.TagSymbol;
//
///**
// * Created by Michael von Wenckstern on 31.05.2016.
// */
//public class IsTraceableSymbol extends TagSymbol {
// public static final TraceabilityKind KIND = TraceabilityKind.INSTANCE;
//
// /**
// * is marker symbol so it has no value by itself
// */
// public IsTraceableSymbol() {
// // true to set that it is marked
// super(KIND);
// }
//
// @Override
// public String toString() {
// return "IsTraceable";
// }
//
// public static class TraceabilityKind extends TagKind {
// public static final TraceabilityKind INSTANCE = new TraceabilityKind();
//
// protected TraceabilityKind() {
// }
// }
//}
/**
*
* ******************************************************************************
* 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.embeddedmontiarc.tag;//package de.monticore.lang.montiarc.tag;
//
//import java.util.Optional;
//
//import de.monticore.lang.montiarc.montiarc._symboltable.ComponentSymbol;
//import de.monticore.lang.montiarc.tagging._ast.ASTNameScope;
//import de.monticore.lang.montiarc.tagging._ast.ASTScope;
//import de.monticore.lang.montiarc.tagging._ast.ASTTag;
//import de.monticore.lang.montiarc.tagging._ast.ASTTaggingUnit;
//import de.monticore.lang.montiarc.tagging._symboltable.TagSymbolCreator;
//import de.monticore.symboltable.Scope;
//import de.se_rwth.commons.Joiners;
//import de.se_rwth.commons.logging.Log;
//
///**
// * Created by Michael von Wenckstern on 31.05.2016.
// * only for this tests --> this should be generated using the tag schema
// */
//public class IsTraceableSymbolCreator implements TagSymbolCreator {
//
// public static Scope getGlobalScope(final Scope scope) {
// Scope s = scope;
// while (s.getEnclosingScope().isPresent()) {
// s = s.getEnclosingScope().get();
// }
// return s;
// }
//
// public void create(ASTTaggingUnit unit, Scope gs) {
// if (unit.getQualifiedNames().stream()
// .map(q -> q.toString())
// .filter(n -> n.endsWith("TraceabilityTagSchema"))
// .count() == 0) {
// return; // the tagging model is not conform to the traceability tagging schema
// }
// final String packageName = Joiners.DOT.join(unit.getPackage());
// final String rootCmp = // if-else does not work b/c of final (required by streams)
// (unit.getTagBody().getTargetModel().isPresent()) ?
// Joiners.DOT.join(packageName, ((ASTNameScope) unit.getTagBody().getTargetModel().get())
// .getQualifiedName().toString()) :
// packageName;
//
// for (ASTTag element : unit.getTagBody().getTags()) {
// 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()
// .filter(this::checkScope)
// .map(s -> (ASTNameScope) s)
// .map(s -> getGlobalScope(gs).<ComponentSymbol>resolveDown(
// Joiners.DOT.join(rootCmp, s.getQualifiedName().toString()),
// ComponentSymbol.KIND))
// .filter(Optional::isPresent)
// .map(Optional::get)
// .forEachOrdered(s -> s.addTag(new IsTraceableSymbol())));
// }
// }
//
//
// protected boolean checkScope(ASTScope scope) {
// if (scope.getScopeKind().equals("NameScope")) {
// return true;
// }
// Log.error(String.format("0xT0005 Invalid scope kind: '%s'. IsTraceable expects as scope kind 'NameScope'.",
// scope.getScopeKind()), scope.get_SourcePositionStart());
// return false;
// }
//}
/**
*
* ******************************************************************************
* 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.embeddedmontiarc.tag;//package de.monticore.lang.montiarc.tag;
//
//import de.monticore.lang.montiarc.helper.IndentPrinter;
//import de.monticore.lang.montiarc.tagging._symboltable.TagKind;
//import de.monticore.lang.montiarc.tagging._symboltable.TagSymbol;
//import de.monticore.lang.montiarc.unit.Power;
//
///**
// * Created by Michael von Wenckstern on 31.05.2016.
// */
//public class PowerConsumptionSymbol extends TagSymbol {
// public static final PowerConsumptionKind KIND = PowerConsumptionKind.INSTANCE;
//
// /**
// * is marker symbol so it has no value by itself
// */
// public PowerConsumptionSymbol(double value, Power unit) {
// // true to set that it is marked
// super(KIND, value, unit);
// }
//
// public double getNumber() {
// return getValue(0);
// }
//
// public Power getUnit() {
// return getValue(1);
// }
//
// @Override
// public String toString() {
// return IndentPrinter.groups("PowerConsumption = {0} {1}")
// .params(getNumber(), getUnit())
// .toString();
// }
//
// public static class PowerConsumptionKind extends TagKind {
// public static final PowerConsumptionKind INSTANCE = new PowerConsumptionKind();
//
// protected PowerConsumptionKind() {
// }
// }
//}
/**
*
* ******************************************************************************
* 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.embeddedmontiarc.tag;//package de.monticore.lang.montiarc.tag;
//
//import java.util.Optional;
//
//import de.monticore.lang.montiarc.montiarc._symboltable.ExpandedComponentInstanceSymbol;
//import de.monticore.lang.montiarc.tagging._ast.ASTNameScope;
//import de.monticore.lang.montiarc.tagging._ast.ASTScope;
//import de.monticore.lang.montiarc.tagging._ast.ASTTag;
//import de.monticore.lang.montiarc.tagging._ast.ASTTagElement;
//import de.monticore.lang.montiarc.tagging._ast.ASTTaggingUnit;
//import de.monticore.lang.montiarc.tagging._ast.ASTTargetElement;
//import de.monticore.lang.montiarc.tagging._ast.ASTUnitTagValue;
//import de.monticore.lang.montiarc.tagging._ast.ASTValuedTag;
//import de.monticore.lang.montiarc.tagging._symboltable.TagSymbolCreator;
//import de.monticore.lang.montiarc.unit.Unit;
//import de.monticore.lang.montiarc.unit.Units;
//import de.monticore.literals.literals._ast.ASTDoubleLiteral;
//import de.monticore.literals.literals._ast.ASTFloatLiteral;
//import de.monticore.literals.literals._ast.ASTIntLiteral;
//import de.monticore.literals.literals._ast.ASTLongLiteral;
//import de.monticore.literals.literals._ast.ASTNumericLiteral;
//import de.monticore.literals.literals._ast.ASTSignedDoubleLiteral;
//import de.monticore.literals.literals._ast.ASTSignedFloatLiteral;
//import de.monticore.literals.literals._ast.ASTSignedIntLiteral;
//import de.monticore.literals.literals._ast.ASTSignedLongLiteral;
//import de.monticore.symboltable.Scope;
//import de.se_rwth.commons.Joiners;
//import de.se_rwth.commons.logging.Log;
//
///**
// * Created by Michael von Wenckstern on 31.05.2016.
// * only for this tests --> this should be generated using the tag schema
// */
//public class PowerConsumptionSymbolCreator implements TagSymbolCreator {
// // TODO ASTNumericLiteral should have a getValue() method
// protected static double getValue(ASTNumericLiteral numericLiteral) {
// if (numericLiteral instanceof ASTDoubleLiteral) {
// return ((ASTDoubleLiteral) numericLiteral).getValue();
// }
// else if (numericLiteral instanceof ASTSignedDoubleLiteral) {
// return ((ASTSignedDoubleLiteral) numericLiteral).getValue();
// }
// else if (numericLiteral instanceof ASTIntLiteral) {
// return ((ASTIntLiteral) numericLiteral).getValue();
// }
// else if (numericLiteral instanceof ASTSignedIntLiteral) {
// return ((ASTSignedIntLiteral) numericLiteral).getValue();
// }
// else if (numericLiteral instanceof ASTFloatLiteral) {
// return ((ASTFloatLiteral) numericLiteral).getValue();
// }
// else if (numericLiteral instanceof ASTSignedFloatLiteral) {
// return ((ASTSignedFloatLiteral) numericLiteral).getValue();
// }
// else if (numericLiteral instanceof ASTLongLiteral) {
// return ((ASTLongLiteral) numericLiteral).getValue();
// }
// else if (numericLiteral instanceof ASTSignedLongLiteral) {
// return ((ASTSignedLongLiteral) numericLiteral).getValue();
// }
// else {
// throw new Error("unexpected ASTNumericLiteral: " + numericLiteral.getClass());
// }
// }
//
// public static Scope getGlobalScope(final Scope scope) {
// Scope s = scope;
// while (s.getEnclosingScope().isPresent()) {
// s = s.getEnclosingScope().get();
// }
// return s;
// }
//
// public void create(ASTTaggingUnit unit, Scope gs) {
// if (unit.getQualifiedNames().stream()
// .map(q -> q.toString())
// .filter(n -> n.endsWith("PowerConsumptionTagSchema"))
// .count() == 0) {
// return; // the tagging model is not conform to the traceability tagging schema
// }
// final String packageName = Joiners.DOT.join(unit.getPackage());
// final String rootCmp = // if-else does not work b/c of final (required by streams)
// (unit.getTagBody().getTargetModel().isPresent()) ?
// Joiners.DOT.join(packageName, ((ASTNameScope) unit.getTagBody().getTargetModel().get())
// .getQualifiedName().toString()) :
// packageName;
//
// for (final ASTTagElement element : unit.getTagBody().getTagElements()) {
// if (element instanceof ASTTargetElement) {
// ((ASTTargetElement) element).getTags().stream()
// .filter(t -> t.getName().equals("PowerConsumption"))
// .filter(this::checkASTTagKind)
// .map(t -> (ASTValuedTag) t)
// .filter(this::checkValueKind)
// .map(v -> (ASTUnitTagValue) v.getTagValue())
// .filter(this::checkUnitKind)
// .forEachOrdered(v ->
// ((ASTTargetElement) element).getScopes().stream()
// .filter(this::checkScope)
// .map(s -> (ASTNameScope) s)
// .map(s -> getGlobalScope(gs).<ExpandedComponentInstanceSymbol>
// resolveDown(Joiners.DOT.join(rootCmp, // resolve down does not try to reload symbol
// s.getQualifiedName().toString()), ExpandedComponentInstanceSymbol.KIND))
// .filter(Optional::isPresent)
// .map(Optional::get)
// .forEachOrdered(s -> s.addTag(new PowerConsumptionSymbol(getValue(v.getNumericLiteral()),
// Units.getPower(v.getUnit()).get())))
// );
// }
// }
// }
//
// protected boolean checkUnitKind(ASTUnitTagValue unit) {
// if (Units.getPower(unit.getUnit()).isPresent()) {
// return true;
// }
// Optional<Unit> u = Units.getUnit(unit.getUnit());
// if(u.isPresent()) {
// Log.error(String.format("0xTEST1 Invalid unit kind: '%s' of unit '%s'. ComponentLayout expects as unit kind 'Power'.",
// u.get().getKind(), u.get().toString()), unit.get_SourcePositionStart(), Units.getAvailablePowerUnits());
// return false;
// }
// Log.error(String.format("0xTEST2 Unit is unknown: '%s'.", unit.getUnit()), unit.get_SourcePositionStart());
// return false;
// }
//
// protected boolean checkASTTagKind(ASTTag tag) {
// if (tag.getTagKind().equals("ValuedTag")) {
// return true;
// }
// Log.error(String.format("0xTEST3 Invalid tag kind: '%s'. ComponentLayout expects as tag kind 'ValuedTag'.",
// tag.getTagKind()), tag.get_SourcePositionStart());
// return false;
// }
//
// protected boolean checkValueKind(ASTValuedTag tag) {
// if (tag.getTagValue() != null &&
// tag.getTagValue().getValueKind().equals("UnitValue")) {
// return true;
// }
// Log.error(String.format("0xTEST4 Invalid value kind: '%s'. ComponentLayout expects as tag kind 'UnitValue'.",
// tag.getTagValue() != null ? tag.getTagValue().getValueKind() : "tag value is zero"),
// tag.get_SourcePositionStart());
// return false;
// }
//
// protected boolean checkScope(ASTScope scope) {
// if (scope.getScopeKind().equals("NameScope")) {
// return true;
// }
// Log.error(String.format("0xTEST5 Invalid scope kind: '%s'. ComponentLayout expects as scope kind 'NameScope'.",
// scope.getScopeKind()), scope.get_SourcePositionStart());
// return false;
// }
//}
/**
*
* ******************************************************************************
* 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.embeddedmontiarc.tag.drawing;
public class ComponentLayoutSymbol extends DrawableSymbol {
public static final ComponentLayoutKind KIND = ComponentLayoutKind.INSTANCE;
public ComponentLayoutSymbol(int id, int x, int y, int width, int height,
int layoutPosition, boolean isOnTop, int reservedHorizontalSpace) {
super(KIND, id, x, y);
addValues(width, height, layoutPosition, isOnTop, reservedHorizontalSpace);
}
protected ComponentLayoutSymbol(ComponentLayoutKind kind, int id, int x, int y, int width, int height,
int layoutPosition, boolean isOnTop, int reservedHorizontalSpace) {
super(kind, id, x, y);
addValues(width, height, layoutPosition, isOnTop, reservedHorizontalSpace);
}
public int getWidth() {
return getValue(3);
}
public int getHeight() {
return getValue(4);
}
public int getLayoutPosition() {
return getValue(5);
}
public boolean isOnTop() {
return getValue(6);
}
public int getReservedHorizontalSpace() {
return getValue(7);
}
@Override
public String toString() {
return String.format(
"componentLayout = { id=%d, x=%d, y=%d, width=%d, height=%d, \n" +
" layoutPosition=%d, %s reservedHorizontalSpace=%d }",
getId(), getX(), getY(), getWidth(), getHeight(),
getLayoutPosition(), isOnTop() ? "isOnTop," : "", getReservedHorizontalSpace());
}
public static class ComponentLayoutKind extends DrawableKind {
public static final ComponentLayoutKind INSTANCE = new ComponentLayoutKind();
protected ComponentLayoutKind() {
}
}
}
/**
*
* ******************************************************************************
* 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.embeddedmontiarc.tag.drawing;
import de.monticore.lang.montiarc.montiarc._symboltable.ExpandedComponentInstanceSymbol;
import de.monticore.lang.montiarc.tagging._ast.ASTNameScope;
import de.monticore.lang.montiarc.tagging._ast.ASTScope;
import de.monticore.lang.montiarc.tagging._ast.ASTTag;
import de.monticore.lang.montiarc.tagging._ast.ASTTaggingUnit;
import de.monticore.lang.montiarc.tagging._symboltable.TagSymbolCreator;
import de.monticore.symboltable.Scope;
import de.se_rwth.commons.Joiners;
import de.se_rwth.commons.logging.Log;
import java.util.Optional;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* Created by MichaelvonWenckstern on 04.06.2016.
*/
public class ComponentLayoutSymbolCreator implements TagSymbolCreator {
/**
* regular expression pattern:
* id = {id} , pos = ({x} , {y}) , size = ({width} , {height}) ,
* layoutPosition = {layoutPosition} , reservedHorizontalSpace = {reservedHorizontalSpace}
* ( , isOnTop)?
* to test the pattern just enter:
* \s*id\s*=\s*([1-9]\d*)\s*,\s*pos\s*=\s*\(([1-9]\d*)\s*,\s*([1-9]\d*)\)\s*,
* \s*size\s*=\s*\(([1-9]\d*)\s*,\s*([1-9]\d*)\)\s*,\s*layoutPosition\s*=
* \s*([1-9]\d*)\s*,\s*reservedHorizontalSpace\s*=\s*([1-9]\d*)\s*(?:,\s*(isOnTop))?\s*
* at http://www.regexplanet.com/advanced/java/index.html
*/
public static final Pattern pattern = Pattern.compile(
"\\{\\s*id\\s*=\\s*([1-9]\\d*)\\s*,\\s*pos\\s*=\\s*\\(([1-9]\\d*)\\s*,\\s*"
+ "([1-9]\\d*)\\)\\s*,\\s*size\\s*=\\s*\\(([1-9]\\d*)\\s*,\\s*([1-9]"
+ "\\d*)\\)\\s*,\\s*layoutPosition\\s*=\\s*([1-9]\\d*)\\s*,\\s*"
+ "reservedHorizontalSpace\\s*=\\s*([1-9]\\d*)\\s*(?:,\\s*(isOnTop))?\\s*\\}");
public static Scope getGlobalScope(final Scope scope) {
Scope s = scope;
while (s.getEnclosingScope().isPresent()) {
s = s.getEnclosingScope().get();
}