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

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

Issue 1639533003: Record static constant public fields. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Serialize only constant constructors. Created 4 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
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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 bool isPublic(String name) => !name.startsWith('_'); 57 bool isPublic(String name) => !name.startsWith('_');
58 58
59 @override 59 @override
60 visitClassDeclaration(ClassDeclaration node) { 60 visitClassDeclaration(ClassDeclaration node) {
61 UnlinkedPublicNameBuilder cls = addNameIfPublic( 61 UnlinkedPublicNameBuilder cls = addNameIfPublic(
62 node.name.name, 62 node.name.name,
63 ReferenceKind.classOrEnum, 63 ReferenceKind.classOrEnum,
64 node.typeParameters?.typeParameters?.length ?? 0); 64 node.typeParameters?.typeParameters?.length ?? 0);
65 if (cls != null) { 65 if (cls != null) {
66 for (ClassMember member in node.members) { 66 for (ClassMember member in node.members) {
67 if (member is FieldDeclaration &&
68 member.isStatic &&
69 member.fields.isConst) {
70 for (VariableDeclaration field in member.fields.variables) {
71 String name = field.name.name;
72 if (isPublic(name)) {
73 cls.constMembers.add(new UnlinkedPublicNameBuilder(
74 name: name,
75 kind: ReferenceKind.constField,
76 numTypeParameters: 0));
77 }
78 }
79 }
67 if (member is MethodDeclaration && 80 if (member is MethodDeclaration &&
68 member.isStatic && 81 member.isStatic &&
69 !member.isGetter && 82 !member.isGetter &&
70 !member.isSetter && 83 !member.isSetter &&
71 !member.isOperator) { 84 !member.isOperator) {
72 String name = member.name.name; 85 String name = member.name.name;
73 if (isPublic(name)) { 86 if (isPublic(name)) {
74 cls.executables.add(new UnlinkedPublicNameBuilder( 87 cls.constMembers.add(new UnlinkedPublicNameBuilder(
75 name: name, 88 name: name,
76 kind: ReferenceKind.staticMethod, 89 kind: ReferenceKind.staticMethod,
77 numTypeParameters: 90 numTypeParameters:
78 member.typeParameters?.typeParameters?.length ?? 0)); 91 member.typeParameters?.typeParameters?.length ?? 0));
79 } 92 }
80 } 93 }
81 if (member is ConstructorDeclaration) { 94 if (member is ConstructorDeclaration && member.constKeyword != null) {
82 String name = member.name != null ? member.name.name : ''; 95 String name = member.name != null ? member.name.name : '';
83 if (isPublic(name)) { 96 if (isPublic(name)) {
84 cls.executables.add(new UnlinkedPublicNameBuilder( 97 cls.constMembers.add(new UnlinkedPublicNameBuilder(
85 name: name, 98 name: name,
86 kind: ReferenceKind.constructor, 99 kind: ReferenceKind.constructor,
87 numTypeParameters: 0)); 100 numTypeParameters: 0));
88 } 101 }
89 } 102 }
90 } 103 }
91 } 104 }
92 } 105 }
93 106
94 @override 107 @override
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 151
139 @override 152 @override
140 visitVariableDeclaration(VariableDeclaration node) { 153 visitVariableDeclaration(VariableDeclaration node) {
141 String name = node.name.name; 154 String name = node.name.name;
142 addNameIfPublic(name, ReferenceKind.topLevelPropertyAccessor, 0); 155 addNameIfPublic(name, ReferenceKind.topLevelPropertyAccessor, 0);
143 if (!node.isFinal && !node.isConst) { 156 if (!node.isFinal && !node.isConst) {
144 addNameIfPublic('$name=', ReferenceKind.topLevelPropertyAccessor, 0); 157 addNameIfPublic('$name=', ReferenceKind.topLevelPropertyAccessor, 0);
145 } 158 }
146 } 159 }
147 } 160 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/summary/prelink.dart ('k') | pkg/analyzer/lib/src/summary/summarize_elements.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698