Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 0a15269

Browse files
DanTupCommit Queue
authored and
Commit Queue
committed
[dds/dap] Remove macro support from debug adapters/DAP
This removes support for dart-macro+file URIs (and using URIs in the DAP protocol in general) and all related code/tests. Change-Id: I7cbbcc8463e7c352517d5bd58e8cdf63c7d23c0d Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/460940 Reviewed-by: Jessy Yameogo <yjessy@google.com> Commit-Queue: Ben Konyi <bkonyi@google.com> Reviewed-by: Ben Konyi <bkonyi@google.com>
1 parent 5436fcd commit 0a15269

18 files changed

+91
-268
lines changed

‎pkg/dds/CHANGELOG.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# 5.2.0-wip
22

33
- [DAP] `Stopped(reason: 'entry')` events will no longer be lost if an isolate has not yet reached the `PauseStart` state when connecting to the VM.
4+
- **Breaking change:** [DAP] Support for the custom `supportsDartUris` client capability and `dart-macro+file:///` mappings that supported the Dart macros experiment have been removed.
45

56
# 5.1.0
67
- Update to version 2.1 of the DDS protocol.

‎pkg/dds/lib/src/dap/adapters/dart.dart‎

Lines changed: 31 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -1240,7 +1240,7 @@ abstract class DartDebugAdapter<TL extends LaunchRequestArguments,
12401240

12411241
// Ensure that we stop watching for a VM Service info file if we are using
12421242
// these utils.
1243-
if (this case VmServiceInfoFileUtils vmServiceUtils) {
1243+
if (this case finalVmServiceInfoFileUtils vmServiceUtils) {
12441244
vmServiceUtils.stopWaitingForVmServiceInfoFile();
12451245
}
12461246

@@ -1319,32 +1319,29 @@ abstract class DartDebugAdapter<TL extends LaunchRequestArguments,
13191319
return false;
13201320
}
13211321

1322-
final packageFileLikeUri = await thread.resolveUriToPackageLibPath(uri);
1323-
if (packageFileLikeUri == null) {
1322+
final packageFileUri = await thread.resolveUriToPackageLibPath(uri);
1323+
if (packageFileUri == null) {
13241324
return false;
13251325
}
13261326

1327-
return !isInUserProject(packageFileLikeUri);
1327+
return !isInUserProject(packageFileUri);
13281328
}
13291329

