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

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

Issue 2667693002: Serialize prefixes directly, without intermediate map. (Closed)
Patch Set: Created 3 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
« no previous file with comments | « no previous file | no next file » | 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) 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/dart/element/type.dart' show DartType; 10 import 'package:analyzer/dart/element/type.dart' show DartType;
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 */ 259 */
260 final List<UnlinkedImportBuilder> unlinkedImports = <UnlinkedImportBuilder>[]; 260 final List<UnlinkedImportBuilder> unlinkedImports = <UnlinkedImportBuilder>[];
261 261
262 /** 262 /**
263 * The unlinked portion of the "references table". This is the list of 263 * The unlinked portion of the "references table". This is the list of
264 * objects which should be written to [UnlinkedUnit.references]. 264 * objects which should be written to [UnlinkedUnit.references].
265 */ 265 */
266 final List<UnlinkedReferenceBuilder> unlinkedReferences = 266 final List<UnlinkedReferenceBuilder> unlinkedReferences =
267 <UnlinkedReferenceBuilder>[new UnlinkedReferenceBuilder()]; 267 <UnlinkedReferenceBuilder>[new UnlinkedReferenceBuilder()];
268 268
269 /**
270 * Map associating names used as prefixes in this compilation unit with their
271 * associated indices into [UnlinkedUnit.references].
272 */
273 final Map<String, int> prefixIndices = <String, int>{};
274 269
275 /** 270 /**
276 * List of [_Scope]s currently in effect. This is used to resolve type names 271 * List of [_Scope]s currently in effect. This is used to resolve type names
277 * to type parameters within classes, typedefs, and executables, as well as 272 * to type parameters within classes, typedefs, and executables, as well as
278 * references to class members. 273 * references to class members.
279 */ 274 */
280 final List<_Scope> scopes = <_Scope>[]; 275 final List<_Scope> scopes = <_Scope>[];
281 276
282 /** 277 /**
283 * True if 'dart:core' has been explicitly imported. 278 * True if 'dart:core' has been explicitly imported.
(...skipping 622 matching lines...) Expand 10 before | Expand all | Expand 10 after
906 b.reference = serializeReference(null, 'dynamic'); 901 b.reference = serializeReference(null, 'dynamic');
907 return b; 902 return b;
908 } 903 }
909 } 904 }
910 if (scope is _TypeParameterScope) { 905 if (scope is _TypeParameterScope) {
911 indexOffset += scope.length; 906 indexOffset += scope.length;
912 } 907 }
913 } 908 }
914 b.reference = serializeReference(null, name); 909 b.reference = serializeReference(null, name);
915 } else if (identifier is PrefixedIdentifier) { 910 } else if (identifier is PrefixedIdentifier) {
916 int prefixIndex = prefixIndices.putIfAbsent(identifier.prefix.name, 911 int prefixIndex = serializeSimpleReference(identifier.prefix.name);
917 () => serializeSimpleReference(identifier.prefix.name));
918 b.reference = 912 b.reference =
919 serializeReference(prefixIndex, identifier.identifier.name); 913 serializeReference(prefixIndex, identifier.identifier.name);
920 } else { 914 } else {
921 throw new StateError( 915 throw new StateError(
922 'Unexpected identifier type: ${identifier.runtimeType}'); 916 'Unexpected identifier type: ${identifier.runtimeType}');
923 } 917 }
924 if (typeArguments != null) { 918 if (typeArguments != null) {
925 b.typeArguments = 919 b.typeArguments =
926 typeArguments.arguments.map(serializeTypeName).toList(); 920 typeArguments.arguments.map(serializeTypeName).toList();
927 } 921 }
(...skipping 492 matching lines...) Expand 10 before | Expand all | Expand 10 after
1420 /** 1414 /**
1421 * A [_TypeParameterScope] is a [_Scope] which defines [_ScopedTypeParameter]s. 1415 * A [_TypeParameterScope] is a [_Scope] which defines [_ScopedTypeParameter]s.
1422 */ 1416 */
1423 class _TypeParameterScope extends _Scope { 1417 class _TypeParameterScope extends _Scope {
1424 /** 1418 /**
1425 * Get the number of [_ScopedTypeParameter]s defined in this 1419 * Get the number of [_ScopedTypeParameter]s defined in this
1426 * [_TypeParameterScope]. 1420 * [_TypeParameterScope].
1427 */ 1421 */
1428 int get length => _definedNames.length; 1422 int get length => _definedNames.length;
1429 } 1423 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698