Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 347839

Summary: [1.7][quick assist]Quick assists for base conversion
Product: [Eclipse Project] JDT Reporter: Deepak Azad <deepakazad>
Component: UIAssignee: JDT-UI-Inbox <jdt-ui-inbox>
Status: ASSIGNED --- QA Contact:
Severity: enhancement    
Priority: P4 CC: markus.kell.r, pyvesdev
Version: 3.7   
Target Milestone: ---   
Hardware: All   
OS: All   
Whiteboard:
Attachments:
Description Flags
v0.5 none

Description Deepak Azad CLA 2011-05-31 13:56:47 EDT
Now we can have binary, octal, decimal and hexadecimal literals in Java code. It might be useful to have quick assists which convert integer literals from one base to another.
Comment 1 Markus Keller CLA 2011-06-01 07:14:59 EDT
The relevance of these quick assists should be lower than the relevance of the Extract ... quick assists.

Negative numbers will need some special love, otherwise converting e.g.

    public static final int CONST= 0xFFFFFFFF;

to decimal will result in -1, and when you convert only the NumberLiteral back to hex, you'd get -0x1.

Also make sure it behaves well with floating-point literals.
Comment 2 Deepak Azad CLA 2011-06-09 07:21:27 EDT
Created attachment 197682 [details]
v0.5

I had written this code a while back. The patch uses apis from Integer class to do the parsing and conversion, but these APIs have not been completely updated (e.g. they do not handle underscores). Hence the patch is far from perfect. Will come back to it at some point in the future.
Comment 3 Pierre-Yves Bigourdan CLA 2020-01-28 04:28:35 EST
This seems like a nice feature. Any chance you could complete your patch Deepak? :)