Search in sources :

Example 1 with InternalScope

use of org.yakindu.sct.model.stext.stext.InternalScope in project statecharts by Yakindu.

the class STextProposalProvider method completeKeyword.

/**
 * Validates if a keyword should be viewed by the proposal view.
 *
 * Builds dependent on the ContentAssistContext a list with keywords which
 * shouldn't be displayed by the proposal view.
 */
@Override
public void completeKeyword(Keyword keyword, ContentAssistContext contentAssistContext, ICompletionProposalAcceptor acceptor) {
    List<Keyword> suppressKeywords = new ArrayList<Keyword>();
    EObject rootModel = contentAssistContext.getRootModel();
    if (rootModel instanceof TransitionSpecification) {
        suppressKeywords(suppressKeywords, (TransitionSpecification) rootModel);
    } else if (rootModel instanceof SimpleScope) {
        suppressKeywords(suppressKeywords, (SimpleScope) rootModel);
    } else if (rootModel instanceof StatechartSpecification) {
        suppressKeywords(suppressKeywords, (StatechartSpecification) rootModel);
    }
    EObject currentModel = contentAssistContext.getCurrentModel();
    if (currentModel instanceof InterfaceScope) {
        suppressKeywords(suppressKeywords, (InterfaceScope) currentModel);
    }
    if (currentModel instanceof FeatureCall) {
        suppressKeywords(suppressKeywords, (FeatureCall) currentModel);
    }
    if (currentModel instanceof ElementReferenceExpression) {
        suppressKeywords(suppressKeywords, (ElementReferenceExpression) currentModel);
    }
    if (currentModel instanceof InternalScope) {
        suppressKeywords(suppressKeywords, (InternalScope) currentModel);
    }
    if (!suppressKeywords.contains(keyword)) {
        super.completeKeyword(keyword, contentAssistContext, new AcceptorDelegate(acceptor));
    }
}
Also used : Keyword(org.eclipse.xtext.Keyword) SimpleScope(org.yakindu.sct.model.stext.stext.SimpleScope) EObject(org.eclipse.emf.ecore.EObject) ArrayList(java.util.ArrayList) InternalScope(org.yakindu.sct.model.stext.stext.InternalScope) TransitionSpecification(org.yakindu.sct.model.stext.stext.TransitionSpecification) StatechartSpecification(org.yakindu.sct.model.stext.stext.StatechartSpecification) InterfaceScope(org.yakindu.sct.model.stext.stext.InterfaceScope) FeatureCall(org.yakindu.base.expressions.expressions.FeatureCall) ElementReferenceExpression(org.yakindu.base.expressions.expressions.ElementReferenceExpression)

Example 2 with InternalScope

use of org.yakindu.sct.model.stext.stext.InternalScope in project statecharts by Yakindu.

the class ModelSequencertDeclarationsTest method testMapEmptyInternalScope.

/**
 * An InternalScope must be mapped to an InternalScope.
 */
@Test
public void testMapEmptyInternalScope() {
    InternalScope scope = _createInternalScope(null);
    Scope _scope = structureMapping.mapScope(scope);
    assertTrue(_scope instanceof InternalScope);
}
Also used : StextTestFactory._createInternalScope(org.yakindu.sct.model.stext.test.util.StextTestFactory._createInternalScope) InterfaceScope(org.yakindu.sct.model.stext.stext.InterfaceScope) StextTestFactory._createInterfaceScope(org.yakindu.sct.model.stext.test.util.StextTestFactory._createInterfaceScope) Scope(org.yakindu.sct.model.sgraph.Scope) InternalScope(org.yakindu.sct.model.stext.stext.InternalScope) StextTestFactory._createInternalScope(org.yakindu.sct.model.stext.test.util.StextTestFactory._createInternalScope) InternalScope(org.yakindu.sct.model.stext.stext.InternalScope) Test(org.junit.Test)

Example 3 with InternalScope

use of org.yakindu.sct.model.stext.stext.InternalScope in project statecharts by Yakindu.

the class StatechartObjectViewerFilter method select.

