module.exports = function (source) {
  return new SourceBuilder(source);
};

function SourceBuilder(source) {
  this.source_ = source;
}

SourceBuilder.prototype.build = function(name) {
  if (!this.source_.hasSource(name)) {
    return null;
  }
  var source = this.source_.getSource(name);
  var entityArray = [];
  var count = 0;
  source['entities'].forEach(function(entityName) {
    var entity = this.source_.getEntity(entityName);
    entity.name = entityName;
    entityArray.push(entity);
  }, this);
  source['references'] = entityArray;
  return source;
}

@@ -431,16 +431,36 @@
 yName);%0A
+    if (entity) %7B%0A  
     enti
@@ -481,24 +481,26 @@
 tyName;%0A    
+ 
+ 
 entityArray.
@@ -513,16 +513,22 @@
 ntity);%0A
+    %7D%0A
   %7D, thi

fix bug