/**
   * Searches the documentation of the function in which <code>node</code> lies.
   *
   * @param node some node or a function definition
   * @param information additional information about the region
   * @return the documentation of the function or <code>null</code>
   */
  protected NesCDocComment getFunctionDocumentation(
      FunctionDefinition node, DocumentRegionInformation information) {
    NesCDocComment[] comments = node.getComments();
    if (comments != null && comments.length > 0) return comments[comments.length - 1];

    Name definitionName = node.resolveName();
    if (definitionName == null) return null;

    String[] segments = definitionName.segments();
    if (segments.length != 2) return null;

    NesCInterfaceReference reference = node.resolveInterface();
    if (reference == null) return null;

    NesCInterface interfaze = reference.getRawReference();
    if (interfaze == null) return null;

    Field base = interfaze.getField(segments[1]);
    if (base == null) return null;

    FieldModelNode baseNode = base.asNode();
    if (baseNode == null) return null;

    NesC12DocComment nesComment = baseNode.getDocumentation();
    return new NesCDocComment(0, null, nesComment.getComment(), true);
  }
예제 #2
0
  public static FieldModelNode toNode(Field field) {
    if (field == null) return null;

    if (field.asNode() != null) return field.asNode();

    if (field.asSimple() != null) return new FieldModelNode(field.asSimple());

    return null;
  }