Search in sources :

Example 6 with NamedElement

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();
}
Also used : EObject(org.eclipse.emf.ecore.EObject) ArrayList(java.util.ArrayList) NamedElement(org.yakindu.base.base.NamedElement)

Example 7 with NamedElement

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;
}
Also used : IGraphicalEditPart(org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart) IElementType(org.eclipse.gmf.runtime.emf.type.core.IElementType) EObject(org.eclipse.emf.ecore.EObject) View(org.eclipse.gmf.runtime.notation.View) NamedElement(org.yakindu.base.base.NamedElement)

Example 8 with NamedElement

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());
}
Also used : Execution(org.yakindu.sct.model.sexec.Execution) AssignmentExpression(org.yakindu.base.expressions.expressions.AssignmentExpression) AssignmentExpression(org.yakindu.base.expressions.expressions.AssignmentExpression) Expression(org.yakindu.base.expressions.expressions.Expression) PrimitiveValueExpression(org.yakindu.base.expressions.expressions.PrimitiveValueExpression) ElementReferenceExpression(org.yakindu.base.expressions.expressions.ElementReferenceExpression) ElementReferenceExpression(org.yakindu.base.expressions.expressions.ElementReferenceExpression) FeatureCall(org.yakindu.base.expressions.expressions.FeatureCall) NamedElement(org.yakindu.base.base.NamedElement)

Example 9 with NamedElement

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);
    }
}
Also used : EObject(org.eclipse.emf.ecore.EObject) ExitEvent(org.yakindu.sct.model.stext.stext.ExitEvent) EntryEvent(org.yakindu.sct.model.stext.stext.EntryEvent) Event(org.yakindu.base.types.Event) NamedElement(org.yakindu.base.base.NamedElement) Check(org.eclipse.xtext.validation.Check)

Example 10 with NamedElement

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);
    }
}
Also used : EventRaisingExpression(org.yakindu.sct.model.stext.stext.EventRaisingExpression) Expression(org.yakindu.base.expressions.expressions.Expression) AssignmentExpression(org.yakindu.base.expressions.expressions.AssignmentExpression) EventValueReferenceExpression(org.yakindu.sct.model.stext.stext.EventValueReferenceExpression) ElementReferenceExpression(org.yakindu.base.expressions.expressions.ElementReferenceExpression) PostFixUnaryExpression(org.yakindu.base.expressions.expressions.PostFixUnaryExpression) EObject(org.eclipse.emf.ecore.EObject) ExitEvent(org.yakindu.sct.model.stext.stext.ExitEvent) EntryEvent(org.yakindu.sct.model.stext.stext.EntryEvent) Event(org.yakindu.base.types.Event) ElementReferenceExpression(org.yakindu.base.expressions.expressions.ElementReferenceExpression) FeatureCall(org.yakindu.base.expressions.expressions.FeatureCall) NamedElement(org.yakindu.base.base.NamedElement) Check(org.eclipse.xtext.validation.Check)

Aggregations

NamedElement (org.yakindu.base.base.NamedElement)12 EObject (org.eclipse.emf.ecore.EObject)8 ElementReferenceExpression (org.yakindu.base.expressions.expressions.ElementReferenceExpression)4 FeatureCall (org.yakindu.base.expressions.expressions.FeatureCall)4 Check (org.eclipse.xtext.validation.Check)3 Event (org.yakindu.base.types.Event)3 EntryEvent (org.yakindu.sct.model.stext.stext.EntryEvent)3 ExitEvent (org.yakindu.sct.model.stext.stext.ExitEvent)3 AssignmentExpression (org.yakindu.base.expressions.expressions.AssignmentExpression)2 Expression (org.yakindu.base.expressions.expressions.Expression)2 ArrayList (java.util.ArrayList)1 Resource (org.eclipse.emf.ecore.resource.Resource)1 IGraphicalEditPart (org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart)1 IElementType (org.eclipse.gmf.runtime.emf.type.core.IElementType)1 View (org.eclipse.gmf.runtime.notation.View)1 InputDialog (org.eclipse.jface.dialogs.InputDialog)1 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)1 IWorkbenchWindow (org.eclipse.ui.IWorkbenchWindow)1 LazyLinkingResource (org.eclipse.xtext.linking.lazy.LazyLinkingResource)1 PostFixUnaryExpression (org.yakindu.base.expressions.expressions.PostFixUnaryExpression)1