You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Improve representation of static/declared types in getHover response from analysis server #34196
final a =_getAnimal();
if (a isHorse) {
print(a.showSize);
}
Inside the if block the variable a has a static type of Horse (yay!). However, the elementDescription returned by the server is just Animal a so it's not clear from the tooltip that analysis is treating this as a Horse.
The actual server response looks something like this:
The staticType is available here. However in the case where matches the declared type (for ex. a standard String) the field is still populated. Since the declared type is embedded inside the elementDescription property it's hard for an editor to display this information well (to avoid redundancy, we'd have to parse elementDescription up).
Split elementDescription into its two parts (declared type and name)
A single "description" field that combines all of this information to display to the user
Omit the staticType if it's redundant (already in elementDescription)
Also:
We need to think about cases where there is no declared type (such as var x = ...), cases like the one above where the declared and static type are significantly different (Object vs Instance), and cases where the static type is just a refinement (List vs List<String>). And, of course, we shouldn't forget the cases where the variable isn't declared at all.
Activity
DanTup commentedon Jun 6, 2023
5bf643b added the static type to the hover: