lambda finder available!
"Zdeněk Troníček"
tronicek at fit.cvut.cz
Mon Nov 15 04:56:45 PST 2010
RefactoringNG can help with such refactorings. It does not work with JDK 7
now but certainly will in future.
http://kenai.com/projects/refactoringng/pages/Home
Z.
--
Zdenek Tronicek
FIT CTU in Prague
maurizio cimadamore napsal(a):
> On 13/11/2010 06:09, Thomas Jung wrote:
>> Hi Maurizio,
>>
>> nice feature. Could the message also contain the lambda expression?
>> I've no idea about the compiler internals. Can you generate java code
>> from the AST at this stage?
> Nice idea, I will think about it - it certainly looks feasible.
>
>> Hopefully IDEs will support batch conversions when lambda expressions
>> are in Java.
> Yeah - the compiler note can be used by IDE such as NetBeans to
> perform/suggest refactoring (similar to what we have done in project
> coin for diamond, multicatch and strings in switch).
>
> Maurizio
>> Thomas
>>
>> On 12 November 2010 18:55, Maurizio Cimadamore
>> <maurizio.cimadamore at oracle.com> wrote:
>>> Hi,
>>> I'd like to spend few time in order to discuss a feature that I pushed
>>> while back and that probably went unnoticed (I just realized that the
>>> commit message didn't contain anything too specific about that :-) ).
>>>
>>> The idea is to find all potential anonymous inner class creation
>>> expressions that can be potentially replaced by a lambda expression. In
>>> order to turn this 'lambda finder' feature on, you need to pass the
>>> compiler the hidden flag '-XDidentifyLambdaCandidate=true'.
>>>
>>> This is an example of how the flag works; assume that you have the
>>> following code:
>>>
>>> class Test {
>>> Runnable r = new Runnable() { void run() {
>>> System.out.println("Hello!");
>>> } };
>>> }
>>>
>>> if you compile the above program with the hidden flag, javac will emit
>>> the following note:
>>>
>>> Test.java:2: Note: This anonymous inner class creation can be turned
>>> into a lambda expression.
>>> Runnable r = new Runnable() { public void run() {
>>> System.out.println("Hello!"); } };
>>> ^
>>>
>>> This means that this feature can be helpful (I hope) in order to
>>> refactor existing code base to use lambda expressions.
>>>
>>> Maurizio
>>>
>>>
>>>
>
>
>
More information about the lambda-dev
mailing list