Skip to content

Commit 56642b7

Browse files
authored
Fix setting g3 breakpoints (#2713)
See b/449706507#comment3 for the detailed explanations. Since the logic added as a fallback and only under `isInternalBuild` branch, I believe this change cannot have unexpected side effects.
1 parent bb5af96 commit 56642b7

File tree

2 files changed

+25
-4
lines changed

2 files changed

+25
-4
lines changed

dwds/lib/src/utilities/dart_uri.dart

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -147,12 +147,21 @@ class DartUri {
147147
final packageUri = _resolvedUriToUri[uri];
148148
if (packageUri != null) return packageUri;
149149

150-
// If this is an internal app, then the given uri might be g3-relative:
150+
// If this is an internal app, then the given uri might
151+
// be relative or absolute google3 uri.
151152
if (globalToolConfiguration.appMetadata.isInternalBuild) {
152-
// TODO(https://github.com/dart-lang/webdev/issues/2198): Verify if the
153-
// intermediary conversion to resolvedUri is causing performance issues.
154153
final resolvedUri = _g3RelativeUriToResolvedUri[uri];
155-
return _resolvedUriToUri[resolvedUri];
154+
final g3PackageUri = _resolvedUriToUri[resolvedUri];
155+
if (g3PackageUri != null) {
156+
return g3PackageUri;
157+
}
158+
159+
// If the input is an absolute URI (like file:/// or google3:///),
160+
// return it as is, as DWDS can use it directly.
161+
final parsedUri = Uri.tryParse(uri);
162+
if (parsedUri != null && parsedUri.hasAbsolutePath) {
163+
return uri;
164+
}
156165
}
157166

158167
return null;

dwds/test/dart_uri_test.dart

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,5 +220,17 @@ void main() {
220220
final resolved = DartUri.toPackageUri('g3:///path.dart');
221221
expect(resolved, 'package:path/path.dart');
222222
});
223+
224+
test('can resolve absolute file paths', () {
225+
final absolute = 'file:///cloud/user/workspace/project/path.dart';
226+
final resolved = DartUri.toPackageUri(absolute);
227+
expect(resolved, absolute);
228+
});
229+
230+
test('can resolve absolute g3 paths', () {
231+
final absolute = 'google3:///cloud/user/workspace/project/path.dart';
232+
final resolved = DartUri.toPackageUri(absolute);
233+
expect(resolved, absolute);
234+
});
223235
});
224236
}

0 commit comments

Comments
 (0)