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 245936 - [Declarative Hint] Please add feature to discern modifiers
Summary: [Declarative Hint] Please add feature to discern modifiers
Status: RESOLVED WONTFIX
Alias: None
Product: java
Classification: Unclassified
Component: Hints (show other bugs)
Version: 8.0.1
Hardware: PC Linux
: P3 normal (vote)
Assignee: Jan Lahoda
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-07-24 08:58 UTC by tomzi
Modified: 2016-07-07 07:18 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description tomzi 2014-07-24 08:58:02 UTC
I'd like to be able to transform this:
@ServiceLocator
private myServiceLocator;

to this 
@ServiceLocator
private transient myServiceLocator;

Currently this does not seem to be possible 

maybe it could be sth like

$mods$ $type $name; :: $mod$ contains @ServiceLoctor && $mod$ not contains transient
==> $mod$ transient $type $name;
Comment 1 Jan Lahoda 2014-07-25 05:31:14 UTC
This should work:
---
$mods$ @test2.ServiceLocator $type $name = $init$; :: !matchesAny($_, "$mods2$ transient $type2 $name2 = $init2$;")
=>
$mods$ @test2.ServiceLocator transient $type $name = $init$;
;;
---

Some notes:
-partial matching of modifiers should (AFAIK) work for a few releases now (since NB 7.3, as far as I can tell). I was convinced it is documented, but seems it is not. It is necessary to start with $mods$ (the name itself is not important of course) and then provide the modifiers and annotations that must be present - that is needed so that the pattern can be parsed correctly.
-sadly, specifying which modifiers should not be present is harder - above, matchesAny is used for that (note the varibles used by the embedded pattern are not the same as the variables used in the base pattern; that is done intentionally to avoid interferrence between the base and the embedded pattern).
Comment 2 tomzi 2014-07-25 06:50:54 UTC
COOL!Could you add this example (and other ones) to http://wiki.netbeans.org/JavaDeclarativeHintsFormat, since from there it was not easy to see how you use these conditions in this context... :)
Comment 3 tomzi 2014-07-25 07:27:50 UTC
Another question: I mixed the @.. a little around and wanted to have different messages shown on the hint, so I tried this:

@com.infonova.base.context.annotation.ByServiceLocator $mods$ $type $name = $init$; :: !matchesAny($_, "$mods2$ transient $type2 $name2 = $init2$;")
=> @com.infonova.base.context.annotation.ByServiceLocator $mods$ transient $type $name = $init$;
=> <!hint='Add transient'>
=> <!description="convert @ByServiceLocator private var to @ByServiceLocator private transient var">
;;

But whenever I click on the hint over
@ByServiceLocator
private Service service; 

I get:
'Rewrite to @ByServiceLocator  private@com.mypackage.ByServiceLocator transient @ByServiceLocator  private Service service: = $init$;'

which is kinda ugly.
Is there a nicer way to show what it actually creates?
Comment 4 Martin Balin 2016-07-07 07:18:05 UTC
This old bug may not be relevant anymore. If you can still reproduce it in 8.2 development builds please reopen this issue.

Thanks for your cooperation,
NetBeans IDE 8.2 Release Boss