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

Side by Side Diff: pkg/analyzer/test/src/summary/resynthesize_test.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) 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 462 matching lines...) Expand 10 before | Expand all | Expand 10 after
473 // We don't resynthesize prefixed identifiers when the prefix refers to 473 // We don't resynthesize prefixed identifiers when the prefix refers to
474 // a PrefixElement or a ClassElement. We use simple identifiers with 474 // a PrefixElement or a ClassElement. We use simple identifiers with
475 // correct elements. 475 // correct elements.
476 if (o.prefix.staticElement is PrefixElement || 476 if (o.prefix.staticElement is PrefixElement ||
477 o.prefix.staticElement is ClassElement) { 477 o.prefix.staticElement is ClassElement) {
478 compareConstAsts(r, o.identifier, desc); 478 compareConstAsts(r, o.identifier, desc);
479 } else { 479 } else {
480 fail('Prefix of type ${o.prefix.staticElement.runtimeType} should not' 480 fail('Prefix of type ${o.prefix.staticElement.runtimeType} should not'
481 ' have been elided'); 481 ' have been elided');
482 } 482 }
483 } else if (o is SimpleIdentifier && r is PrefixedIdentifier) {
484 // In 'class C {static const a = 0; static const b = a;}' the reference
485 // to 'a' in 'b' is serialized as a fully qualified 'C.a' reference.
486 if (r.prefix.staticElement is ClassElement) {
487 compareConstAsts(r.identifier, o, desc);
Paul Berry 2016/04/04 15:51:25 Please add a check to verify that r.prefix.staticE
488 } else {
489 fail('Prefix of type ${r.prefix.staticElement.runtimeType} should not'
490 ' have been elided');
491 }
483 } else if (o is PropertyAccess && 492 } else if (o is PropertyAccess &&
484 o.target is PrefixedIdentifier && 493 o.target is PrefixedIdentifier &&
485 r is PrefixedIdentifier) { 494 r is PrefixedIdentifier) {
486 // We don't resynthesize prefixed identifiers when the prefix refers to 495 // We don't resynthesize prefixed identifiers when the prefix refers to
487 // a PrefixElement or a ClassElement. Which means that if the original 496 // a PrefixElement or a ClassElement. Which means that if the original
488 // expression was e.g. `prefix.topLevelVariableName.length`, it will get 497 // expression was e.g. `prefix.topLevelVariableName.length`, it will get
489 // resynthesized as `topLevelVariableName.length` 498 // resynthesized as `topLevelVariableName.length`
490 PrefixedIdentifier oTarget = o.target; 499 PrefixedIdentifier oTarget = o.target;
491 checkElidablePrefix(oTarget.prefix); 500 checkElidablePrefix(oTarget.prefix);
492 compareConstAsts( 501 compareConstAsts(
(...skipping 3735 matching lines...) Expand 10 before | Expand all | Expand 10 after
4228 fail('Unexpectedly tried to get unlinked summary for $uri'); 4237 fail('Unexpectedly tried to get unlinked summary for $uri');
4229 } 4238 }
4230 return serializedUnit; 4239 return serializedUnit;
4231 } 4240 }
4232 4241
4233 @override 4242 @override
4234 bool hasLibrarySummary(String uri) { 4243 bool hasLibrarySummary(String uri) {
4235 return true; 4244 return true;
4236 } 4245 }
4237 } 4246 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/summary/summarize_elements.dart ('k') | pkg/analyzer/test/src/summary/summarize_ast_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698