Bug 424266 - [1.8][clean up] Convert anonymous to lambda should preserve comments
Summary: [1.8][clean up] Convert anonymous to lambda should preserve comments
Status: ASSIGNED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 4.4   Edit
Hardware: All All
: P3 minor (vote)
Target Milestone: ---   Edit
Assignee: Fabrice Tiercelin CLA
QA Contact:
URL:
Whiteboard: stalebug
Keywords:
: 516830 (view as bug list)
Depends on:
Blocks:
 
Reported: 2013-12-17 14:05 EST by Markus Keller CLA
Modified: 2022-12-15 06:10 EST (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Markus Keller CLA 2013-12-17 14:05:04 EST
When testing the anonymous -> lambda conversion cleanups on jdt.ui, I saw cases where comments were lost in the process.

We could try to preserve
- Javadoc on the method
- if we create a lambda without a block: comments inside the method body before/after the first/last statement

The comments could be inserted on separate lines just before/after the enclosing statement of the lambda expression.

We should not preserve block comments on the method, since these are often boilerplate /* (non-Javadoc) ... */

Examples:

- TableTextCellEditor.java:

text.addFocusListener(new FocusAdapter() {
    @Override
    public void focusLost(FocusEvent e) {
        e.display.asyncExec(new Runnable() {
            @Override
            public void run() {
                // without the asyncExec, focus has not had a chance to go to the content assist proposals
                TableTextCellEditor.this.focusLost();
            }
        });
    }
});

- IntroduceFactoryRefactoring.java:

	Arrays.sort(hits, new Comparator<SearchMatch>() {
		/**
		 * Sort by descending offset, such that nested constructor calls are processed first.
		 * This is necessary, since they can only be moved into the factory method invocation
		 * after they have been rewritten.
		 */
		@Override
		public int compare(SearchMatch m1, SearchMatch m2) {
			return m2.getOffset() - m1.getOffset();
		}
	});
Comment 1 Markus Keller CLA 2014-02-06 07:58:30 EST
If we find a good solution, we should also apply it to bug 427169 comment 4.
Comment 2 Noopur Gupta CLA 2017-05-18 04:31:07 EDT
*** Bug 516830 has been marked as a duplicate of this bug. ***
Comment 3 Eclipse Genie CLA 2020-09-22 06:43:57 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.
Comment 4 Lars Vogel CLA 2020-09-22 07:20:04 EDT
Fabrice, is that issue still relevant?
Comment 5 Eclipse Genie CLA 2022-12-15 06:10:34 EST
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.