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

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

Issue 1816583002: Issue 26034#3. Fix for indexing references to synthetic fields. (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 745 matching lines...) Expand 10 before | Expand all | Expand 10 after
756 } 756 }
757 '''); 757 ''');
758 ClassElement enumElement = findElement('MyEnum'); 758 ClassElement enumElement = findElement('MyEnum');
759 assertThat(enumElement.getGetter('values')) 759 assertThat(enumElement.getGetter('values'))
760 ..isReferencedAt('values);', true); 760 ..isReferencedAt('values);', true);
761 assertThat(enumElement.getGetter('index'))..isReferencedAt('index);', true); 761 assertThat(enumElement.getGetter('index'))..isReferencedAt('index);', true);
762 assertThat(enumElement.getGetter('A'))..isReferencedAt('A);', true); 762 assertThat(enumElement.getGetter('A'))..isReferencedAt('A);', true);
763 assertThat(enumElement.getGetter('B'))..isReferencedAt('B);', true); 763 assertThat(enumElement.getGetter('B'))..isReferencedAt('B);', true);
764 } 764 }
765 765
766 void test_isReferencedBy_FieldElement_synthetic_hasGetter() {
767 verifyNoTestUnitErrors = false;
768 _indexTestUnit('''
769 class A {
770 A() : f = 42;
771 int get f => 0;
772 }
773 ''');
774 ClassElement element2 = findElement('A');
775 assertThat(element2.getField('f')).isWrittenAt('f = 42', true);
776 }
777
778 void test_isReferencedBy_FieldElement_synthetic_hasGetterSetter() {
779 verifyNoTestUnitErrors = false;
780 _indexTestUnit('''
781 class A {
782 A() : f = 42;
783 int get f => 0;
784 set f(_) {}
785 }
786 ''');
787 ClassElement element2 = findElement('A');
788 assertThat(element2.getField('f')).isWrittenAt('f = 42', true);
789 }
790
791 void test_isReferencedBy_FieldElement_synthetic_hasSetter() {
792 verifyNoTestUnitErrors = false;
793 _indexTestUnit('''
794 class A {
795 A() : f = 42;
796 set f(_) {}
797 }
798 ''');
799 ClassElement element2 = findElement('A');
800 assertThat(element2.getField('f')).isWrittenAt('f = 42', true);
801 }
802
766 void test_isReferencedBy_FunctionElement() { 803 void test_isReferencedBy_FunctionElement() {
767 _indexTestUnit(''' 804 _indexTestUnit('''
768 foo() {} 805 foo() {}
769 main() { 806 main() {
770 print(foo); 807 print(foo);
771 print(foo()); 808 print(foo());
772 } 809 }
773 '''); 810 ''');
774 FunctionElement element = findElement('foo'); 811 FunctionElement element = findElement('foo');
775 assertThat(element) 812 assertThat(element)
(...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after
1243 final bool isQualified; 1280 final bool isQualified;
1244 1281
1245 _Relation(this.kind, this.offset, this.length, this.isQualified); 1282 _Relation(this.kind, this.offset, this.length, this.isQualified);
1246 1283
1247 @override 1284 @override
1248 String toString() { 1285 String toString() {
1249 return '_Relation{kind: $kind, offset: $offset, length: $length, ' 1286 return '_Relation{kind: $kind, offset: $offset, length: $length, '
1250 'isQualified: $isQualified}'; 1287 'isQualified: $isQualified}';
1251 } 1288 }
1252 } 1289 }
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