Honza-cz opened a new issue, #6311:
URL: https://github.com/apache/netbeans/issues/6311
### Apache NetBeans version
Apache NetBeans 18
### What happened
When using Optional/Stream and other monads, netbeans is not able to extract
method correctly from lambda expression. Input parameters are missing (in some
cases).
I am willing to fix it if you can provide a pointer, which module/java class
is responsible for that.
### How to reproduce
Assume following code:
```
public class ExtractMethodDemo {
public static void main(String[] args) {
String first = "hello";
String second = "world";
System.out.println(
java.util.Optional.ofNullable("-")
.map(t -> first + t + second)
.orElseThrow()
);
}
}
```
I would like to move code `t -> first + t + second` to a new method, some
kind or parametrized factory, so I select it ALT SHIFT M (extract method)
It creates following not compilable method
```
public class ExtractMethodDemo {
public static void main(String[] args) {
String first = "hello";
String second = "world";
System.out.println(java.util.Optional.ofNullable("-")
.map(factory())
.orElseThrow()
);
}
private static Function<String, String> factory() {
return t -> first + t + second;
}
}
```
Function lacks input parameters as `Function<String, String> factory(String
first, String second)`
### Did this work correctly in an earlier version?
No / Don't know
### Operating System
Ubuntu
### JDK
8/17
### Apache NetBeans packaging
Apache NetBeans binary zip
### Anything else
_No response_
### Are you willing to submit a pull request?
Yes
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists