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.
Product Version: NetBeans IDE Dev (Build 201505220001) Java: 1.8.0_45; Java HotSpot(TM) 64-Bit Server VM 25.45-b02 Runtime: Java(TM) SE Runtime Environment 1.8.0_45-b14 System: Windows 7 version 6.1 running on amd64; UTF-8; pl_PL (nb) Suppress Warning hint doesn't work for guarded block if there is no other SuppressWarnings annotations for this block. If there is already a SuppressWarnings, the hint work adding another warning type to it. Tested with the initComponents method, and the following warnings: * Convert2Lambda: - when I had @SuppressWarnings("rawtypes"), hint worked creating @SuppressWarnings({"rawtypes", "Convert2Lambda"}) - when I had no SuppressWarnings, hint didn't work and displayed message "Cannot apply fix in a guarded block" * Convert2Diamond: same as above * unchecked: same as above * rawtypes: doesn't have a hint (see bug 250590)
The trouble is that the code generator attempts to insert the annotation right before the method, more specifically in between the method and its javadoc, where the annotation would be generated under normal circumstances. Such fix is rather tough. Anyway, hints should be disabled on guarded code - the user cannot do anything with it anyway. Hints based on tree kinds already checked that, but hints based on patterns lacked the guard block check. So I take the easier path :) but the API manipulation methods will be still unable to insert @annotation before method in a guarded block. Hints suppressed in jet-main#656a757b5343
No, please, don't disable hints completely. They work at least when there is already an annotation, adding another suppress. It will be a regression.
Part of hints were already disabled; the distinction between the two types is just an implementation detail of how they are triggered. So from this point of view the 8.1beta behaviour is a defect: either all hints must be enabled for guarded blocks, or none. Since the user typically cannot intervene with computer-maintained content inside GB (be it beaninfo feature descriptor or form init), it does not make much sense to report suggestions. Compiler diagnostic (errors, warnings) use a different trigger mechanism and should not be affected by this change.
I've checked one more possibility how to fix the @SuppressWarning addition ... Sadly there's not currently an easy way how to express to the code generator that the fold comment which is already part of the guarded section is "sticky" and annotation should be generated before it. Lowering the priority, leaving open - perhaps some bright idea occurs to me.
Integrated into 'main-silver', will be available in build *201509300002* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress) Changeset: http://hg.netbeans.org/main-silver/rev/656a757b5343 User: Svata Dedic <sdedic@netbeans.org> Log: #252560: suppress pattern-based hints in guarded blocks