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

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

Issue 1530303005: Separate prelinked and unlinked parts of summaries. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years 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) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, 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 analyzer.test.src.summary.summary_test; 5 library analyzer.test.src.summary.summary_test;
6 6
7 import 'package:analyzer/dart/element/element.dart'; 7 import 'package:analyzer/dart/element/element.dart';
8 import 'package:analyzer/src/generated/engine.dart'; 8 import 'package:analyzer/src/generated/engine.dart';
9 import 'package:analyzer/src/generated/java_engine_io.dart'; 9 import 'package:analyzer/src/generated/java_engine_io.dart';
10 import 'package:analyzer/src/generated/source.dart'; 10 import 'package:analyzer/src/generated/source.dart';
(...skipping 27 matching lines...) Expand all
38 serializeLibraryElement(element.library); 38 serializeLibraryElement(element.library);
39 return findClass(element.name, failIfAbsent: true); 39 return findClass(element.name, failIfAbsent: true);
40 } 40 }
41 41
42 /** 42 /**
43 * Serialize the given [library] element, then deserialize it and store the 43 * Serialize the given [library] element, then deserialize it and store the
44 * resulting summary in [lib]. 44 * resulting summary in [lib].
45 */ 45 */
46 void serializeLibraryElement(LibraryElement library) { 46 void serializeLibraryElement(LibraryElement library) {
47 BuilderContext builderContext = new BuilderContext(); 47 BuilderContext builderContext = new BuilderContext();
48 PrelinkedLibraryBuilder serializedLib = summarize_elements.serializeLibrary( 48 summarize_elements.LibrarySerializationResult serializedLib =
49 builderContext, library, typeProvider); 49 summarize_elements.serializeLibrary(
50 List<int> encodedLib = serializedLib.toBuffer(); 50 builderContext, library, typeProvider);
51 lib = new PrelinkedLibrary.fromBuffer(encodedLib); 51 prelinked =
52 new PrelinkedLibrary.fromBuffer(serializedLib.prelinked.toBuffer());
53 unlinkedUnits = serializedLib.unlinkedUnits
54 .map((UnlinkedUnitBuilder b) =>
55 new UnlinkedUnit.fromBuffer(b.toBuffer()))
56 .toList();
52 } 57 }
53 58
54 @override 59 @override
55 void serializeLibraryText(String text, {bool allowErrors: false}) { 60 void serializeLibraryText(String text, {bool allowErrors: false}) {
56 Source source = addSource(text); 61 Source source = addSource(text);
57 LibraryElement library = resolve2(source); 62 LibraryElement library = resolve2(source);
58 if (!allowErrors) { 63 if (!allowErrors) {
59 assertNoErrors(source); 64 assertNoErrors(source);
60 } 65 }
61 serializeLibraryElement(library); 66 serializeLibraryElement(library);
62 expect(definingUnit.unlinked.imports.length, lib.importDependencies.length); 67 expect(
63 for (PrelinkedUnit unit in lib.units) { 68 unlinkedUnits[0].imports.length, prelinked.importDependencies.length);
64 expect(unit.unlinked.references.length, unit.references.length); 69 expect(prelinked.units.length, unlinkedUnits.length);
70 for (int i = 0; i < prelinked.units.length; i++) {
71 expect(unlinkedUnits[i].references.length,
72 prelinked.units[i].references.length);
65 } 73 }
66 } 74 }
67 75
68 @override 76 @override
69 void setUp() { 77 void setUp() {
70 super.setUp(); 78 super.setUp();
71 AnalysisOptionsImpl options = new AnalysisOptionsImpl(); 79 AnalysisOptionsImpl options = new AnalysisOptionsImpl();
72 options.enableGenericMethods = true; 80 options.enableGenericMethods = true;
73 resetWithOptions(options); 81 resetWithOptions(options);
74 } 82 }
75 83
76 test_class_no_superclass() { 84 test_class_no_superclass() {
77 UnlinkedClass cls = serializeClassElement(typeProvider.objectType.element); 85 UnlinkedClass cls = serializeClassElement(typeProvider.objectType.element);
78 expect(cls.supertype, isNull); 86 expect(cls.supertype, isNull);
79 expect(cls.hasNoSupertype, isTrue); 87 expect(cls.hasNoSupertype, isTrue);
80 } 88 }
81 } 89 }
82 90
83 /** 91 /**
84 * Base class containing most summary tests. This allows summary tests to be 92 * Base class containing most summary tests. This allows summary tests to be
85 * re-used to exercise all the different ways in which summaries can be 93 * re-used to exercise all the different ways in which summaries can be
86 * generated (e.g. direct from the AST, from the element model, from a 94 * generated (e.g. direct from the AST, from the element model, from a
87 * "relinking" process, etc.) 95 * "relinking" process, etc.)
88 */ 96 */
89 abstract class SummaryTest { 97 abstract class SummaryTest {
90 /** 98 /**
91 * The result of serializing and then deserializing the library under test. 99 * Prelinked summary that results from serializing and then deserializing the
100 * library under test.
92 */ 101 */
93 PrelinkedLibrary lib; 102 PrelinkedLibrary prelinked;
103
104 /**
105 * Unlinked compilation unit summaries that result from serializing and
106 * deserializing the library under test.
107 */
108 List<UnlinkedUnit> unlinkedUnits;
94 109
95 /** 110 /**
96 * `true` if the summary was created directly from the AST (and hence 111 * `true` if the summary was created directly from the AST (and hence
97 * contains information that is not obtainable from the element model alone). 112 * contains information that is not obtainable from the element model alone).
98 * TODO(paulberry): modify the element model so that it contains all the data 113 * TODO(paulberry): modify the element model so that it contains all the data
99 * that summaries need, so that this flag is no longer needed. 114 * that summaries need, so that this flag is no longer needed.
100 */ 115 */
101 bool get checkAstDerivedData; 116 bool get checkAstDerivedData;
102 117
103 /** 118 /**
104 * Get access to the prelinked defining compilation unit. 119 * Get access to the prelinked defining compilation unit.
105 */ 120 */
106 PrelinkedUnit get definingUnit => lib.units[0]; 121 PrelinkedUnit get definingUnit => prelinked.units[0];
107 122
108 /** 123 /**
109 * Convert [path] to a suitably formatted absolute path URI for the current 124 * Convert [path] to a suitably formatted absolute path URI for the current
110 * platform. 125 * platform.
111 */ 126 */
112 String absUri(String path) { 127 String absUri(String path) {
113 return FileUtilities2.createFile(path).toURI().toString(); 128 return FileUtilities2.createFile(path).toURI().toString();
114 } 129 }
115 130
116 /** 131 /**
(...skipping 17 matching lines...) Expand all
134 * a file reachable via the given [absoluteUri] and [relativeUri]. 149 * a file reachable via the given [absoluteUri] and [relativeUri].
135 */ 150 */
136 void checkDependency(int dependency, String absoluteUri, String relativeUri) { 151 void checkDependency(int dependency, String absoluteUri, String relativeUri) {
137 if (!checkAstDerivedData) { 152 if (!checkAstDerivedData) {
138 // The element model doesn't (yet) store enough information to recover 153 // The element model doesn't (yet) store enough information to recover
139 // relative URIs, so we have to use the absolute URI. 154 // relative URIs, so we have to use the absolute URI.
140 // TODO(paulberry): fix this. 155 // TODO(paulberry): fix this.
141 relativeUri = absoluteUri; 156 relativeUri = absoluteUri;
142 } 157 }
143 expect(dependency, new isInstanceOf<int>()); 158 expect(dependency, new isInstanceOf<int>());
144 expect(lib.dependencies[dependency].uri, relativeUri); 159 expect(prelinked.dependencies[dependency].uri, relativeUri);
145 } 160 }
146 161
147 /** 162 /**
148 * Verify that the given [typeRef] represents the type `dynamic`. 163 * Verify that the given [typeRef] represents the type `dynamic`.
149 */ 164 */
150 void checkDynamicTypeRef(UnlinkedTypeRef typeRef) { 165 void checkDynamicTypeRef(UnlinkedTypeRef typeRef) {
151 checkTypeRef(typeRef, null, null, null); 166 checkTypeRef(typeRef, null, null, null);
152 } 167 }
153 168
154 /** 169 /**
155 * Verify that the dependency table contains an entry for a file reachable 170 * Verify that the dependency table contains an entry for a file reachable
156 * via the given [absoluteUri] and [relativeUri]. 171 * via the given [absoluteUri] and [relativeUri].
157 */ 172 */
158 void checkHasDependency(String absoluteUri, String relativeUri) { 173 void checkHasDependency(String absoluteUri, String relativeUri) {
159 if (!checkAstDerivedData) { 174 if (!checkAstDerivedData) {
160 // The element model doesn't (yet) store enough information to recover 175 // The element model doesn't (yet) store enough information to recover
161 // relative URIs, so we have to use the absolute URI. 176 // relative URIs, so we have to use the absolute URI.
162 // TODO(paulberry): fix this. 177 // TODO(paulberry): fix this.
163 relativeUri = absoluteUri; 178 relativeUri = absoluteUri;
164 } 179 }
165 for (PrelinkedDependency dep in lib.dependencies) { 180 for (PrelinkedDependency dep in prelinked.dependencies) {
166 if (dep.uri == relativeUri) { 181 if (dep.uri == relativeUri) {
167 return; 182 return;
168 } 183 }
169 } 184 }
170 fail('Did not find dependency $absoluteUri'); 185 fail('Did not find dependency $absoluteUri');
171 } 186 }
172 187
173 /** 188 /**
174 * Verify that the dependency table *does not* contain any entries for a file 189 * Verify that the dependency table *does not* contain any entries for a file
175 * reachable via the given [absoluteUri] and [relativeUri]. 190 * reachable via the given [absoluteUri] and [relativeUri].
176 */ 191 */
177 void checkLacksDependency(String absoluteUri, String relativeUri) { 192 void checkLacksDependency(String absoluteUri, String relativeUri) {
178 if (!checkAstDerivedData) { 193 if (!checkAstDerivedData) {
179 // The element model doesn't (yet) store enough information to recover 194 // The element model doesn't (yet) store enough information to recover
180 // relative URIs, so we have to use the absolute URI. 195 // relative URIs, so we have to use the absolute URI.
181 // TODO(paulberry): fix this. 196 // TODO(paulberry): fix this.
182 relativeUri = absoluteUri; 197 relativeUri = absoluteUri;
183 } 198 }
184 for (PrelinkedDependency dep in lib.dependencies) { 199 for (PrelinkedDependency dep in prelinked.dependencies) {
185 if (dep.uri == relativeUri) { 200 if (dep.uri == relativeUri) {
186 fail('Unexpected dependency found: $relativeUri'); 201 fail('Unexpected dependency found: $relativeUri');
187 } 202 }
188 } 203 }
189 } 204 }
190 205
191 /** 206 /**
192 * Verify that the given [typeRef] represents a reference to a type parameter 207 * Verify that the given [typeRef] represents a reference to a type parameter
193 * having the given [deBruijnIndex]. 208 * having the given [deBruijnIndex].
194 */ 209 */
195 void checkParamTypeRef(UnlinkedTypeRef typeRef, int deBruijnIndex) { 210 void checkParamTypeRef(UnlinkedTypeRef typeRef, int deBruijnIndex) {
196 expect(typeRef, new isInstanceOf<UnlinkedTypeRef>()); 211 expect(typeRef, new isInstanceOf<UnlinkedTypeRef>());
197 expect(typeRef.reference, 0); 212 expect(typeRef.reference, 0);
198 expect(typeRef.typeArguments, isEmpty); 213 expect(typeRef.typeArguments, isEmpty);
199 expect(typeRef.paramReference, deBruijnIndex); 214 expect(typeRef.paramReference, deBruijnIndex);
200 } 215 }
201 216
202 /** 217 /**
203 * Verify that [prefixReference] is a valid reference to a prefix having the 218 * Verify that [prefixReference] is a valid reference to a prefix having the
204 * given [name]. 219 * given [name].
205 */ 220 */
206 void checkPrefix(int prefixReference, String name) { 221 void checkPrefix(int prefixReference, String name) {
207 expect(prefixReference, isNot(0)); 222 expect(prefixReference, isNot(0));
208 expect( 223 expect(unlinkedUnits[0].references[prefixReference].prefixReference, 0);
209 definingUnit.unlinked.references[prefixReference].prefixReference, 0); 224 expect(unlinkedUnits[0].references[prefixReference].name, name);
210 expect(definingUnit.unlinked.references[prefixReference].name, name);
211 expect(definingUnit.references[prefixReference].dependency, 0); 225 expect(definingUnit.references[prefixReference].dependency, 0);
212 expect(definingUnit.references[prefixReference].kind, 226 expect(definingUnit.references[prefixReference].kind,
213 PrelinkedReferenceKind.prefix); 227 PrelinkedReferenceKind.prefix);
214 expect(definingUnit.references[prefixReference].unit, 0); 228 expect(definingUnit.references[prefixReference].unit, 0);
215 } 229 }
216 230
217 /** 231 /**
218 * Verify that the given [typeRef] represents a reference to a type declared 232 * Verify that the given [typeRef] represents a reference to a type declared
219 * in a file reachable via [absoluteUri] and [relativeUri], having name 233 * in a file reachable via [absoluteUri] and [relativeUri], having name
220 * [expectedName]. If [expectedPrefix] is supplied, verify that the type is 234 * [expectedName]. If [expectedPrefix] is supplied, verify that the type is
221 * reached via the given prefix. If [allowTypeParameters] is true, allow the 235 * reached via the given prefix. If [allowTypeParameters] is true, allow the
222 * type reference to supply type parameters. [expectedKind] is the kind of 236 * type reference to supply type parameters. [expectedKind] is the kind of
223 * object referenced. [sourceUnit] is the compilation unit within which the 237 * object referenced. [prelinkedSourceUnit] and [unlinkedSourceUnit] refer
224 * [typeRef] appears; if not specified it is assumed to be the defining 238 * to the compilation unit within which the [typeRef] appears; if not
225 * compilation unit. [expectedTargetUnit] is the index of the compilation 239 * specified they are assumed to refer to the defining compilation unit.
226 * unit in which the target of the [typeRef] is expected to appear; if not 240 * [expectedTargetUnit] is the index of the compilation unit in which the
227 * specified it is assumed to be the defining compilation unit. 241 * target of the [typeRef] is expected to appear; if not specified it is
242 * assumed to be the defining compilation unit.
228 */ 243 */
229 void checkTypeRef(UnlinkedTypeRef typeRef, String absoluteUri, 244 void checkTypeRef(UnlinkedTypeRef typeRef, String absoluteUri,
230 String relativeUri, String expectedName, 245 String relativeUri, String expectedName,
231 {String expectedPrefix, 246 {String expectedPrefix,
232 bool allowTypeParameters: false, 247 bool allowTypeParameters: false,
233 PrelinkedReferenceKind expectedKind: PrelinkedReferenceKind.classOrEnum, 248 PrelinkedReferenceKind expectedKind: PrelinkedReferenceKind.classOrEnum,
234 int expectedTargetUnit: 0, 249 int expectedTargetUnit: 0,
235 PrelinkedUnit sourceUnit}) { 250 PrelinkedUnit prelinkedSourceUnit,
236 sourceUnit ??= definingUnit; 251 UnlinkedUnit unlinkedSourceUnit}) {
252 prelinkedSourceUnit ??= definingUnit;
253 unlinkedSourceUnit ??= unlinkedUnits[0];
237 expect(typeRef, new isInstanceOf<UnlinkedTypeRef>()); 254 expect(typeRef, new isInstanceOf<UnlinkedTypeRef>());
238 expect(typeRef.paramReference, 0); 255 expect(typeRef.paramReference, 0);
239 int index = typeRef.reference; 256 int index = typeRef.reference;
240 UnlinkedReference reference = sourceUnit.unlinked.references[index]; 257 UnlinkedReference reference = unlinkedSourceUnit.references[index];
241 PrelinkedReference referenceResolution = sourceUnit.references[index]; 258 PrelinkedReference referenceResolution =
259 prelinkedSourceUnit.references[index];
242 if (index == 0) { 260 if (index == 0) {
243 // Index 0 is reserved for "dynamic". 261 // Index 0 is reserved for "dynamic".
244 expect(reference.name, isEmpty); 262 expect(reference.name, isEmpty);
245 expect(reference.prefixReference, 0); 263 expect(reference.prefixReference, 0);
246 } 264 }
247 if (absoluteUri == null) { 265 if (absoluteUri == null) {
248 expect(referenceResolution.dependency, 0); 266 expect(referenceResolution.dependency, 0);
249 } else { 267 } else {
250 checkDependency(referenceResolution.dependency, absoluteUri, relativeUri); 268 checkDependency(referenceResolution.dependency, absoluteUri, relativeUri);
251 } 269 }
(...skipping 29 matching lines...) Expand all
281 expectedKind: PrelinkedReferenceKind.unresolved); 299 expectedKind: PrelinkedReferenceKind.unresolved);
282 } 300 }
283 301
284 fail_test_import_missing() { 302 fail_test_import_missing() {
285 // TODO(paulberry): At the moment unresolved imports are not included in 303 // TODO(paulberry): At the moment unresolved imports are not included in
286 // the element model, so we can't pass this test. 304 // the element model, so we can't pass this test.
287 // Unresolved imports are included since this is necessary for proper 305 // Unresolved imports are included since this is necessary for proper
288 // dependency tracking. 306 // dependency tracking.
289 serializeLibraryText('import "foo.dart";', allowErrors: true); 307 serializeLibraryText('import "foo.dart";', allowErrors: true);
290 // Second import is the implicit import of dart:core 308 // Second import is the implicit import of dart:core
291 expect(definingUnit.unlinked.imports, hasLength(2)); 309 expect(unlinkedUnits[0].imports, hasLength(2));
292 checkDependency(lib.importDependencies[0], absUri('/foo.dart'), 'foo.dart'); 310 checkDependency(
311 prelinked.importDependencies[0], absUri('/foo.dart'), 'foo.dart');
293 } 312 }
294 313
295 /** 314 /**
296 * Find the class with the given [className] in the summary, and return its 315 * Find the class with the given [className] in the summary, and return its
297 * [UnlinkedClass] data structure. If [unit] is not given, the class is 316 * [UnlinkedClass] data structure. If [unit] is not given, the class is
298 * looked for in the defining compilation unit. 317 * looked for in the defining compilation unit.
299 */ 318 */
300 UnlinkedClass findClass(String className, 319 UnlinkedClass findClass(String className,
301 {bool failIfAbsent: false, PrelinkedUnit unit}) { 320 {bool failIfAbsent: false, UnlinkedUnit unit}) {
302 unit ??= definingUnit; 321 unit ??= unlinkedUnits[0];
303 UnlinkedClass result; 322 UnlinkedClass result;
304 for (UnlinkedClass cls in unit.unlinked.classes) { 323 for (UnlinkedClass cls in unit.classes) {
305 if (cls.name == className) { 324 if (cls.name == className) {
306 if (result != null) { 325 if (result != null) {
307 fail('Duplicate class $className'); 326 fail('Duplicate class $className');
308 } 327 }
309 result = cls; 328 result = cls;
310 } 329 }
311 } 330 }
312 if (result == null && failIfAbsent) { 331 if (result == null && failIfAbsent) {
313 fail('Class $className not found in serialized output'); 332 fail('Class $className not found in serialized output');
314 } 333 }
315 return result; 334 return result;
316 } 335 }
317 336
318 /** 337 /**
319 * Find the enum with the given [enumName] in the summary, and return its 338 * Find the enum with the given [enumName] in the summary, and return its
320 * [UnlinkedEnum] data structure. If [unit] is not given, the enum is looked 339 * [UnlinkedEnum] data structure. If [unit] is not given, the enum is looked
321 * for in the defining compilation unit. 340 * for in the defining compilation unit.
322 */ 341 */
323 UnlinkedEnum findEnum(String enumName, 342 UnlinkedEnum findEnum(String enumName,
324 {bool failIfAbsent: false, PrelinkedUnit unit}) { 343 {bool failIfAbsent: false, UnlinkedUnit unit}) {
325 unit ??= definingUnit; 344 unit ??= unlinkedUnits[0];
326 UnlinkedEnum result; 345 UnlinkedEnum result;
327 for (UnlinkedEnum e in unit.unlinked.enums) { 346 for (UnlinkedEnum e in unit.enums) {
328 if (e.name == enumName) { 347 if (e.name == enumName) {
329 if (result != null) { 348 if (result != null) {
330 fail('Duplicate enum $enumName'); 349 fail('Duplicate enum $enumName');
331 } 350 }
332 result = e; 351 result = e;
333 } 352 }
334 } 353 }
335 if (result == null && failIfAbsent) { 354 if (result == null && failIfAbsent) {
336 fail('Enum $enumName not found in serialized output'); 355 fail('Enum $enumName not found in serialized output');
337 } 356 }
338 return result; 357 return result;
339 } 358 }
340 359
341 /** 360 /**
342 * Find the executable with the given [executableName] in the summary, and 361 * Find the executable with the given [executableName] in the summary, and
343 * return its [UnlinkedExecutable] data structure. If [executables] is not 362 * return its [UnlinkedExecutable] data structure. If [executables] is not
344 * given, then the executable is searched for in the defining compilation 363 * given, then the executable is searched for in the defining compilation
345 * unit. 364 * unit.
346 */ 365 */
347 UnlinkedExecutable findExecutable(String executableName, 366 UnlinkedExecutable findExecutable(String executableName,
348 {List<UnlinkedExecutable> executables, bool failIfAbsent: false}) { 367 {List<UnlinkedExecutable> executables, bool failIfAbsent: false}) {
349 executables ??= definingUnit.unlinked.executables; 368 executables ??= unlinkedUnits[0].executables;
350 UnlinkedExecutable result; 369 UnlinkedExecutable result;
351 for (UnlinkedExecutable executable in executables) { 370 for (UnlinkedExecutable executable in executables) {
352 if (executable.name == executableName) { 371 if (executable.name == executableName) {
353 if (result != null) { 372 if (result != null) {
354 fail('Duplicate executable $executableName'); 373 fail('Duplicate executable $executableName');
355 } 374 }
356 result = executable; 375 result = executable;
357 } 376 }
358 } 377 }
359 if (result == null && failIfAbsent) { 378 if (result == null && failIfAbsent) {
360 fail('Executable $executableName not found in serialized output'); 379 fail('Executable $executableName not found in serialized output');
361 } 380 }
362 return result; 381 return result;
363 } 382 }
364 383
365 /** 384 /**
366 * Find the typedef with the given [typedefName] in the summary, and return 385 * Find the typedef with the given [typedefName] in the summary, and return
367 * its [UnlinkedTypedef] data structure. If [unit] is not given, the typedef 386 * its [UnlinkedTypedef] data structure. If [unit] is not given, the typedef
368 * is looked for in the defining compilation unit. 387 * is looked for in the defining compilation unit.
369 */ 388 */
370 UnlinkedTypedef findTypedef(String typedefName, 389 UnlinkedTypedef findTypedef(String typedefName,
371 {bool failIfAbsent: false, PrelinkedUnit unit}) { 390 {bool failIfAbsent: false, UnlinkedUnit unit}) {
372 unit ??= definingUnit; 391 unit ??= unlinkedUnits[0];
373 UnlinkedTypedef result; 392 UnlinkedTypedef result;
374 for (UnlinkedTypedef type in unit.unlinked.typedefs) { 393 for (UnlinkedTypedef type in unit.typedefs) {
375 if (type.name == typedefName) { 394 if (type.name == typedefName) {
376 if (result != null) { 395 if (result != null) {
377 fail('Duplicate typedef $typedefName'); 396 fail('Duplicate typedef $typedefName');
378 } 397 }
379 result = type; 398 result = type;
380 } 399 }
381 } 400 }
382 if (result == null && failIfAbsent) { 401 if (result == null && failIfAbsent) {
383 fail('Typedef $typedefName not found in serialized output'); 402 fail('Typedef $typedefName not found in serialized output');
384 } 403 }
385 return result; 404 return result;
386 } 405 }
387 406
388 /** 407 /**
389 * Find the top level variable with the given [variableName] in the summary, 408 * Find the top level variable with the given [variableName] in the summary,
390 * and return its [UnlinkedVariable] data structure. If [variables] is not 409 * and return its [UnlinkedVariable] data structure. If [variables] is not
391 * specified, the variable is looked for in the defining compilation unit. 410 * specified, the variable is looked for in the defining compilation unit.
392 */ 411 */
393 UnlinkedVariable findVariable(String variableName, 412 UnlinkedVariable findVariable(String variableName,
394 {List<UnlinkedVariable> variables, bool failIfAbsent: false}) { 413 {List<UnlinkedVariable> variables, bool failIfAbsent: false}) {
395 variables ??= definingUnit.unlinked.variables; 414 variables ??= unlinkedUnits[0].variables;
396 UnlinkedVariable result; 415 UnlinkedVariable result;
397 for (UnlinkedVariable variable in variables) { 416 for (UnlinkedVariable variable in variables) {
398 if (variable.name == variableName) { 417 if (variable.name == variableName) {
399 if (result != null) { 418 if (result != null) {
400 fail('Duplicate variable $variableName'); 419 fail('Duplicate variable $variableName');
401 } 420 }
402 result = variable; 421 result = variable;
403 } 422 }
404 } 423 }
405 if (result == null && failIfAbsent) { 424 if (result == null && failIfAbsent) {
(...skipping 684 matching lines...) Expand 10 before | Expand all | Expand 10 after
1090 ''' 1109 '''
1091 part of my.lib; 1110 part of my.lib;
1092 1111
1093 class C {} 1112 class C {}
1094 enum E { v } 1113 enum E { v }
1095 var v; 1114 var v;
1096 f() {} 1115 f() {}
1097 typedef F(); 1116 typedef F();
1098 '''); 1117 ''');
1099 serializeLibraryText('library my.lib; part "part1.dart";'); 1118 serializeLibraryText('library my.lib; part "part1.dart";');
1100 PrelinkedUnit unit = lib.units[1]; 1119 UnlinkedUnit unit = unlinkedUnits[1];
1101 expect(findClass('C', unit: unit), isNotNull); 1120 expect(findClass('C', unit: unit), isNotNull);
1102 expect(findEnum('E', unit: unit), isNotNull); 1121 expect(findEnum('E', unit: unit), isNotNull);
1103 expect(findVariable('v', variables: unit.unlinked.variables), isNotNull); 1122 expect(findVariable('v', variables: unit.variables), isNotNull);
1104 expect( 1123 expect(findExecutable('f', executables: unit.executables), isNotNull);
1105 findExecutable('f', executables: unit.unlinked.executables), isNotNull);
1106 expect(findTypedef('F', unit: unit), isNotNull); 1124 expect(findTypedef('F', unit: unit), isNotNull);
1107 } 1125 }
1108 1126
1109 test_enum() { 1127 test_enum() {
1110 UnlinkedEnum e = serializeEnumText('enum E { v1 }'); 1128 UnlinkedEnum e = serializeEnumText('enum E { v1 }');
1111 expect(e.name, 'E'); 1129 expect(e.name, 'E');
1112 expect(e.values, hasLength(1)); 1130 expect(e.values, hasLength(1));
1113 expect(e.values[0].name, 'v1'); 1131 expect(e.values[0].name, 'v1');
1114 } 1132 }
1115 1133
(...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after
1533 } 1551 }
1534 1552
1535 test_executable_type_param_in_return_type() { 1553 test_executable_type_param_in_return_type() {
1536 // TODO(paulberry): also test top level executables. 1554 // TODO(paulberry): also test top level executables.
1537 UnlinkedExecutable ex = serializeMethodText('T f<T>() => null;'); 1555 UnlinkedExecutable ex = serializeMethodText('T f<T>() => null;');
1538 checkParamTypeRef(ex.returnType, 1); 1556 checkParamTypeRef(ex.returnType, 1);
1539 } 1557 }
1540 1558
1541 test_export_hide_order() { 1559 test_export_hide_order() {
1542 serializeLibraryText('export "dart:async" hide Future, Stream;'); 1560 serializeLibraryText('export "dart:async" hide Future, Stream;');
1543 expect(definingUnit.unlinked.exports, hasLength(1)); 1561 expect(unlinkedUnits[0].exports, hasLength(1));
1544 expect(definingUnit.unlinked.exports[0].combinators, hasLength(1)); 1562 expect(unlinkedUnits[0].exports[0].combinators, hasLength(1));
1545 expect(definingUnit.unlinked.exports[0].combinators[0].shows, isEmpty); 1563 expect(unlinkedUnits[0].exports[0].combinators[0].shows, isEmpty);
1546 expect(definingUnit.unlinked.exports[0].combinators[0].hides, hasLength(2)); 1564 expect(unlinkedUnits[0].exports[0].combinators[0].hides, hasLength(2));
1547 checkCombinatorName( 1565 checkCombinatorName(
1548 definingUnit.unlinked.exports[0].combinators[0].hides[0], 'Future'); 1566 unlinkedUnits[0].exports[0].combinators[0].hides[0], 'Future');
1549 checkCombinatorName( 1567 checkCombinatorName(
1550 definingUnit.unlinked.exports[0].combinators[0].hides[1], 'Stream'); 1568 unlinkedUnits[0].exports[0].combinators[0].hides[1], 'Stream');
1551 } 1569 }
1552 1570
1553 test_export_no_combinators() { 1571 test_export_no_combinators() {
1554 serializeLibraryText('export "dart:async";'); 1572 serializeLibraryText('export "dart:async";');
1555 expect(definingUnit.unlinked.exports, hasLength(1)); 1573 expect(unlinkedUnits[0].exports, hasLength(1));
1556 expect(definingUnit.unlinked.exports[0].combinators, isEmpty); 1574 expect(unlinkedUnits[0].exports[0].combinators, isEmpty);
1557 } 1575 }
1558 1576
1559 test_export_show_order() { 1577 test_export_show_order() {
1560 serializeLibraryText('export "dart:async" show Future, Stream;'); 1578 serializeLibraryText('export "dart:async" show Future, Stream;');
1561 expect(definingUnit.unlinked.exports, hasLength(1)); 1579 expect(unlinkedUnits[0].exports, hasLength(1));
1562 expect(definingUnit.unlinked.exports[0].combinators, hasLength(1)); 1580 expect(unlinkedUnits[0].exports[0].combinators, hasLength(1));
1563 expect(definingUnit.unlinked.exports[0].combinators[0].shows, hasLength(2)); 1581 expect(unlinkedUnits[0].exports[0].combinators[0].shows, hasLength(2));
1564 expect(definingUnit.unlinked.exports[0].combinators[0].hides, isEmpty); 1582 expect(unlinkedUnits[0].exports[0].combinators[0].hides, isEmpty);
1565 checkCombinatorName( 1583 checkCombinatorName(
1566 definingUnit.unlinked.exports[0].combinators[0].shows[0], 'Future'); 1584 unlinkedUnits[0].exports[0].combinators[0].shows[0], 'Future');
1567 checkCombinatorName( 1585 checkCombinatorName(
1568 definingUnit.unlinked.exports[0].combinators[0].shows[1], 'Stream'); 1586 unlinkedUnits[0].exports[0].combinators[0].shows[1], 'Stream');
1569 } 1587 }
1570 1588
1571 test_export_uri() { 1589 test_export_uri() {
1572 addNamedSource('/a.dart', 'library my.lib;'); 1590 addNamedSource('/a.dart', 'library my.lib;');
1573 String uriString = '"a.dart"'; 1591 String uriString = '"a.dart"';
1574 String libraryText = 'export $uriString;'; 1592 String libraryText = 'export $uriString;';
1575 serializeLibraryText(libraryText); 1593 serializeLibraryText(libraryText);
1576 expect(definingUnit.unlinked.exports, hasLength(1)); 1594 expect(unlinkedUnits[0].exports, hasLength(1));
1577 expect(definingUnit.unlinked.exports[0].uri, 'a.dart'); 1595 expect(unlinkedUnits[0].exports[0].uri, 'a.dart');
1578 } 1596 }
1579 1597
1580 test_field() { 1598 test_field() {
1581 UnlinkedClass cls = serializeClassText('class C { int i; }'); 1599 UnlinkedClass cls = serializeClassText('class C { int i; }');
1582 UnlinkedVariable variable = findVariable('i', variables: cls.fields); 1600 UnlinkedVariable variable = findVariable('i', variables: cls.fields);
1583 expect(variable, isNotNull); 1601 expect(variable, isNotNull);
1584 expect(variable.isConst, isFalse); 1602 expect(variable.isConst, isFalse);
1585 expect(variable.isStatic, isFalse); 1603 expect(variable.isStatic, isFalse);
1586 expect(variable.isFinal, isFalse); 1604 expect(variable.isFinal, isFalse);
1587 expect(findExecutable('i', executables: cls.executables), isNull); 1605 expect(findExecutable('i', executables: cls.executables), isNull);
(...skipping 24 matching lines...) Expand all
1612 List<UnlinkedParam> params = cls.executables[0].parameters; 1630 List<UnlinkedParam> params = cls.executables[0].parameters;
1613 checkParamTypeRef(params[0].type, 4); 1631 checkParamTypeRef(params[0].type, 4);
1614 checkParamTypeRef(params[1].type, 3); 1632 checkParamTypeRef(params[1].type, 3);
1615 checkParamTypeRef(params[2].type, 2); 1633 checkParamTypeRef(params[2].type, 2);
1616 checkParamTypeRef(params[3].type, 1); 1634 checkParamTypeRef(params[3].type, 1);
1617 } 1635 }
1618 1636
1619 test_import_deferred() { 1637 test_import_deferred() {
1620 serializeLibraryText( 1638 serializeLibraryText(
1621 'import "dart:async" deferred as a; main() { print(a.Future); }'); 1639 'import "dart:async" deferred as a; main() { print(a.Future); }');
1622 expect(definingUnit.unlinked.imports[0].isDeferred, isTrue); 1640 expect(unlinkedUnits[0].imports[0].isDeferred, isTrue);
1623 } 1641 }
1624 1642
1625 test_import_dependency() { 1643 test_import_dependency() {
1626 serializeLibraryText('import "dart:async"; Future x;'); 1644 serializeLibraryText('import "dart:async"; Future x;');
1627 // Second import is the implicit import of dart:core 1645 // Second import is the implicit import of dart:core
1628 expect(definingUnit.unlinked.imports, hasLength(2)); 1646 expect(unlinkedUnits[0].imports, hasLength(2));
1629 checkDependency(lib.importDependencies[0], 'dart:async', 'dart:async'); 1647 checkDependency(
1648 prelinked.importDependencies[0], 'dart:async', 'dart:async');
1630 } 1649 }
1631 1650
1632 test_import_explicit() { 1651 test_import_explicit() {
1633 serializeLibraryText('import "dart:core"; int i;'); 1652 serializeLibraryText('import "dart:core"; int i;');
1634 expect(definingUnit.unlinked.imports, hasLength(1)); 1653 expect(unlinkedUnits[0].imports, hasLength(1));
1635 expect(definingUnit.unlinked.imports[0].isImplicit, isFalse); 1654 expect(unlinkedUnits[0].imports[0].isImplicit, isFalse);
1636 } 1655 }
1637 1656
1638 test_import_hide_order() { 1657 test_import_hide_order() {
1639 serializeLibraryText( 1658 serializeLibraryText(
1640 'import "dart:async" hide Future, Stream; Completer c;'); 1659 'import "dart:async" hide Future, Stream; Completer c;');
1641 // Second import is the implicit import of dart:core 1660 // Second import is the implicit import of dart:core
1642 expect(definingUnit.unlinked.imports, hasLength(2)); 1661 expect(unlinkedUnits[0].imports, hasLength(2));
1643 expect(definingUnit.unlinked.imports[0].combinators, hasLength(1)); 1662 expect(unlinkedUnits[0].imports[0].combinators, hasLength(1));
1644 expect(definingUnit.unlinked.imports[0].combinators[0].shows, isEmpty); 1663 expect(unlinkedUnits[0].imports[0].combinators[0].shows, isEmpty);
1645 expect(definingUnit.unlinked.imports[0].combinators[0].hides, hasLength(2)); 1664 expect(unlinkedUnits[0].imports[0].combinators[0].hides, hasLength(2));
1646 checkCombinatorName( 1665 checkCombinatorName(
1647 definingUnit.unlinked.imports[0].combinators[0].hides[0], 'Future'); 1666 unlinkedUnits[0].imports[0].combinators[0].hides[0], 'Future');
1648 checkCombinatorName( 1667 checkCombinatorName(
1649 definingUnit.unlinked.imports[0].combinators[0].hides[1], 'Stream'); 1668 unlinkedUnits[0].imports[0].combinators[0].hides[1], 'Stream');
1650 } 1669 }
1651 1670
1652 test_import_implicit() { 1671 test_import_implicit() {
1653 // The implicit import of dart:core is represented in the model. 1672 // The implicit import of dart:core is represented in the model.
1654 serializeLibraryText(''); 1673 serializeLibraryText('');
1655 expect(definingUnit.unlinked.imports, hasLength(1)); 1674 expect(unlinkedUnits[0].imports, hasLength(1));
1656 checkDependency(lib.importDependencies[0], 'dart:core', 'dart:core'); 1675 checkDependency(prelinked.importDependencies[0], 'dart:core', 'dart:core');
1657 expect(definingUnit.unlinked.imports[0].uri, isEmpty); 1676 expect(unlinkedUnits[0].imports[0].uri, isEmpty);
1658 expect(definingUnit.unlinked.imports[0].prefixReference, 0); 1677 expect(unlinkedUnits[0].imports[0].prefixReference, 0);
1659 expect(definingUnit.unlinked.imports[0].combinators, isEmpty); 1678 expect(unlinkedUnits[0].imports[0].combinators, isEmpty);
1660 expect(definingUnit.unlinked.imports[0].isImplicit, isTrue); 1679 expect(unlinkedUnits[0].imports[0].isImplicit, isTrue);
1661 } 1680 }
1662 1681
1663 test_import_no_combinators() { 1682 test_import_no_combinators() {
1664 serializeLibraryText('import "dart:async"; Future x;'); 1683 serializeLibraryText('import "dart:async"; Future x;');
1665 // Second import is the implicit import of dart:core 1684 // Second import is the implicit import of dart:core
1666 expect(definingUnit.unlinked.imports, hasLength(2)); 1685 expect(unlinkedUnits[0].imports, hasLength(2));
1667 expect(definingUnit.unlinked.imports[0].combinators, isEmpty); 1686 expect(unlinkedUnits[0].imports[0].combinators, isEmpty);
1668 } 1687 }
1669 1688
1670 test_import_no_flags() { 1689 test_import_no_flags() {
1671 serializeLibraryText('import "dart:async"; Future x;'); 1690 serializeLibraryText('import "dart:async"; Future x;');
1672 expect(definingUnit.unlinked.imports[0].isImplicit, isFalse); 1691 expect(unlinkedUnits[0].imports[0].isImplicit, isFalse);
1673 expect(definingUnit.unlinked.imports[0].isDeferred, isFalse); 1692 expect(unlinkedUnits[0].imports[0].isDeferred, isFalse);
1674 } 1693 }
1675 1694
1676 test_import_non_deferred() { 1695 test_import_non_deferred() {
1677 serializeLibraryText( 1696 serializeLibraryText(
1678 'import "dart:async" as a; main() { print(a.Future); }'); 1697 'import "dart:async" as a; main() { print(a.Future); }');
1679 expect(definingUnit.unlinked.imports[0].isDeferred, isFalse); 1698 expect(unlinkedUnits[0].imports[0].isDeferred, isFalse);
1680 } 1699 }
1681 1700
1682 test_import_of_file_with_missing_part() { 1701 test_import_of_file_with_missing_part() {
1683 // Other references in foo.dart should be resolved even though foo.dart's 1702 // Other references in foo.dart should be resolved even though foo.dart's
1684 // part declaration for bar.dart refers to a non-existent file. 1703 // part declaration for bar.dart refers to a non-existent file.
1685 addNamedSource('/foo.dart', 'part "bar.dart"; class C {}'); 1704 addNamedSource('/foo.dart', 'part "bar.dart"; class C {}');
1686 serializeLibraryText('import "foo.dart"; C x;'); 1705 serializeLibraryText('import "foo.dart"; C x;');
1687 checkTypeRef(findVariable('x').type, absUri('/foo.dart'), 'foo.dart', 'C'); 1706 checkTypeRef(findVariable('x').type, absUri('/foo.dart'), 'foo.dart', 'C');
1688 } 1707 }
1689 1708
1690 test_import_of_missing_export() { 1709 test_import_of_missing_export() {
1691 // Other references in foo.dart should be resolved even though foo.dart's 1710 // Other references in foo.dart should be resolved even though foo.dart's
1692 // re-export of bar.dart refers to a non-existent file. 1711 // re-export of bar.dart refers to a non-existent file.
1693 addNamedSource('/foo.dart', 'export "bar.dart"; class C {}'); 1712 addNamedSource('/foo.dart', 'export "bar.dart"; class C {}');
1694 serializeLibraryText('import "foo.dart"; C x;'); 1713 serializeLibraryText('import "foo.dart"; C x;');
1695 checkTypeRef(findVariable('x').type, absUri('/foo.dart'), 'foo.dart', 'C'); 1714 checkTypeRef(findVariable('x').type, absUri('/foo.dart'), 'foo.dart', 'C');
1696 } 1715 }
1697 1716
1698 test_import_offset() { 1717 test_import_offset() {
1699 String libraryText = ' import "dart:async"; Future x;'; 1718 String libraryText = ' import "dart:async"; Future x;';
1700 serializeLibraryText(libraryText); 1719 serializeLibraryText(libraryText);
1701 expect( 1720 expect(unlinkedUnits[0].imports[0].offset, libraryText.indexOf('import'));
1702 definingUnit.unlinked.imports[0].offset, libraryText.indexOf('import'));
1703 } 1721 }
1704 1722
1705 test_import_prefix_name() { 1723 test_import_prefix_name() {
1706 String libraryText = 'import "dart:async" as a; a.Future x;'; 1724 String libraryText = 'import "dart:async" as a; a.Future x;';
1707 serializeLibraryText(libraryText); 1725 serializeLibraryText(libraryText);
1708 // Second import is the implicit import of dart:core 1726 // Second import is the implicit import of dart:core
1709 expect(definingUnit.unlinked.imports, hasLength(2)); 1727 expect(unlinkedUnits[0].imports, hasLength(2));
1710 checkPrefix(definingUnit.unlinked.imports[0].prefixReference, 'a'); 1728 checkPrefix(unlinkedUnits[0].imports[0].prefixReference, 'a');
1711 } 1729 }
1712 1730
1713 test_import_prefix_none() { 1731 test_import_prefix_none() {
1714 serializeLibraryText('import "dart:async"; Future x;'); 1732 serializeLibraryText('import "dart:async"; Future x;');
1715 // Second import is the implicit import of dart:core 1733 // Second import is the implicit import of dart:core
1716 expect(definingUnit.unlinked.imports, hasLength(2)); 1734 expect(unlinkedUnits[0].imports, hasLength(2));
1717 expect(definingUnit.unlinked.imports[0].prefixReference, 0); 1735 expect(unlinkedUnits[0].imports[0].prefixReference, 0);
1718 } 1736 }
1719 1737
1720 test_import_prefix_reference() { 1738 test_import_prefix_reference() {
1721 UnlinkedVariable variable = 1739 UnlinkedVariable variable =
1722 serializeVariableText('import "dart:async" as a; a.Future v;'); 1740 serializeVariableText('import "dart:async" as a; a.Future v;');
1723 checkTypeRef(variable.type, 'dart:async', 'dart:async', 'Future', 1741 checkTypeRef(variable.type, 'dart:async', 'dart:async', 'Future',
1724 expectedPrefix: 'a'); 1742 expectedPrefix: 'a');
1725 } 1743 }
1726 1744
1727 test_import_reference() { 1745 test_import_reference() {
(...skipping 26 matching lines...) Expand all
1754 expectedPrefix: 'a'); 1772 expectedPrefix: 'a');
1755 checkTypeRef(findVariable('s').type, 'dart:async', 'dart:async', 'Stream', 1773 checkTypeRef(findVariable('s').type, 'dart:async', 'dart:async', 'Stream',
1756 expectedPrefix: 'a'); 1774 expectedPrefix: 'a');
1757 } 1775 }
1758 1776
1759 test_import_show_order() { 1777 test_import_show_order() {
1760 String libraryText = 1778 String libraryText =
1761 'import "dart:async" show Future, Stream; Future x; Stream y;'; 1779 'import "dart:async" show Future, Stream; Future x; Stream y;';
1762 serializeLibraryText(libraryText); 1780 serializeLibraryText(libraryText);
1763 // Second import is the implicit import of dart:core 1781 // Second import is the implicit import of dart:core
1764 expect(definingUnit.unlinked.imports, hasLength(2)); 1782 expect(unlinkedUnits[0].imports, hasLength(2));
1765 expect(definingUnit.unlinked.imports[0].combinators, hasLength(1)); 1783 expect(unlinkedUnits[0].imports[0].combinators, hasLength(1));
1766 expect(definingUnit.unlinked.imports[0].combinators[0].shows, hasLength(2)); 1784 expect(unlinkedUnits[0].imports[0].combinators[0].shows, hasLength(2));
1767 expect(definingUnit.unlinked.imports[0].combinators[0].hides, isEmpty); 1785 expect(unlinkedUnits[0].imports[0].combinators[0].hides, isEmpty);
1768 checkCombinatorName( 1786 checkCombinatorName(
1769 definingUnit.unlinked.imports[0].combinators[0].shows[0], 'Future'); 1787 unlinkedUnits[0].imports[0].combinators[0].shows[0], 'Future');
1770 checkCombinatorName( 1788 checkCombinatorName(
1771 definingUnit.unlinked.imports[0].combinators[0].shows[1], 'Stream'); 1789 unlinkedUnits[0].imports[0].combinators[0].shows[1], 'Stream');
1772 } 1790 }
1773 1791
1774 test_import_uri() { 1792 test_import_uri() {
1775 String uriString = '"dart:async"'; 1793 String uriString = '"dart:async"';
1776 String libraryText = 'import $uriString; Future x;'; 1794 String libraryText = 'import $uriString; Future x;';
1777 serializeLibraryText(libraryText); 1795 serializeLibraryText(libraryText);
1778 // Second import is the implicit import of dart:core 1796 // Second import is the implicit import of dart:core
1779 expect(definingUnit.unlinked.imports, hasLength(2)); 1797 expect(unlinkedUnits[0].imports, hasLength(2));
1780 expect(definingUnit.unlinked.imports[0].uri, 'dart:async'); 1798 expect(unlinkedUnits[0].imports[0].uri, 'dart:async');
1781 } 1799 }
1782 1800
1783 test_library_named() { 1801 test_library_named() {
1784 String text = 'library foo.bar;'; 1802 String text = 'library foo.bar;';
1785 serializeLibraryText(text); 1803 serializeLibraryText(text);
1786 expect(definingUnit.unlinked.libraryName, 'foo.bar'); 1804 expect(unlinkedUnits[0].libraryName, 'foo.bar');
1787 } 1805 }
1788 1806
1789 test_library_unnamed() { 1807 test_library_unnamed() {
1790 serializeLibraryText(''); 1808 serializeLibraryText('');
1791 expect(definingUnit.unlinked.libraryName, isEmpty); 1809 expect(unlinkedUnits[0].libraryName, isEmpty);
1792 } 1810 }
1793 1811
1794 test_parts_defining_compilation_unit() { 1812 test_parts_defining_compilation_unit() {
1795 serializeLibraryText(''); 1813 serializeLibraryText('');
1796 expect(lib.units, hasLength(1)); 1814 expect(prelinked.units, hasLength(1));
1797 expect(definingUnit.unlinked.parts, isEmpty); 1815 expect(unlinkedUnits[0].parts, isEmpty);
1798 } 1816 }
1799 1817
1800 test_parts_included() { 1818 test_parts_included() {
1801 addNamedSource('/part1.dart', 'part of my.lib;'); 1819 addNamedSource('/part1.dart', 'part of my.lib;');
1802 String partString = '"part1.dart"'; 1820 String partString = '"part1.dart"';
1803 String libraryText = 'library my.lib; part $partString;'; 1821 String libraryText = 'library my.lib; part $partString;';
1804 serializeLibraryText(libraryText); 1822 serializeLibraryText(libraryText);
1805 expect(lib.units, hasLength(2)); 1823 expect(prelinked.units, hasLength(2));
1806 expect(definingUnit.unlinked.parts, hasLength(1)); 1824 expect(unlinkedUnits[0].parts, hasLength(1));
1807 expect(definingUnit.unlinked.parts[0].uri, 'part1.dart'); 1825 expect(unlinkedUnits[0].parts[0].uri, 'part1.dart');
1808 } 1826 }
1809 1827
1810 test_type_arguments_explicit() { 1828 test_type_arguments_explicit() {
1811 UnlinkedTypeRef typeRef = serializeTypeText('List<int>'); 1829 UnlinkedTypeRef typeRef = serializeTypeText('List<int>');
1812 checkTypeRef(typeRef, 'dart:core', 'dart:core', 'List', 1830 checkTypeRef(typeRef, 'dart:core', 'dart:core', 'List',
1813 allowTypeParameters: true); 1831 allowTypeParameters: true);
1814 expect(typeRef.typeArguments, hasLength(1)); 1832 expect(typeRef.typeArguments, hasLength(1));
1815 checkTypeRef(typeRef.typeArguments[0], 'dart:core', 'dart:core', 'int'); 1833 checkTypeRef(typeRef.typeArguments[0], 'dart:core', 'dart:core', 'int');
1816 } 1834 }
1817 1835
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
1866 checkTypeRef(typeRef.typeArguments[1], 'dart:core', 'dart:core', 'Object'); 1884 checkTypeRef(typeRef.typeArguments[1], 'dart:core', 'dart:core', 'Object');
1867 } 1885 }
1868 1886
1869 test_type_dynamic() { 1887 test_type_dynamic() {
1870 checkDynamicTypeRef(serializeTypeText('dynamic')); 1888 checkDynamicTypeRef(serializeTypeText('dynamic'));
1871 } 1889 }
1872 1890
1873 test_type_reference_from_part() { 1891 test_type_reference_from_part() {
1874 addNamedSource('/a.dart', 'part of foo; C v;'); 1892 addNamedSource('/a.dart', 'part of foo; C v;');
1875 serializeLibraryText('library foo; part "a.dart"; class C {}'); 1893 serializeLibraryText('library foo; part "a.dart"; class C {}');
1876 checkTypeRef( 1894 checkTypeRef(findVariable('v', variables: unlinkedUnits[1].variables).type,
1877 findVariable('v', variables: lib.units[1].unlinked.variables).type, 1895 null, null, 'C',
1878 null,
1879 null,
1880 'C',
1881 expectedKind: PrelinkedReferenceKind.classOrEnum, 1896 expectedKind: PrelinkedReferenceKind.classOrEnum,
1882 sourceUnit: lib.units[1]); 1897 prelinkedSourceUnit: prelinked.units[1],
1898 unlinkedSourceUnit: unlinkedUnits[1]);
1883 } 1899 }
1884 1900
1885 test_type_reference_to_class_argument() { 1901 test_type_reference_to_class_argument() {
1886 UnlinkedClass cls = serializeClassText('class C<T, U> { T t; U u; }'); 1902 UnlinkedClass cls = serializeClassText('class C<T, U> { T t; U u; }');
1887 { 1903 {
1888 UnlinkedTypeRef typeRef = 1904 UnlinkedTypeRef typeRef =
1889 findVariable('t', variables: cls.fields, failIfAbsent: true).type; 1905 findVariable('t', variables: cls.fields, failIfAbsent: true).type;
1890 checkParamTypeRef(typeRef, 2); 1906 checkParamTypeRef(typeRef, 2);
1891 } 1907 }
1892 { 1908 {
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
2129 serializeClassText('class C { static int i; }').fields[0]; 2145 serializeClassText('class C { static int i; }').fields[0];
2130 expect(variable.isStatic, isTrue); 2146 expect(variable.isStatic, isTrue);
2131 } 2147 }
2132 2148
2133 test_variable_type() { 2149 test_variable_type() {
2134 UnlinkedVariable variable = 2150 UnlinkedVariable variable =
2135 serializeVariableText('int i;', variableName: 'i'); 2151 serializeVariableText('int i;', variableName: 'i');
2136 checkTypeRef(variable.type, 'dart:core', 'dart:core', 'int'); 2152 checkTypeRef(variable.type, 'dart:core', 'dart:core', 'int');
2137 } 2153 }
2138 } 2154 }
OLDNEW
« no previous file with comments | « pkg/analyzer/test/src/summary/resynthesize_test.dart ('k') | pkg/analyzer/tool/summary/idl.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698