@@ -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 final VmServiceInfoFileUtils 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
0 commit comments