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

[Wip] Add a server analysis API to retrieve a mapping from 'dart:' URIs to 'file:' URIs. #47377

Closed
bleroux opened this issue Oct 5, 2021 · 2 comments
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

Comments

@bleroux
Copy link

bleroux commented Oct 5, 2021

To register a proper breakpoint in SDK Code, IDEs needs to knows that a given source file is related to a dart: Uri.
The analysis server parses .yaml files and knows that a given files is mapped to a dart: URI. Exposing this with an API will avoid to find a workaround in each IDE.

Example using VSCode :

  • Given this simple code : print('Dart');
  • Before launching the VM, select print statement and 'go-to-definition'
  • Add a breakpoint in print source code

The breakpoint is added with the file: URI that the IDE gets from the analysis server.

When launching the VM from the IDE, breakpoint will not be hit as the VM can't associate the file: URI to a dart: URI.
This can't be fixed properly at the VM level because the VM usually loads SDK librairies from snaphsot files so it can't resolve a file: URI.
To avoid duplicating .yaml parsing code or relating on hacks (guessing a file is from the SDK), it might be useful to add an API to the analysis server.

Related issues :

@srawlins srawlins added analyzer-server area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. labels Oct 6, 2021
@scheglov
Copy link
Contributor

scheglov commented Oct 6, 2021

We might have it already, see

</dd></dl></dd><dt class="request"><a name="request_execution.mapUri">execution.mapUri</a></dt><dd><div class="box"><pre>request: {

@scheglov scheglov added the P3 A lower priority bug or feature request label Oct 6, 2021
@bleroux
Copy link
Author

bleroux commented Oct 6, 2021

@scheglov
Thank you for pointing out this Api !!! (My bad : I was to focused on the 'Analysis domain' when reading the API specification).

I tried it and it works nicely 👍

File to URI :

{"id": "4", "method": "execution.mapUri", "params": {"id": "1", "file":"/home/bruno/flutter/bin/cache/pkg/sky_engine/lib/core/core.dart"}}
{"id":"4","result":{"uri":"dart:core"}}

URI to file :

{"id": "5", "method": "execution.mapUri", "params": {"id": "1", "uri": "dart:core"}}
{"id":"5","result":{"file":"/home/bruno/flutter/bin/cache/pkg/sky_engine/lib/core/core.dart"}}

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
Projects
None yet
Development

No branches or pull requests

3 participants