Program: 73361
Project: 73361
Buggy source:
/** 
 * Recursively search through an attribute and its contained attributes to find any unresolved references to other attributes.
 * @param attribute The attribute to be traversed.
 * @param container The original container of the attribute.
 * @param parsedContainer The temporary container from which the new copiedunresolved attributes will be generated.
 * @param hideVariables If true, add MoML that will make all the foundvariables hidden from the user interface when they are copied.
 * @exception IllegalActionException If there is a problem parsingan attribute, or validating a variable.
 */
private void _recursiveFindUndefinedConstantsOrIdentifiesInAttribute(Attribute attribute,NamedObj container,TypedCompositeActor parsedContainer,boolean hideVariables) throws IllegalActionException {
  if (attribute instanceof Variable) {
    Variable variable=(Variable)attribute;
    boolean doGetToken=true;
    while (doGetToken) {
      doGetToken=false;
      try {
        variable.getToken();
      }
 catch (      IllegalActionException ex) {
        doGetToken=_findUndefinedConstantsOrIdentifiers(ex,container,parsedContainer,hideVariables);
      }
    }
    ;
  }
  if (attribute instanceof AbstractSettableAttribute) {
    AbstractSettableAttribute settable=(AbstractSettableAttribute)attribute;
    PtParser ptParser=new PtParser();
    ASTPtRootNode parseTree=null;
    try {
      parseTree=ptParser.generateParseTree(settable.getExpression());
    }
 catch (    Exception ex) {
    }
    if (parseTree != null) {
      ParseTreeFreeVariableCollector variableCollector=new ParseTreeFreeVariableCollector();
      Set set=variableCollector.collectFreeVariables(parseTree,null);
      for (Iterator elements=set.iterator(); elements.hasNext(); ) {
        String name=(String)elements.next();
        if (parsedContainer.getAttribute(name) == null) {
          _findUndefinedConstantsOrIdentifiers(name,name,container,parsedContainer,hideVariables);
        }
      }
    }
  }
  List<Attribute> containedAttributes=attribute.attributeList();
  for (  Attribute containedAttribute : containedAttributes) {
    _recursiveFindUndefinedConstantsOrIdentifiesInAttribute(containedAttribute,container,parsedContainer,hideVariables);
  }
}

Fixed version (ground truth):
/** 
 * Recursively search through an attribute and its contained attributes to find any unresolved references to other attributes.
 * @param attribute The attribute to be traversed.
 * @param container The original container of the attribute.
 * @param parsedContainer The temporary container from which the new copiedunresolved attributes will be generated.
 * @param hideVariables If true, add MoML that will make all the foundvariables hidden from the user interface when they are copied.
 * @exception IllegalActionException If there is a problem parsingan attribute, or validating a variable.
 */
private void _recursiveFindUndefinedConstantsOrIdentifiesInAttribute(Attribute attribute,NamedObj container,TypedCompositeActor parsedContainer,boolean hideVariables) throws IllegalActionException {
  if (attribute instanceof Variable) {
    Variable variable=(Variable)attribute;
    boolean doGetToken=true;
    while (doGetToken) {
      doGetToken=false;
      try {
        variable.getToken();
      }
 catch (      IllegalActionException ex) {
        doGetToken=_findUndefinedConstantsOrIdentifiers(ex,container,parsedContainer,hideVariables);
      }
    }
    ;
  }
  if (attribute instanceof AbstractSettableAttribute) {
    AbstractSettableAttribute settable=(AbstractSettableAttribute)attribute;
    PtParser ptParser=new PtParser();
    ASTPtRootNode parseTree=null;
    try {
      parseTree=ptParser.generateParseTree(settable.getExpression());
    }
 catch (    Throwable throwable) {
    }
    if (parseTree != null) {
      ParseTreeFreeVariableCollector variableCollector=new ParseTreeFreeVariableCollector();
      Set set=variableCollector.collectFreeVariables(parseTree,null);
      for (Iterator elements=set.iterator(); elements.hasNext(); ) {
        String name=(String)elements.next();
        if (parsedContainer.getAttribute(name) == null) {
          _findUndefinedConstantsOrIdentifiers(name,name,container,parsedContainer,hideVariables);
        }
      }
    }
  }
  List<Attribute> containedAttributes=attribute.attributeList();
  for (  Attribute containedAttribute : containedAttributes) {
    _recursiveFindUndefinedConstantsOrIdentifiesInAttribute(containedAttribute,container,parsedContainer,hideVariables);
  }
}