Search in sources :

Example 1 with FeatureCall

use of org.yakindu.base.expressions.expressions.FeatureCall 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 FeatureCall

use of org.yakindu.base.expressions.expressions.FeatureCall 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 3 with FeatureCall

use of org.yakindu.base.expressions.expressions.FeatureCall in project statecharts by Yakindu.

the class STextScopeProvider method scope_FeatureCall_feature.

public IScope scope_FeatureCall_feature(final FeatureCall context, EReference reference) {
    Predicate<IEObjectDescription> predicate = calculateFilterPredicate(context, reference);
    Expression owner = context.getOwner();
    EObject element = null;
    if (owner instanceof ElementReferenceExpression) {
        element = ((ElementReferenceExpression) owner).getReference();
    } else if (owner instanceof FeatureCall) {
        element = ((FeatureCall) owner).getFeature();
    } else {
        return getDelegate().getScope(context, reference);
    }
    IScope scope = IScope.NULLSCOPE;
    InferenceResult result = typeInferrer.infer(owner);
    Type ownerType = result != null ? result.getType() : null;
    if (element instanceof Scope) {
        scope = Scopes.scopeFor(((Scope) element).getDeclarations());
        return new FilteringScope(scope, predicate);
    } else if (ownerType != null) {
        scope = Scopes.scopeFor(typeSystem.getPropertyExtensions(ownerType));
        scope = Scopes.scopeFor(typeSystem.getOperationExtensions(ownerType), scope);
    }
    if (ownerType instanceof ComplexType) {
        return addScopeForComplexType((ComplexType) ownerType, scope, predicate);
    }
    if (ownerType instanceof EnumerationType) {
        return addScopeForEnumType((EnumerationType) ownerType, scope, predicate);
    }
    return scope;
}
Also used : InferenceResult(org.yakindu.base.types.inferrer.ITypeSystemInferrer.InferenceResult) EnumerationType(org.yakindu.base.types.EnumerationType) IEObjectDescription(org.eclipse.xtext.resource.IEObjectDescription) ComplexType(org.yakindu.base.types.ComplexType) EnumerationType(org.yakindu.base.types.EnumerationType) Type(org.yakindu.base.types.Type) FilteringScope(org.eclipse.xtext.scoping.impl.FilteringScope) InterfaceScope(org.yakindu.sct.model.stext.stext.InterfaceScope) Scope(org.yakindu.sct.model.sgraph.Scope) IScope(org.eclipse.xtext.scoping.IScope) SimpleScope(org.eclipse.xtext.scoping.impl.SimpleScope) InternalScope(org.yakindu.sct.model.stext.stext.InternalScope) ImportScope(org.eclipse.xtext.scoping.impl.ImportScope) Expression(org.yakindu.base.expressions.expressions.Expression) ElementReferenceExpression(org.yakindu.base.expressions.expressions.ElementReferenceExpression) EObject(org.eclipse.emf.ecore.EObject) IScope(org.eclipse.xtext.scoping.IScope) ElementReferenceExpression(org.yakindu.base.expressions.expressions.ElementReferenceExpression) FeatureCall(org.yakindu.base.expressions.expressions.FeatureCall) ComplexType(org.yakindu.base.types.ComplexType) FilteringScope(org.eclipse.xtext.scoping.impl.FilteringScope)

Example 4 with FeatureCall

use of org.yakindu.base.expressions.expressions.FeatureCall in project statecharts by Yakindu.

the class RenameRefactoring method internalExecute.

@Override
protected void internalExecute() {
    NamedElement element = getContextObject();
    Collection<EObject> elementReferers = findReferers(element);
    element.setName(newName);
    for (EObject referer : elementReferers) {
        if (referer instanceof FeatureCall) {
            FeatureCall featureCall = (FeatureCall) referer;
            featureCall.setFeature(element);
        } else if (referer instanceof ElementReferenceExpression) {
            ElementReferenceExpression expr = (ElementReferenceExpression) referer;
            expr.setReference(element);
        }
    }
}
Also used : EObject(org.eclipse.emf.ecore.EObject) NamedElement(org.yakindu.base.base.NamedElement) FeatureCall(org.yakindu.base.expressions.expressions.FeatureCall) ElementReferenceExpression(org.yakindu.base.expressions.expressions.ElementReferenceExpression)

Example 5 with FeatureCall

use of org.yakindu.base.expressions.expressions.FeatureCall in project statecharts by Yakindu.

the class RenameElementHandler method unwrap.

/**
 * Unwraps the given selection into a state sgraph element
 *
 * @param selection the current selection
 * @return the state sgraph element for the given selection
 */
public NamedElement unwrap(ISelection selection) {
    IStructuredSelection structuredSelection = (IStructuredSelection) selection;
    EObject selectedElement = (EObject) structuredSelection.getFirstElement();
    // We need to find the actual element in our statechart for this fake element
    if (selectedElement instanceof FeatureCall) {
        return findElementForFakeInStatechart((NamedElement) ((FeatureCall) selectedElement).getFeature());
    } else if (selectedElement instanceof ElementReferenceExpression) {
        return findElementForFakeInStatechart((NamedElement) ((ElementReferenceExpression) selectedElement).getReference());
    }
    if (selectedElement instanceof NamedElement)
        return findElementForFakeInStatechart((NamedElement) selectedElement);
    return null;
}
Also used : EObject(org.eclipse.emf.ecore.EObject) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) FeatureCall(org.yakindu.base.expressions.expressions.FeatureCall) ElementReferenceExpression(org.yakindu.base.expressions.expressions.ElementReferenceExpression) NamedElement(org.yakindu.base.base.NamedElement)

Aggregations

FeatureCall (org.yakindu.base.expressions.expressions.FeatureCall)11 ElementReferenceExpression (org.yakindu.base.expressions.expressions.ElementReferenceExpression)9 EObject (org.eclipse.emf.ecore.EObject)8 Expression (org.yakindu.base.expressions.expressions.Expression)6 AssignmentExpression (org.yakindu.base.expressions.expressions.AssignmentExpression)5 Check (org.eclipse.xtext.validation.Check)4 NamedElement (org.yakindu.base.base.NamedElement)4 PostFixUnaryExpression (org.yakindu.base.expressions.expressions.PostFixUnaryExpression)4 EventRaisingExpression (org.yakindu.sct.model.stext.stext.EventRaisingExpression)3 EventValueReferenceExpression (org.yakindu.sct.model.stext.stext.EventValueReferenceExpression)3 InterfaceScope (org.yakindu.sct.model.stext.stext.InterfaceScope)3 Execution (org.yakindu.sct.model.sexec.Execution)2 InternalScope (org.yakindu.sct.model.stext.stext.InternalScope)2 VariableDefinition (org.yakindu.sct.model.stext.stext.VariableDefinition)2 ArrayList (java.util.ArrayList)1 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)1 Keyword (org.eclipse.xtext.Keyword)1 QualifiedName (org.eclipse.xtext.naming.QualifiedName)1 IEObjectDescription (org.eclipse.xtext.resource.IEObjectDescription)1 IScope (org.eclipse.xtext.scoping.IScope)1