Bug 570785 - Extract method refactoring provide better default names
Summary: Extract method refactoring provide better default names
Status: ASSIGNED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Text (show other bugs)
Version: 4.19   Edit
Hardware: All All
: P3 enhancement with 1 vote (vote)
Target Milestone: ---   Edit
Assignee: JDT-Text-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords: bugday, helpwanted
Depends on:
Blocks:
 
Reported: 2021-01-30 19:06 EST by Max Rydahl Andersen CLA
Modified: 2021-07-02 15:54 EDT (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 Max Rydahl Andersen CLA 2021-01-30 19:06:16 EST
when doing refactoring in i.e. intellij it will take into account the "context".

i.e. trying to extract a method for "Catalog catalog = getMergedCatalog(cwd, false);" intellij will offer to call the method "getCatalog" while eclipse calls it "extracted".

This applies to almost all refactorings afaics.
Comment 1 Mickael Istria CLA 2021-01-31 05:09:02 EST
Seems like a relatively easy fix.
@Roland: does JDT-LS reuse the default proposals from JDT here? If we change that part of JDT, would JDT-LS automatically have access to this enhancement?
Comment 2 Roland Grunberg CLA 2021-02-01 10:21:39 EST
This rang a bell, and I managed to find https://git.eclipse.org/r/c/jdt/eclipse.jdt.ui/+/162579 , where we did something similar.

This is all in org.eclipse.jdt.core.NamingConventions#suggest* .

I think for blocks of text there could be some heuristic where the suggestions are based off the last declared variable that is not being referenced in the selected range.

The extract method refactoring is copied over into jdt-ls because it's currently sitting under jdt.ui (and not under core.manipulation).