Search in sources :

Example 1 with SimpleScope

use of org.yakindu.sct.model.stext.stext.SimpleScope 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 SimpleScope

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

the class StextTestFactory method getOrCreateSimpleScope.

public static SimpleScope getOrCreateSimpleScope(State state) {
    for (Scope scope : state.getScopes()) {
        if (scope instanceof SimpleScope) {
            return (SimpleScope) scope;
        }
    }
    SimpleScope scope = StextFactory.eINSTANCE.createSimpleScope();
    state.getScopes().add(scope);
    return scope;
}
Also used : InterfaceScope(org.yakindu.sct.model.stext.stext.InterfaceScope) SimpleScope(org.yakindu.sct.model.stext.stext.SimpleScope) Scope(org.yakindu.sct.model.sgraph.Scope) InternalScope(org.yakindu.sct.model.stext.stext.InternalScope) SimpleScope(org.yakindu.sct.model.stext.stext.SimpleScope)

Aggregations

InterfaceScope (org.yakindu.sct.model.stext.stext.InterfaceScope)2 InternalScope (org.yakindu.sct.model.stext.stext.InternalScope)2 SimpleScope (org.yakindu.sct.model.stext.stext.SimpleScope)2 ArrayList (java.util.ArrayList)1 EObject (org.eclipse.emf.ecore.EObject)1 Keyword (org.eclipse.xtext.Keyword)1 ElementReferenceExpression (org.yakindu.base.expressions.expressions.ElementReferenceExpression)1 FeatureCall (org.yakindu.base.expressions.expressions.FeatureCall)1 Scope (org.yakindu.sct.model.sgraph.Scope)1 StatechartSpecification (org.yakindu.sct.model.stext.stext.StatechartSpecification)1 TransitionSpecification (org.yakindu.sct.model.stext.stext.TransitionSpecification)1