Modifier and Type | Method and Description |
---|---|
static boolean |
areOnSameLine(DetailAST ast1,
DetailAST ast2)
Determines if two ASTs are on the same line.
|
static Optional<DetailAST> |
findFirstTokenByPredicate(DetailAST root,
Predicate<DetailAST> predicate)
|
static void |
forEachChild(DetailAST root,
int type,
Consumer<DetailAST> action)
Performs an action for each child of
DetailAST root node
which matches the given token type. |
static int[] |
getAllTokenIds()
Get all token IDs that are available in TokenTypes.
|
static int |
getIntFromField(Field field,
Object object)
Gets the value of a static or instance field of type int or of another primitive type
convertible to type int via a widening conversion.
|
static String |
getShortDescription(String name)
Returns the short description of a token for a given name.
|
static int |
getTokenId(String name)
Returns the ID of a token for a given name.
|
static String |
getTokenName(int id)
Returns the name of a token for a given ID.
|
static int |
getTokenTypesTotalNumber()
Get total number of TokenTypes.
|
static boolean |
isCommentType(int type)
Is argument comment-related type (SINGLE_LINE_COMMENT,
BLOCK_COMMENT_BEGIN, BLOCK_COMMENT_END, COMMENT_CONTENT).
|
static boolean |
isCommentType(String type)
Is argument comment-related type name (SINGLE_LINE_COMMENT,
BLOCK_COMMENT_BEGIN, BLOCK_COMMENT_END, COMMENT_CONTENT).
|
static Map<String,Integer> |
nameToValueMapFromPublicIntFields(Class<?> cls)
Creates a map of 'field name' to 'field value' from all
public int fields
of a class. |
static String[] |
valueToNameArrayFromNameToValueMap(Map<String,Integer> map)
Creates an array of map keys for quick value-to-name lookup for the map.
|
public static int getIntFromField(Field field, Object object)
field
- from which the int should be extractedobject
- to extract the int value fromIllegalStateException
- if this Field object is enforcing Java language access control
and the underlying field is inaccessibleField.getInt(Object)
public static Map<String,Integer> nameToValueMapFromPublicIntFields(Class<?> cls)
public
int
fields
of a class.cls
- source classpublic static String[] valueToNameArrayFromNameToValueMap(Map<String,Integer> map)
map
- source mappublic static int getTokenTypesTotalNumber()
public static int[] getAllTokenIds()
public static String getTokenName(int id)
id
- the ID of the token name to getIllegalArgumentException
- when id is not validpublic static int getTokenId(String name)
name
- the name of the token ID to getIllegalArgumentException
- when id is nullpublic static String getShortDescription(String name)
name
- the name of the token ID to getIllegalArgumentException
- when name is unknownpublic static boolean isCommentType(int type)
type
- token type.public static boolean isCommentType(String type)
type
- token type name.public static Optional<DetailAST> findFirstTokenByPredicate(DetailAST root, Predicate<DetailAST> predicate)
public static void forEachChild(DetailAST root, int type, Consumer<DetailAST> action)
DetailAST
root node
which matches the given token type.root
- root node.type
- token type to match.action
- action to perform on the nodes.public static boolean areOnSameLine(DetailAST ast1, DetailAST ast2)
ast1
- the first ASTast2
- the second ASTCopyright © 2001–2020. All rights reserved.