Bug 347839 - [1.7][quick assist]Quick assists for base conversion
Summary: [1.7][quick assist]Quick assists for base conversion
Status: ASSIGNED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.7   Edit
Hardware: All All
: P4 enhancement (vote)
Target Milestone: ---   Edit
Assignee: JDT-UI-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-05-31 13:56 EDT by Deepak Azad CLA
Modified: 2020-01-28 04:28 EST (History)
2 users (show)

See Also:


Attachments
v0.5 (6.78 KB, patch)
2011-06-09 07:21 EDT, Deepak Azad CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
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? :)