Search in sources :

Example 1 with TransitionSpecification

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

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

the class StextImportAwareScopeProvider method internalGetImportedNamespaceResolvers.

@Override
protected List<ImportNormalizer> internalGetImportedNamespaceResolvers(final EObject context, boolean ignoreCase) {
    List<ImportNormalizer> importedNamespaceResolvers = Lists.newArrayList();
    List<ImportScope> importScopes = null;
    if (context instanceof StateSpecification || context instanceof TransitionSpecification) {
        importScopes = EcoreUtil2.getAllContentsOfType(getStatechart(context), ImportScope.class);
    } else {
        importScopes = EcoreUtil2.getAllContentsOfType(context, ImportScope.class);
    }
    for (ImportScope scope : importScopes) {
        importedNamespaceResolvers.addAll(createNamespaceResolver(scope, ignoreCase));
    }
    return importedNamespaceResolvers;
}
Also used : StateSpecification(org.yakindu.sct.model.stext.stext.StateSpecification) ImportNormalizer(org.eclipse.xtext.scoping.impl.ImportNormalizer) ImportScope(org.yakindu.sct.model.stext.stext.ImportScope) TransitionSpecification(org.yakindu.sct.model.stext.stext.TransitionSpecification)

Example 3 with TransitionSpecification

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

the class StextResource method parseTransition.

protected void parseTransition(Transition transition) {
    IParseResult parseResult = parse(transition, TransitionSpecification.class.getSimpleName());
    TransitionSpecification rootASTElement = (TransitionSpecification) parseResult.getRootASTElement();
    transition.getProperties().clear();
    if (rootASTElement.getReaction() != null) {
        TransitionReaction reaction = rootASTElement.getReaction();
        transition.setEffect(reaction.getEffect());
        transition.setTrigger(reaction.getTrigger());
        transition.getProperties().addAll(reaction.getProperties());
    }
}
Also used : TransitionSpecification(org.yakindu.sct.model.stext.stext.TransitionSpecification) IParseResult(org.eclipse.xtext.parser.IParseResult) TransitionReaction(org.yakindu.sct.model.stext.stext.TransitionReaction)

Example 4 with TransitionSpecification

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

the class TransitionRootImpl method basicSetDef.

/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public NotificationChain basicSetDef(TransitionSpecification newDef, NotificationChain msgs) {
    TransitionSpecification oldDef = def;
    def = newDef;
    if (eNotificationRequired()) {
        ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, StextPackage.TRANSITION_ROOT__DEF, oldDef, newDef);
        if (msgs == null)
            msgs = notification;
        else
            msgs.add(notification);
    }
    return msgs;
}
Also used : ENotificationImpl(org.eclipse.emf.ecore.impl.ENotificationImpl) TransitionSpecification(org.yakindu.sct.model.stext.stext.TransitionSpecification)

Aggregations

TransitionSpecification (org.yakindu.sct.model.stext.stext.TransitionSpecification)4 ArrayList (java.util.ArrayList)1 EObject (org.eclipse.emf.ecore.EObject)1 ENotificationImpl (org.eclipse.emf.ecore.impl.ENotificationImpl)1 Keyword (org.eclipse.xtext.Keyword)1 IParseResult (org.eclipse.xtext.parser.IParseResult)1 ImportNormalizer (org.eclipse.xtext.scoping.impl.ImportNormalizer)1 ElementReferenceExpression (org.yakindu.base.expressions.expressions.ElementReferenceExpression)1 FeatureCall (org.yakindu.base.expressions.expressions.FeatureCall)1 ImportScope (org.yakindu.sct.model.stext.stext.ImportScope)1 InterfaceScope (org.yakindu.sct.model.stext.stext.InterfaceScope)1 InternalScope (org.yakindu.sct.model.stext.stext.InternalScope)1 SimpleScope (org.yakindu.sct.model.stext.stext.SimpleScope)1 StateSpecification (org.yakindu.sct.model.stext.stext.StateSpecification)1 StatechartSpecification (org.yakindu.sct.model.stext.stext.StatechartSpecification)1 TransitionReaction (org.yakindu.sct.model.stext.stext.TransitionReaction)1