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

Side by Side Diff: pkg/analyzer/test/src/summary/resynthesize_test.dart

Issue 1995763003: Build top-level variables and property accessors lazily. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Fixes for review comments. Created 4 years, 7 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/resynthesize.dart ('k') | 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) 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 test.src.serialization.elements_test; 5 library test.src.serialization.elements_test;
6 6
7 import 'dart:convert'; 7 import 'dart:convert';
8 8
9 import 'package:analyzer/dart/ast/ast.dart'; 9 import 'package:analyzer/dart/ast/ast.dart';
10 import 'package:analyzer/dart/constant/value.dart'; 10 import 'package:analyzer/dart/constant/value.dart';
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 compareTypes(r.type, o.type, desc); 253 compareTypes(r.type, o.type, desc);
254 expect(r.hasBeenInferred, o.hasBeenInferred, reason: desc); 254 expect(r.hasBeenInferred, o.hasBeenInferred, reason: desc);
255 } 255 }
256 256
257 void compareCompilationUnitElements(CompilationUnitElementImpl resynthesized, 257 void compareCompilationUnitElements(CompilationUnitElementImpl resynthesized,
258 CompilationUnitElementImpl original) { 258 CompilationUnitElementImpl original) {
259 String desc = 'Compilation unit ${original.source.uri}'; 259 String desc = 'Compilation unit ${original.source.uri}';
260 compareUriReferencedElements(resynthesized, original, desc); 260 compareUriReferencedElements(resynthesized, original, desc);
261 expect(resynthesized.source, original.source); 261 expect(resynthesized.source, original.source);
262 expect(resynthesized.librarySource, original.librarySource); 262 expect(resynthesized.librarySource, original.librarySource);
263 expect(resynthesized.types.length, original.types.length); 263 expect(resynthesized.types.length, original.types.length,
264 reason: '$desc types');
264 for (int i = 0; i < resynthesized.types.length; i++) { 265 for (int i = 0; i < resynthesized.types.length; i++) {
265 compareClassElements( 266 compareClassElements(
266 resynthesized.types[i], original.types[i], original.types[i].name); 267 resynthesized.types[i], original.types[i], original.types[i].name);
267 } 268 }
268 expect(resynthesized.topLevelVariables.length, 269 expect(resynthesized.topLevelVariables.length,
269 original.topLevelVariables.length); 270 original.topLevelVariables.length,
271 reason: '$desc topLevelVariables');
270 for (int i = 0; i < resynthesized.topLevelVariables.length; i++) { 272 for (int i = 0; i < resynthesized.topLevelVariables.length; i++) {
271 String name = resynthesized.topLevelVariables[i].name; 273 String name = resynthesized.topLevelVariables[i].name;
272 compareTopLevelVariableElements( 274 compareTopLevelVariableElements(
273 resynthesized.topLevelVariables[i], 275 resynthesized.topLevelVariables[i],
274 original.topLevelVariables 276 original.topLevelVariables
275 .singleWhere((TopLevelVariableElement e) => e.name == name), 277 .singleWhere((TopLevelVariableElement e) => e.name == name),
276 'variable $name'); 278 'variable $name');
277 } 279 }
278 expect(resynthesized.functions.length, original.functions.length); 280 expect(resynthesized.functions.length, original.functions.length,
281 reason: '$desc functions');
279 for (int i = 0; i < resynthesized.functions.length; i++) { 282 for (int i = 0; i < resynthesized.functions.length; i++) {
280 compareFunctionElements(resynthesized.functions[i], original.functions[i], 283 compareFunctionElements(resynthesized.functions[i], original.functions[i],
281 'function ${original.functions[i].name}'); 284 'function ${original.functions[i].name}');
282 } 285 }
283 expect(resynthesized.functionTypeAliases.length, 286 expect(resynthesized.functionTypeAliases.length,
284 original.functionTypeAliases.length); 287 original.functionTypeAliases.length,
288 reason: '$desc functionTypeAliases');
285 for (int i = 0; i < resynthesized.functionTypeAliases.length; i++) { 289 for (int i = 0; i < resynthesized.functionTypeAliases.length; i++) {
286 compareFunctionTypeAliasElements( 290 compareFunctionTypeAliasElements(
287 resynthesized.functionTypeAliases[i], 291 resynthesized.functionTypeAliases[i],
288 original.functionTypeAliases[i], 292 original.functionTypeAliases[i],
289 original.functionTypeAliases[i].name); 293 original.functionTypeAliases[i].name);
290 } 294 }
291 expect(resynthesized.enums.length, original.enums.length); 295 expect(resynthesized.enums.length, original.enums.length,
296 reason: '$desc enums');
292 for (int i = 0; i < resynthesized.enums.length; i++) { 297 for (int i = 0; i < resynthesized.enums.length; i++) {
293 compareClassElements( 298 compareClassElements(
294 resynthesized.enums[i], original.enums[i], original.enums[i].name); 299 resynthesized.enums[i], original.enums[i], original.enums[i].name);
295 } 300 }
296 expect(resynthesized.accessors.length, original.accessors.length); 301 expect(resynthesized.accessors.length, original.accessors.length,
302 reason: '$desc accessors');
297 for (int i = 0; i < resynthesized.accessors.length; i++) { 303 for (int i = 0; i < resynthesized.accessors.length; i++) {
298 String name = resynthesized.accessors[i].name; 304 String name = resynthesized.accessors[i].name;
299 if (original.accessors[i].isGetter) { 305 if (original.accessors[i].isGetter) {
300 comparePropertyAccessorElements( 306 comparePropertyAccessorElements(
301 resynthesized.accessors[i], 307 resynthesized.accessors[i],
302 original.accessors 308 original.accessors
303 .singleWhere((PropertyAccessorElement e) => e.name == name), 309 .singleWhere((PropertyAccessorElement e) => e.name == name),
304 'getter $name'); 310 'getter $name');
305 } else { 311 } else {
306 comparePropertyAccessorElements( 312 comparePropertyAccessorElements(
(...skipping 4215 matching lines...) Expand 10 before | Expand all | Expand 10 after
4522 fail('Unexpectedly tried to get unlinked summary for $uri'); 4528 fail('Unexpectedly tried to get unlinked summary for $uri');
4523 } 4529 }
4524 return serializedUnit; 4530 return serializedUnit;
4525 } 4531 }
4526 4532
4527 @override 4533 @override
4528 bool hasLibrarySummary(String uri) { 4534 bool hasLibrarySummary(String uri) {
4529 return true; 4535 return true;
4530 } 4536 }
4531 } 4537 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/summary/resynthesize.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698