@NotNull public static String buildPreview(@NotNull final String header,@Nullable final String qName,@Nullable final String fullText){
  if (fullText == null) {
    return header;
  }
  Map<String,String> links=ContainerUtilRt.newHashMap();
  process(fullText,new LinksCollector(links));
  Map<String,String> toAdd=ContainerUtilRt.newHashMap();
  for (  Map.Entry<String,String> entry : links.entrySet()) {
    String shortName=parseShortName(entry.getKey());
    if (shortName != null) {
      toAdd.put(shortName,entry.getValue());
    }
    String longName=parseLongName(entry.getKey(),entry.getValue());
    if (longName != null) {
      toAdd.put(longName,entry.getValue());
    }
  }
  links.putAll(toAdd);
  if (qName != null) {
    links.put(qName,DocumentationManagerProtocol.PSI_ELEMENT_PROTOCOL + qName);
  }
  List<TextRange> modifiedRanges=ContainerUtilRt.newArrayList();
  List<String> sortedReplacements=ContainerUtilRt.newArrayList(links.keySet());
  Collections.sort(sortedReplacements,REPLACEMENTS_COMPARATOR);
  StringBuilder buffer=new StringBuilder(header);
  replace(buffer,"\n","<br/>",modifiedRanges);
  for (  String replaceFrom : sortedReplacements) {
    String visibleName=replaceFrom;
    int i=visibleName.lastIndexOf('.');
    if (i > 0 && i < visibleName.length() - 1) {
      visibleName=visibleName.substring(i + 1);
    }
    replace(buffer,replaceFrom,String.format("<a href=\"%s\">%s</a>",links.get(replaceFrom),visibleName),modifiedRanges);
  }
  return buffer.toString();
}

@ NotNull public static String buildPreview ( @ NotNull final String header , @ Nullable final String qName , @ Nullable final String fullText ) { if ( fullText == null ) { return header ; } Map < String , String > links = ContainerUtilRt . newHashMap ( ) ; process ( fullText , new LinksCollector ( links ) ) ; Map < String , String > toAdd = ContainerUtilRt . newHashMap ( ) ; for ( Map . Entry < String , String > entry : links . entrySet ( ) ) { String shortName = parseShortName ( entry . getKey ( ) ) ; if ( shortName != null ) { toAdd . put ( shortName , entry . getValue ( ) ) ; } String longName = parseLongName ( entry . getKey ( ) , entry . getValue ( ) ) ; if ( longName != null ) { toAdd . put ( longName , entry . getValue ( ) ) ; } } links . putAll ( toAdd ) ; if ( qName != null ) { links . put ( qName , DocumentationManagerProtocol . PSI_ELEMENT_PROTOCOL + qName ) ; } List < TextRange > modifiedRanges = ContainerUtilRt . newArrayList ( ) ; List < String > sortedReplacements = ContainerUtilRt . newArrayList ( links . keySet ( ) ) ; Collections . sort ( sortedReplacements , REPLACEMENTS_COMPARATOR ) ; StringBuilder buffer = new StringBuilder ( header ) ; replace ( buffer , "\n" , "<br/>" , modifiedRanges ) ; for ( String replaceFrom : sortedReplacements ) { String visibleName = replaceFrom ; int i = visibleName . lastIndexOf ( '.' ) ; if ( i > 0 && i < visibleName . length ( ) - 1 ) { visibleName = visibleName . substring ( i + 1 ) ; } replace ( buffer , replaceFrom , String . format ( "<a href=\"%s\">%s</a>" , links . get ( replaceFrom ) , visibleName ) , modifiedRanges ) ; } return buffer . toString ( ) ; }
allows to build a documentation preview from the given arguments . basically , takes given ' header ' text and tries to modify it by using hyperlink information encapsulated at the given ' full text ' .
