Please use the Apache issue tracking system for new NetBeans issues (https://issues.apache.org/jira/projects/NETBEANS0/issues) !!
Bug 143677 - Show warning on current line for how to display hints not working
Show warning on current line for how to display hints not working
Status: RESOLVED FIXED
Product: php
Classification: Unclassified
Component: Editor
6.x
All All
: P3 with 1 vote (vote)
: 8.0
Assigned To: Ondrej Brejla
issues@php
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2008-08-12 22:04 UTC by tonybeckham
Modified: 2013-02-06 13:53 UTC (History)
2 users (show)

See Also:
Issue Type: DEFECT
:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description tonybeckham 2008-08-12 22:04:08 UTC
System:
Product Version: NetBeans IDE Dev (Build 200808120201)
Java: 1.5.0_13; Java HotSpot(TM) Client VM 1.5.0_13-119
System: Mac OS X version 10.5.4 running on i386; MacRoman; en_US (nb)

Problem:
In the Editor, Hints panel for PHP, the "Show As warning on current line" does nothing.  Sometimes changing the Show as
to error or warning and accepting so the hint is shown in the editor, then changing the option back to Show as warning
on current line will show the hint at the current line.
Comment 1 tonybeckham 2008-08-12 22:12:12 UTC
Steps:
1. Create new PHP application
2. In the NetBeans options set Hints for PHP to include Unknown Function under experimental
3. For the Show as leave as Warning
4. In index.php add a non-existent function call foo(); warning is shown
5. Go back to the Hints options and change to Show as Warning on Current Line and press OK
6. No warning for for foo(); 
Comment 2 Tomasz Slota 2008-08-13 10:35:38 UTC
reproducible, probably a P2.

 The problem is located in the GSF (or possibly editor) infrastructure, reassigning
Comment 3 Torbjorn Norbye 2008-08-24 06:19:57 UTC
This is a PHP bug - your HintsProvider's "computeSuggestions" method isn't implemented (it's an empty stub - ditto for
computeSelectionHints, though that isn't a problem since users cannot convert hints to selection hints like they can for
suggestions, so you only run into this once you try to implement a selection hint (like extract method / introduce
variable / etc.)

computeSuggestions() is the method that is supposed to compute caret-sensitive hints. (Yeah, the name could be better...
this is the same as it is for Java. I think the idea is that caret-sensitive hints are typically for "errors" that are
really suggestions, e.g. when you in Ruby place your caret on something like "if !x", it offers ("suggests") to convert
it to "unless x".  computeHints() on the other hand are for errors that really are errors no matter where the caret is.)

There are a lot of warning-on-current-line suggestions in Ruby, so you can test these there to see how it works.
Comment 4 Petr Pisl 2008-08-25 13:33:08 UTC
Assigning back to Tomasz.
Comment 5 Tomasz Slota 2008-08-26 12:00:19 UTC
I don't see how this bug is related to "suggestions".

I think it is about the GSF UI for setting priority for individual hints ("show as: error/warning/warning on current line"). If it is not possible to set up ordinary 
hints (as opposed to suggestions) to  show as "warning on current line" this option should not be available. Or am I getting something wrong?

I am reassigning back to GSF. 
PS. Possibly this is not a P2 after all
Comment 6 Torbjorn Norbye 2008-08-27 22:53:30 UTC
> Or am I getting something wrong?

Yes - you must implement computeSuggestions(), it isn't optional.  A suggestion is simply a hint which is only enabled
for the current line. Therefore, changing a "hint" to "warning on current line" is actually making it a suggestion.
(This is also why the option works fine for Ruby and JavaScript and not PHP: they implement computeSuggestions.)

Typically, you just look at the caret position, compute the AST path from the root down to this caret position, and then
run all the rules that have nodetypes matching this path. 

(This also explains why "Warning On Current Line" isn't just something that's handled by GSF. It -could- run ALL rules
on the entire buffer, and then just simply quietly filter out any hints that aren't on the current line. But that could
be very expensive. The advantage of suggestions is that they are actually only run when the caret intersects an AST node
for a rule corresponding to a suggestion.)

We could optionally let a hints provider say whether it refuses to implement suggestions, and therefore the UI could
refuse to let you change a hint into a suggestion (which is what changing from Error/Warning to Warning On Current Line
does) - but that isn't there today, and I'm not sure it's a good idea.  There are times when you think a hint is "too
noisy" but you're willing to see it when you are touching code that is affected by the rule.  

P.S. Yes, the whole UI concepts around warnings/suggestions are a bit fuzzy and could need some clearing up. But I
believe we're doing roughly the same thing as the Java module here.
Comment 7 Tomasz Slota 2010-02-10 08:44:45 UTC
reassigning to default owner
Comment 8 Filip Zamboj 2010-09-15 12:26:17 UTC
batch reassigning
Comment 9 Ondrej Brejla 2011-10-04 10:08:44 UTC
Still reproducible in 7.1.
Comment 10 Ondrej Brejla 2012-10-22 13:33:46 UTC
Still valid in 7.3dev. Hints infrastructure should be rewritten a bit to allow computeSuggestions() method to handle manager.getHints(true, ...) (common hints which should be visible only on current line) properly.
Comment 11 Ondrej Brejla 2013-02-06 13:53:15 UTC
Fixed in web-main #8304e2548596


By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2014, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo