Search in sources :

Example 1 with Property

use of org.yakindu.base.types.Property in project statecharts by Yakindu.

the class ExpressionsJavaValidator method checkAssignmentToFinalVariable.

@Check(CheckType.FAST)
public void checkAssignmentToFinalVariable(AssignmentExpression exp) {
    Expression varRef = exp.getVarRef();
    EObject referencedObject = null;
    if (varRef instanceof FeatureCall)
        referencedObject = ((FeatureCall) varRef).getFeature();
    else if (varRef instanceof ElementReferenceExpression)
        referencedObject = ((ElementReferenceExpression) varRef).getReference();
    if (referencedObject instanceof Property) {
        if (((Property) referencedObject).isConst()) {
            error(ERROR_ASSIGNMENT_TO_CONST_MSG, ExpressionsPackage.Literals.ASSIGNMENT_EXPRESSION__VAR_REF, ERROR_ASSIGNMENT_TO_CONST_CODE);
        }
    }
}
Also used : PostFixUnaryExpression(org.yakindu.base.expressions.expressions.PostFixUnaryExpression) AssignmentExpression(org.yakindu.base.expressions.expressions.AssignmentExpression) Expression(org.yakindu.base.expressions.expressions.Expression) ArgumentExpression(org.yakindu.base.expressions.expressions.ArgumentExpression) ElementReferenceExpression(org.yakindu.base.expressions.expressions.ElementReferenceExpression) EObject(org.eclipse.emf.ecore.EObject) FeatureCall(org.yakindu.base.expressions.expressions.FeatureCall) ElementReferenceExpression(org.yakindu.base.expressions.expressions.ElementReferenceExpression) Property(org.yakindu.base.types.Property) Check(org.eclipse.xtext.validation.Check)

Example 2 with Property

use of org.yakindu.base.types.Property in project statecharts by Yakindu.

the class AbstractTypeSystemTest method createProperty.

protected Property createProperty(String name) {
    Property property = TypesFactory.eINSTANCE.createProperty();
    property.setName(name);
    return property;
}
Also used : Property(org.yakindu.base.types.Property)

Example 3 with Property

use of org.yakindu.base.types.Property in project statecharts by Yakindu.

the class SGenScopeProvider method getElementReferenceScope.

protected IScope getElementReferenceScope(EObject context) {
    GeneratorModel generatorModel = (GeneratorModel) EcoreUtil.getRootContainer(context);
    EList<PropertyDefinition> properties = generatorModel.getProperties();
    List<Property> all = buildInDeclarations.getDeclarations();
    return Scopes.scopeFor(properties, Scopes.scopeFor(all));
}
Also used : GeneratorModel(org.yakindu.sct.model.sgen.GeneratorModel) PropertyDefinition(org.yakindu.sct.model.sgen.PropertyDefinition) Property(org.yakindu.base.types.Property)

Example 4 with Property

use of org.yakindu.base.types.Property in project statecharts by Yakindu.

the class RenameRefactoringTest method testRenameVariable.

@Test
public void testRenameVariable() {
    Statechart initial = models.loadStatechartFromResource(RENAMING + INITIAL_STATECHART);
    // get element to rename
    Property someVariable = null;
    EList<Scope> scopes = initial.getScopes();
    for (Scope scope : scopes) {
        if (scope instanceof InterfaceScope) {
            InterfaceScope iScope = (InterfaceScope) scope;
            someVariable = iScope.getVariables().get(0);
        }
    }
    Statechart expected = models.loadStatechartFromResource(RENAMING + "AfterRenamingVariable.sct");
    testRenaming(initial, expected, someVariable, "someNewVariableName");
}
Also used : Scope(org.yakindu.sct.model.sgraph.Scope) InterfaceScope(org.yakindu.sct.model.stext.stext.InterfaceScope) Statechart(org.yakindu.sct.model.sgraph.Statechart) InterfaceScope(org.yakindu.sct.model.stext.stext.InterfaceScope) Property(org.yakindu.base.types.Property) Test(org.junit.Test) RefactoringTest(org.yakindu.sct.refactoring.refactor.RefactoringTest)

Example 5 with Property

use of org.yakindu.base.types.Property in project statecharts by Yakindu.

the class PropertyItemProvider method getText.

/**
 * This returns the label text for the adapted class.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated NOT
 */
@Override
public String getText(Object object) {
    Property variable = (Property) object;
    StringBuilder builder = new StringBuilder();
    if (variable.getName() != null) {
        builder.append(variable.getName());
        builder.append(" : ");
    }
    if (variable.getType() != null)
        builder.append(variable.getType().getName());
    else
        builder.append("unknown");
    return builder.toString();
}
Also used : Property(org.yakindu.base.types.Property)

Aggregations

Property (org.yakindu.base.types.Property)6 ArrayList (java.util.ArrayList)1 EObject (org.eclipse.emf.ecore.EObject)1 Check (org.eclipse.xtext.validation.Check)1 Test (org.junit.Test)1 ArgumentExpression (org.yakindu.base.expressions.expressions.ArgumentExpression)1 AssignmentExpression (org.yakindu.base.expressions.expressions.AssignmentExpression)1 ElementReferenceExpression (org.yakindu.base.expressions.expressions.ElementReferenceExpression)1 Expression (org.yakindu.base.expressions.expressions.Expression)1 FeatureCall (org.yakindu.base.expressions.expressions.FeatureCall)1 PostFixUnaryExpression (org.yakindu.base.expressions.expressions.PostFixUnaryExpression)1 PrimitiveType (org.yakindu.base.types.PrimitiveType)1 Type (org.yakindu.base.types.Type)1 GeneratorModel (org.yakindu.sct.model.sgen.GeneratorModel)1 PropertyDefinition (org.yakindu.sct.model.sgen.PropertyDefinition)1 Scope (org.yakindu.sct.model.sgraph.Scope)1 Statechart (org.yakindu.sct.model.sgraph.Statechart)1 InterfaceScope (org.yakindu.sct.model.stext.stext.InterfaceScope)1 RefactoringTest (org.yakindu.sct.refactoring.refactor.RefactoringTest)1