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

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

Issue 1786023005: Fix for indexing synthetic getter/setter references. (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
« no previous file with comments | « pkg/analyzer/lib/src/summary/index_unit.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) 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 'dart:convert'; 5 import 'dart:convert';
6 6
7 import 'package:analyzer/dart/ast/ast.dart'; 7 import 'package:analyzer/dart/ast/ast.dart';
8 import 'package:analyzer/dart/element/element.dart'; 8 import 'package:analyzer/dart/element/element.dart';
9 import 'package:analyzer/src/summary/format.dart'; 9 import 'package:analyzer/src/summary/format.dart';
10 import 'package:analyzer/src/summary/idl.dart'; 10 import 'package:analyzer/src/summary/idl.dart';
(...skipping 683 matching lines...) Expand 10 before | Expand all | Expand 10 after
694 assertThat(field)..isWrittenAt('field});', true); 694 assertThat(field)..isWrittenAt('field});', true);
695 // m() 695 // m()
696 assertThat(setter)..isReferencedAt('field = 2; // nq', false); 696 assertThat(setter)..isReferencedAt('field = 2; // nq', false);
697 assertThat(getter)..isReferencedAt('field); // nq', false); 697 assertThat(getter)..isReferencedAt('field); // nq', false);
698 // main() 698 // main()
699 assertThat(setter)..isReferencedAt('field = 3; // q', true); 699 assertThat(setter)..isReferencedAt('field = 3; // q', true);
700 assertThat(getter)..isReferencedAt('field); // q', true); 700 assertThat(getter)..isReferencedAt('field); // q', true);
701 assertThat(field)..isReferencedAt('field: 4', true); 701 assertThat(field)..isReferencedAt('field: 4', true);
702 } 702 }
703 703
704 void test_isReferencedBy_FieldElement_multiple() {
705 _indexTestUnit('''
706 class A {
707 var aaa;
708 var bbb;
709 A(this.aaa, this.bbb) {}
710 m() {
711 print(aaa);
712 aaa = 1;
713 print(bbb);
714 bbb = 2;
715 }
716 }
717 ''');
718 // aaa
719 {
720 FieldElement field = findElement('aaa');
721 PropertyAccessorElement getter = field.getter;
722 PropertyAccessorElement setter = field.setter;
723 assertThat(field)..isWrittenAt('aaa, ', true);
724 assertThat(getter)..isReferencedAt('aaa);', false);
725 assertThat(setter)..isReferencedAt('aaa = 1;', false);
726 }
727 // bbb
728 {
729 FieldElement field = findElement('bbb');
730 PropertyAccessorElement getter = field.getter;
731 PropertyAccessorElement setter = field.setter;
732 assertThat(field)..isWrittenAt('bbb) {}', true);
733 assertThat(getter)..isReferencedAt('bbb);', false);
734 assertThat(setter)..isReferencedAt('bbb = 2;', false);
735 }
736 }
737
704 void test_isReferencedBy_FunctionElement() { 738 void test_isReferencedBy_FunctionElement() {
705 _indexTestUnit(''' 739 _indexTestUnit('''
706 foo() {} 740 foo() {}
707 main() { 741 main() {
708 print(foo); 742 print(foo);
709 print(foo()); 743 print(foo());
710 } 744 }
711 '''); 745 ''');
712 FunctionElement element = findElement('foo'); 746 FunctionElement element = findElement('foo');
713 assertThat(element) 747 assertThat(element)
(...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after
1136 final bool isQualified; 1170 final bool isQualified;
1137 1171
1138 _Relation(this.kind, this.offset, this.length, this.isQualified); 1172 _Relation(this.kind, this.offset, this.length, this.isQualified);
1139 1173
1140 @override 1174 @override
1141 String toString() { 1175 String toString() {
1142 return '_Relation{kind: $kind, offset: $offset, length: $length, ' 1176 return '_Relation{kind: $kind, offset: $offset, length: $length, '
1143 'isQualified: $isQualified}'; 1177 'isQualified: $isQualified}';
1144 } 1178 }
1145 } 1179 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/summary/index_unit.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698