protected void calculateDerivedVariableObjects(DerivedStateAwareResource resource) { TreeIterator<EObject> it = resource.getAllContents(); while(it.hasNext()) { EObject obj = it.next(); if (obj instanceof Pattern) { Pattern pattern = (Pattern) obj; for (PatternBody body : pattern.getBodies()) { EList<Variable> variables = body.getVariables(); variables.addAll(getAllVariablesInBody(body, variables)); } for (Annotation annotation : pattern.getAnnotations()) { for (AnnotationParameter parameter : annotation.getParameters()) { if ((parameter.getValue()) instanceof VariableReference) { final VariableReference reference = (VariableReference) parameter.getValue(); setDeclaredParameter(pattern, reference); } else if ((parameter.getValue()) instanceof ListValue) { ListValue listValue = (ListValue) (parameter.getValue()); for (VariableReference reference : Iterables.filter(listValue.getValues(), VariableReference.class)) { setDeclaredParameter(pattern, reference); } } } } it.prune(); } } }
/** * @since 1.4 */ protected void calculateAggregateTypes(DerivedStateAwareResource resource) { TreeIterator<EObject> it = resource.getAllContents(); while (it.hasNext()) { EObject obj = it.next(); if (obj instanceof AggregatedValue) { AggregatedValue aggregatedValue = (AggregatedValue) obj; if (AggregatorUtil.mustHaveAggregatorVariables(aggregatedValue)) { VariableReference aggregateParameter = AggregatorUtil.getAggregatorVariable(aggregatedValue); if (aggregateParameter == null) { aggregatedValue.setAggregateType(typeReferences.findDeclaredType(Void.class, aggregatedValue)); } else { JvmTypeReference jvmType = typeInferrer.getJvmType(aggregateParameter, aggregatedValue); aggregatedValue.setAggregateType(jvmType.getType()); } } } else if (obj instanceof JvmType) { it.prune(); } } } }