Package org.fife.rsta.ac.java
Class Util
- java.lang.Object
-
- org.fife.rsta.ac.java.Util
-
public final class Util extends java.lang.ObjectUtility methods for Java completion.- Version:
- 1.0
-
-
Field Summary
Fields Modifier and Type Field Description (package private) static java.util.regex.PatternDOC_COMMENT_LINE_HEADEROptional leading text for doc comment lines (except the first line) that should be removed if it exists.private static ClassFilelastCUClassFileParamprivate static SourceLocationlastCUFileParamprivate static CompilationUnitlastCUFromDiskA cache of the lastCompilationUnitread from some attached source on disk.(package private) static java.util.regex.PatternLINK_TAG_MEMBER_PATTERNPattern matching a link in a "@link" tag.
-
Constructor Summary
Constructors Modifier Constructor Description privateUtil()Private constructor to prevent instantiation.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description private static voidappendDocCommentTail(java.lang.StringBuilder sb, java.lang.StringBuilder tail)private static voidappendLinkTagText(java.lang.StringBuilder appendTo, java.lang.String linkContent)Appends HTML representing a "link" or "linkplain" Javadoc element to a string buffer.static java.lang.StringdocCommentToHtml(java.lang.String dc)Converts a Java documentation comment to HTML.private static java.lang.StringBuilderfixDocComment(java.lang.StringBuilder text)private static java.lang.StringfixLinkText(java.lang.String text)Tidies up a link's display text for use in a <a> tag.private static java.lang.StringforXML(java.lang.String aText)static CompilationUnitgetCompilationUnitFromDisk(SourceLocation loc, ClassFile cf)Used byMemberCompletion.Dataimplementations to get an AST from a source file in aSourceLocation.static java.lang.StringgetUnqualified(java.lang.String clazz)Returns the "unqualified" version of a (possibly) fully-qualified class name.private static intindexOf(char ch, java.lang.CharSequence sb, int offs)Returns the next location of a single character in a character sequence.static booleanisFullyQualified(java.lang.String str)Returns whether the specified string is "fully qualified," that is, whether it contains a '.' character.private static booleanisInPreBlock(java.lang.String line, boolean prevValue)Returns whether this line ends in the middle of a pre-block.private static java.lang.StringpossiblyStripDocCommentTail(java.lang.String str)Removes the tail end of a documentation comment from a string, if it exists.static java.lang.String[]splitOnChar(java.lang.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).
-
-
-
Field Detail
-
DOC_COMMENT_LINE_HEADER
static final java.util.regex.Pattern DOC_COMMENT_LINE_HEADER
Optional leading text for doc comment lines (except the first line) that should be removed if it exists.
-
LINK_TAG_MEMBER_PATTERN
static final java.util.regex.Pattern LINK_TAG_MEMBER_PATTERN
Pattern matching a link in a "@link" tag. This should match the following:- ClassName
- fully.qualified.ClassName
- #method
- #method(int, int)
- String#method
- String#method(params)
- fully.qualified.ClassName#method
- fully.qualified.ClassName#method(params)
"<a href=...") are not matched and should be handled separately.
-
lastCUFromDisk
private static CompilationUnit lastCUFromDisk
A cache of the lastCompilationUnitread from some attached source on disk. This is cached because, in some scenarios, the methodgetCompilationUnitFromDisk(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
-
-
Method Detail
-
appendDocCommentTail
private static void appendDocCommentTail(java.lang.StringBuilder sb, java.lang.StringBuilder tail)
-
appendLinkTagText
private static void appendLinkTagText(java.lang.StringBuilder appendTo, java.lang.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 java.lang.String docCommentToHtml(java.lang.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 java.lang.String forXML(java.lang.String aText)
-
fixDocComment
private static java.lang.StringBuilder fixDocComment(java.lang.StringBuilder text)
-
fixLinkText
private static java.lang.String fixLinkText(java.lang.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 byMemberCompletion.Dataimplementations to get an AST from a source file in aSourceLocation. 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- TheClassFilerepresenting the source grab from the location.- Returns:
- The compilation unit, or
nullif it is not found or an IO error occurs.
-
getUnqualified
public static java.lang.String getUnqualified(java.lang.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, java.lang.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(java.lang.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:
getUnqualified(String)
-
isInPreBlock
private static boolean isInPreBlock(java.lang.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 java.lang.String possiblyStripDocCommentTail(java.lang.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 java.lang.String[] splitOnChar(java.lang.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 fromString.split(String)), in the case wherestrends withch- 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 '.').
-
-