コード例 #1
0
 static JsObjectImpl create(
     JsParserResult parserResult,
     ObjectNode objectNode,
     List<Identifier> fqName,
     ModelBuilder modelBuilder,
     boolean belongsToParent) {
   JsObjectImpl scope = modelBuilder.getCurrentObject();
   JsObject parent = scope;
   JsObject result = null;
   Identifier name = fqName.get(fqName.size() - 1);
   JsObjectImpl newObject;
   if (!belongsToParent) {
     List<Identifier> objectName =
         fqName.size() > 1 ? fqName.subList(0, fqName.size() - 1) : fqName;
     parent = ModelUtils.getJsObject(modelBuilder, objectName);
   }
   result = parent.getProperty(name.getName());
   newObject =
       new JsObjectImpl(
           parent,
           name,
           ModelUtils.documentOffsetRange(
               parserResult, objectNode.getStart(), objectNode.getFinish()));
   newObject.setDeclared(true);
   if (result != null) {
     // the object already exist due a definition of a property => needs to be copied
     for (String propertyName : result.getProperties().keySet()) {
       newObject.addProperty(propertyName, result.getProperty(propertyName));
     }
   }
   JsDocumentationHolder docHolder = parserResult.getDocumentationHolder();
   newObject.setDocumentation(docHolder.getDocumentation(objectNode));
   parent.addProperty(name.getName(), newObject);
   return (JsObjectImpl) newObject;
 }
コード例 #2
0
 static JsObjectImpl createAnonymousObject(
     JsParserResult parserResult, ObjectNode objectNode, ModelBuilder modelBuilder) {
   String name = modelBuilder.getUnigueNameForAnonymObject();
   JsObjectImpl result =
       new AnonymousObject(
           modelBuilder.getGlobal(),
           name,
           ModelUtils.documentOffsetRange(
               parserResult, objectNode.getStart(), objectNode.getFinish()));
   modelBuilder.getGlobal().addProperty(name, result);
   JsDocumentationHolder docHolder = parserResult.getDocumentationHolder();
   result.setDocumentation(docHolder.getDocumentation(objectNode));
   return result;
 }