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

Side by Side Diff: pkg/analyzer/lib/src/summary/prelink.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 import 'package:analyzer/src/generated/utilities_dart.dart'; 5 import 'package:analyzer/src/generated/utilities_dart.dart';
6 import 'package:analyzer/src/summary/format.dart'; 6 import 'package:analyzer/src/summary/format.dart';
7 import 'package:analyzer/src/summary/idl.dart'; 7 import 'package:analyzer/src/summary/idl.dart';
8 import 'package:analyzer/src/summary/name_filter.dart'; 8 import 'package:analyzer/src/summary/name_filter.dart';
9 9
10 /** 10 /**
(...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after
414 List<LinkedReferenceBuilder> references = <LinkedReferenceBuilder>[]; 414 List<LinkedReferenceBuilder> references = <LinkedReferenceBuilder>[];
415 for (int i = 0; i < unit.references.length; i++) { 415 for (int i = 0; i < unit.references.length; i++) {
416 UnlinkedReference reference = unit.references[i]; 416 UnlinkedReference reference = unit.references[i];
417 Map<String, _Meaning> namespace; 417 Map<String, _Meaning> namespace;
418 if (reference.prefixReference == 0) { 418 if (reference.prefixReference == 0) {
419 namespace = privateNamespace; 419 namespace = privateNamespace;
420 } else { 420 } else {
421 // Prefix references must always point backward. 421 // Prefix references must always point backward.
422 assert(reference.prefixReference < i); 422 assert(reference.prefixReference < i);
423 namespace = prefixNamespaces[reference.prefixReference]; 423 namespace = prefixNamespaces[reference.prefixReference];
424 // If in `a.length` the `a` prefix is a top-level variable or a field, 424 // Expressions like 'a.b.c.d' cannot be prelinked.
425 // then it must be the `String.length` property reference. 425 namespace ??= const <String, _Meaning>{};
426 if (namespace == null && reference.name == 'length') {
427 ReferenceKind prefixKind = references[reference.prefixReference].kind;
428 if (prefixKind == ReferenceKind.topLevelPropertyAccessor ||
429 prefixKind == ReferenceKind.propertyAccessor) {
430 references
431 .add(new LinkedReferenceBuilder(kind: ReferenceKind.length));
432 continue;
433 }
434 }
435 // Anything prefixed with 'unresolved' is unresolved.
436 if (references[reference.prefixReference].kind ==
437 ReferenceKind.unresolved) {
438 namespace = const <String, _Meaning>{};
439 }
440 // Prefix references must always point to proper prefixes.
441 assert(namespace != null);
442 } 426 }
443 _Meaning meaning = namespace[reference.name]; 427 _Meaning meaning = namespace[reference.name];
444 if (meaning != null) { 428 if (meaning != null) {
445 if (meaning is _PrefixMeaning) { 429 if (meaning is _PrefixMeaning) {
446 prefixNamespaces[i] = meaning.namespace; 430 prefixNamespaces[i] = meaning.namespace;
447 } else if (meaning is _ClassMeaning) { 431 } else if (meaning is _ClassMeaning) {
448 prefixNamespaces[i] = meaning.namespace; 432 prefixNamespaces[i] = meaning.namespace;
449 } 433 }
450 references.add(meaning.encodeReference()); 434 references.add(meaning.encodeReference());
451 } else { 435 } else {
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
514 */ 498 */
515 String resolveUri(String sourceUri, String relativeUri) { 499 String resolveUri(String sourceUri, String relativeUri) {
516 if (sourceUri == null) { 500 if (sourceUri == null) {
517 return relativeUri; 501 return relativeUri;
518 } else { 502 } else {
519 return resolveRelativeUri(Uri.parse(sourceUri), Uri.parse(relativeUri)) 503 return resolveRelativeUri(Uri.parse(sourceUri), Uri.parse(relativeUri))
520 .toString(); 504 .toString();
521 } 505 }
522 } 506 }
523 } 507 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698