@@ -4,7 +4,7 @@ Author: Bob Nystrom
4
4
5
5
Status: In-progress
6
6
7
- Version 0.1 (see [ CHANGELOG] ( #CHANGELOG ) at end)
7
+ Version 0.2 (see [ CHANGELOG] ( #CHANGELOG ) at end)
8
8
9
9
Experiment flag: unquoted-imports
10
10
@@ -101,7 +101,7 @@ import dart/isolate;
101
101
import flutter_test;
102
102
import path;
103
103
import flutter/material;
104
- import analyzer/dart/ast/visitor;
104
+ import analyzer/dart/ast/visitor/visitor ;
105
105
import widget.tla.server;
106
106
import widget.tla.proto/client/component;
107
107
```
@@ -110,8 +110,9 @@ You can probably infer what's going on from the before and after, but the basic
110
110
idea is that the library is a slash-separated series of dotted identifier
111
111
segments. The first segment is the name of the package. The rest is the path to
112
112
the library within that package. A ` .dart ` extension is implicitly added to the
113
- end. If there is only a single segment, it is treated as both package name and
114
- path. If the package name is ` dart ` , it's a "dart:" library import.
113
+ end. If there is only a single segment, it is treated as the package name and
114
+ its last dotted component is the path. If the package name is ` dart ` , it's a
115
+ "dart:" library import.
115
116
116
117
The way I think about the proposed syntax is that relative imports are
117
118
* physical* in that they specify the actual relative path on the file system from
@@ -189,7 +190,7 @@ import 'package:flutter/material.dart';
189
190
import flutter/material ;
190
191
191
192
import 'package:analyzer/dart/ast/visitor/visitor.dart';
192
- import analyzer/dart/ast/visitor ;
193
+ import analyzer/dart/ast/visitor/visitor ;
193
194
194
195
import 'package:widget.tla.proto/client/component.dart';
195
196
import widget.tla.proto/client/component ;
@@ -340,8 +341,14 @@ a string literal containing that string. The process is:
340
341
341
342
1 . Let * name* be the segment.
342
343
343
- 2 . The URI is "package:* name* /* name* .dart". * So ` import test; ` desugars to
344
- ` import "package:test/test.dart"; ` .
344
+ 2 . Let * path* be the last identifier in the segment. * If the segment is
345
+ only a single identifier, this is the entire segment. Otherwise, it's
346
+ the last identifier after the last ` . ` . So in ` foo ` , * path* is ` foo ` .
347
+ In ` foo.bar.baz ` , it's ` baz ` .*
348
+
349
+ 3 . The URI is "package:* name* /* path* .dart". * So ` import test; ` desugars to
350
+ ` import "package:test/test.dart"; ` , and ` import server.api; ` desugars
351
+ to ` import "package:server.api/api.dart"; ` .*
345
352
346
353
5 . Else:
347
354
@@ -410,6 +417,11 @@ new unquoted style whenever an existing directive could use it.
410
417
411
418
## Changelog
412
419
420
+ ### 0.2
421
+
422
+ - Handle dotted identifiers in single-segment imports specially. * This makes
423
+ them work better for common cases in Google's monorepo.*
424
+
413
425
### 0.1
414
426
415
427
- Initial draft.
0 commit comments