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

Side by Side 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, 10 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 unified diff | Download patch
« no previous file with comments | « no previous file | pkg/analyzer/lib/src/dart/analysis/driver.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file.
4
5 import 'package:analyzer/dart/ast/ast.dart';
6
7 /**
8 * Compute the [DefinedNames] for the given [unit].
9 */
10 DefinedNames computeDefinedNames(CompilationUnit unit) {
11 DefinedNames names = new DefinedNames();
12
13 void appendName(Set<String> names, SimpleIdentifier node) {
14 String name = node?.name;
15 if (name != null && name.length != 0) {
16 names.add(name);
17 }
18 }
19
20 void appendClassMemberName(ClassMember member) {
21 if (member is MethodDeclaration) {
22 appendName(names.classMemberNames, member.name);
23 } else if (member is FieldDeclaration) {
24 for (VariableDeclaration field in member.fields.variables) {
25 appendName(names.classMemberNames, field.name);
26 }
27 }
28 }
29
30 void appendTopLevelName(CompilationUnitMember member) {
31 if (member is NamedCompilationUnitMember) {
32 appendName(names.topLevelNames, member.name);
33 if (member is ClassDeclaration) {
34 member.members.forEach(appendClassMemberName);
35 }
36 } else if (member is TopLevelVariableDeclaration) {
37 for (VariableDeclaration variable in member.variables.variables) {
38 appendName(names.topLevelNames, variable.name);
39 }
40 }
41 }
42
43 unit.declarations.forEach(appendTopLevelName);
44 return names;
45 }
46
47 /**
48 * Defined top-level and class member names.
49 */
50 class DefinedNames {
51 final Set<String> topLevelNames = new Set<String>();
52 final Set<String> classMemberNames = new Set<String>();
53 }
OLDNEW
« 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