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

Side by Side Diff: pkg/analyzer/lib/src/summary/public_namespace_computer.dart

Issue 1619253003: Include explicit constructors and static methods into UnlinkedPublicName (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 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. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library analyzer.src.summary.public_namespace_visitor; 5 library analyzer.src.summary.public_namespace_visitor;
6 6
7 import 'package:analyzer/analyzer.dart'; 7 import 'package:analyzer/analyzer.dart';
8 import 'package:analyzer/src/summary/format.dart'; 8 import 'package:analyzer/src/summary/format.dart';
9 9
10 /** 10 /**
(...skipping 25 matching lines...) Expand all
36 } 36 }
37 37
38 class _PublicNamespaceVisitor extends RecursiveAstVisitor { 38 class _PublicNamespaceVisitor extends RecursiveAstVisitor {
39 final List<UnlinkedPublicNameBuilder> names = <UnlinkedPublicNameBuilder>[]; 39 final List<UnlinkedPublicNameBuilder> names = <UnlinkedPublicNameBuilder>[];
40 final List<UnlinkedExportPublicBuilder> exports = 40 final List<UnlinkedExportPublicBuilder> exports =
41 <UnlinkedExportPublicBuilder>[]; 41 <UnlinkedExportPublicBuilder>[];
42 final List<String> parts = <String>[]; 42 final List<String> parts = <String>[];
43 43
44 _PublicNamespaceVisitor(); 44 _PublicNamespaceVisitor();
45 45
46 void addNameIfPublic(String name, ReferenceKind kind, int numTypeParameters) { 46 UnlinkedPublicNameBuilder addNameIfPublic(
47 String name, ReferenceKind kind, int numTypeParameters) {
47 if (isPublic(name)) { 48 if (isPublic(name)) {
48 names.add(new UnlinkedPublicNameBuilder( 49 UnlinkedPublicNameBuilder b = new UnlinkedPublicNameBuilder(
49 name: name, kind: kind, numTypeParameters: numTypeParameters)); 50 name: name, kind: kind, numTypeParameters: numTypeParameters);
51 names.add(b);
52 return b;
50 } 53 }
54 return null;
51 } 55 }
52 56
53 bool isPublic(String name) => !name.startsWith('_'); 57 bool isPublic(String name) => !name.startsWith('_');
54 58
55 @override 59 @override
56 visitClassDeclaration(ClassDeclaration node) { 60 visitClassDeclaration(ClassDeclaration node) {
57 addNameIfPublic(node.name.name, ReferenceKind.classOrEnum, 61 UnlinkedPublicNameBuilder cls = addNameIfPublic(
62 node.name.name,
63 ReferenceKind.classOrEnum,
58 node.typeParameters?.typeParameters?.length ?? 0); 64 node.typeParameters?.typeParameters?.length ?? 0);
65 if (cls != null) {
66 for (ClassMember member in node.members) {
67 if (member is MethodDeclaration &&
68 member.isStatic &&
69 !member.isGetter &&
70 !member.isSetter &&
71 !member.isOperator) {
72 String name = member.name.name;
73 if (isPublic(name)) {
74 cls.executables.add(new UnlinkedPublicNameBuilder(
75 name: name,
76 kind: ReferenceKind.staticMethod,
77 numTypeParameters:
78 member.typeParameters?.typeParameters?.length ?? 0));
79 }
80 }
81 if (member is ConstructorDeclaration) {
82 String name = member.name != null ? member.name.name : '';
83 if (isPublic(name)) {
84 cls.executables.add(new UnlinkedPublicNameBuilder(
85 name: name,
86 kind: ReferenceKind.constructor,
87 numTypeParameters: 0));
88 }
89 }
90 }
91 }
59 } 92 }
60 93
61 @override 94 @override
62 visitClassTypeAlias(ClassTypeAlias node) { 95 visitClassTypeAlias(ClassTypeAlias node) {
63 addNameIfPublic(node.name.name, ReferenceKind.classOrEnum, 96 addNameIfPublic(node.name.name, ReferenceKind.classOrEnum,
64 node.typeParameters?.typeParameters?.length ?? 0); 97 node.typeParameters?.typeParameters?.length ?? 0);
65 } 98 }
66 99
67 @override 100 @override
68 visitEnumDeclaration(EnumDeclaration node) { 101 visitEnumDeclaration(EnumDeclaration node) {
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 138
106 @override 139 @override
107 visitVariableDeclaration(VariableDeclaration node) { 140 visitVariableDeclaration(VariableDeclaration node) {
108 String name = node.name.name; 141 String name = node.name.name;
109 addNameIfPublic(name, ReferenceKind.topLevelPropertyAccessor, 0); 142 addNameIfPublic(name, ReferenceKind.topLevelPropertyAccessor, 0);
110 if (!node.isFinal && !node.isConst) { 143 if (!node.isFinal && !node.isConst) {
111 addNameIfPublic('$name=', ReferenceKind.topLevelPropertyAccessor, 0); 144 addNameIfPublic('$name=', ReferenceKind.topLevelPropertyAccessor, 0);
112 } 145 }
113 } 146 }
114 } 147 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698