This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 218861 - Add hint: Extract constants from strings and numbers
Summary: Add hint: Extract constants from strings and numbers
Status: NEW
Alias: None
Product: java
Classification: Unclassified
Component: Hints (show other bugs)
Version: 7.3
Hardware: PC Windows 7
: P3 normal with 1 vote (vote)
Assignee: Svata Dedic
URL:
Keywords:
: 238295 (view as bug list)
Depends on:
Blocks:
 
Reported: 2012-09-23 13:21 UTC by markiewb
Modified: 2014-06-12 22:07 UTC (History)
3 users (show)

See Also:
Issue Type: ENHANCEMENT
Exception Reporter:


Attachments
How it is done in IntellijIDEA - taken from http://jetbrains.dzone.com/articles/top-20-refactoring-features (44.46 KB, image/png)
2014-06-12 22:07 UTC, markiewb
Details

Note You need to log in before you can comment on or make changes to this bug.
Description markiewb 2012-09-23 13:21:14 UTC
Select a inner part of a string constant, execute the hint and the selected part is extracted to a variable/field/parameter/constant.

See the feature in eclipse: http://eclipseone.wordpress.com/2010/04/19/extract-constants-from-strings-and-numbers-with-eclipse-refactorings/
Comment 1 markiewb 2013-11-16 13:09:33 UTC
Somehow related to https://netbeans.org/bugzilla/show_bug.cgi?id=238295
Comment 2 Svata Dedic 2013-12-03 09:41:51 UTC
I understand how extraction of a part of String could work, but what to do with numbers ? I've read through the original text on EclipseONE, but the former two procedures are just NetBeans Introduce Constant hint, we're missing just the last extract part of string intention. Do I miss something ?
Comment 3 Svata Dedic 2013-12-03 10:34:24 UTC
*** Bug 238295 has been marked as a duplicate of this bug. ***
Comment 4 markiewb 2013-12-03 19:46:12 UTC
(In reply to Svata Dedic from comment #2)
> I understand how extraction of a part of String could work, but what to do
> with numbers ? I've read through the original text on EclipseONE, but the
> former two procedures are just NetBeans Introduce Constant hint, we're
> missing just the last extract part of string intention. Do I miss something ?

No, you didn't. The subheading "Pick out part of a string" was the only relevant one.

I like to propose a patch for it, but org.netbeans.spi.java.hints.HintContext only provides the caret location and not the selection start and selection end.

That was the reason I only support "split at caret" in my plugin https://github.com/markiewb/nb-additional-hints/commit/f5530a3989bed487b0473db7c74c541c83a2da84

BTW: Is it possible to set the caret location/selection after applying a fix/transformation? Worth an RFE I think...
Comment 5 markiewb 2014-06-12 22:07:47 UTC
Created attachment 147654 [details]
How it is done in IntellijIDEA - taken from http://jetbrains.dzone.com/articles/top-20-refactoring-features