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.
When Debugging tooltips show values of the variables even when caret is placed over the variable name in comment or in different source file which is not debugged.
Tooltips are effectively temporary watches that are displayed in a tooltip, hence the described behavior. We would need additional checks to limit their display to scope, etc. So, let's say it is 'by design' and maybe we could make it a RFE or P4.
I'd like to keep this issue as P3 DEFECT, since the behavior is confusing. Is new debugger API designed to handle this?
Symbols in other files may still be valid: static variables, constants, enumerations, reference types, static methods. We would need some special mode of operation in expression evaluator that will "evaluate only in static context". The other solution is to disable tooltips in other files completely. The first is too much work for low effect and the second is a limitation in functionality.
This has nathing common wit debugger apis. It depends on Java Parser functionality. It can be iproved in the future.
*** Issue 51795 has been marked as a duplicate of this issue. ***
IMHO to fix this, we would have to retrieve the type of the enclosing class from the editor. And then evaluate the variable as <class type>.this.<variable name> - can be done after issue #59735 is fixed. This would work for fields, I'm not sure about local variables... Also, we should disable tooltips on Java keywords - they look terribly.
*** Issue 68315 has been marked as a duplicate of this issue. ***
Tooltips shown on strings in source code ("text") contain meaningless messages too: text = >"text" is not a know variable in current context< The same for any word in comment. Tooltips on classes show: java.lang.Object = >Unknown type "java.lang.Object"< I would not present such things about debugger :).
*** Issue 110457 has been marked as a duplicate of this issue. ***
Also reported the tooltip disappeared after some delay -- no repro-case available. It is probably too late to fix in NB 6; if so, this issue should be addressed in the next release.
Scheduling for the next version, restrictions of this kind must be done carefully. Using the Java parser, we can detect the correct scope for local variables and we can evaluate fields with the respect to the correct class.
Fixed, the following features have been implemented: - tooltip is not displayed on comments - tooltip is displayed only for current class and its super classes - it is still possible to show tooltip for an arbitrary piece of code when it is selected in editor (this works even for comments) http://hg.netbeans.org/main/rev/6b491fda81bd
verified in NB 6.9 RC1