Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request - include the data of a constant when hovering over a constant. #45777

Open
ghost opened this issue Apr 21, 2021 · 14 comments
Open
Labels
analyzer-server area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. P3 A lower priority bug or feature request type-enhancement A request for a change that isn't a bug

Comments

@ghost
Copy link

ghost commented Apr 21, 2021

@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?

const MY_CONST = const MyClass(5);

class MyClass {
  final int value;
  const MyClass(this.value);
}

Screenshot 2021-04-10 at 14 30 31

This issue was moved by helin24 from flutter/flutter-intellij#5392.

@ghost
Copy link
Author

ghost commented Apr 21, 2021

move[bot] commented on Apr 15, 2021, 3:58 PM UTC:

⚠️ You must have write permission for the target repository.

@ghost
Copy link
Author

ghost commented Apr 21, 2021

@jwren commented on Apr 15, 2021, 7:46 PM UTC:

I created a tracking issue in YouTrack: https://youtrack.jetbrains.com/issue/WEB-50553

@annagrin annagrin self-assigned this Apr 21, 2021
@annagrin annagrin added this to To do in Expression evaluation in web debugger via automation Apr 21, 2021
@annagrin annagrin removed their assignment Apr 21, 2021
@bwilkerson
Copy link
Member

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.

@annagrin
Copy link
Contributor

Related: #41999

@annagrin
Copy link
Contributor

@helin24 @bwilkerson is this request for displaying values during debugging?

@bwilkerson
Copy link
Member

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.

@helin24
Copy link
Contributor

helin24 commented Apr 21, 2021

This is my understanding as well - looking to see values of constants on mouseover in editor, for example.

@annagrin
Copy link
Contributor

@bwilkerson @atreeon it does not for web platform, so I wonder if the request is the same as the issue I linked above.

@jwren
Copy link
Member

jwren commented Apr 21, 2021

@annagrin that is correct, this is not when debugging, but from the static analysis of the source

@lrhn lrhn added analyzer-server area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. labels Apr 22, 2021
@atreeon
Copy link

atreeon commented Apr 22, 2021

Hi, thanks for updating this. Apologies for not specifying whether in debug or outside of debug. Can we have this outside of debug too?

@srawlins srawlins added the P3 A lower priority bug or feature request label Jul 20, 2021
@srawlins
Copy link
Member

This would be a pretty neat feature, and I suspect not wildly difficult. 😄

@bwilkerson
Copy link
Member

See my comments above regarding executing toString (#45777 (comment)). 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.)

@jwren
Copy link
Member

jwren commented Jul 20, 2021

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.

@bwilkerson
Copy link
Member

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.

@srawlins srawlins added the type-enhancement A request for a change that isn't a bug label Mar 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
analyzer-server area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. P3 A lower priority bug or feature request type-enhancement A request for a change that isn't a bug
Projects
None yet
Development

No branches or pull requests

7 participants