Skip to content

Commit ea81fac

Browse files
scheglovCommit Queue
authored andcommitted
Elements. Rename 'LibraryElement2.functions' to 'topLevelFunctions'.
For consistency with the name of the item `TopLevelFunctionElement`, as `List<TopLevelVariableElement2> get topLevelVariables` does. Change-Id: I52f119493ecdfeb4005926c46f1ac14838a6d46d Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/396980 Commit-Queue: Konstantin Shcheglov <[email protected]> Reviewed-by: Brian Wilkerson <[email protected]>
1 parent 5681cfa commit ea81fac

File tree

8 files changed

+17
-27
lines changed

8 files changed

+17
-27
lines changed

pkg/analysis_server/lib/src/services/correction/dart/change_to.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ class ChangeTo extends ResolvedCorrectionProducer {
238238
);
239239
// Check to this library units.
240240
if (prefixName == null) {
241-
for (var function in unitResult.libraryElement2.functions) {
241+
for (var function in unitResult.libraryElement2.topLevelFunctions) {
242242
finder._update(function);
243243
}
244244
}

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1445,12 +1445,6 @@ abstract class LibraryElement2 implements Element2, Annotatable {
14451445
/// `part` directive.
14461446
List<LibraryFragment> get fragments;
14471447

1448-
/// The functions defined in this library.
1449-
///
1450-
/// There is no guarantee of the order in which the functions will be
1451-
/// returned. In particular, they are not guaranteed to be in lexical order.
1452-
List<TopLevelFunctionElement> get functions;
1453-
14541448
/// The getters defined in this library.
14551449
///
14561450
/// There is no guarantee of the order in which the getters will be returned.
@@ -1502,6 +1496,12 @@ abstract class LibraryElement2 implements Element2, Annotatable {
15021496
/// In particular, they are not guaranteed to be in lexical order.
15031497
List<SetterElement> get setters;
15041498

1499+
/// The functions defined in this library.
1500+
///
1501+
/// There is no guarantee of the order in which the functions will be
1502+
/// returned. In particular, they are not guaranteed to be in lexical order.
1503+
List<TopLevelFunctionElement> get topLevelFunctions;
1504+
15051505
/// The top level variables defined in this library.
15061506
///
15071507
/// There is no guarantee of the order in which the top level variables will

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6495,10 +6495,10 @@ class LibraryElementImpl extends ElementImpl
64956495
List<ExtensionTypeElementImpl2> extensionTypes = [];
64966496

64976497
@override
6498-
List<TopLevelFunctionElementImpl> functions = [];
6498+
List<MixinElementImpl2> mixins = [];
64996499

65006500
@override
6501-
List<MixinElementImpl2> mixins = [];
6501+
List<TopLevelFunctionElementImpl> topLevelFunctions = [];
65026502

65036503
@override
65046504
List<TopLevelVariableElementImpl2> topLevelVariables = [];
@@ -6545,7 +6545,7 @@ class LibraryElementImpl extends ElementImpl
65456545
...classes,
65466546
...extensions,
65476547
...extensionTypes,
6548-
...functions,
6548+
...topLevelFunctions,
65496549
...mixins,
65506550
...typeAliases,
65516551
...getters,
@@ -6893,7 +6893,7 @@ class LibraryElementImpl extends ElementImpl
68936893

68946894
@override
68956895
TopLevelFunctionElement? getTopLevelFunction(String name) {
6896-
return _getElementByName(functions, name);
6896+
return _getElementByName(topLevelFunctions, name);
68976897
}
68986898

68996899
@override

pkg/analyzer/lib/src/summary2/bundle_reader.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1197,7 +1197,7 @@ class LibraryReader {
11971197
fragment.element = element;
11981198
} else {
11991199
var element = TopLevelFunctionElementImpl(reference2, fragment);
1200-
_libraryElement.functions.add(element);
1200+
_libraryElement.topLevelFunctions.add(element);
12011201
}
12021202

12031203
var linkedData = FunctionElementLinkedData(

pkg/analyzer/lib/src/summary2/element_builder.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -903,7 +903,7 @@ class ElementBuilder extends ThrowingAstVisitor<void> {
903903
elementReference,
904904
fragment,
905905
);
906-
_libraryBuilder.element.functions.add(element);
906+
_libraryBuilder.element.topLevelFunctions.add(element);
907907

908908
elementBuilder = TopLevelFunctionElementBuilder(
909909
element: element,

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

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

55
import 'package:analyzer/dart/ast/ast.dart';
66
import 'package:analyzer/dart/element/element.dart';
7-
import 'package:analyzer/dart/element/element2.dart';
87
import 'package:analyzer/src/test_utilities/function_ast_visitor.dart';
98
import 'package:analyzer/src/utilities/extensions/element.dart';
109

@@ -468,15 +467,6 @@ abstract class _FindElementBase {
468467
throw StateError('Not found: $name');
469468
}
470469

471-
TopLevelFunctionElement topFunction2(String name) {
472-
for (var function in (unitElement.asElement2 as LibraryElement2).functions) {
473-
if (function.displayName == name) {
474-
return function;
475-
}
476-
}
477-
throw StateError('Not found: $name');
478-
}
479-
480470
PropertyAccessorElement topGet(String name) {
481471
return topVar(name).getter!;
482472
}

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class FindElement2 extends _FindElementBase {
4141
}
4242

4343
TopLevelFunctionElement function(String name) {
44-
for (var function in libraryElement.functions) {
44+
for (var function in libraryElement.topLevelFunctions) {
4545
if (function.name3 == name) {
4646
return function;
4747
}
@@ -186,7 +186,7 @@ class FindElement2 extends _FindElementBase {
186186

187187
findInExecutables(libraryElement.getters);
188188
findInExecutables(libraryElement.setters);
189-
findInExecutables(libraryElement.functions);
189+
findInExecutables(libraryElement.topLevelFunctions);
190190

191191
findInClasses(libraryElement.classes);
192192
findInClasses(libraryElement.enums);
@@ -463,7 +463,7 @@ abstract class _FindElementBase {
463463
}
464464

465465
TopLevelFunctionElement topFunction(String name) {
466-
for (var function in libraryElement.functions) {
466+
for (var function in libraryElement.topLevelFunctions) {
467467
if (function.name3 == name) {
468468
return function;
469469
}

pkg/analyzer/test/src/summary/element_text.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ class _Element2Writer extends _AbstractElementWriter {
239239
_writeElementList('getters', e, e.getters, _writeGetterElement);
240240
_writeElementList('setters', e, e.setters, _writeSetterElement);
241241
_writeElementList(
242-
'functions', e, e.functions, _writeTopLevelFunctionElement);
242+
'functions', e, e.topLevelFunctions, _writeTopLevelFunctionElement);
243243

244244
if (configuration.withExportScope) {
245245
_sink.writelnWithIndent('exportedReferences');

0 commit comments

Comments
 (0)