Skip to content

Commit 0d470ac

Browse files
pqCommit Queue
authored andcommitted
[element model] migrate element_library_private_types_in_public_api
Bug: https://github.com/dart-lang/linter/issues/5099 Change-Id: I33e2d5dc3f54c04db560ceeaaab2824ca5903a44 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/390360 Auto-Submit: Phil Quitslund <[email protected]> Reviewed-by: Brian Wilkerson <[email protected]> Commit-Queue: Brian Wilkerson <[email protected]>
1 parent f37e852 commit 0d470ac

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

pkg/linter/analyzer_use_new_elements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ lib/src/rules/leading_newlines_in_multiline_strings.dart
7575
lib/src/rules/library_annotations.dart
7676
lib/src/rules/library_names.dart
7777
lib/src/rules/library_prefixes.dart
78+
lib/src/rules/library_private_types_in_public_api.dart
7879
lib/src/rules/lines_longer_than_80_chars.dart
7980
lib/src/rules/list_remove_unrelated_type.dart
8081
lib/src/rules/literal_only_boolean_expressions.dart

pkg/linter/lib/src/rules/library_private_types_in_public_api.dart

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

55
import 'package:analyzer/dart/ast/ast.dart';
66
import 'package:analyzer/dart/ast/visitor.dart';
7-
import 'package:analyzer/dart/element/element.dart';
7+
import 'package:analyzer/dart/element/element2.dart';
88
import 'package:analyzer/dart/element/type.dart';
99

1010
import '../analyzer.dart';
@@ -129,10 +129,10 @@ class Validator extends SimpleAstVisitor<void> {
129129
}
130130

131131
// Check implicit type.
132-
var element = node.declaredElement;
133-
if (element is FieldFormalParameterElement) {
132+
var element = node.declaredFragment?.element;
133+
if (element is FieldFormalParameterElement2) {
134134
var type = element.type;
135-
if (type is InterfaceType && isPrivateName(type.element.name)) {
135+
if (type is InterfaceType && isPrivateName(type.element3.name)) {
136136
rule.reportLintForToken(node.name);
137137
}
138138
}
@@ -211,7 +211,7 @@ class Validator extends SimpleAstVisitor<void> {
211211

212212
@override
213213
void visitNamedType(NamedType node) {
214-
var element = node.element;
214+
var element = node.element2;
215215
if (element != null && isPrivate(element)) {
216216
rule.reportLintForToken(node.name2);
217217
}
@@ -241,10 +241,10 @@ class Validator extends SimpleAstVisitor<void> {
241241
}
242242

243243
// Check implicit type.
244-
var element = node.declaredElement;
245-
if (element is SuperFormalParameterElement) {
244+
var element = node.declaredFragment?.element;
245+
if (element is SuperFormalParameterElement2) {
246246
var type = element.type;
247-
if (type is InterfaceType && isPrivateName(type.element.name)) {
247+
if (type is InterfaceType && isPrivateName(type.element3.name)) {
248248
rule.reportLintForToken(node.name);
249249
}
250250
}
@@ -275,7 +275,7 @@ class Validator extends SimpleAstVisitor<void> {
275275

276276
/// Return `true` if the given [element] is private or is defined in a private
277277
/// library.
278-
static bool isPrivate(Element element) => isPrivateName(element.name);
278+
static bool isPrivate(Element2 element) => isPrivateName(element.name);
279279

280280
static bool isPrivateName(String? name) =>
281281
name != null && Identifier.isPrivateName(name);
@@ -288,7 +288,7 @@ class Visitor extends SimpleAstVisitor<void> {
288288

289289
@override
290290
void visitCompilationUnit(CompilationUnit node) {
291-
var element = node.declaredElement;
291+
var element = node.declaredFragment?.element;
292292
if (element != null && !Validator.isPrivate(element)) {
293293
var validator = Validator(rule);
294294
node.declarations.accept(validator);

0 commit comments

Comments
 (0)