Class Util

java.lang.Object
org.fife.rsta.ac.java.Util

public final class Util extends Object
Utility methods for Java completion.
Version:
1.0
  • Field Details

    • DOC_COMMENT_LINE_HEADER

      static final Pattern DOC_COMMENT_LINE_HEADER
      Optional leading text for doc comment lines (except the first line) that should be removed if it exists.
    • lastCUFromDisk

      private static CompilationUnit lastCUFromDisk
      A cache of the last CompilationUnit read from some attached source on disk. This is cached because, in some scenarios, the method getCompilationUnitFromDisk(SourceLocation, ClassFile) will be called for the same class many times in a row (such as to get method parameter info for all methods in a single class).
    • lastCUFileParam

      private static SourceLocation lastCUFileParam
    • lastCUClassFileParam

      private static ClassFile lastCUClassFileParam
  • Constructor Details

    • Util

      private Util()
      Private constructor to prevent instantiation.
  • Method Details

    • appendDocCommentTail

      private static void appendDocCommentTail(StringBuilder sb, StringBuilder tail)
    • appendLinkTagText

      private static void appendLinkTagText(StringBuilder appendTo, String linkContent)
      Appends HTML representing a "link" or "linkplain" Javadoc element to a string buffer.

      For some information on this format, see http://docs.oracle.com/javase/7/docs/technotes/tools/windows/javadoc.html#see.

      Parameters:
      appendTo - The buffer to append to.
      linkContent - The content of a "link", "linkplain" or "see" item.
    • docCommentToHtml

      public static String docCommentToHtml(String dc)
      Converts a Java documentation comment to HTML.
       This is a
       pre block
       
      Parameters:
      dc - The documentation comment.
      Returns:
      An HTML version of the comment.
    • forXML

      private static String forXML(String aText)
    • fixDocComment

      private static StringBuilder fixDocComment(StringBuilder text)
    • fixLinkText

      private static String fixLinkText(String text)
      Tidies up a link's display text for use in a <a> tag.
      Parameters:
      text - The text (a class, method, or field signature).
      Returns:
      The display value for the signature.
    • getCompilationUnitFromDisk

      public static CompilationUnit getCompilationUnitFromDisk(SourceLocation loc, ClassFile cf)
      Used by MemberCompletion.Data implementations to get an AST from a source file in a SourceLocation. Classes should prefer this method over calling into the location directly since this method caches the most recent result for performance.
      Parameters:
      loc - A directory or zip/jar file.
      cf - The ClassFile representing the source grab from the location.
      Returns:
      The compilation unit, or null if it is not found or an IO error occurs.
    • getUnqualified

      public static String getUnqualified(String clazz)
      Returns the "unqualified" version of a (possibly) fully-qualified class name.
      Parameters:
      clazz - The class name.
      Returns:
      The unqualified version of the name.
    • indexOf

      private static int indexOf(char ch, CharSequence sb, int offs)
      Returns the next location of a single character in a character sequence. This method is here because StringBuilder doesn't get this method added to it until Java 1.5.
      Parameters:
      ch - The character to look for.
      sb - The character sequence.
      offs - The offset at which to start looking.
      Returns:
      The next location of the character, or -1 if it is not found.
    • isFullyQualified

      public static boolean isFullyQualified(String str)
      Returns whether the specified string is "fully qualified," that is, whether it contains a '.' character.
      Parameters:
      str - The string to check.
      Returns:
      Whether the string is fully qualified.
      See Also:
    • isInPreBlock

      private static boolean isInPreBlock(String line, boolean prevValue)
      Returns whether this line ends in the middle of a pre-block.
      Parameters:
      line - The line's contents.
      prevValue - Whether this line started in a pre-block.
      Returns:
      Whether the line ends in a pre-block.
    • possiblyStripDocCommentTail

      private static String possiblyStripDocCommentTail(String str)
      Removes the tail end of a documentation comment from a string, if it exists.
      Parameters:
      str - The string.
      Returns:
      The string, possibly with the documentation comment tail removed.
    • splitOnChar

      public static String[] splitOnChar(String str, int ch)
      A faster way to split on a single char than String#split(), since we'll be doing this in a tight loop possibly thousands of times (rt.jar). This is also fundamentally different from String.split(String)), in the case where str ends with ch - this method will return an empty item at the end of the returned array, while String#split() will not.
      Parameters:
      str - The string to split.
      ch - The char to split on.
      Returns:
      The string, split on the character (e.g. '/' or '.').