Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(974)

Unified Diff: pkg/analyzer/lib/src/dart/analysis/defined_names.dart

Issue 2670843004: Record defined top-level/class-mebber names with unlinked bundles. (Closed)
Patch Set: Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | pkg/analyzer/lib/src/dart/analysis/driver.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/lib/src/dart/analysis/defined_names.dart
diff --git a/pkg/analyzer/lib/src/dart/analysis/defined_names.dart b/pkg/analyzer/lib/src/dart/analysis/defined_names.dart
new file mode 100644
index 0000000000000000000000000000000000000000..58d0a65c1776272b91abc3d076e0974fa2019b95
--- /dev/null
+++ b/pkg/analyzer/lib/src/dart/analysis/defined_names.dart
@@ -0,0 +1,53 @@
+// Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+import 'package:analyzer/dart/ast/ast.dart';
+
+/**
+ * Compute the [DefinedNames] for the given [unit].
+ */
+DefinedNames computeDefinedNames(CompilationUnit unit) {
+ DefinedNames names = new DefinedNames();
+
+ void appendName(Set<String> names, SimpleIdentifier node) {
+ String name = node?.name;
+ if (name != null && name.length != 0) {
+ names.add(name);
+ }
+ }
+
+ void appendClassMemberName(ClassMember member) {
+ if (member is MethodDeclaration) {
+ appendName(names.classMemberNames, member.name);
+ } else if (member is FieldDeclaration) {
+ for (VariableDeclaration field in member.fields.variables) {
+ appendName(names.classMemberNames, field.name);
+ }
+ }
+ }
+
+ void appendTopLevelName(CompilationUnitMember member) {
+ if (member is NamedCompilationUnitMember) {
+ appendName(names.topLevelNames, member.name);
+ if (member is ClassDeclaration) {
+ member.members.forEach(appendClassMemberName);
+ }
+ } else if (member is TopLevelVariableDeclaration) {
+ for (VariableDeclaration variable in member.variables.variables) {
+ appendName(names.topLevelNames, variable.name);
+ }
+ }
+ }
+
+ unit.declarations.forEach(appendTopLevelName);
+ return names;
+}
+
+/**
+ * Defined top-level and class member names.
+ */
+class DefinedNames {
+ final Set<String> topLevelNames = new Set<String>();
+ final Set<String> classMemberNames = new Set<String>();
+}
« no previous file with comments | « no previous file | pkg/analyzer/lib/src/dart/analysis/driver.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698