static JsFunctionImpl create(
      JsParserResult parserResult,
      FunctionNode functionNode,
      List<Identifier> fqName,
      ModelBuilder modelBuilder,
      boolean isAnnonymous) {
    JsObjectImpl inObject = modelBuilder.getCurrentObject();
    JsObject globalObject = modelBuilder.getGlobal();
    JsObject parentObject = isAnnonymous ? globalObject : inObject;
    int start = Token.descPosition(functionNode.getFirstToken());
    int end =
        Token.descPosition(functionNode.getLastToken())
            + Token.descLength(functionNode.getLastToken());
    List<Identifier> parameters = new ArrayList(functionNode.getParameters().size());
    for (IdentNode node : functionNode.getParameters()) {
      parameters.add(create(parserResult, node));
    }
    JsFunctionImpl result;
    if (fqName.size() > 1) {
      List<Identifier> objectName = fqName.subList(0, fqName.size() - 1);
      parentObject = isAnnonymous ? globalObject : ModelUtils.getJsObject(modelBuilder, objectName);
      result =
          new JsFunctionImpl(
              modelBuilder.getCurrentDeclarationScope(),
              parentObject,
              fqName.get(fqName.size() - 1),
              parameters,
              ModelUtils.documentOffsetRange(parserResult, start, end));
      if (parentObject instanceof JsFunction && !"prototype".equals(parentObject.getName())) {
        result.addModifier(Modifier.STATIC);
      }
    } else {
      result =
          new JsFunctionImpl(
              modelBuilder.getCurrentDeclarationScope(),
              inObject,
              fqName.get(fqName.size() - 1),
              parameters,
              ModelUtils.documentOffsetRange(parserResult, start, end));
    }
    String propertyName = result.getDeclarationName().getName();
    JsObject property = parentObject.getProperty(propertyName); // the already existing property

    parentObject.addProperty(result.getDeclarationName().getName(), result);
    if (property != null) {
      result.addOccurrence(property.getDeclarationName().getOffsetRange());
      for (Occurrence occurrence : property.getOccurrences()) {
        result.addOccurrence(occurrence.getOffsetRange());
      }
    }
    JsDocumentationHolder docHolder = parserResult.getDocumentationHolder();
    result.setDocumentation(docHolder.getDocumentation(functionNode));
    result.setAnonymous(isAnnonymous);
    return result;
  }