Search in sources :

Example 11 with Statechart

use of org.yakindu.sct.model.sgraph.Statechart in project statecharts by Yakindu.

the class STextGlobalScopeProvider method getScope.

public IScope getScope(Resource context, EReference reference, Predicate<IEObjectDescription> filter) {
    IScope parentScope = super.getScope(context, reference, filter);
    parentScope = new SimpleScope(parentScope, filterPropertiesOfLibrary(context, reference, filter).getAllElements());
    final Statechart statechart = getStatechart(context);
    parentScope = new TypeSystemAwareScope(parentScope, typeSystem, qualifiedNameProvider, reference.getEReferenceType());
    IScope result = new FilteringScope(parentScope, new Predicate<IEObjectDescription>() {

        @Override
        public boolean apply(IEObjectDescription input) {
            String userData = input.getUserData(DomainRegistry.DOMAIN_ID);
            if (userData == null)
                return true;
            return statechart.getDomainID().equals(userData);
        }
    });
    result = filterAnnotations(reference, result);
    return new FilteringScope(result, input -> {
        String isVisible = input.getUserData(TypedResourceDescriptionStrategy.IS_VISIBLE_TYPE);
        return isVisible == null || Boolean.valueOf(isVisible);
    });
}
Also used : SimpleScope(org.eclipse.xtext.scoping.impl.SimpleScope) IScope(org.eclipse.xtext.scoping.IScope) Statechart(org.yakindu.sct.model.sgraph.Statechart) FilteringScope(org.eclipse.xtext.scoping.impl.FilteringScope) IEObjectDescription(org.eclipse.xtext.resource.IEObjectDescription)

Example 12 with Statechart

use of org.yakindu.sct.model.sgraph.Statechart in project statecharts by Yakindu.

the class STextScopeProvider method scope_ActiveStateReferenceExpression_value.

public IScope scope_ActiveStateReferenceExpression_value(EObject context, EReference reference) {
    Statechart statechart = getStatechart(context);
    if (statechart == null)
        return IScope.NULLSCOPE;
    List<State> allStates = EcoreUtil2.getAllContentsOfType(statechart, State.class);
    IScope scope = Scopes.scopeFor(allStates, nameProvider, IScope.NULLSCOPE);
    return new ImportScope(getActiveStateNormalizer(context), scope, new EObjectDescriptionLookUp(Lists.newArrayList(scope.getAllElements())), reference.getEReferenceType(), false);
}
Also used : EObjectDescriptionLookUp(org.eclipse.xtext.resource.impl.EObjectDescriptionLookUp) State(org.yakindu.sct.model.sgraph.State) ImportScope(org.eclipse.xtext.scoping.impl.ImportScope) Statechart(org.yakindu.sct.model.sgraph.Statechart) IScope(org.eclipse.xtext.scoping.IScope)

Example 13 with Statechart

use of org.yakindu.sct.model.sgraph.Statechart in project statecharts by Yakindu.

the class RenameElementHandler method findElementForFakeInStatechart.

private NamedElement findElementForFakeInStatechart(NamedElement fakeElement) {
    Resource resource = fakeElement.eResource();
    // only do something if element is really from fake resource
    if (resource instanceof LazyLinkingResource) {
        Statechart sct = getStatechartFromFakeResource((LazyLinkingResource) resource);
        EList<Scope> scopes = sct.getScopes();
        for (Scope scope : scopes) {
            // check all declarations
            EList<Declaration> declarations = scope.getDeclarations();
            for (Declaration decl : declarations) {
                if (decl.eClass().getName().equals(fakeElement.eClass().getName()) && decl.getName().equals(fakeElement.getName())) {
                    return decl;
                }
            }
            // check scope itself it is a named one
            if (scope instanceof NamedElement) {
                NamedElement namedScope = (NamedElement) scope;
                if (namedScope.eClass().getName().equals(fakeElement.eClass().getName()) && namedScope.getName().equals(fakeElement.getName())) {
                    return namedScope;
                }
            }
        }
    }
    return fakeElement;
}
Also used : Scope(org.yakindu.sct.model.sgraph.Scope) LazyLinkingResource(org.eclipse.xtext.linking.lazy.LazyLinkingResource) LazyLinkingResource(org.eclipse.xtext.linking.lazy.LazyLinkingResource) Resource(org.eclipse.emf.ecore.resource.Resource) Statechart(org.yakindu.sct.model.sgraph.Statechart) Declaration(org.yakindu.base.types.Declaration) NamedElement(org.yakindu.base.base.NamedElement)

