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

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

Issue 2342893002: Issue 27044. Summarize configurations of imports and exports, AST based. (Closed)
Patch Set: No equality test means '== true'. Created 4 years, 3 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 | « pkg/analyzer/lib/src/summary/idl.dart ('k') | pkg/analyzer/lib/src/summary/summarize_ast.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 import 'package:analyzer/src/summary/idl.dart'; 9 import 'package:analyzer/src/summary/idl.dart';
10 10
11 /** 11 /**
12 * Compute the public namespace portion of the summary for the given [unit], 12 * Compute the public namespace portion of the summary for the given [unit],
13 * which is presumed to be an unresolved AST. 13 * which is presumed to be an unresolved AST.
14 */ 14 */
15 UnlinkedPublicNamespaceBuilder computePublicNamespace(CompilationUnit unit) { 15 UnlinkedPublicNamespaceBuilder computePublicNamespace(CompilationUnit unit) {
16 _PublicNamespaceVisitor visitor = new _PublicNamespaceVisitor(); 16 _PublicNamespaceVisitor visitor = new _PublicNamespaceVisitor();
17 unit.accept(visitor); 17 unit.accept(visitor);
18 return new UnlinkedPublicNamespaceBuilder( 18 return new UnlinkedPublicNamespaceBuilder(
19 names: visitor.names, exports: visitor.exports, parts: visitor.parts); 19 names: visitor.names, exports: visitor.exports, parts: visitor.parts);
20 } 20 }
21 21
22 /**
23 * Serialize a [Configuration] into a [UnlinkedConfigurationBuilder].
24 */
25 UnlinkedConfigurationBuilder serializeConfiguration(
26 Configuration configuration) {
27 return new UnlinkedConfigurationBuilder(
28 name: configuration.name.components.map((i) => i.name).join('.'),
29 value: configuration.value?.stringValue ?? 'true',
30 uri: configuration.libraryUri.stringValue);
31 }
32
22 class _CombinatorEncoder extends SimpleAstVisitor<UnlinkedCombinatorBuilder> { 33 class _CombinatorEncoder extends SimpleAstVisitor<UnlinkedCombinatorBuilder> {
23 _CombinatorEncoder(); 34 _CombinatorEncoder();
24 35
25 List<String> encodeNames(NodeList<SimpleIdentifier> names) => 36 List<String> encodeNames(NodeList<SimpleIdentifier> names) =>
26 names.map((SimpleIdentifier id) => id.name).toList(); 37 names.map((SimpleIdentifier id) => id.name).toList();
27 38
28 @override 39 @override
29 UnlinkedCombinatorBuilder visitHideCombinator(HideCombinator node) { 40 UnlinkedCombinatorBuilder visitHideCombinator(HideCombinator node) {
30 return new UnlinkedCombinatorBuilder(hides: encodeNames(node.hiddenNames)); 41 return new UnlinkedCombinatorBuilder(hides: encodeNames(node.hiddenNames));
31 } 42 }
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 } 144 }
134 } 145 }
135 } 146 }
136 147
137 @override 148 @override
138 visitExportDirective(ExportDirective node) { 149 visitExportDirective(ExportDirective node) {
139 exports.add(new UnlinkedExportPublicBuilder( 150 exports.add(new UnlinkedExportPublicBuilder(
140 uri: node.uri.stringValue, 151 uri: node.uri.stringValue,
141 combinators: node.combinators 152 combinators: node.combinators
142 .map((Combinator c) => c.accept(new _CombinatorEncoder())) 153 .map((Combinator c) => c.accept(new _CombinatorEncoder()))
143 .toList())); 154 .toList(),
155 configurations:
156 node.configurations.map(serializeConfiguration).toList()));
144 } 157 }
145 158
146 @override 159 @override
147 visitFunctionDeclaration(FunctionDeclaration node) { 160 visitFunctionDeclaration(FunctionDeclaration node) {
148 String name = node.name.name; 161 String name = node.name.name;
149 if (node.isSetter) { 162 if (node.isSetter) {
150 name += '='; 163 name += '=';
151 } 164 }
152 addNameIfPublic( 165 addNameIfPublic(
153 name, 166 name,
(...skipping 16 matching lines...) Expand all
170 183
171 @override 184 @override
172 visitVariableDeclaration(VariableDeclaration node) { 185 visitVariableDeclaration(VariableDeclaration node) {
173 String name = node.name.name; 186 String name = node.name.name;
174 addNameIfPublic(name, ReferenceKind.topLevelPropertyAccessor, 0); 187 addNameIfPublic(name, ReferenceKind.topLevelPropertyAccessor, 0);
175 if (!node.isFinal && !node.isConst) { 188 if (!node.isFinal && !node.isConst) {
176 addNameIfPublic('$name=', ReferenceKind.topLevelPropertyAccessor, 0); 189 addNameIfPublic('$name=', ReferenceKind.topLevelPropertyAccessor, 0);
177 } 190 }
178 } 191 }
179 } 192 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/summary/idl.dart ('k') | pkg/analyzer/lib/src/summary/summarize_ast.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698