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

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

Issue 1859493002: Replace 'length' with more generic 'extractProperty' operation. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 8 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) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, 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 serialization.summarize_ast; 5 library serialization.summarize_ast;
6 6
7 import 'package:analyzer/dart/ast/ast.dart'; 7 import 'package:analyzer/dart/ast/ast.dart';
8 import 'package:analyzer/dart/ast/token.dart'; 8 import 'package:analyzer/dart/ast/token.dart';
9 import 'package:analyzer/dart/ast/visitor.dart'; 9 import 'package:analyzer/dart/ast/visitor.dart';
10 import 'package:analyzer/src/generated/utilities_dart.dart'; 10 import 'package:analyzer/src/generated/utilities_dart.dart';
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 b.reference = 82 b.reference =
83 visitor.serializeReference(prefix, identifier.identifier.name); 83 visitor.serializeReference(prefix, identifier.identifier.name);
84 } else { 84 } else {
85 throw new StateError( 85 throw new StateError(
86 'Unexpected identifier type: ${identifier.runtimeType}'); 86 'Unexpected identifier type: ${identifier.runtimeType}');
87 } 87 }
88 return b; 88 return b;
89 } 89 }
90 90
91 @override 91 @override
92 EntityRefBuilder serializePropertyAccess(PropertyAccess access) { 92 EntityRefBuilder serializeIdentifierSequence(Expression expr) {
93 Expression target = access.target; 93 if (expr is Identifier) {
94 if (target is Identifier) { 94 return serializeIdentifier(expr);
95 EntityRefBuilder targetRef = serializeIdentifier(target); 95 }
96 return new EntityRefBuilder(reference: visitor.serializeReference( 96 if (expr is PropertyAccess) {
97 targetRef.reference, access.propertyName.name)); 97 int targetId = serializeIdentifierSequence(expr.target).reference;
98 int nameId = visitor.serializeReference(targetId, expr.propertyName.name);
99 return new EntityRefBuilder(reference: nameId);
98 } else { 100 } else {
99 // TODO(scheglov) should we handle other targets in malformed constants? 101 throw new StateError('Unexpected node type: ${expr.runtimeType}');
100 throw new StateError('Unexpected target type: ${target.runtimeType}');
101 } 102 }
102 } 103 }
103 104
104 @override 105 @override
105 EntityRefBuilder serializeType(TypeName node) { 106 EntityRefBuilder serializeType(TypeName node) {
106 return visitor.serializeTypeName(node); 107 return visitor.serializeTypeName(node);
107 } 108 }
108 } 109 }
109 110
110 /** 111 /**
(...skipping 706 matching lines...) Expand 10 before | Expand all | Expand 10 after
817 b.isFinal = variables.isFinal; 818 b.isFinal = variables.isFinal;
818 b.isConst = variables.isConst; 819 b.isConst = variables.isConst;
819 b.isStatic = isDeclaredStatic; 820 b.isStatic = isDeclaredStatic;
820 b.name = variable.name.name; 821 b.name = variable.name.name;
821 b.nameOffset = variable.name.offset; 822 b.nameOffset = variable.name.offset;
822 b.type = serializeTypeName(variables.type); 823 b.type = serializeTypeName(variables.type);
823 b.documentationComment = serializeDocumentation(documentationComment); 824 b.documentationComment = serializeDocumentation(documentationComment);
824 b.annotations = serializeAnnotations(annotations); 825 b.annotations = serializeAnnotations(annotations);
825 b.codeRange = serializeCodeRange(variables.parent); 826 b.codeRange = serializeCodeRange(variables.parent);
826 if (variable.isConst || 827 if (variable.isConst ||
827 variable.isFinal && isField && !isDeclaredStatic) { 828 variable.isFinal && isField && !isDeclaredStatic ||
829 variables.type == null) {
828 Expression initializer = variable.initializer; 830 Expression initializer = variable.initializer;
829 if (initializer != null) { 831 if (initializer != null) {
830 b.constExpr = serializeConstExpr(initializer); 832 b.constExpr = serializeConstExpr(initializer);
831 } 833 }
832 } 834 }
833 if (variable.initializer != null && 835 if (variable.initializer != null &&
834 (variables.isFinal || variables.isConst)) { 836 (variables.isFinal || variables.isConst)) {
835 b.propagatedTypeSlot = assignSlot(); 837 b.propagatedTypeSlot = assignSlot();
836 } 838 }
837 bool isSemanticallyStatic = !isField || isDeclaredStatic; 839 bool isSemanticallyStatic = !isField || isDeclaredStatic;
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after
1237 /** 1239 /**
1238 * A [_TypeParameterScope] is a [_Scope] which defines [_ScopedTypeParameter]s. 1240 * A [_TypeParameterScope] is a [_Scope] which defines [_ScopedTypeParameter]s.
1239 */ 1241 */
1240 class _TypeParameterScope extends _Scope { 1242 class _TypeParameterScope extends _Scope {
1241 /** 1243 /**
1242 * Get the number of [_ScopedTypeParameter]s defined in this 1244 * Get the number of [_ScopedTypeParameter]s defined in this
1243 * [_TypeParameterScope]. 1245 * [_TypeParameterScope].
1244 */ 1246 */
1245 int get length => _definedNames.length; 1247 int get length => _definedNames.length;
1246 } 1248 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698