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
Inline Values is not aware of conditional branches and may show for code that's not executed #5454
For example here, the branch was not taken, but it's where we're showing the inline value:
There's no way the analysis server can know which code paths were taken, so we need to use some rules that aren't affected which branches are taken. That might leaving it as it is, or might mean excluding all branches (except the current one - although that itself may be risky because we don't know how reliable the "execution pointer" position we're given is).
I did some testing with Java, and it appears that they do not show inline values for any branches unless you are inside that branch:
java.inline.values.mp4
This means once you step out of the conditional block, those values disappear. While it'd be nicer IMO if they stayed there, that's not possible with the current API and I think what they're doing is better than what we're currently doing and I think we should do the same.
I think this might be as simple as in our visitor, skipping the super call for any Block if stoppedLocation.end is not within that block.
Edit: I'll also note that Java does not only show the last instance of a variable like we do, but I do not think that is better - I think it gets quite noisy.
Activity
DanTup commentedon Jun 5, 2025
I did some testing with Java, and it appears that they do not show inline values for any branches unless you are inside that branch:
java.inline.values.mp4
This means once you step out of the conditional block, those values disappear. While it'd be nicer IMO if they stayed there, that's not possible with the current API and I think what they're doing is better than what we're currently doing and I think we should do the same.
I think this might be as simple as in our visitor, skipping the
supercall for anyBlockifstoppedLocation.endis not within that block.(cc @bwilkerson @jwren @FMorschel in case you have any opinions on this before I do)
Edit: I'll also note that Java does not only show the last instance of a variable like we do, but I do not think that is better - I think it gets quite noisy.
FMorschel commentedon Jun 5, 2025
I agree that it feels more intuitive than our current behaviour.
bwilkerson commentedon Jun 5, 2025
Sounds reasonable to me.
DanTup commentedon Jun 5, 2025
Great - I tried it out and this looks much better. I'll add some tests and send a CL. Thanks!
inline.values.dart.mp4
[analysis_server] Exclude blocks/switch cases from Inline Values unle…
DanTup commentedon Jun 5, 2025
Fixed by dart-lang/sdk@9df0000 (ships in the SDK).