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

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

Issue 1829463002: Issue 26063. Index declarations in even partically analyzed units. (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 '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 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 int set s (_) {} 92 int set s (_) {}
93 }'''); 93 }''');
94 _assertDefinedName('s', IndexNameKind.classMember, 's (_) {}'); 94 _assertDefinedName('s', IndexNameKind.classMember, 's (_) {}');
95 } 95 }
96 96
97 void test_definedName_topLevel_class() { 97 void test_definedName_topLevel_class() {
98 _indexTestUnit('class A {}'); 98 _indexTestUnit('class A {}');
99 _assertDefinedName('A', IndexNameKind.topLevel, 'A {}'); 99 _assertDefinedName('A', IndexNameKind.topLevel, 'A {}');
100 } 100 }
101 101
102 void test_definedName_topLevel_class2() {
103 _indexTestUnit('class A {}', declOnly: true);
104 _assertDefinedName('A', IndexNameKind.topLevel, 'A {}');
105 }
106
102 void test_definedName_topLevel_classAlias() { 107 void test_definedName_topLevel_classAlias() {
103 _indexTestUnit(''' 108 _indexTestUnit('''
104 class M {} 109 class M {}
105 class C = Object with M;'''); 110 class C = Object with M;''');
106 _assertDefinedName('C', IndexNameKind.topLevel, 'C ='); 111 _assertDefinedName('C', IndexNameKind.topLevel, 'C =');
107 } 112 }
108 113
109 void test_definedName_topLevel_enum() { 114 void test_definedName_topLevel_enum() {
110 _indexTestUnit('enum E {a, b, c}'); 115 _indexTestUnit('enum E {a, b, c}');
111 _assertDefinedName('E', IndexNameKind.topLevel, 'E {'); 116 _assertDefinedName('E', IndexNameKind.topLevel, 'E {');
(...skipping 1050 matching lines...) Expand 10 before | Expand all | Expand 10 after
1162 } 1167 }
1163 _failWithIndexDump('Unit $unitElement of $element is not referenced'); 1168 _failWithIndexDump('Unit $unitElement of $element is not referenced');
1164 return -1; 1169 return -1;
1165 } 1170 }
1166 1171
1167 int _getUriId(Uri uri) { 1172 int _getUriId(Uri uri) {
1168 String str = uri.toString(); 1173 String str = uri.toString();
1169 return _getStringId(str); 1174 return _getStringId(str);
1170 } 1175 }
1171 1176
1172 void _indexTestUnit(String code) { 1177 void _indexTestUnit(String code, {bool declOnly: false}) {
1173 resolveTestUnit(code); 1178 resolveTestUnit(code);
1174 PackageIndexAssembler assembler = new PackageIndexAssembler(); 1179 PackageIndexAssembler assembler = new PackageIndexAssembler();
1175 assembler.index(testUnit); 1180 if (declOnly) {
1181 assembler.indexDeclarations(testUnit);
1182 } else {
1183 assembler.indexUnit(testUnit);
1184 }
1176 // assemble, write and read 1185 // assemble, write and read
1177 PackageIndexBuilder indexBuilder = assembler.assemble(); 1186 PackageIndexBuilder indexBuilder = assembler.assemble();
1178 List<int> indexBytes = indexBuilder.toBuffer(); 1187 List<int> indexBytes = indexBuilder.toBuffer();
1179 packageIndex = new PackageIndex.fromBuffer(indexBytes); 1188 packageIndex = new PackageIndex.fromBuffer(indexBytes);
1180 // prepare the only unit index 1189 // prepare the only unit index
1181 expect(packageIndex.units, hasLength(1)); 1190 expect(packageIndex.units, hasLength(1));
1182 unitIndex = packageIndex.units[0]; 1191 unitIndex = packageIndex.units[0];
1183 expect(unitIndex.unit, _getUnitId(testUnitElement)); 1192 expect(unitIndex.unit, _getUnitId(testUnitElement));
1184 } 1193 }
1185 } 1194 }
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
1280 final bool isQualified; 1289 final bool isQualified;
1281 1290
1282 _Relation(this.kind, this.offset, this.length, this.isQualified); 1291 _Relation(this.kind, this.offset, this.length, this.isQualified);
1283 1292
1284 @override 1293 @override
1285 String toString() { 1294 String toString() {
1286 return '_Relation{kind: $kind, offset: $offset, length: $length, ' 1295 return '_Relation{kind: $kind, offset: $offset, length: $length, '
1287 'isQualified: $isQualified}'; 1296 'isQualified: $isQualified}';
1288 } 1297 }
1289 } 1298 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/summary/index_unit.dart ('k') | pkg/analyzer/tool/summary/build_sdk_summaries.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698