Open ghost opened 3 years ago
move[bot] commented on Apr 15, 2021, 3:58 PM UTC:
@jwren commented on Apr 15, 2021, 7:46 PM UTC:
I created a tracking issue in YouTrack: https://youtrack.jetbrains.com/issue/WEB-50553
As the YouTrack issue notes, this support would be in the analysis server.
The analysis server has performed a symbolic execution of the constant, so it does know the value of the constant. The problem is that the analysis server does not have the ability to execute code other than that allowed in constant expressions, so it can't execute the toString
method of an arbitrary object. We could nicely display "primitive" objects (ints, booleans, strings, etc.), but we'd need to figure out how to display instances of user defined classes.
It might be worthwhile to display the value of constants when they are primitive types even if we can't display user defined types.
@helin24 @bwilkerson is this request for displaying values during debugging?
My assumption is that the request is for values to be displayed when not debugging, but @atreeon can answer that better than I can. It's my understanding that IntelliJ already displays values of both constants and non-constants while debugging.
This is my understanding as well - looking to see values of constants on mouseover in editor, for example.
@bwilkerson @atreeon it does not for web platform, so I wonder if the request is the same as the issue I linked above.
@annagrin that is correct, this is not when debugging, but from the static analysis of the source
Hi, thanks for updating this. Apologies for not specifying whether in debug or outside of debug. Can we have this outside of debug too?
This would be a pretty neat feature, and I suspect not wildly difficult. 😄
See my comments above regarding executing toString
(https://github.com/dart-lang/sdk/issues/45777#issuecomment-824201597). Do you have ideas for how to display readable values without executing user code? The only alternative I've thought of would be a basic object dump, something like MyClass(value: 5)
(using the example from the OP). Maybe most constant values would be simple enough for this form, but there is at least an edge case where this form would be unreadable. For example, consider something like one of our error codes (https://github.com/dart-lang/sdk/blob/master/pkg/analyzer/lib/src/error/codes.dart#L71). I think that would be difficult to display nicely in a hover.
(There are also extreme cases such as https://github.com/dart-lang/sdk/blob/master/pkg/analysis_server/lib/src/services/correction/fix_internal.dart#L320, but we'd probably need to have some kind of cut-off so that all we displayed in a case like that was a notice that the value is too large.)
Echoing what you said above Brian:
It might be worthwhile to display the value of constants when they are primitive types even if we can't display user defined types.
"Just" having the values for final
primitives would go along way.
If we're talking about final
rather than const
then that's a different issue. The analyzer computed values for all const
fields because doing so is required to be spec compliant. But it doesn't compute values for final
fields, so we wouldn't have any value to display. But adding support for const
fields of primitive types might be useful and we can always expand the support in the future.
@atreeon commented on Apr 10, 2021, 1:31 PM UTC:
In other languages and IDEs when a constant variable is hovered over the data of the constant is shown in the popup help box. Would this be possible in flutter intellij idea?
This issue was moved by helin24 from flutter/flutter-intellij#5392.