public Collection<ExpressionObject<?>> analyzeExpression(GenericPK id,Expression formula,ExpressionAST expression) throws ScopeException {
  ExtractReferences visitor=new ExtractReferences();
  List<ExpressionRef> references=visitor.apply(expression);
  String internal=rewriteExpressionValue(formula.getValue(),expression,references);
  if (!internal.equals(formula.getValue())) {
    formula.setInternal(internal);
  }
 else {
    formula.setInternal(null);
  }
  int level=computeReferenceTree(expression,references);
  formula.setLevel(level);
  Collection<ExpressionObject<?>> objects=new HashSet<>();
  for (  ExpressionRef expr : references) {
    Object ref=expr.getReference();
    if (ref != null && ref instanceof Property) {
      Property property=(Property)ref;
      ExpressionObject<?> object=property.getExpressionObject();
      if (object != null) {
        objects.add(object);
      }
    }
  }
  if (!objects.isEmpty()) {
    Collection<ExpressionObject<?>> closure=null;
    Collection<ExpressionObject<?>> transitiveClosure=objects;
    do {
      closure=transitiveClosure;
      transitiveClosure=transitiveClosure(id,closure);
    }
 while (closure.size() < transitiveClosure.size());
    Collection<ReferencePK<?>> IDs=new HashSet<>();
    for (    ExpressionObject<?> object : transitiveClosure) {
      ReferencePK<?> refPk=reference(object);
      if (refPk != null) {
        IDs.add(refPk);
      }
    }
    formula.setReferences(IDs);
    return transitiveClosure;
  }
 else {
    return objects;
  }
}

public Collection < ExpressionObject < ? > > analyzeExpression ( GenericPK id , Expression formula , ExpressionAST expression ) throws ScopeException { ExtractReferences visitor = new ExtractReferences ( ) ; List < ExpressionRef > references = visitor . apply ( expression ) ; String internal = rewriteExpressionValue ( formula . getValue ( ) , expression , references ) ; if ( ! internal . equals ( formula . getValue ( ) ) ) { formula . setInternal ( internal ) ; } else { formula . setInternal ( null ) ; } int level = computeReferenceTree ( expression , references ) ; formula . setLevel ( level ) ; Collection < ExpressionObject < ? > > objects = new HashSet < > ( ) ; for ( ExpressionRef expr : references ) { Object ref = expr . getReference ( ) ; if ( ref != null && ref instanceof Property ) { Property property = ( Property ) ref ; ExpressionObject < ? > object = property . getExpressionObject ( ) ; if ( object != null ) { objects . add ( object ) ; } } } if ( ! objects . isEmpty ( ) ) { Collection < ExpressionObject < ? > > closure = null ; Collection < ExpressionObject < ? > > transitiveClosure = objects ; do { closure = transitiveClosure ; transitiveClosure = transitiveClosure ( id , closure ) ; } while ( closure . size ( ) < transitiveClosure . size ( ) ) ; Collection < ReferencePK < ? > > IDs = new HashSet < > ( ) ; for ( ExpressionObject < ? > object : transitiveClosure ) { ReferencePK < ? > refPk = reference ( object ) ; if ( refPk != null ) { IDs . add ( refPk ) ; } } formula . setReferences ( IDs ) ; return transitiveClosure ; } else { return objects ; } }
analyze the formula using the given parsed expression and update the formula private fields accordingly
