Skip to content

Commit 86f4b57

Browse files
scheglovCommit Queue
authored andcommitted
Elements. Stop referencing Element in Reference.
Change-Id: Ib5fe940ec9260c45fffea10fedf083b59e3ba2c3 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/412343 Commit-Queue: Konstantin Shcheglov <[email protected]> Reviewed-by: Paul Berry <[email protected]>
1 parent ebb7e10 commit 86f4b57

File tree

3 files changed

+11
-19
lines changed

3 files changed

+11
-19
lines changed

pkg/analyzer/lib/src/dart/analysis/library_context.dart

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
// for details. All rights reserved. Use of this source code is governed by a
33
// BSD-style license that can be found in the LICENSE file.
44

5-
// ignore_for_file: analyzer_use_new_elements
6-
75
/// @docImport 'package:analyzer/src/generated/engine.dart';
86
library;
97

@@ -12,7 +10,6 @@ import 'dart:collection';
1210
import 'dart:typed_data';
1311

1412
import 'package:analyzer/dart/analysis/declared_variables.dart';
15-
import 'package:analyzer/dart/element/element.dart' show CompilationUnitElement;
1613
import 'package:analyzer/file_system/file_system.dart';
1714
import 'package:analyzer/src/context/context.dart';
1815
import 'package:analyzer/src/dart/analysis/analysis_options_map.dart';
@@ -100,7 +97,7 @@ class LibraryContext {
10097
}
10198
}
10299

103-
/// Computes a [CompilationUnitElement] for the given library/unit pair.
100+
/// Computes a [CompilationUnitElementImpl] for the given library/unit pair.
104101
CompilationUnitElementImpl computeUnitElement(
105102
LibraryFileKind library,
106103
FileState unit,

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

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,8 @@
22
// for details. All rights reserved. Use of this source code is governed by a
33
// BSD-style license that can be found in the LICENSE file.
44

5-
// ignore_for_file: analyzer_use_new_elements
6-
75
import 'dart:collection';
86

9-
import 'package:analyzer/dart/element/element.dart';
107
import 'package:analyzer/dart/element/element2.dart';
118
import 'package:analyzer/src/context/context.dart';
129
import 'package:analyzer/src/dart/analysis/session.dart';
@@ -180,9 +177,9 @@ class LinkedElementFactory {
180177
}
181178

182179
// TODO(scheglov): Why would this method return `null`?
183-
Element? elementOfReference(Reference reference) {
184-
if (reference.element != null) {
185-
return reference.element;
180+
ElementImpl? elementOfReference(Reference reference) {
181+
if (reference.element case var element?) {
182+
return element;
186183
}
187184
if (reference.parent == null) {
188185
return null;
@@ -298,5 +295,5 @@ class LinkedElementFactory {
298295
libraryElement.hasTypeProviderSystemSet = true;
299296
}
300297

301-
void _disposeLibrary(Element? libraryElement) {}
298+
void _disposeLibrary(ElementImpl? libraryElement) {}
302299
}

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

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,14 @@
22
// for details. All rights reserved. Use of this source code is governed by a
33
// BSD-style license that can be found in the LICENSE file.
44

5-
// ignore_for_file: analyzer_use_new_elements
6-
7-
import 'package:analyzer/dart/element/element.dart';
85
import 'package:analyzer/dart/element/element2.dart';
6+
import 'package:analyzer/src/dart/element/element.dart';
97
import 'package:meta/meta.dart';
108

11-
/// Indirection between a name and the corresponding [Element].
9+
/// Indirection between a name and the corresponding [ElementImpl].
1210
///
1311
/// References are organized in a prefix tree.
14-
/// Each reference knows its parent, children, and the [Element].
12+
/// Each reference knows its parent, children, and the [ElementImpl].
1513
///
1614
/// Library:
1715
/// URI of library
@@ -26,7 +24,7 @@ import 'package:meta/meta.dart';
2624
/// "@method"
2725
/// Name of the method
2826
///
29-
/// There is only one reference object per [Element].
27+
/// There is only one reference object per [ElementImpl].
3028
class Reference {
3129
/// The name of the container used for duplicate declarations.
3230
static const _defName = '@def';
@@ -37,8 +35,8 @@ class Reference {
3735
/// The simple name of the reference in its [parent].
3836
String name;
3937

40-
/// The corresponding [Element], or `null` if a named container.
41-
Element? element;
38+
/// The corresponding [ElementImpl], or `null` if a named container.
39+
ElementImpl? element;
4240

4341
/// The corresponding [Element2], or `null` if a named container.
4442
Element2? element2;

0 commit comments

Comments
 (0)