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

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

Issue 1584313005: Downplay the distinction between linked and prelinked summaries. (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( 46 void addNameIfPublic(String name, ReferenceKind kind, int numTypeParameters) {
47 String name, PrelinkedReferenceKind kind, int numTypeParameters) {
48 if (isPublic(name)) { 47 if (isPublic(name)) {
49 names.add(new UnlinkedPublicNameBuilder( 48 names.add(new UnlinkedPublicNameBuilder(
50 name: name, kind: kind, numTypeParameters: numTypeParameters)); 49 name: name, kind: kind, numTypeParameters: numTypeParameters));
51 } 50 }
52 } 51 }
53 52
54 bool isPublic(String name) => !name.startsWith('_'); 53 bool isPublic(String name) => !name.startsWith('_');
55 54
56 @override 55 @override
57 visitClassDeclaration(ClassDeclaration node) { 56 visitClassDeclaration(ClassDeclaration node) {
58 addNameIfPublic(node.name.name, PrelinkedReferenceKind.classOrEnum, 57 addNameIfPublic(node.name.name, ReferenceKind.classOrEnum,
59 node.typeParameters?.typeParameters?.length ?? 0); 58 node.typeParameters?.typeParameters?.length ?? 0);
60 } 59 }
61 60
62 @override 61 @override
63 visitClassTypeAlias(ClassTypeAlias node) { 62 visitClassTypeAlias(ClassTypeAlias node) {
64 addNameIfPublic(node.name.name, PrelinkedReferenceKind.classOrEnum, 63 addNameIfPublic(node.name.name, ReferenceKind.classOrEnum,
65 node.typeParameters?.typeParameters?.length ?? 0); 64 node.typeParameters?.typeParameters?.length ?? 0);
66 } 65 }
67 66
68 @override 67 @override
69 visitEnumDeclaration(EnumDeclaration node) { 68 visitEnumDeclaration(EnumDeclaration node) {
70 addNameIfPublic(node.name.name, PrelinkedReferenceKind.classOrEnum, 0); 69 addNameIfPublic(node.name.name, ReferenceKind.classOrEnum, 0);
71 } 70 }
72 71
73 @override 72 @override
74 visitExportDirective(ExportDirective node) { 73 visitExportDirective(ExportDirective node) {
75 exports.add(new UnlinkedExportPublicBuilder( 74 exports.add(new UnlinkedExportPublicBuilder(
76 uri: node.uri.stringValue, 75 uri: node.uri.stringValue,
77 combinators: node.combinators 76 combinators: node.combinators
78 .map((Combinator c) => c.accept(new _CombinatorEncoder())) 77 .map((Combinator c) => c.accept(new _CombinatorEncoder()))
79 .toList())); 78 .toList()));
80 } 79 }
81 80
82 @override 81 @override
83 visitFunctionDeclaration(FunctionDeclaration node) { 82 visitFunctionDeclaration(FunctionDeclaration node) {
84 String name = node.name.name; 83 String name = node.name.name;
85 if (node.isSetter) { 84 if (node.isSetter) {
86 name += '='; 85 name += '=';
87 } 86 }
88 addNameIfPublic( 87 addNameIfPublic(
89 name, 88 name,
90 node.isGetter || node.isSetter 89 node.isGetter || node.isSetter
91 ? PrelinkedReferenceKind.topLevelPropertyAccessor 90 ? ReferenceKind.topLevelPropertyAccessor
92 : PrelinkedReferenceKind.topLevelFunction, 91 : ReferenceKind.topLevelFunction,
93 node.functionExpression.typeParameters?.typeParameters?.length ?? 0); 92 node.functionExpression.typeParameters?.typeParameters?.length ?? 0);
94 } 93 }
95 94
96 @override 95 @override
97 visitFunctionTypeAlias(FunctionTypeAlias node) { 96 visitFunctionTypeAlias(FunctionTypeAlias node) {
98 addNameIfPublic(node.name.name, PrelinkedReferenceKind.typedef, 97 addNameIfPublic(node.name.name, ReferenceKind.typedef,
99 node.typeParameters?.typeParameters?.length ?? 0); 98 node.typeParameters?.typeParameters?.length ?? 0);
100 } 99 }
101 100
102 @override 101 @override
103 visitPartDirective(PartDirective node) { 102 visitPartDirective(PartDirective node) {
104 parts.add(node.uri.stringValue); 103 parts.add(node.uri.stringValue);
105 } 104 }
106 105
107 @override 106 @override
108 visitVariableDeclaration(VariableDeclaration node) { 107 visitVariableDeclaration(VariableDeclaration node) {
109 String name = node.name.name; 108 String name = node.name.name;
110 addNameIfPublic(name, PrelinkedReferenceKind.topLevelPropertyAccessor, 0); 109 addNameIfPublic(name, ReferenceKind.topLevelPropertyAccessor, 0);
111 if (!node.isFinal && !node.isConst) { 110 if (!node.isFinal && !node.isConst) {
112 addNameIfPublic( 111 addNameIfPublic('$name=', ReferenceKind.topLevelPropertyAccessor, 0);
113 '$name=', PrelinkedReferenceKind.topLevelPropertyAccessor, 0);
114 } 112 }
115 } 113 }
116 } 114 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/summary/prelink.dart ('k') | pkg/analyzer/lib/src/summary/resynthesize.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698