Example 14 with Statechart

use of org.yakindu.sct.model.sgraph.Statechart in project statecharts by Yakindu.

the class AbstractSCTLaunchConfigurationDelegate method launch.

public void launch(ILaunchConfiguration configuration, String mode, ILaunch launch, IProgressMonitor monitor) throws CoreException {
    String filename = configuration.getAttribute(FILE_NAME, DEFAULT_FILE_NAME);
    Statechart statechart = loadStatechart(filename);
    SCTDebugTarget target = createDebugTarget(launch, statechart);
    launch.addDebugTarget(target);
    try {
        target.init();
        target.start();
    } catch (InitializationException e) {
    // handled in AbstractExecutionFlowSimulationEngine
    }
}
Also used : SCTDebugTarget(org.yakindu.sct.simulation.core.debugmodel.SCTDebugTarget) Statechart(org.yakindu.sct.model.sgraph.Statechart)

Example 15 with Statechart

use of org.yakindu.sct.model.sgraph.Statechart in project statecharts by Yakindu.

the class ResourceUtil method loadStatechart.

public static Statechart loadStatechart(String filename) {
    Resource resource = loadResource(filename);
    Statechart statechart = (Statechart) EcoreUtil.getObjectByType(resource.getContents(), SGraphPackage.Literals.STATECHART);
    return statechart;
}
Also used : Resource(org.eclipse.emf.ecore.resource.Resource) Statechart(org.yakindu.sct.model.sgraph.Statechart)

Aggregations

Statechart (org.yakindu.sct.model.sgraph.Statechart)132 Test (org.junit.Test)89 ExecutionFlow (org.yakindu.sct.model.sexec.ExecutionFlow)65 SGraphTestFactory._createStatechart (org.yakindu.sct.model.sgraph.test.util.SGraphTestFactory._createStatechart)63 Region (org.yakindu.sct.model.sgraph.Region)59 State (org.yakindu.sct.model.sgraph.State)59 ExecutionState (org.yakindu.sct.model.sexec.ExecutionState)57 SGraphTestFactory._createRegion (org.yakindu.sct.model.sgraph.test.util.SGraphTestFactory._createRegion)57 SGraphTestFactory._createState (org.yakindu.sct.model.sgraph.test.util.SGraphTestFactory._createState)51 VariableDefinition (org.yakindu.sct.model.stext.stext.VariableDefinition)48 StextTestFactory._createInterfaceScope (org.yakindu.sct.model.stext.test.util.StextTestFactory._createInterfaceScope)48 InterfaceScope (org.yakindu.sct.model.stext.stext.InterfaceScope)47 StextTestFactory._createVariableDefinition (org.yakindu.sct.model.stext.test.util.StextTestFactory._createVariableDefinition)47 Sequence (org.yakindu.sct.model.sexec.Sequence)40 Entry (org.yakindu.sct.model.sgraph.Entry)30 SCTTestUtil.findState (org.yakindu.sct.model.sexec.transformation.test.SCTTestUtil.findState)29 SGraphTestFactory._createEntry (org.yakindu.sct.model.sgraph.test.util.SGraphTestFactory._createEntry)29 Reaction (org.yakindu.sct.model.sexec.Reaction)25 Scope (org.yakindu.sct.model.sgraph.Scope)25 EnterState (org.yakindu.sct.model.sexec.EnterState)21