use of org.yakindu.base.base.NamedElement in project statecharts by Yakindu.
the class SCTDebugElement method fullQfn.
public String fullQfn(NamedElement element) {
List<String> qfnFragments = new ArrayList<String>();
qfnFragments.add(element.getName());
EObject current = element;
while (current.eContainer() != EcoreUtil.getRootContainer(current)) {
current = current.eContainer();
if (current instanceof NamedElement) {
String name = ((NamedElement) current).getName();
if (name != null) {
qfnFragments.add(name.replaceAll(" ", ""));
} else {
qfnFragments.add("<name>");
}
}
}
Collections.reverse(qfnFragments);
StringBuilder sb = new StringBuilder();
sb.append(element.getName() != null ? element.getName() : element.eClass().getName());
sb.append(" (");
String sep = "";
for (String s : qfnFragments) {
sb.append(sep).append(s);
sep = ".";
}
sb.append(")");
sb.append(" resource: ");
sb.append(element.eResource().getURI().lastSegment());
return sb.toString();
}
use of org.yakindu.base.base.NamedElement in project statecharts by Yakindu.
the class SheetLabelProvider method getText.
public String getText(Object element) {
element = unwrap(element);
if (element instanceof IGraphicalEditPart) {
EObject semanticElement = ((IGraphicalEditPart) element).resolveSemanticElement();
if (semanticElement == null) {
View view = ((IGraphicalEditPart) element).getNotationView();
return view.getType();
} else {
IElementType elementType = ElementTypeRegistry.getInstance().getElementType(semanticElement);
StringBuilder builder = new StringBuilder();
builder.append(elementType.getDisplayName());
if (semanticElement instanceof NamedElement && ((NamedElement) semanticElement).getName() != null) {
builder.append(' ');
builder.append(((NamedElement) semanticElement).getName());
}
return builder.toString();
}
}
return null;
}
use of org.yakindu.base.base.NamedElement in project statecharts by Yakindu.
the class Assert method assertAssignment.
public static void assertAssignment(Step step, String variableName, AssignmentOperator operator, String value) {
assertClass(Execution.class, step);
Execution exec = (Execution) step;
assertTrue(exec.getStatement() instanceof AssignmentExpression);
AssignmentExpression assignment = (AssignmentExpression) exec.getStatement();
assertEquals(operator, assignment.getOperator());
Expression varRef = assignment.getVarRef();
if (varRef instanceof ElementReferenceExpression) {
ElementReferenceExpression elementRef = (ElementReferenceExpression) varRef;
assertEquals(variableName, ((NamedElement) elementRef.getReference()).getName());
} else if (varRef instanceof FeatureCall) {
FeatureCall call = (FeatureCall) varRef;
assertEquals(variableName, ((NamedElement) call.getFeature()).getName());
}
assertExpressionEquals(value, assignment.getExpression());
}
use of org.yakindu.base.base.NamedElement in project statecharts by Yakindu.
the class STextJavaValidator method checkRaisingExpressionEvent.
@Check(CheckType.FAST)
public void checkRaisingExpressionEvent(EventRaisingExpression expression) {
EObject element = unwrap(expression.getEvent());
if (element != null && (!(element instanceof Event))) {
String elementName = "";
if (element instanceof NamedElement) {
elementName = ((NamedElement) element).getName();
}
error(String.format("'%s' is not an event.", elementName), StextPackage.Literals.EVENT_RAISING_EXPRESSION__EVENT, -1);
}
}
use of org.yakindu.base.base.NamedElement in project statecharts by Yakindu.
the class STextJavaValidator method checkValueOfNoEvent.
@Check(CheckType.FAST)
public void checkValueOfNoEvent(EventValueReferenceExpression exp) {
Expression eventExpr = exp.getValue();
EObject element = null;
if (eventExpr instanceof ElementReferenceExpression) {
element = ((ElementReferenceExpression) eventExpr).getReference();
} else if (eventExpr instanceof FeatureCall) {
element = ((FeatureCall) eventExpr).getFeature();
}
if (element != null && (!(element instanceof Event))) {
String elementName = "";
if (element instanceof NamedElement) {
elementName = "'" + ((NamedElement) element).getName() + "' ";
}
error(elementName + "is no event.", StextPackage.Literals.EVENT_VALUE_REFERENCE_EXPRESSION__VALUE, 0, VALUE_OF_REQUIRES_EVENT);
}
}
Aggregations