Java 类com.intellij.lang.documentation.DocumentationUtil 实例源码

项目:intellij-ce-playground    文件:XmlDocumentationProvider.java   
protected String generateDoc(String str, String name, String typeName, String version) {
  if (str == null) return null;
  StringBuilder buf = new StringBuilder(str.length() + 20);

  DocumentationUtil.formatEntityName(typeName == null ? XmlBundle.message("xml.javadoc.tag.name.message"):typeName,name,buf);

  final String indent = "  ";
  final StringBuilder builder = buf.append(XmlBundle.message("xml.javadoc.description.message")).append(indent).
      append(HtmlDocumentationProvider.NBSP).append(str);
  if (version != null) {
    builder.append(HtmlDocumentationProvider.BR).append(XmlBundle.message("xml.javadoc.version.message")).append(indent)
        .append(HtmlDocumentationProvider.NBSP).append(version);
  }
  return builder.toString();
}
项目:tools-idea    文件:XmlDocumentationProvider.java   
protected String generateDoc(String str, String name, String typeName, String version) {
  if (str == null) return null;
  StringBuilder buf = new StringBuilder(str.length() + 20);

  DocumentationUtil.formatEntityName(typeName == null ? XmlBundle.message("xml.javadoc.tag.name.message"):typeName,name,buf);

  final String indent = "  ";
  final StringBuilder builder = buf.append(XmlBundle.message("xml.javadoc.description.message")).append(indent).
      append(HtmlDocumentationProvider.NBSP).append(str);
  if (version != null) {
    builder.append(HtmlDocumentationProvider.BR).append(XmlBundle.message("xml.javadoc.version.message")).append(indent)
        .append(HtmlDocumentationProvider.NBSP).append(version);
  }
  return builder.toString();
}
项目:consulo-xml    文件:XmlDocumentationProvider.java   
protected String generateDoc(String str, String name, String typeName, String version) {
  if (str == null) return null;
  StringBuilder buf = new StringBuilder(str.length() + 20);

  DocumentationUtil.formatEntityName(typeName == null ? XmlBundle.message("xml.javadoc.tag.name.message"):typeName,name,buf);

  final String indent = "  ";
  final StringBuilder builder = buf.append(XmlBundle.message("xml.javadoc.description.message")).append(indent).
      append(HtmlDocumentationProvider.NBSP).append(str);
  if (version != null) {
    builder.append(HtmlDocumentationProvider.BR).append(XmlBundle.message("xml.javadoc.version.message")).append(indent)
        .append(HtmlDocumentationProvider.NBSP).append(version);
  }
  return builder.toString();
}
项目:intellij-ce-playground    文件:HtmlDocumentationProvider.java   
private static String generateJavaDoc(EntityDescriptor descriptor, boolean omitHtmlSpecifics, PsiElement element) {
  StringBuilder buf = new StringBuilder();
  final boolean isTag = descriptor instanceof HtmlTagDescriptor;

  if (isTag) {
    DocumentationUtil.formatEntityName(XmlBundle.message("xml.javadoc.tag.name.message"),descriptor.getName(),buf);
  } else {
    DocumentationUtil.formatEntityName(XmlBundle.message("xml.javadoc.attribute.name.message"),descriptor.getName(),buf);
  }

  buf.append(XmlBundle.message("xml.javadoc.description.message")).append(NBSP).append(descriptor.getDescription()).append(BR);

  if (isTag) {
    final HtmlTagDescriptor tagDescriptor = (HtmlTagDescriptor)descriptor;

    if (!omitHtmlSpecifics) {
      boolean hasStartTag = tagDescriptor.isHasStartTag();
      if (!hasStartTag) {
        buf.append(XmlBundle.message("xml.javadoc.start.tag.could.be.omitted.message")).append(BR);
      }
      if (!tagDescriptor.isEmpty() && !tagDescriptor.isHasEndTag()) {
        buf.append(XmlBundle.message("xml.javadoc.end.tag.could.be.omitted.message")).append(BR);
      }
    }

    if (tagDescriptor.isEmpty()) {
      buf.append(XmlBundle.message("xml.javadoc.is.empty.message")).append(BR);
    }
  } else {
    final HtmlAttributeDescriptor attributeDescriptor = (HtmlAttributeDescriptor)descriptor;

    buf.append(XmlBundle.message("xml.javadoc.attr.type.message", attributeDescriptor.getType())).append(BR);
    if (!attributeDescriptor.isHasDefaultValue())
      buf.append(XmlBundle.message("xml.javadoc.attr.default.required.message")).append(BR);
  }

  char dtdId = descriptor.getDtd();
  boolean deprecated = dtdId == EntityDescriptor.LOOSE_DTD;
  if (deprecated) {
    buf.append(XmlBundle.message("xml.javadoc.deprecated.message", true)).append(BR);
  }

  if (dtdId == EntityDescriptor.LOOSE_DTD) {
    buf.append(XmlBundle.message("xml.javadoc.defined.in.loose.dtd.message"));
  }
  else if (dtdId == EntityDescriptor.FRAME_DTD) {
    buf.append(XmlBundle.message("xml.javadoc.defined.in.frameset.dtd.message"));
  }
  else {
    buf.append(XmlBundle.message("xml.javadoc.defined.in.any.dtd.message"));
  }

  if (!isTag) {
    ColorSampleLookupValue.addColorPreviewAndCodeToLookup(element,buf);
  }

  if (element != null) {
    buf.append(XmlDocumentationProvider.generateHtmlAdditionalDocTemplate(element));
  }

  return buf.toString();
}
项目:tools-idea    文件:HtmlDocumentationProvider.java   
private static String generateJavaDoc(EntityDescriptor descriptor, boolean ommitHtmlSpecifics, PsiElement element) {
  StringBuilder buf = new StringBuilder();
  final boolean istag = descriptor instanceof HtmlTagDescriptor;

  if (istag) {
    DocumentationUtil.formatEntityName(XmlBundle.message("xml.javadoc.tag.name.message"),descriptor.getName(),buf);
  } else {
    DocumentationUtil.formatEntityName(XmlBundle.message("xml.javadoc.attribute.name.message"),descriptor.getName(),buf);
  }

  buf.append(XmlBundle.message("xml.javadoc.description.message")).append(NBSP).append(descriptor.getDescription()).append(BR);

  if (istag) {
    final HtmlTagDescriptor tagDescriptor = (HtmlTagDescriptor)descriptor;

    if (!ommitHtmlSpecifics) {
      boolean hasStartTag = tagDescriptor.isHasStartTag();
      if (!hasStartTag) {
        buf.append(XmlBundle.message("xml.javadoc.start.tag.could.be.omitted.message")).append(BR);
      }
      if (!tagDescriptor.isEmpty() && !tagDescriptor.isHasEndTag()) {
        buf.append(XmlBundle.message("xml.javadoc.end.tag.could.be.omitted.message")).append(BR);
      }
    }

    if (tagDescriptor.isEmpty()) {
      buf.append(XmlBundle.message("xml.javadoc.is.empty.message")).append(BR);
    }
  } else {
    final HtmlAttributeDescriptor attributeDescriptor = (HtmlAttributeDescriptor)descriptor;

    buf.append(XmlBundle.message("xml.javadoc.attr.type.message", attributeDescriptor.getType())).append(BR);
    if (!attributeDescriptor.isHasDefaultValue())
      buf.append(XmlBundle.message("xml.javadoc.attr.default.required.message")).append(BR);
  }

  char dtdId = descriptor.getDtd();
  boolean deprecated = dtdId == HtmlTagDescriptor.LOOSE_DTD;
  if (deprecated) {
    buf.append(XmlBundle.message("xml.javadoc.deprecated.message", deprecated)).append(BR);
  }

  if (dtdId == HtmlTagDescriptor.LOOSE_DTD) {
    buf.append(XmlBundle.message("xml.javadoc.defined.in.loose.dtd.message"));
  }
  else if (dtdId == HtmlTagDescriptor.FRAME_DTD) {
    buf.append(XmlBundle.message("xml.javadoc.defined.in.frameset.dtd.message"));
  }
  else {
    buf.append(XmlBundle.message("xml.javadoc.defined.in.any.dtd.message"));
  }

  if (!istag) {
    ColorSampleLookupValue.addColorPreviewAndCodeToLookup(element,buf);
  }

  if (element != null) {
    buf.append(XmlDocumentationProvider.generateHtmlAdditionalDocTemplate(element));
  }

  return buf.toString();
}
项目:consulo-xml    文件:HtmlDocumentationProvider.java   
private static String generateJavaDoc(EntityDescriptor descriptor, boolean ommitHtmlSpecifics, PsiElement element) {
  StringBuilder buf = new StringBuilder();
  final boolean istag = descriptor instanceof HtmlTagDescriptor;

  if (istag) {
    DocumentationUtil.formatEntityName(XmlBundle.message("xml.javadoc.tag.name.message"),descriptor.getName(),buf);
  } else {
    DocumentationUtil.formatEntityName(XmlBundle.message("xml.javadoc.attribute.name.message"),descriptor.getName(),buf);
  }

  buf.append(XmlBundle.message("xml.javadoc.description.message")).append(NBSP).append(descriptor.getDescription()).append(BR);

  if (istag) {
    final HtmlTagDescriptor tagDescriptor = (HtmlTagDescriptor)descriptor;

    if (!ommitHtmlSpecifics) {
      boolean hasStartTag = tagDescriptor.isHasStartTag();
      if (!hasStartTag) {
        buf.append(XmlBundle.message("xml.javadoc.start.tag.could.be.omitted.message")).append(BR);
      }
      if (!tagDescriptor.isEmpty() && !tagDescriptor.isHasEndTag()) {
        buf.append(XmlBundle.message("xml.javadoc.end.tag.could.be.omitted.message")).append(BR);
      }
    }

    if (tagDescriptor.isEmpty()) {
      buf.append(XmlBundle.message("xml.javadoc.is.empty.message")).append(BR);
    }
  } else {
    final HtmlAttributeDescriptor attributeDescriptor = (HtmlAttributeDescriptor)descriptor;

    buf.append(XmlBundle.message("xml.javadoc.attr.type.message", attributeDescriptor.getType())).append(BR);
    if (!attributeDescriptor.isHasDefaultValue())
      buf.append(XmlBundle.message("xml.javadoc.attr.default.required.message")).append(BR);
  }

  char dtdId = descriptor.getDtd();
  boolean deprecated = dtdId == HtmlTagDescriptor.LOOSE_DTD;
  if (deprecated) {
    buf.append(XmlBundle.message("xml.javadoc.deprecated.message", deprecated)).append(BR);
  }

  if (dtdId == HtmlTagDescriptor.LOOSE_DTD) {
    buf.append(XmlBundle.message("xml.javadoc.defined.in.loose.dtd.message"));
  }
  else if (dtdId == HtmlTagDescriptor.FRAME_DTD) {
    buf.append(XmlBundle.message("xml.javadoc.defined.in.frameset.dtd.message"));
  }
  else {
    buf.append(XmlBundle.message("xml.javadoc.defined.in.any.dtd.message"));
  }

  if (!istag) {
    addColorPreviewAndCodeToLookup(element, buf);
  }

  if (element != null) {
    buf.append(XmlDocumentationProvider.generateHtmlAdditionalDocTemplate(element));
  }

  return buf.toString();
}