Package randoop.sequence
Class VariableRenamer
- java.lang.Object
-
- randoop.sequence.VariableRenamer
-
class VariableRenamer extends Object
-
-
Field Summary
Fields Modifier and Type Field Description Sequence
sequence
The sequence in which every variable will be renamed.private static int
VAR_NAME_MAX_DEPTH
Maximum depth to concatenate parameterized type names.
-
Constructor Summary
Constructors Constructor Description VariableRenamer(Sequence sequence)
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description private static String
capitalizeString(String variableName)
Capitalize the variable name while preserving any capitalized letters after the first letter.(package private) static String
getVariableName(Type type)
Heuristically transforms variables to better names based on its type name.private static String
getVariableName(Type type, int depth)
Heuristically renames each variable to a name that is based on the variable's type.private static String
lowercaseFirstCharacter(String variableName)
Lowercase the first character in the variable name while preserving any capitalized letters after the first letter.
-
-
-
Field Detail
-
sequence
public final Sequence sequence
The sequence in which every variable will be renamed.
-
VAR_NAME_MAX_DEPTH
private static final int VAR_NAME_MAX_DEPTH
Maximum depth to concatenate parameterized type names.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
VariableRenamer
public VariableRenamer(Sequence sequence)
-
-
Method Detail
-
getVariableName
static String getVariableName(Type type)
Heuristically transforms variables to better names based on its type name. Here are some examples:int var0 = 1 becomes int int0 = 1 ClassName var0 = new ClassName() becomes ClassName className = new ClassName() Class var0 = null becomes Class cls = null Queue<Set<List<Comparable<String>>>> var0 = null becomes Queue<Set<List<Comparable<String>>>> listSetQueue = null ArrayList<String> var0 = null becomes ArrayList<String> strList = null
- Parameters:
type
- the type to use as base of variable name- Returns:
- a variable name based on its type, with the first character lowercase and the final character not a digit
-
getVariableName
private static String getVariableName(Type type, int depth)
Heuristically renames each variable to a name that is based on the variable's type.- Parameters:
type
- the type to use as the base of the variable namedepth
- the number of components (i.e. type arguments) of the type that will be used to create a name for the variable- Returns:
- a variable name based on its type and is camel cased. The first character may be uppercase.
-
capitalizeString
private static String capitalizeString(String variableName)
Capitalize the variable name while preserving any capitalized letters after the first letter.- Parameters:
variableName
- the name of the variable- Returns:
- capitalized form of variable name
-
lowercaseFirstCharacter
private static String lowercaseFirstCharacter(String variableName)
Lowercase the first character in the variable name while preserving any capitalized letters after the first letter.- Parameters:
variableName
- the name of the variable- Returns:
- variableName with the first letter lowercased
-
-