[CQ] migrate to using `fileNameFromUri` (#8847)
diff --git a/packages/devtools_app/lib/src/screens/debugger/breakpoints.dart b/packages/devtools_app/lib/src/screens/debugger/breakpoints.dart index f49b875..e1e37d0 100644 --- a/packages/devtools_app/lib/src/screens/debugger/breakpoints.dart +++ b/packages/devtools_app/lib/src/screens/debugger/breakpoints.dart
@@ -110,7 +110,7 @@ String _descriptionFor(BreakpointAndSourcePosition breakpoint) { final scriptUri = breakpoint.scriptUri; - final fileName = scriptUri == null ? 'file' : scriptUri.split('/').last; + final fileName = scriptUri == null ? 'file' : fileNameFromUri(scriptUri); // Consider showing columns in the future if we allow multiple breakpoints // per line. return '$fileName:${breakpoint.line}';
diff --git a/packages/devtools_app/lib/src/screens/debugger/debugger_model.dart b/packages/devtools_app/lib/src/screens/debugger/debugger_model.dart index e254876..7dc18d8 100644 --- a/packages/devtools_app/lib/src/screens/debugger/debugger_model.dart +++ b/packages/devtools_app/lib/src/screens/debugger/debugger_model.dart
@@ -6,6 +6,7 @@ import '../../shared/diagnostics/primitives/source_location.dart'; import '../../shared/primitives/simple_items.dart'; +import '../../shared/primitives/utils.dart'; import '../../shared/ui/search.dart'; /// Whether to include properties surfaced through Diagnosticable objects as @@ -230,7 +231,7 @@ if (uri == null) { return uri; } - final file = uri.split('/').last; + final file = fileNameFromUri(uri); return line == null ? file : '$file:$line'; } } @@ -238,5 +239,5 @@ // ignore: avoid_classes_with_only_static_members, fine for utility method. abstract class ScriptRefUtils { static String fileName(ScriptRef scriptRef) => - Uri.parse(scriptRef.uri!).path.split('/').last; + fileNameFromUri(Uri.parse(scriptRef.uri!).path)!; }
diff --git a/packages/devtools_app/lib/src/screens/debugger/debugger_screen.dart b/packages/devtools_app/lib/src/screens/debugger/debugger_screen.dart index 9404ce3..b347e91 100644 --- a/packages/devtools_app/lib/src/screens/debugger/debugger_screen.dart +++ b/packages/devtools_app/lib/src/screens/debugger/debugger_screen.dart
@@ -499,7 +499,7 @@ return 'paused$reason'; } - final fileName = ' at ${scriptUri.split('/').last}'; + final fileName = ' at ${fileNameFromUri(scriptUri)}'; final tokenPos = location?.tokenPos; final scriptRef = location?.script; if (tokenPos == null || scriptRef == null) {
diff --git a/packages/devtools_app/lib/src/screens/debugger/file_search.dart b/packages/devtools_app/lib/src/screens/debugger/file_search.dart index 3777e3c..319f32a 100644 --- a/packages/devtools_app/lib/src/screens/debugger/file_search.dart +++ b/packages/devtools_app/lib/src/screens/debugger/file_search.dart
@@ -292,7 +292,7 @@ } String _fileName(String fullPath) { - return _fileNamesCache[fullPath] ??= fullPath.split('/').last; + return _fileNamesCache[fullPath] ??= fileNameFromUri(fullPath)!; } }
diff --git a/packages/devtools_app/lib/src/screens/performance/panes/rebuild_stats/rebuild_stats.dart b/packages/devtools_app/lib/src/screens/performance/panes/rebuild_stats/rebuild_stats.dart index f9408ee..254c19e 100644 --- a/packages/devtools_app/lib/src/screens/performance/panes/rebuild_stats/rebuild_stats.dart +++ b/packages/devtools_app/lib/src/screens/performance/panes/rebuild_stats/rebuild_stats.dart
@@ -248,7 +248,7 @@ return '<resolving location>'; } - return '${fileUriString.split('/').last}:${dataObject.location.line}'; + return '${fileNameFromUri(fileUriString)}:${dataObject.location.line}'; } @override
diff --git a/packages/devtools_app/lib/src/shared/console/widgets/description.dart b/packages/devtools_app/lib/src/shared/console/widgets/description.dart index ba3c705..4e1f493 100644 --- a/packages/devtools_app/lib/src/shared/console/widgets/description.dart +++ b/packages/devtools_app/lib/src/shared/console/widgets/description.dart
@@ -460,7 +460,7 @@ overflow: TextOverflow.ellipsis, text: TextSpan( text: - '${location.getFile()!.split('/').last}:${location.getLine()}:${location.getColumn()} ', + '${fileNameFromUri(location.getFile())}:${location.getLine()}:${location.getColumn()} ', style: DiagnosticsTextStyles.regular(Theme.of(context).colorScheme), ), ),
diff --git a/packages/devtools_app/lib/src/shared/primitives/utils.dart b/packages/devtools_app/lib/src/shared/primitives/utils.dart index 0dab37a..c4c993c 100644 --- a/packages/devtools_app/lib/src/shared/primitives/utils.dart +++ b/packages/devtools_app/lib/src/shared/primitives/utils.dart
@@ -1074,9 +1074,6 @@ /// favor of a new request. class ProcessCancelledException implements Exception {} -// TODO(mtaylee): Prefer to use this helper method whenever a call to -// .split('/').last is made on a String (usually on URIs). -// See https://github.com/flutter/devtools/issues/4360. /// Returns the file name from a URI or path string, by splitting the [uri] at /// the directory separators '/', and returning the last element. String? fileNameFromUri(String? uri) => uri?.split('/').lastOrNull;