use of org.yakindu.base.expressions.expressions.ElementReferenceExpression 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));
}
}
use of org.yakindu.base.expressions.expressions.ElementReferenceExpression 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);
}
}
}
use of org.yakindu.base.expressions.expressions.ElementReferenceExpression 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;
}
use of org.yakindu.base.expressions.expressions.ElementReferenceExpression 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);
}
}
}
use of org.yakindu.base.expressions.expressions.ElementReferenceExpression 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;
}
Aggregations