vscode-java icon indicating copy to clipboard operation
vscode-java copied to clipboard

toString Generator shows fields in wrong order

Open boteomap2 opened this issue 3 years ago • 1 comments

Environment
  • Operating System: Windows 10
  • JDK version: 17
  • Visual Studio Code version: 1.68.0
  • Java extension version: 0.23.0
Description

toString Generator shows fields in the wrong order leading to code generated in the wrong order too.

Untitled

Expected result:

Fields should show in correct order like the constructor.

Untitled1

boteomap2 avatar Jun 10 '22 10:06 boteomap2

@CsCherrYY Looks like another code action ux related issue. Guess you might be interested in this. :)

jdneo avatar Jun 10 '22 12:06 jdneo

we now get the candidate list via ITypeBinding.getDeclaredFields(): https://github.com/eclipse/eclipse.jdt.ls/blob/726ece1d1fd26480028c217f1d27193f4cd05760/org.eclipse.jdt.ls.core/src/org/eclipse/jdt/ls/core/internal/handlers/JdtDomModels.java#L60

The return array seems to not be in particular order. Maybe IType.getFields() returns the correct definition order.

CsCherrYY avatar Aug 26 '22 02:08 CsCherrYY