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

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

Issue 1738213003: Use separate relation kinds for qualified usages. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 9 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/dart/ast/ast.dart'; 5 import 'package:analyzer/dart/ast/ast.dart';
6 import 'package:analyzer/dart/ast/token.dart'; 6 import 'package:analyzer/dart/ast/token.dart';
7 import 'package:analyzer/dart/ast/visitor.dart'; 7 import 'package:analyzer/dart/ast/visitor.dart';
8 import 'package:analyzer/dart/element/element.dart'; 8 import 'package:analyzer/dart/element/element.dart';
9 import 'package:analyzer/src/generated/utilities_dart.dart'; 9 import 'package:analyzer/src/generated/utilities_dart.dart';
10 import 'package:analyzer/src/summary/format.dart'; 10 import 'package:analyzer/src/summary/format.dart';
(...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after
439 // LocationImpl location = _createLocationForNode(name); 439 // LocationImpl location = _createLocationForNode(name);
440 // // name invocation 440 // // name invocation
441 // recordRelationshipIndexable( 441 // recordRelationshipIndexable(
442 // new IndexableName(name.name), IndexConstants.IS_INVOKED_BY, location); 442 // new IndexableName(name.name), IndexConstants.IS_INVOKED_BY, location);
443 // element invocation 443 // element invocation
444 Element element = name.bestElement; 444 Element element = name.bestElement;
445 if (element is MethodElement || 445 if (element is MethodElement ||
446 element is PropertyAccessorElement || 446 element is PropertyAccessorElement ||
447 element is FunctionElement || 447 element is FunctionElement ||
448 element is VariableElement) { 448 element is VariableElement) {
449 recordRelation(element, IndexRelationKind.IS_INVOKED_BY, name); 449 IndexRelationKind kind = node.realTarget != null
450 ? IndexRelationKind.IS_INVOKED_QUALIFIED_BY
451 : IndexRelationKind.IS_INVOKED_BY;
452 recordRelation(element, kind, name);
450 } else if (element is ClassElement) { 453 } else if (element is ClassElement) {
451 recordRelation(element, IndexRelationKind.IS_REFERENCED_BY, name); 454 recordRelation(element, IndexRelationKind.IS_REFERENCED_BY, name);
452 } 455 }
453 node.target?.accept(this); 456 node.target?.accept(this);
454 node.argumentList?.accept(this); 457 node.argumentList?.accept(this);
455 } 458 }
456 459
457 @override 460 @override
458 visitPartDirective(PartDirective node) { 461 visitPartDirective(PartDirective node) {
459 Element element = node.element; 462 Element element = node.element;
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
504 // indexableName, IndexConstants.NAME_IS_DEFINED_BY, location); 507 // indexableName, IndexConstants.NAME_IS_DEFINED_BY, location);
505 return; 508 return;
506 } 509 }
507 Element element = node.bestElement; 510 Element element = node.bestElement;
508 // this.field parameter 511 // this.field parameter
509 if (element is FieldFormalParameterElement) { 512 if (element is FieldFormalParameterElement) {
510 recordRelation(element.field, IndexRelationKind.IS_REFERENCED_BY, node); 513 recordRelation(element.field, IndexRelationKind.IS_REFERENCED_BY, node);
511 return; 514 return;
512 } 515 }
513 // record specific relations 516 // record specific relations
514 // TODO(scheglov) consider removing the conditions 517 IndexRelationKind kind = node.isQualified
515 if (element is ClassElement || 518 ? IndexRelationKind.IS_REFERENCED_QUALIFIED_BY
516 element is FunctionElement || 519 : IndexRelationKind.IS_REFERENCED_BY;
517 element is FunctionTypeAliasElement || 520 recordRelation(element, kind, node);
518 element is LabelElement ||
519 element is MethodElement ||
520 element is ParameterElement ||
521 element is PrefixElement ||
522 element is PropertyAccessorElement ||
523 element is PropertyInducingElement ||
524 element is TypeParameterElement) {
525 recordRelation(element, IndexRelationKind.IS_REFERENCED_BY, node);
526 }
527 } 521 }
528 522
529 @override 523 @override
530 visitSuperConstructorInvocation(SuperConstructorInvocation node) { 524 visitSuperConstructorInvocation(SuperConstructorInvocation node) {
531 ConstructorElement element = node.staticElement; 525 ConstructorElement element = node.staticElement;
532 if (node.constructorName != null) { 526 if (node.constructorName != null) {
533 int offset = node.period.offset; 527 int offset = node.period.offset;
534 int length = node.constructorName.end - offset; 528 int length = node.constructorName.end - offset;
535 recordRelationOffset( 529 recordRelationOffset(
536 element, IndexRelationKind.IS_REFERENCED_BY, offset, length); 530 element, IndexRelationKind.IS_REFERENCED_BY, offset, length);
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
623 }); 617 });
624 return new UnitIndexBuilder( 618 return new UnitIndexBuilder(
625 elements: relations.map((r) => r.elementInfo.id).toList(), 619 elements: relations.map((r) => r.elementInfo.id).toList(),
626 kinds: relations.map((r) => r.kind).toList(), 620 kinds: relations.map((r) => r.kind).toList(),
627 locationOffsets: relations.map((r) => r.offset).toList(), 621 locationOffsets: relations.map((r) => r.offset).toList(),
628 locationLengths: relations.map((r) => r.length).toList(), 622 locationLengths: relations.map((r) => r.length).toList(),
629 libraryUri: pkg._getUriId(unitElement.library.source.uri), 623 libraryUri: pkg._getUriId(unitElement.library.source.uri),
630 unitUri: pkg._getUriId(unitElement.source.uri)); 624 unitUri: pkg._getUriId(unitElement.source.uri));
631 } 625 }
632 } 626 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/summary/idl.dart ('k') | pkg/analyzer/test/src/summary/index_unit_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698