@Override
public boolean select(Viewer viewer, Object parentElement, Object element) {
    if (element instanceof DomainNavigatorItem) {
        DomainNavigatorItem navigatorItem = (DomainNavigatorItem) element;
        EObject modelElement = navigatorItem.getEObject();
        if (modelElement instanceof Diagram) {
            return false;
        }
        if (modelElement instanceof Trigger) {
            return false;
        }
        if (modelElement instanceof InternalScope || modelElement instanceof InterfaceScope) {
            return true;
        }
        if (modelElement instanceof Scope) {
            return false;
        }
        if (modelElement instanceof LocalReaction) {
            return false;
        }
        if (modelElement instanceof ReactionEffect) {
            return false;
        }
        if (modelElement instanceof Expression) {
            return false;
        }
    }
    return true;
}
Also used : LocalReaction(org.yakindu.sct.model.stext.stext.LocalReaction) Trigger(org.yakindu.sct.model.sgraph.Trigger) Scope(org.yakindu.sct.model.sgraph.Scope) InterfaceScope(org.yakindu.sct.model.stext.stext.InterfaceScope) InternalScope(org.yakindu.sct.model.stext.stext.InternalScope) Expression(org.yakindu.base.expressions.expressions.Expression) EObject(org.eclipse.emf.ecore.EObject) InternalScope(org.yakindu.sct.model.stext.stext.InternalScope) InterfaceScope(org.yakindu.sct.model.stext.stext.InterfaceScope) ReactionEffect(org.yakindu.sct.model.stext.stext.ReactionEffect) Diagram(org.eclipse.gmf.runtime.notation.Diagram)

Example 4 with InternalScope

use of org.yakindu.sct.model.stext.stext.InternalScope in project statecharts by Yakindu.

the class SCTResourceTest method testStatechartParsing.

@Test
public void testStatechartParsing() {
    Statechart statechart = createStatechart("internal: event Event1");
    assertEquals(0, statechart.getScopes().size());
    res.getContents().add(statechart);
    assertEquals(1, statechart.getScopes().size());
    Scope scope = statechart.getScopes().get(0);
    assertTrue(scope instanceof InternalScope);
    EList<Declaration> declarations = ((InternalScope) scope).getDeclarations();
    Declaration declaration = declarations.get(0);
    assertTrue(declaration instanceof EventDefinition);
    assertEquals("" + res.getSyntaxDiagnostics(), 0, res.getSyntaxDiagnostics().size());
}
Also used : Scope(org.yakindu.sct.model.sgraph.Scope) InternalScope(org.yakindu.sct.model.stext.stext.InternalScope) InternalScope(org.yakindu.sct.model.stext.stext.InternalScope) Statechart(org.yakindu.sct.model.sgraph.Statechart) Declaration(org.yakindu.base.types.Declaration) EventDefinition(org.yakindu.sct.model.stext.stext.EventDefinition) Test(org.junit.Test)

Example 5 with InternalScope

use of org.yakindu.sct.model.stext.stext.InternalScope in project statecharts by Yakindu.

the class SCTResourceTest method testStatechartSerializing1.

@Test
public void testStatechartSerializing1() throws Exception {
    res.setSerializerEnabled(true);
    Statechart statechart = createStatechart("internal: event Event1");
    res.getContents().add(statechart);
    Scope internalScope = (InternalScope) statechart.getScopes().get(0);
    Event event = internalScope.getEvents().get(0);
    event.setName("Event2");
    assertEquals("internal: event Event2", statechart.getSpecification().trim());
    assertEquals("" + res.getSyntaxDiagnostics(), 0, res.getSyntaxDiagnostics().size());
}
Also used : Scope(org.yakindu.sct.model.sgraph.Scope) InternalScope(org.yakindu.sct.model.stext.stext.InternalScope) InternalScope(org.yakindu.sct.model.stext.stext.InternalScope) Statechart(org.yakindu.sct.model.sgraph.Statechart) Event(org.yakindu.base.types.Event) ExitEvent(org.yakindu.sct.model.stext.stext.ExitEvent) Test(org.junit.Test)

Aggregations

InternalScope (org.yakindu.sct.model.stext.stext.InternalScope)8 Scope (org.yakindu.sct.model.sgraph.Scope)5 EObject (org.eclipse.emf.ecore.EObject)4 Statechart (org.yakindu.sct.model.sgraph.Statechart)4 InterfaceScope (org.yakindu.sct.model.stext.stext.InterfaceScope)4 Test (org.junit.Test)3 Check (org.eclipse.xtext.validation.Check)2 ElementReferenceExpression (org.yakindu.base.expressions.expressions.ElementReferenceExpression)2 Declaration (org.yakindu.base.types.Declaration)2 EventDefinition (org.yakindu.sct.model.stext.stext.EventDefinition)2 ArrayList (java.util.ArrayList)1 Resource (org.eclipse.emf.ecore.resource.Resource)1 Diagram (org.eclipse.gmf.runtime.notation.Diagram)1 Keyword (org.eclipse.xtext.Keyword)1 ICompositeNode (org.eclipse.xtext.nodemodel.ICompositeNode)1 XtextResource (org.eclipse.xtext.resource.XtextResource)1 IScope (org.eclipse.xtext.scoping.IScope)1 FilteringScope (org.eclipse.xtext.scoping.impl.FilteringScope)1 ImportScope (org.eclipse.xtext.scoping.impl.ImportScope)1 SimpleScope (org.eclipse.xtext.scoping.impl.SimpleScope)1