/**
   * 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);
  }
  private void init(
      Name identifier,
      ModelAttribute[] attributes,
      Modifiers modifiers,
      Type type,
      Value initialValue,
      boolean enumeration) {
    if (delegate == null)
      delegate =
          new SimpleField(modifiers, type, identifier, attributes, initialValue, null, getPath());

    if (enumeration) {
      if (initialValue == null) setLabel(identifier.toIdentifier());
      else setLabel(identifier.toIdentifier() + " : " + initialValue.toLabel());
    } else {
      if (type != null && type.asFunctionType() != null) {
        setLabel(type.toLabel(identifier.toIdentifier(), Type.Label.SMALL));
      } else {
        if (type != null)
          setLabel(identifier.toIdentifier() + " : " + type.toLabel(null, Type.Label.SMALL));
        else setLabel(identifier.toIdentifier());
      }
    }

    setAttributes(attributes);
    setTags(getFieldTags(modifiers, type, enumeration));
    getTags().add(Tag.IDENTIFIABLE);
    setContent(new LabelContent(getLabel(), new Icon(getTags(), attributes), getPath()));
  }
  public static final String fieldId(Name name, Type type) {
    if (name == null && type == null)
      throw new NullPointerException("either name or type must not be null");

    if (name == null) return "-" + type.id(false);

    if (type == null) return name.toIdentifier();

    return name.toIdentifier() + "-" + type.id(false);
  }
  /**
   * Searches documentation for <code>field</code>.
   *
   * @param field the identifier of some field
   * @param region additional information about the document
   * @return the documentation or <code>null</code>
   */
  protected String getFieldDocumentation(Identifier field, DocumentRegionInformation region) {
    ASTNode node = field;

    while (node != null) {
      if (node instanceof FunctionDefinition) {
        FunctionDefinition definition = (FunctionDefinition) node;
        FieldModelNode fieldNode = definition.resolveNode();
        if (fieldNode != null) {
          Name[] arguments = fieldNode.getArgumentNames();
          if (arguments != null) {
            for (Name name : arguments) {
              if (name != null) {
                if (name.toIdentifier().equals(field.getName())) {
                  NesCDocComment comment = getFunctionDocumentation(definition, region);
                  if (comment == null) return null;
                  return comment.getAnalysis().getParameterDescription(field.getName());
                }
              }
            }
          }
        }
      }

      NesCDocComment[] comments = node.getComments();
      if (comments != null) {
        for (int i = comments.length - 1; i >= 0; i--) {
          String documentation = comments[i].getAnalysis().getParameterDescription(field.getName());
          if (documentation != null) return documentation;
        }
      }

      node = node.getParent();
    }

    return null;
  }
 public String getNodeName() {
   Name name = getName();
   if (name == null) return null;
   return name.toIdentifier();
 }