You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm generating code that uses arrays in parameters / return types for methods. When compiling these, the classes for those are not defined. I therefore use the ClassName class to define this. The main problem I'm experiencing is that the imports become messed up if I try to add [] after the class name, it can for example looks like this:
So to say, the array specifier becomes included into the import, which makes the project not compile.
What did you want to happen?
Either make it possible to programatically specify arrays for ClassName instances, or remove the [] qualifier from the simplified name when generating imports.
Contribution
I can make a pr for this if necessary.
The text was updated successfully, but these errors were encountered:
I can't really test since you don't have an example, but are you sure you're not supposed to use ArrayTypeName.get for the places where you want to use it? I see this
public static ClassName get(Class<?> clazz) {
checkNotNull(clazz, "clazz == null");
checkArgument(!clazz.isPrimitive(), "primitive types cannot be represented as a ClassName");
checkArgument(!void.class.equals(clazz), "'void' type cannot be represented as a ClassName");
checkArgument(!clazz.isArray(), "array types cannot be represented as a ClassName");
in class name which kinda makes me feel like you can't actually use a direct array type in class name.
What happened?
I'm generating code that uses arrays in parameters / return types for methods. When compiling these, the classes for those are not defined. I therefore use the ClassName class to define this. The main problem I'm experiencing is that the imports become messed up if I try to add
[]
after the class name, it can for example looks like this:So to say, the array specifier becomes included into the import, which makes the project not compile.
What did you want to happen?
Either make it possible to programatically specify arrays for ClassName instances, or remove the
[]
qualifier from the simplified name when generating imports.Contribution
I can make a pr for this if necessary.
The text was updated successfully, but these errors were encountered: