Skip to content

Commit 3b31443

Browse files
author
Anna Gringauze
authored
Update DartUri to handle mode urls (#1734)
1 parent 7e03357 commit 3b31443

File tree

8 files changed

+28
-7
lines changed

8 files changed

+28
-7
lines changed

dwds/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
- Allows correct relative source map paths resolution.
1616
- Add `PackageUriMapper` class to allow mapping uris to server paths.
1717
- Update the min SDK constraint to 2.18.0.
18+
- Make DartUri work for `google3:` uris.
1819

1920
**Breaking changes**
2021

dwds/lib/src/debugging/debugger.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -502,7 +502,7 @@ class Debugger extends Domain {
502502

503503
final url = urlForScriptId(location.scriptId);
504504
if (url == null) {
505-
logger.severe('Failed to create dart frame for ${frame.functionName}: '
505+
logger.fine('Failed to create dart frame for ${frame.functionName}: '
506506
'cannot find url for script ${location.scriptId}');
507507
return null;
508508
}

dwds/lib/src/utilities/dart_uri.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class DartUri {
3131
factory DartUri(String uri, [String? root]) {
3232
// TODO(annagrin): Support creating DartUris from `dart:` uris.
3333
// Issue: https://github.com/dart-lang/webdev/issues/1584
34-
if (uri.startsWith('org-dartlang-app:')) {
34+
if (uri.startsWith('org-dartlang-app:') || uri.startsWith('google3:')) {
3535
return DartUri._fromDartLangUri(uri);
3636
}
3737
if (uri.startsWith('package:')) {

dwds/test/dart_uri_test.dart

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,13 @@ class TestStrategy extends FakeStrategy {
1919
String? serverPathForAppUri(String appUrl) {
2020
final appUri = Uri.parse(appUrl);
2121
if (appUri.isScheme('org-dartlang-app')) {
22-
return 'foo';
22+
return appUri.path;
2323
}
2424
if (appUri.isScheme('package')) {
25-
return '/packages/${appUri.path}';
25+
return 'packages/${appUri.path}';
26+
}
27+
if (appUri.isScheme('google3')) {
28+
return appUri.path;
2629
}
2730
return null;
2831
}
@@ -42,8 +45,13 @@ void main() {
4245
});
4346

4447
test('parses org-dartlang-app paths', () {
45-
final uri = DartUri('org-dartlang-app:////blah/main.dart');
46-
expect(uri.serverPath, 'foo');
48+
final uri = DartUri('org-dartlang-app:///blah/main.dart');
49+
expect(uri.serverPath, '/blah/main.dart');
50+
});
51+
52+
test('parses google3 paths', () {
53+
final uri = DartUri('google3:///blah/main.dart');
54+
expect(uri.serverPath, '/blah/main.dart');
4755
});
4856

4957
test('parses packages paths', () {
@@ -86,7 +94,7 @@ void main() {
8694
expect(resolved, 'org-dartlang-sdk:///sdk/lib/io/io.dart');
8795
}, skip: 'https://github.com/dart-lang/webdev/issues/1584');
8896

89-
test('can unresolve uris', () {
97+
test('can un-resolve uris', () {
9098
final unresolved =
9199
DartUri.toPackageUri('org-dartlang-sdk:///sdk/lib/io/io.dart');
92100
expect(unresolved, 'dart:io');

fixtures/_testCircular1/lib/library1.dart

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,7 @@ import 'package:_test_circular2/library2.dart';
1212
String concatenate(String a, String b) {
1313
return '$a$b'; // Breakpoint: Concatenate
1414
}
15+
16+
void printGlobal() {
17+
print(globalValue);
18+
}

fixtures/_testCircular1Sound/lib/library1.dart

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,7 @@ import 'package:_test_circular2_sound/library2.dart';
1010
String concatenate(String a, String b) {
1111
return '$a$b'; // Breakpoint: Concatenate
1212
}
13+
14+
void printGlobal() {
15+
print(globalValue);
16+
}

fixtures/_testCircular2/lib/library2.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
import 'package:_test_circular1/library1.dart';
88

9+
int globalValue = 0;
10+
911
void testCircularDependencies() {
1012
print(concatenate('a', 'b')); // Breakpoint: testCircularDependencies
1113
}

fixtures/_testCircular2Sound/lib/library2.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
import 'package:_test_circular1_sound/library1.dart';
66

7+
int globalValue = 0;
8+
79
void testCircularDependencies() {
810
print(concatenate('a', 'b')); // Breakpoint: testCircularDependencies
911
}

0 commit comments

Comments
 (0)