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

Side by Side Diff: pkg/analysis_server/lib/src/services/index/index_contributor.dart

Issue 1162853004: Issue 23568. Fix for NPE in index when unresolved field formal parameter. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 6 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 | pkg/analysis_server/lib/src/services/index/indexable_element.dart » ('j') | 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) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 services.src.index.index_contributor; 5 library services.src.index.index_contributor;
6 6
7 import 'dart:collection' show Queue; 7 import 'dart:collection' show Queue;
8 8
9 import 'package:analysis_server/analysis/index/index_core.dart'; 9 import 'package:analysis_server/analysis/index/index_core.dart';
10 import 'package:analysis_server/analysis/index/index_dart.dart'; 10 import 'package:analysis_server/analysis/index/index_dart.dart';
(...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after
435 } else { 435 } else {
436 int start = node.thisKeyword.end; 436 int start = node.thisKeyword.end;
437 location = _createLocationForOffset(start, 0); 437 location = _createLocationForOffset(start, 0);
438 } 438 }
439 recordRelationship(element, IndexConstants.IS_REFERENCED_BY, location); 439 recordRelationship(element, IndexConstants.IS_REFERENCED_BY, location);
440 super.visitRedirectingConstructorInvocation(node); 440 super.visitRedirectingConstructorInvocation(node);
441 } 441 }
442 442
443 @override 443 @override
444 visitSimpleIdentifier(SimpleIdentifier node) { 444 visitSimpleIdentifier(SimpleIdentifier node) {
445 IndexableObject indexable = 445 Element nameElement = new NameElement(node.name);
Brian Wilkerson 2015/06/01 21:52:20 I understand why lines 484-485 need to change, but
scheglov 2015/06/01 22:07:24 We use "nameElement" only once, in different branc
446 new IndexableElement(new NameElement(node.name));
447 LocationImpl location = _createLocationForNode(node); 446 LocationImpl location = _createLocationForNode(node);
448 if (location == null) { 447 if (location == null) {
449 return; 448 return;
450 } 449 }
451 // name in declaration 450 // name in declaration
452 if (node.inDeclarationContext()) { 451 if (node.inDeclarationContext()) {
453 _store.recordRelationship( 452 recordRelationship(
454 indexable, IndexConstants.NAME_IS_DEFINED_BY, location); 453 nameElement, IndexConstants.NAME_IS_DEFINED_BY, location);
455 return; 454 return;
456 } 455 }
457 // prepare information 456 // prepare information
458 Element element = node.bestElement; 457 Element element = node.bestElement;
459 // stop if already handled 458 // stop if already handled
460 if (_isAlreadyHandledName(node)) { 459 if (_isAlreadyHandledName(node)) {
461 return; 460 return;
462 } 461 }
463 // record name read/write 462 // record name read/write
464 if (element != null && element.enclosingElement is ClassElement || 463 if (element != null && element.enclosingElement is ClassElement ||
465 element == null && location.isQualified) { 464 element == null && location.isQualified) {
466 bool inGetterContext = node.inGetterContext(); 465 bool inGetterContext = node.inGetterContext();
467 bool inSetterContext = node.inSetterContext(); 466 bool inSetterContext = node.inSetterContext();
468 if (inGetterContext && inSetterContext) { 467 if (inGetterContext && inSetterContext) {
469 _store.recordRelationship( 468 recordRelationship(
470 indexable, IndexConstants.IS_READ_WRITTEN_BY, location); 469 nameElement, IndexConstants.IS_READ_WRITTEN_BY, location);
471 } else if (inGetterContext) { 470 } else if (inGetterContext) {
472 _store.recordRelationship( 471 recordRelationship(nameElement, IndexConstants.IS_READ_BY, location);
473 indexable, IndexConstants.IS_READ_BY, location);
474 } else if (inSetterContext) { 472 } else if (inSetterContext) {
475 _store.recordRelationship( 473 recordRelationship(nameElement, IndexConstants.IS_WRITTEN_BY, location);
476 indexable, IndexConstants.IS_WRITTEN_BY, location);
477 } 474 }
478 } 475 }
479 // this.field parameter 476 // this.field parameter
480 if (element is FieldFormalParameterElement) { 477 if (element is FieldFormalParameterElement) {
481 RelationshipImpl relationship = peekElement().element == element 478 RelationshipImpl relationship = peekElement().element == element
482 ? IndexConstants.IS_WRITTEN_BY 479 ? IndexConstants.IS_WRITTEN_BY
483 : IndexConstants.IS_REFERENCED_BY; 480 : IndexConstants.IS_REFERENCED_BY;
484 _store.recordRelationship( 481 recordRelationship(element.field, relationship, location);
485 new IndexableElement(element.field), relationship, location);
486 return; 482 return;
487 } 483 }
488 // record specific relations 484 // record specific relations
489 if (element is ClassElement || 485 if (element is ClassElement ||
490 element is FunctionElement || 486 element is FunctionElement ||
491 element is FunctionTypeAliasElement || 487 element is FunctionTypeAliasElement ||
492 element is LabelElement || 488 element is LabelElement ||
493 element is MethodElement || 489 element is MethodElement ||
494 element is PropertyAccessorElement || 490 element is PropertyAccessorElement ||
495 element is PropertyInducingElement || 491 element is PropertyInducingElement ||
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after
798 } 794 }
799 795
800 /** 796 /**
801 * @return `true` if given "node" is part of [PrefixedIdentifier] "prefix.node ". 797 * @return `true` if given "node" is part of [PrefixedIdentifier] "prefix.node ".
802 */ 798 */
803 static bool _isIdentifierInPrefixedIdentifier(SimpleIdentifier node) { 799 static bool _isIdentifierInPrefixedIdentifier(SimpleIdentifier node) {
804 AstNode parent = node.parent; 800 AstNode parent = node.parent;
805 return parent is PrefixedIdentifier && parent.identifier == node; 801 return parent is PrefixedIdentifier && parent.identifier == node;
806 } 802 }
807 } 803 }
OLDNEW
« no previous file with comments | « no previous file | pkg/analysis_server/lib/src/services/index/indexable_element.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698