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; }
static JsObjectImpl create( JsParserResult parserResult, PropertyNode propertyNode, Identifier name, ModelBuilder modelBuilder, boolean belongsToParent) { JsObjectImpl scope = modelBuilder.getCurrentObject(); JsObjectImpl property = new JsObjectImpl(scope, name, name.getOffsetRange()); JsDocumentationHolder docHolder = parserResult.getDocumentationHolder(); property.setDocumentation(docHolder.getDocumentation(propertyNode)); return property; }