Interface NodeWithVariables<N extends Node>
- All Known Implementing Classes:
FieldDeclaration
,VariableDeclarationExpr
public interface NodeWithVariables<N extends Node>
A node which has a list of variables.
-
Method Summary
Modifier and TypeMethodDescriptiondefault N
addVariable(VariableDeclarator variableDeclarator)
calculateMaximumCommonType(List<Type> types)
default Type
Returns the type that is shared between all variables.default Type
Returns the element type.Returns the type that maximum shared type between all variables.default VariableDeclarator
getVariable(int i)
default N
setAllTypes(Type newType)
Sets the type of all variables.default N
setVariable(int i, VariableDeclarator variableDeclarator)
setVariables(NodeList<VariableDeclarator> variables)
-
Method Details
-
getVariables
NodeList<VariableDeclarator> getVariables() -
setVariables
-
getVariable
-
setVariable
-
addVariable
-
getCommonType
Returns the type that is shared between all variables. This is a shortcut for when you are certain that all variables share one type. What makes this difficult is arrays, and being able to set the type.
Forint a;
this is int.
Forint a,b,c,d;
this is also int.
Forint a,b[],c;
this is an assertion error since b is an int[], not an int.
Forint a,b;
, then doing setType(String) on b, this is an assertion error. It is also a situation that you don't really want. -
getElementType
Returns the element type.
Forint a;
this is int.
Forint a,b,c,d;
this is also int.
Forint a,b[],c;
this is also int. Note: no mention of b being an array.
Forint a,b;
, then doing setType(String) on b, then calling getElementType(). This is an assertion error. It is also a situation that you don't really want. -
setAllTypes
Sets the type of all variables. Erases any existing type. This is a shortcut for setting a type on all variable declarators separately. -
getMaximumCommonType
Returns the type that maximum shared type between all variables. The minimum common type does never include annotations on the array level.
Forint a;
this is int.
Forint a,b,c,d;
this is also int.
Forint a,b[],c;
this is also int.
Forint[] a[][],b[],c[][];
this is int[][]. -
calculateMaximumCommonType
-