Class LocalNames
java.lang.Object
io.github.projectunified.craftcommand.processor.LocalNames
Allocates the local variable names of one generated command slot.
Names are derived from the parameters the user declared, so generated code reads num1 and
num2 rather than param_0 and param_1. Names that would shadow a local the generated
code itself relies on are given a unique suffix instead.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionAllocates a local for a parameter, based on the name the user declared for it.static StringdeclaredName(ParameterModel parameter) The identifier a parameter was declared with in the command class.
-
Constructor Details
-
LocalNames
public LocalNames()
-
-
Method Details
-
declaredName
The identifier a parameter was declared with in the command class.- Parameters:
parameter- the parameter model- Returns:
- the declared identifier, or
nullwhen the parameter has no element
-
allocate
Allocates a local for a parameter, based on the name the user declared for it.- Parameters:
preferred- the declared name, ornullto use the fallbackfallback- the name to use when the declared name is unusable- Returns:
- a name that is unique within the generated method
-