paul-bennett / juggle

A declarative search tool for Java APIs
Apache License 2.0
5 stars 0 forks source link

Juggle should emit `...` rather than `[]` for varargs params #119

Closed paul-bennett closed 5 months ago

paul-bennett commented 5 months ago

When emitting a method signature, Juggle currently emits any final varargs parameter as an array type. Instead it should emit it as the underlying element type followed by an ellipsis.

Current behaviour:

$ juggle '/java.nio.file.Files.find/' 
public static transient java.util.stream.Stream<interface java.nio.file.Path> java.nio.file.Files.find(java.nio.file.Path,int,java.util.function.BiPredicate<java.nio.file.Path,java.nio.file.attribute.BasicFileAttributes>,java.nio.file.FileVisitOption[]) throws java.io.IOException

Intended behaviour:

$ juggle '/java.nio.file.Files.find/' 
public static transient java.util.stream.Stream<java.nio.file.Path> java.nio.file.Files.find(java.nio.file.Path,int,java.util.function.BiPredicate<java.nio.file.Path,java.nio.file.attribute.BasicFileAttributes>,java.nio.file.FileVisitOption...) throws java.io.IOException
paul-bennett commented 5 months ago

Problem is caused by the way parameters are decoded in TextOutput. Juggle currently uses Method.getGenericParameterTypes(), but should instead look at Method.getParameters() since the latter returns an array of Parameter objects, which include the isVarArgs() method.

Beware though... does the Parameter include the details of generics?

paul-bennett commented 5 months ago

Mostly done. One remaining issue is with Stream<T>.of(T...), which Juggle is listing as taking an array parameter