Skip to content

Commit dfb2554

Browse files
bwilkersonCommit Queue
authored andcommitted
Rename LibraryFragmentInclude to PartInclude
Also renames associated getters, fixes some comments, and removes a getter (`nameOffset`) that should have been `nameOffset2`. Change-Id: I0dc4879c37ec14650d94933c14630176e4d1f57e Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/394386 Reviewed-by: Konstantin Shcheglov <[email protected]> Commit-Queue: Brian Wilkerson <[email protected]>
1 parent 5f5f4bd commit dfb2554

File tree

5 files changed

+22
-32
lines changed

5 files changed

+22
-32
lines changed

pkg/analysis_server/lib/src/status/ast_writer.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ class AstWriter extends UnifyingAstVisitor<void> with TreeWriter {
103103
properties['static invoke type'] = node.staticInvokeType;
104104
properties['static type'] = node.staticType;
105105
} else if (node is PartDirective) {
106-
properties['fragment include'] = node.fragmentInclude;
106+
properties['fragment include'] = node.partInclude;
107107
} else if (node is PostfixExpression) {
108108
properties['element'] = node.element;
109109
properties['static type'] = node.staticType;

pkg/analyzer/lib/dart/element/element2.dart

Lines changed: 13 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1490,7 +1490,7 @@ abstract class LibraryElement2 implements Element2, Annotatable {
14901490
TypeSystem get typeSystem;
14911491
}
14921492

1493-
/// An export directive within a library.
1493+
/// An `export` directive within a library fragment.
14941494
///
14951495
/// Clients may not extend, implement or mix-in this class.
14961496
abstract class LibraryExport {
@@ -1532,11 +1532,6 @@ abstract class LibraryFragment implements Fragment, Annotatable {
15321532
/// The fragments of the extension types declared in this fragment.
15331533
List<ExtensionTypeFragment> get extensionTypes2;
15341534

1535-
/// The `part` directives within this fragment.
1536-
// TODO(brianwilkerson): Rename this, `libraryExports2`, and `libraryImports2`
1537-
// to be consistent with each other.
1538-
List<LibraryFragmentInclude> get fragmentIncludes;
1539-
15401535
/// The fragments of the top-level functions declared in this fragment.
15411536
List<TopLevelFunctionFragment> get functions2;
15421537

@@ -1558,6 +1553,9 @@ abstract class LibraryFragment implements Fragment, Annotatable {
15581553
@override
15591554
LibraryFragment? get nextFragment;
15601555

1556+
/// The `part` directives within this fragment.
1557+
List<PartInclude> get partIncludes;
1558+
15611559
/// The prefixes used by [libraryImports2].
15621560
///
15631561
/// Each prefix can be used in more than one `import` directive.
@@ -1585,15 +1583,7 @@ abstract class LibraryFragment implements Fragment, Annotatable {
15851583
List<TypeAliasFragment> get typeAliases2;
15861584
}
15871585

1588-
/// A 'part' directive within a library fragment.
1589-
///
1590-
/// Clients may not extend, implement or mix-in this class.
1591-
abstract class LibraryFragmentInclude {
1592-
/// The interpretation of the URI specified in the directive.
1593-
DirectiveUri get uri;
1594-
}
1595-
1596-
/// An import directive within a library.
1586+
/// An `import` directive within a library fragment.
15971587
///
15981588
/// Clients may not extend, implement or mix-in this class.
15991589
abstract class LibraryImport {
@@ -1649,12 +1639,6 @@ abstract class LocalFunctionFragment implements ExecutableFragment {
16491639
// @override
16501640
// LocalFunctionElement get element;
16511641

1652-
/// The offset of the name of this fragment in the file that contains the
1653-
/// declaration of this fragment, or `null` if this element doesn't have an
1654-
/// offset.
1655-
// TODO(brianwilkerson): Figure out why the return type is nullable.
1656-
int? get nameOffset;
1657-
16581642
// TODO(brianwilkerson): This should override `nextFragment` to be more
16591643
// specific, but can't because the Impl class supports both local and
16601644
// top-level functions.
@@ -1953,6 +1937,14 @@ abstract class MultiplyDefinedFragment implements Fragment {
19531937
Null get previousFragment;
19541938
}
19551939

1940+
/// A 'part' directive within a library fragment.
1941+
///
1942+
/// Clients may not extend, implement or mix-in this class.
1943+
abstract class PartInclude {
1944+
/// The interpretation of the URI specified in the directive.
1945+
DirectiveUri get uri;
1946+
}
1947+
19561948
/// A pattern variable.
19571949
///
19581950
/// Clients may not extend, implement or mix-in this class.
@@ -2132,7 +2124,6 @@ abstract class PropertyInducingFragment
21322124
/// A synthetic fragment is a fragment that is not represented in the source
21332125
/// code explicitly, but is implied by the source code, such as the default
21342126
/// constructor for a class that does not explicitly define any constructors.
2135-
// TODO(brianwilkerson): Should synthetic elements have a fragment?
21362127
bool get isSynthetic;
21372128

21382129
@override

pkg/analyzer/lib/src/dart/ast/ast.dart

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13613,7 +13613,7 @@ abstract final class PartDirective implements UriBasedDirective {
1361313613
///
1361413614
/// Returns `null` if the AST structure hasn't been resolved.
1361513615
@experimental
13616-
LibraryFragmentInclude? get fragmentInclude;
13616+
PartInclude? get partInclude;
1361713617

1361813618
/// The token representing the `part` keyword.
1361913619
Token get partKeyword;
@@ -13661,8 +13661,7 @@ final class PartDirectiveImpl extends UriBasedDirectiveImpl
1366113661

1366213662
@experimental
1366313663
@override
13664-
LibraryFragmentInclude? get fragmentInclude =>
13665-
element as LibraryFragmentInclude?;
13664+
PartInclude? get partInclude => element as PartInclude?;
1366613665

1366713666
@override
1366813667
ChildEntities get _childEntities => super._childEntities

pkg/analyzer/lib/src/dart/element/element.dart

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -925,10 +925,6 @@ class CompilationUnitElementImpl extends UriReferencedElementImpl
925925
List<ExtensionTypeFragment> get extensionTypes2 =>
926926
extensionTypes.cast<ExtensionTypeFragment>();
927927

928-
@override
929-
List<LibraryFragmentInclude> get fragmentIncludes =>
930-
libraryImportPrefixes.cast<LibraryFragmentInclude>();
931-
932928
@override
933929
List<FunctionElementImpl> get functions {
934930
return _functions;
@@ -1051,6 +1047,10 @@ class CompilationUnitElementImpl extends UriReferencedElementImpl
10511047
return units.elementAtOrNull(index + 1);
10521048
}
10531049

1050+
@override
1051+
List<PartInclude> get partIncludes =>
1052+
libraryImportPrefixes.cast<PartInclude>();
1053+
10541054
@override
10551055
List<PartElementImpl> get parts => _parts;
10561056

@@ -8912,7 +8912,7 @@ mixin ParameterElementMixin implements ParameterElement {
89128912
}
89138913

89148914
class PartElementImpl extends _ExistingElementImpl
8915-
implements PartElement, LibraryFragmentInclude {
8915+
implements PartElement, PartInclude {
89168916
@override
89178917
final DirectiveUri uri;
89188918

pkg/analyzer/lib/src/test_utilities/find_element2.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ class FindElement2 extends _FindElementBase {
226226
LibraryFragment part(String targetUri) {
227227
LibraryFragment? result;
228228

229-
for (var partElement in libraryFragment.fragmentIncludes) {
229+
for (var partElement in libraryFragment.partIncludes) {
230230
var uri = partElement.uri;
231231
if (uri is DirectiveUriWithUnit) {
232232
var unitElement = uri.libraryFragment;

0 commit comments

Comments
 (0)