1330-
/// Checks whether [uri] is inside the users project. This is used to support
1331-
/// debugging "Just My Code" (via [isExternalPackageLibrary]) and also for
1332-
/// stack trace highlighting, where non-user code will be faded.
1330+
/// Checks whether [targetUri] is inside the users project. This is used to
1331+
/// support debugging "Just My Code" (via [isExternalPackageLibrary]) and also
1332+
/// for stack trace highlighting, where non-user code will be faded.
13331333
bool isInUserProject(Uri targetUri) {
1334-
if (!isSupportedFileScheme(targetUri)) {
1334+
if (!targetUri.isScheme('file')) {
13351335
return false;
13361336
}
13371337

1338-
// We could already be 'file', or we could be another supported file scheme
1339-
// like dart-macro+file, but we can only call toFilePath() on a file URI
1340-
// and we use the equivalent path to decide if this is within the workspace.
1341-
var targetPath = targetUri.replace(scheme: 'file').toFilePath();
1342-
1343-
// Always compare paths case-insensitively to avoid any issues where APIs
1344-
// may have returned different casing (e.g. Windows drive letters). It's
1345-
// almost certain a user wouldn't have a "local" package and an "external"
1346-
// package with paths differing only be case.
1347-
targetPath = targetPath.toLowerCase();
1338+
final targetPath = targetUri
1339+
.toFilePath()
1340+
// Always compare paths case-insensitively to avoid any issues where APIs
1341+
// may have returned different casing (e.g. Windows drive letters). It's
1342+
// almost certain a user wouldn't have a "local" package and an "external"
1343+
// package with paths differing only be case.
1344+
.toLowerCase();
13481345

13491346
return projectPaths
13501347
.map((projectPath) => projectPath.toLowerCase())
@@ -1602,9 +1599,7 @@ abstract class DartDebugAdapter<TL extends LaunchRequestArguments,
16021599

16031600
final path = args.source.path;
16041601
final name = args.source.name;
1605-
final uri = path != null
1606-
? normalizeUri(fromClientPathOrUri(path)).toString()
1607-
: name!;
1602+
final uri = path != null ? normalizeUri(Uri.file(path)).toString() : name!;
16081603

16091604
// Use a completer to track when the response is sent, so any events related
16101605
// to these breakpoints are not sent before the client has the IDs.
@@ -1681,7 +1676,7 @@ abstract class DartDebugAdapter<TL extends LaunchRequestArguments,
16811676
}
16821677

16831678
/// Converts a URI in the form org-dartlang-sdk:///sdk/lib/collection/hash_set.dart
1684-
/// to a local file-like URI based on the current SDK.
1679+
/// to a local file URI based on the current SDK.
16851680
Uri? convertOrgDartlangSdkToPath(Uri uri) {
16861681
// org-dartlang-sdk URIs can be in multiple forms:
16871682
//
@@ -2340,14 +2335,14 @@ abstract class DartDebugAdapter<TL extends LaunchRequestArguments,
23402335
final framePaths = await Future.wait(frameLocations.map((frame) async {
23412336
final uri = frame?.uri;
23422337
if (uri == null) return null;
2343-
if (isSupportedFileScheme(uri)) {
2338+
if (uri.isScheme('file')) {
23442339
return (uri: uri, isUserCode: isInUserProject(uri));
23452340
}
23462341
if (thread == null || !isResolvableUri(uri)) return null;
23472342
try {
2348-
final fileLikeUri = await thread.resolveUriToPath(uri);
2349-
return fileLikeUri != null
2350-
? (uri: fileLikeUri, isUserCode: isInUserProject(fileLikeUri))
2343+
final fileUri = await thread.resolveUriToPath(uri);
2344+
return fileUri != null
2345+
? (uri: fileUri, isUserCode: isInUserProject(fileUri))
23512346
: null;
23522347
} catch (e, s) {
23532348
// Swallow errors for the same reason noted above.
@@ -2363,16 +2358,16 @@ abstract class DartDebugAdapter<TL extends LaunchRequestArguments,
23632358
final uri = frameLocation?.uri;
23642359
final framePathInfo = framePaths[i];
23652360

2366-
// A file-like URI ('file://' or 'dart-macro+file://').
2367-
final fileLikeUri = framePathInfo?.uri;
2361+
// A file URI.
2362+
final fileUri = framePathInfo?.uri;
23682363

23692364
// Default to true so that if we don't know whether this is user-project
23702365
// then we leave the formatting as-is and don't fade anything out.
23712366
final isUserProject = framePathInfo?.isUserCode ?? true;
23722367

23732368
// For the name, we usually use the package URI, but if we only had a file
23742369
// URI to begin with, try to make it relative to cwd so it's not so long.
2375-
final name = uri != null && fileLikeUri != null
2370+
final name = uri != null && fileUri != null
23762371
? (uri.isScheme('file')
23772372
? _converter.convertToRelativePath(uri.toFilePath())
23782373
: uri.toString())
@@ -2397,8 +2392,7 @@ abstract class DartDebugAdapter<TL extends LaunchRequestArguments,
23972392
continue;
23982393
}
23992394

2400-
final clientPath =
2401-
fileLikeUri != null ? toClientPathOrUri(fileLikeUri) : null;
2395+
final clientPath = fileUri != null ? toClientPathOrUri(fileUri) : null;
24022396
events.add(
24032397
OutputEventBody(
24042398
category: category,
@@ -2645,19 +2639,19 @@ abstract class DartDebugAdapter<TL extends LaunchRequestArguments,
26452639
return;
26462640
}
26472641

2648-
// Doesn't need resolving if already file-like.
2649-
if (isSupportedFileScheme(uri)) {
2642+
// Doesn't need resolving if already file.
2643+
if (uri.isScheme('file')) {
26502644
return;
26512645
}
26522646

2653-
final fileLikeUri = await thread.resolveUriToPath(uri);
2654-
if (fileLikeUri != null) {
2647+
final fileUri = await thread.resolveUriToPath(uri);
2648+
if (fileUri != null) {
26552649
// Convert:
26562650
// uri -> resolvedUri
26572651
// fileUri -> resolvedFileUri
26582652
final resolvedFieldName =
26592653
'resolved${field.substring(0, 1).toUpperCase()}${field.substring(1)}';
2660-
data[resolvedFieldName] = fileLikeUri.toString();
2654+
data[resolvedFieldName] = fileUri.toString();
26612655
}
26622656
}
26632657

@@ -2888,47 +2882,18 @@ abstract class DartDebugAdapter<TL extends LaunchRequestArguments,
28882882
}
28892883
}
28902884

2891-
/// Whether the current client supports URIs in place of file paths, including
2892-
/// file-like URIs that are not the 'file' scheme (such as 'dart-macro+file').
2893-
bool get clientSupportsUri => _initializeArgs?.supportsDartUris ?? false;
2894-
2895-
/// Returns whether [uri] is a file-like URI scheme that is supported by the
2896-
/// client.
2897-
///
2898-
/// Returning `true` here does not guarantee that the client supports URIs,
2899-
/// the caller should also check [clientSupportsUri].
2900-
bool isSupportedFileScheme(Uri uri) {
2901-
return uri.isScheme('file') ||
2902-
// Handle all file-like schemes that end '+file' like
2903-
// 'dart-macro+file://'.
2904-
(clientSupportsUri && uri.scheme.endsWith('+file'));
2905-
}
2906-
29072885
/// Converts a URI into a form that can be used by the client.
29082886
///
2909-
/// If the client supports URIs (like VS Code), it will be returned unchanged
2910-
/// but otherwise it will be the `toFilePath()` equivalent if a 'file://' URI
2911-
/// and otherwise `null`.
2887+
/// Returns `null` if the uri is not a supported file scheme.
29122888
String? toClientPathOrUri(Uri? uri) {
29132889
if (uri == null) {
29142890
return null;
2915-
} else if (clientSupportsUri) {
2916-
return uri.toString();
29172891
} else if (uri.isScheme('file')) {
29182892
return uri.toFilePath();
29192893
} else {
29202894
return null;
29212895
}
29222896
}
2923-
2924-
/// Converts a String used by the client as a path/URI into a [Uri].
2925-
Uri fromClientPathOrUri(String filePathOrUriString) {
2926-
var uri = Uri.tryParse(filePathOrUriString);
2927-
if (uri == null || !isSupportedFileScheme(uri)) {
2928-
uri = Uri.file(filePathOrUriString);
2929-
}
2930-
return uri;
2931-
}
29322897
}
29332898

29342899
/// An implementation of [LaunchRequestArguments] that includes all fields used

‎pkg/dds/lib/src/dap/adapters/mixins.dart‎

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -260,13 +260,6 @@ mixin FileUtils {
260260
final filePath = uri.toFilePath();
261261
final normalizedPath = normalizePath(filePath);
262262
return Uri.file(normalizedPath);
263-
} else if (uri.scheme.endsWith('+file')) {
264-
// For virtual file schemes, we need to replace the scheme to use
265-
// toFilePath() so we can normalise the path, then convert back.
266-
final originalScheme = uri.scheme;
267-
final filePath = uri.replace(scheme: 'file').toFilePath();
268-
final normalizedPath = normalizePath(filePath);
269-
return Uri.file(normalizedPath).replace(scheme: originalScheme);
270263
} else {
271264
return uri;
272265
}

‎pkg/dds/lib/src/dap/isolate_manager.dart‎

Lines changed: 21 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -922,7 +922,7 @@ class IsolateManager {
922922
var userMessage = error is vm.RPCError
923923
? error.details ?? error.toString()
924924
: error.toString();
925-
var terseMessageMatch =
925+
final terseMessageMatch =
926926
_terseBreakpointFailureRegex.firstMatch(userMessage);
927927
if (terseMessageMatch != null) {
928928
userMessage = terseMessageMatch.group(1) ?? userMessage;
@@ -1298,13 +1298,13 @@ class ThreadInfo with FileUtils {
12981298
/// tokenPos) can share the same response.
12991299
final _scripts = <String, Future<vm.Script>>{};
13001300

1301-
/// A cache of requests (Futures) to resolve URIs to their file-like URIs.
1301+
/// A cache of requests (Futures) to resolve URIs to their file URIs.
13021302
///
13031303
/// Used so that multiple requests that require them (for example looking up
13041304
/// locations for stack frames from tokenPos) can share the same response.
13051305
///
13061306
/// Keys are URIs in string form.
1307-
/// Values are file-like URIs (file: or similar, such as dart-macro+file:).
1307+
/// Values are file URIs.
13081308
final _resolvedPaths = <String, Future<Uri?>>{};
13091309

13101310
/// Whether this isolate has an in-flight user-initiated resume request that
@@ -1370,7 +1370,7 @@ class ThreadInfo with FileUtils {
13701370
///
13711371
/// sdk-path/lib/core/print.dart -> dart:core/print.dart
13721372
/// c:\foo\bar -> package:foo/bar
1373-
/// dart-macro+file:///c:/foo/bar -> dart-macro+package:foo/bar
1373+
/// file:///c:/foo/bar -> package:foo/bar
13741374
///
13751375
/// This is required so that when the user sets a breakpoint in an SDK source
13761376
/// (which they may have navigated to via the Analysis Server) we generate a
@@ -1417,7 +1417,7 @@ class ThreadInfo with FileUtils {
14171417
}
14181418
}
14191419

1420-
/// Batch resolves source URIs from the VM to a file-like URI for the package
1420+
/// Batch resolves source URIs from the VM to a file URI for the package
14211421
/// lib folder.
14221422
///
14231423
/// This method is more performant than repeatedly calling
@@ -1437,7 +1437,7 @@ class ThreadInfo with FileUtils {
14371437
.toList();
14381438
}
14391439

1440-
/// Batch resolves source URIs from the VM to a file-like URI.
1440+
/// Batch resolves source URIs from the VM to a file URI.
14411441
///
14421442
/// This method is more performant than repeatedly calling [resolveUriToPath]
14431443
/// because it resolves multiple URIs in a single request to the VM.
@@ -1513,7 +1513,7 @@ class ThreadInfo with FileUtils {
15131513
// because they were either filtered out of [requiredUris] because they were
15141514
// already there, or we then populated completers for them above.
15151515
final futures = uris.map((uri) async {
1516-
if (_manager._adapter.isSupportedFileScheme(uri)) {
1516+
if (uri.isScheme('file')) {
15171517
return uri;
15181518
} else {
15191519
return await _resolvedPaths[uri.toString()];
@@ -1562,11 +1562,10 @@ class ThreadInfo with FileUtils {
15621562
/// would not be changed.
15631563
final _libraryIsDebuggableById = <String, bool>{};
15641564

1565-
/// Resolves a source URI to a file-like URI for the lib folder of its
1565+
/// Resolves a source URI to a file URI for the lib folder of its
15661566
/// package.
15671567
///
15681568
/// package:foo/a/b/c/d.dart -> file:///code/packages/foo/lib
1569-
/// dart-macro+package:foo/a/b/c/d.dart -> dart-macro+file:///code/packages/foo/lib
15701569
///
15711570
/// This method is an optimisation over calling [resolveUriToPath] where only
15721571
/// the package root is required (for example when determining whether a
@@ -1578,7 +1577,7 @@ class ThreadInfo with FileUtils {
15781577
return result.first;
15791578
}
15801579

1581-
/// Resolves a source URI from the VM to a file-like URI.
1580+
/// Resolves a source URI from the VM to a file URI.
15821581
///
15831582
/// dart:core/print.dart -> sdk-path/lib/core/print.dart
15841583
///
@@ -1596,17 +1595,15 @@ class ThreadInfo with FileUtils {
15961595
int storeData(Object data) => _manager.storeData(this, data);
15971596

15981597
Uri? _convertPathToGoogle3Uri(Uri input) {
1599-
// TODO(dantup): Do we need to handle non-file here? Eg. can we have
1600-
// dart-macro+file:/// for a google3 path?
16011598
if (!input.isScheme('file')) {
16021599
return null;
16031600
}
16041601
final inputPath = input.toFilePath();
16051602

16061603
const search = '/google3/';
16071604
if (inputPath.startsWith('/google') && inputPath.contains(search)) {
1608-
var idx = inputPath.indexOf(search);
1609-
var remainingPath = inputPath.substring(idx + search.length);
1605+
final idx = inputPath.indexOf(search);
1606+
final remainingPath = inputPath.substring(idx + search.length);
16101607
return Uri(
16111608
scheme: 'google3',
16121609
host: '',
@@ -1617,17 +1614,17 @@ class ThreadInfo with FileUtils {
16171614
return null;
16181615
}
16191616

1620-
/// Converts a VM-returned URI to a file-like URI, taking org-dartlang-sdk
1617+
/// Converts a VM-returned URI to a file URI, taking org-dartlang-sdk
16211618
/// schemes into account.
16221619
///
1623-
/// Supports file-like URIs and org-dartlang-sdk:// URIs.
1620+
/// Supports file URIs and org-dartlang-sdk:// URIs.
16241621
Uri? _convertUriToFilePath(Uri? input) {
16251622
if (input == null) {
16261623
return null;
1627-
} else if (_manager._adapter.isSupportedFileScheme(input)) {
1624+
} else if (input.isScheme('file')) {
16281625
return input;
16291626
} else {
1630-
// TODO(dantup): UriConverter should be upgraded to use file-like URIs
1627+
// TODO(dantup): UriConverter should be upgraded to use file URIs
16311628
// instead of paths, but that might be breaking because it's used
16321629
// outside of this package?
16331630
final uriConverter = _manager._adapter.uriConverter();
@@ -1644,8 +1641,8 @@ class ThreadInfo with FileUtils {
16441641
///
16451642
/// [uri] should be the equivalent package: URI and is used to know how many
16461643
/// segments to remove from the file path to get to the lib folder.
1647-
Uri? _trimPathToLibFolder(Uri? fileLikeUri, Uri uri) {
1648-
if (fileLikeUri == null) {
1644+
Uri? _trimPathToLibFolder(Uri? fileUri, Uri uri) {
1645+
if (fileUri == null) {
16491646
return null;
16501647
}
16511648

@@ -1657,14 +1654,14 @@ class ThreadInfo with FileUtils {
16571654
// least as many segments as the path of the URI.
16581655
assert(uri.pathSegments.length > libraryPathSegments);
16591656
if (uri.pathSegments.length <= libraryPathSegments) {
1660-
return fileLikeUri;
1657+
return fileUri;
16611658
}
16621659

16631660
// Strip off the correct number of segments to the resulting path points
16641661
// to the root of the package:/ URI.
1665-
final keepSegments = fileLikeUri.pathSegments.length - libraryPathSegments;
1666-
return fileLikeUri.replace(
1667-
pathSegments: fileLikeUri.pathSegments.sublist(0, keepSegments));
1662+
final keepSegments = fileUri.pathSegments.length - libraryPathSegments;
1663+
return fileUri.replace(
1664+
pathSegments: fileUri.pathSegments.sublist(0, keepSegments));
16681665
}
16691666

16701667
/// Clears all temporary stored for this thread. This includes:

‎pkg/dds/lib/src/dap/protocol_converter.dart‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -609,8 +609,7 @@ class ProtocolConverter {
609609
final uriIsPackage = uri?.isScheme('package') ?? false;
610610
final sourcePathUri =
611611
uri != null ? await thread.resolveUriToPath(uri) : null;
612-
var canShowSource =
613-
sourcePathUri != null && _adapter.isSupportedFileScheme(sourcePathUri);
612+
var canShowSource = sourcePathUri != null && sourcePathUri.isScheme('file');
614613

615614
// If we don't have a local source file but the source is a "dart:" uri we
616615
// might still be able to download the source from the VM.
@@ -639,7 +638,7 @@ class ProtocolConverter {
639638
}
640639

641640
// LSP uses 0 for unknown lines.
642-
var (line, col) = lineCol ?? (0, 0);
641+
final (line, col) = lineCol ?? (0, 0);
643642

644643
// If a source would be considered not-debuggable (for example it's in the
645644
// SDK and debugSdkLibraries=false) then we should also mark it as

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /