-
Notifications
You must be signed in to change notification settings - Fork 300
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
Show static types in tooltips #1160
Comments
We're using the
@bwilkerson Is there value in showing |
It certainly makes sense to tell the user that the static type is "Instance" here, but there might be some value in also telling them how it was declared. Maybe it's largely a question of presentation. I don't know what the current hover text looks like, but perhaps something like this would make sense: The static type is (I say "like this" because I don't think the above is either attractive or readable.) What I'd really like us to be able to display is the information to explain the difference in these two types (something like "because of the 'is' check on line lineNumber"). But it's possible that we ought to make the declared type and the element name be two different fields for ease of composition. (We have yet to find the sweet spot between making it flexible by having lots of fields and reducing the work on the client side by pre-formatting the output.) |
Yeah, this comes up now and I was reminded of it when I saw this. The tooltip for this currently looks kinda sparse, because it's a local variable with no docs or anything:
Yeah, that'd be neat. I'd love to show it as something like this: I think putting the static type first makes sense since it's probably the one the user cares most about here, but with a note about the declared type and why it's different. Looking in our hover code, I noticed we have something called the
I'm not sure I remember every seeing that rendered, so not sure what it is (the server docs just say it's the propagated type, but I'm none the wiser). For now, I'm gonna stick the static type on the end in parens:
And I'm moving propagated type to the same (since where it's currently rendered the label is fixed-with and looks wonky if I force it to show). Hopefully both won't appear at the same time as that'll be a little confusing! |
Ugh, the static type is provided even when it matches the start of I think this may need a server change before we can really improve it. |
As of Dart 2, there shouldn't be any propagated type information (I need to deprecate the field). The propagated type was an early, analyzer-only, attempt to have better type information than the spec allowed for at that time. Now that we have type inference, we no longer compute a propagated type.
I can think of three ways to resolve that problem, two of which I'd already mentioned. First, we could split the We need to think about cases where there is no declared type (such as |
Ah, makes sense (and why I haven't seen it lately).
I don't have any strong preferences on this. Having separate fields is more flexible, but I also like that giving us formatted strings gives a consistency across tools (and also I think people working on the server have a much better understanding of Dart than I, so are likely to format things better than me mashing a bunch of fields together). Any implementation that allows the user to see this extra info - which is a really neat feature of Dart (though it slightly bugs me that it doesn't work if in invert the condition - not sure if that's a bug?) - would be great. I can open an SDK bug if you think it should be tracked over there. |
You and a lot of people :-). There was an effort started to enhance the flow of type information through code structures, but it keeps not being at the top of the language team's list. I keep hoping we can enhance this part of the type system some day.
Probably a good idea. I don't know when we'll have the resources to fix it, and I'd rather we didn't forget about it. |
I've opened dart-lang/sdk#34196 with some notes from this issue. |
Fixes #48147. Fixes Dart-Code/Dart-Code#1160. Change-Id: Icc4bbb5b89a75a14579f72b2c74929e7a05ac688 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/228840 Reviewed-by: Brian Wilkerson <brianwilkerson@google.com> Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Fixed by dart-lang/sdk@5bf643b. |
If I hover over "object" inside this
if
block it saysObject object
, but the type here is known to beInstance
(and theset
method is declared onInstance
).The text was updated successfully, but these errors were encountered: