Bug 570785

Summary: Extract method refactoring provide better default names
Product: [Eclipse Project] JDT Reporter: Max Rydahl Andersen <manderse>
Component: TextAssignee: JDT-Text-Inbox <jdt-text-inbox>
Status: ASSIGNED --- QA Contact:
Severity: enhancement    
Priority: P3 CC: mistria, rgrunber, snjezana.peco
Version: 4.19Keywords: bugday, helpwanted
Target Milestone: ---   
Hardware: All   
OS: All   
Whiteboard:

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).