@Override public TransformationException caseAction(Action action) { final TypeRef actionTypeRef = action.getType(); try { addSuperType(rule, actionTypeRef, ruleReturnType); return null; } catch (TransformationException ex) { return ex; } }
public void consumeAction(Action action, boolean isMany) { if (log.isDebugEnabled()) { log.debug("consumeAction(type = " + action.getType().getClassifier().getName() + ", feature = " + action.getFeature() + ", isMany = " + isMany + ")"); } delegate.consumeAction(action, isMany); }
@Override public String caseAction(Action object) { String f = object.getFeature(); String o = object.getOperator(); o = (o == null) ? "" : o; String result; if (showActionAsRuleCall && f != null) { result = f + o + new Context2NameFunction().apply(object) + card(object); } else { String t = object.getType() != null && object.getType().getClassifier() != null ? object.getType() .getClassifier().getName() : "null"; t = (t == null) ? "" : t; f = (f == null) ? "" : "." + f; result = "{" + t + f + o + "}" + card(object); } return addQualified(result, object); }
public static boolean isAssignedAction(EObject e) { return e instanceof Action && ((Action) e).getFeature() != null; }
public String setOrAdd(final Action it) { String _xifexpression = null; String _operator = it.getOperator(); boolean _equals = Objects.equal(_operator, "+="); if (_equals) { _xifexpression = "add"; } else { _xifexpression = "set"; } return _xifexpression; }
public static boolean isUnassignedAction(EObject e) { return e instanceof Action && ((Action) e).getFeature() == null; }
public static boolean isMultipleAssignment(Action a) { return "+=".equals(a.getOperator()); }
@Override public Xtext2EcoreInterpretationContext caseAction(Action object) { try { TypeRef actionTypeRef = object.getType(); EClassifierInfo actionType = findOrCreateEClassifierInfo(actionTypeRef, null, true); EClassifierInfo currentCompatibleType = context.getCurrentCompatibleType(); Xtext2EcoreInterpretationContext ctx = context.spawnContextWithReferencedType(actionType, object); if (object.getFeature() != null) ctx.addFeature(object.getFeature(), currentCompatibleType, GrammarUtil.isMultipleAssignment(object), true, object); return ctx; } catch (TransformationException e) { reportError(e); } return context; }
protected void assertAction(Action action) { if (action.getFeature() == null) throw new RuntimeException("Only assigned actions are allowed."); }
protected String getAssignmentOperator() { if (element instanceof Action) return ((Action) element).getOperator(); Assignment ass = GrammarUtil.containingAssignment(element); if (ass != null) return ass.getOperator(); return null; }
public EClassifier getType() { return getGrammarElement().getType().getClassifier(); }
protected EObject forceCreateModelElementAndSet(Action action, EObject value) { EObject result = semanticModelBuilder.create(action.getType().getClassifier()); semanticModelBuilder.set(result, action.getFeature(), value, null /* ParserRule */, currentNode); insertCompositeNode(action); associateNodeWithAstElement(currentNode, result); return result; }
public String getFeature() { return getGrammarElement().getFeature(); }
@Check public void checkInstantiatedType(Action action) { checkTypeIsEClass(action.getType()); }
protected EObject forceCreateModelElementAndAdd(Action action, EObject value) { EObject result = semanticModelBuilder.create(action.getType().getClassifier()); semanticModelBuilder.add(result, action.getFeature(), value, null /* ParserRule */, currentNode); insertCompositeNode(action); associateNodeWithAstElement(currentNode, result); return result; }
@Override public Boolean caseAction(Action object) { assignedFeatures = newMultimap(); if (GrammarUtil.isMultipleAssignment(object)) return null; if (object.getFeature() == null) return Boolean.FALSE; checkAssignment(object, object.getFeature()); return Boolean.FALSE; }
public String getUniqueActionName(Action action) { List<Integer> indices = Lists.newArrayList(); EObject current = action; while (current.eContainer() instanceof AbstractElement) { indices.add(current.eContainer().eContents().indexOf(current)); current = current.eContainer(); } Collections.reverse(indices); return action.getType().getClassifier().getName() + "_" + Joiner.on('_').join(indices); } }
protected void getLocallyAssignedContainmentReferences(final Grammar grammar, final Multimap<EClass, EReference> type2ref) { List<Assignment> _containedAssignments = GrammarUtil.containedAssignments(grammar); for (final Assignment assignment : _containedAssignments) { { final EClassifier type = GrammarUtil.findCurrentType(assignment); if ((type instanceof EClass)) { final EStructuralFeature feature = ((EClass)type).getEStructuralFeature(assignment.getFeature()); if (((feature instanceof EReference) && ((EReference) feature).isContainment())) { type2ref.put(((EClass)type), ((EReference) feature)); } } } } List<Action> _containedActions = GrammarUtil.containedActions(grammar); for (final Action action : _containedActions) { { final String featureName = action.getFeature(); if ((featureName != null)) { final EClassifier type = action.getType().getClassifier(); if ((type instanceof EClass)) { final EStructuralFeature feature = ((EClass)type).getEStructuralFeature(featureName); if (((feature instanceof EReference) && ((EReference) feature).isContainment())) { type2ref.put(((EClass)type), ((EReference) feature)); } } } } } }
@Override public Iterable<AbstractElement> getStarts(AbstractElement root) { Set<AbstractElement> result = Sets.newLinkedHashSet(); for (Action act : GrammarUtil.containedActions(root)) if (act.getFeature() != null) result.add(act); for (AbstractElement ele : super.getStarts(root)) if (ele == null) result.add(null); else if (!GrammarUtil.isAssignedAction(ele)) result.add(ele); return result; }