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

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

Issue 1809823002: Don't index library identifiers. (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 890 matching lines...) Expand 10 before | Expand all | Expand 10 after
901 A.foo({this.field}); 901 A.foo({this.field});
902 A.bar() : field = 5; 902 A.bar() : field = 5;
903 } 903 }
904 '''); 904 ''');
905 FieldElement element = findElement('field'); 905 FieldElement element = findElement('field');
906 assertThat(element) 906 assertThat(element)
907 ..isWrittenAt('field})', true) 907 ..isWrittenAt('field})', true)
908 ..isWrittenAt('field = 5', true); 908 ..isWrittenAt('field = 5', true);
909 } 909 }
910 910
911 void test_usedName_inLibraryIdentifier() {
912 verifyNoTestUnitErrors = false;
913 _indexTestUnit('''
914 library aaa.bbb.ccc;
915 class C {
916 var bbb;
917 }
918 main(p) {
919 p.bbb = 1;
920 }
921 ''');
922 assertThatName('bbb')
923 ..isNotUsed('bbb.ccc', IndexRelationKind.IS_READ_BY)
924 ..isUsedQ('bbb = 1;', IndexRelationKind.IS_WRITTEN_BY);
925 }
926
911 void test_usedName_qualified_resolved() { 927 void test_usedName_qualified_resolved() {
912 verifyNoTestUnitErrors = false; 928 verifyNoTestUnitErrors = false;
913 _indexTestUnit(''' 929 _indexTestUnit('''
914 class C { 930 class C {
915 var x; 931 var x;
916 } 932 }
917 main(C c) { 933 main(C c) {
918 c.x; 934 c.x;
919 c.x = 1; 935 c.x = 1;
920 c.x += 2; 936 c.x += 2;
921 c.x(); 937 c.x();
922 } 938 }
923 '''); 939 ''');
924 assertThatName('x') 940 assertThatName('x')
925 ..isNotUsed('x;', IndexRelationKind.IS_READ_BY) 941 ..isNotUsedQ('x;', IndexRelationKind.IS_READ_BY)
926 ..isNotUsed('x = 1;', IndexRelationKind.IS_WRITTEN_BY) 942 ..isNotUsedQ('x = 1;', IndexRelationKind.IS_WRITTEN_BY)
927 ..isNotUsed('x += 2;', IndexRelationKind.IS_READ_WRITTEN_BY) 943 ..isNotUsedQ('x += 2;', IndexRelationKind.IS_READ_WRITTEN_BY)
928 ..isNotUsed('x();', IndexRelationKind.IS_INVOKED_BY); 944 ..isNotUsedQ('x();', IndexRelationKind.IS_INVOKED_BY);
929 } 945 }
930 946
931 void test_usedName_qualified_unresolved() { 947 void test_usedName_qualified_unresolved() {
932 verifyNoTestUnitErrors = false; 948 verifyNoTestUnitErrors = false;
933 _indexTestUnit(''' 949 _indexTestUnit('''
934 main(p) { 950 main(p) {
935 p.x; 951 p.x;
936 p.x = 1; 952 p.x = 1;
937 p.x += 2; 953 p.x += 2;
938 p.x(); 954 p.x();
(...skipping 13 matching lines...) Expand all
952 var x; 968 var x;
953 m() { 969 m() {
954 x; 970 x;
955 x = 1; 971 x = 1;
956 x += 2; 972 x += 2;
957 x(); 973 x();
958 } 974 }
959 } 975 }
960 '''); 976 ''');
961 assertThatName('x') 977 assertThatName('x')
962 ..isNotUsed('x;', IndexRelationKind.IS_READ_BY) 978 ..isNotUsedQ('x;', IndexRelationKind.IS_READ_BY)
963 ..isNotUsed('x = 1;', IndexRelationKind.IS_WRITTEN_BY) 979 ..isNotUsedQ('x = 1;', IndexRelationKind.IS_WRITTEN_BY)
964 ..isNotUsed('x += 2;', IndexRelationKind.IS_READ_WRITTEN_BY) 980 ..isNotUsedQ('x += 2;', IndexRelationKind.IS_READ_WRITTEN_BY)
965 ..isNotUsed('x();', IndexRelationKind.IS_INVOKED_BY); 981 ..isNotUsedQ('x();', IndexRelationKind.IS_INVOKED_BY);
966 } 982 }
967 983
968 void test_usedName_unqualified_unresolved() { 984 void test_usedName_unqualified_unresolved() {
969 verifyNoTestUnitErrors = false; 985 verifyNoTestUnitErrors = false;
970 _indexTestUnit(''' 986 _indexTestUnit('''
971 main() { 987 main() {
972 x; 988 x;
973 x = 1; 989 x = 1;
974 x += 2; 990 x += 2;
975 x(); 991 x();
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
1194 } 1210 }
1195 1211
1196 class _NameIndexAssert { 1212 class _NameIndexAssert {
1197 final PackageIndexAssemblerTest test; 1213 final PackageIndexAssemblerTest test;
1198 final String name; 1214 final String name;
1199 1215
1200 _NameIndexAssert(this.test, this.name); 1216 _NameIndexAssert(this.test, this.name);
1201 1217
1202 void isNotUsed(String search, IndexRelationKind kind) { 1218 void isNotUsed(String search, IndexRelationKind kind) {
1203 test._assertUsedName( 1219 test._assertUsedName(
1220 name, kind, test._expectedLocation(search, false), true);
1221 }
1222
1223 void isNotUsedQ(String search, IndexRelationKind kind) {
1224 test._assertUsedName(
1204 name, kind, test._expectedLocation(search, true), true); 1225 name, kind, test._expectedLocation(search, true), true);
1205 } 1226 }
1206 1227
1207 void isUsed(String search, IndexRelationKind kind) { 1228 void isUsed(String search, IndexRelationKind kind) {
1208 test._assertUsedName( 1229 test._assertUsedName(
1209 name, kind, test._expectedLocation(search, false), false); 1230 name, kind, test._expectedLocation(search, false), false);
1210 } 1231 }
1211 1232
1212 void isUsedQ(String search, IndexRelationKind kind) { 1233 void isUsedQ(String search, IndexRelationKind kind) {
1213 test._assertUsedName( 1234 test._assertUsedName(
1214 name, kind, test._expectedLocation(search, true), false); 1235 name, kind, test._expectedLocation(search, true), false);
1215 } 1236 }
1216 } 1237 }
1217 1238
1218 class _Relation { 1239 class _Relation {
1219 final IndexRelationKind kind; 1240 final IndexRelationKind kind;
1220 final int offset; 1241 final int offset;
1221 final int length; 1242 final int length;
1222 final bool isQualified; 1243 final bool isQualified;
1223 1244
1224 _Relation(this.kind, this.offset, this.length, this.isQualified); 1245 _Relation(this.kind, this.offset, this.length, this.isQualified);
1225 1246
1226 @override 1247 @override
1227 String toString() { 1248 String toString() {
1228 return '_Relation{kind: $kind, offset: $offset, length: $length, ' 1249 return '_Relation{kind: $kind, offset: $offset, length: $length, '
1229 'isQualified: $isQualified}'; 1250 'isQualified: $isQualified}';
1230 } 1251 }
1231 } 1252 }
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