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

Side by Side Diff: pkg/analyzer/test/generated/resolver_test.dart

Issue 2524903002: Rename AstFactory -> AstTestFactory. (Closed)
Patch Set: Created 4 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) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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.generated.resolver_test; 5 library analyzer.test.generated.resolver_test;
6 6
7 import 'dart:collection'; 7 import 'dart:collection';
8 8
9 import 'package:analyzer/dart/ast/ast.dart'; 9 import 'package:analyzer/dart/ast/ast.dart';
10 import 'package:analyzer/dart/ast/token.dart'; 10 import 'package:analyzer/dart/ast/token.dart';
11 import 'package:analyzer/dart/ast/visitor.dart'; 11 import 'package:analyzer/dart/ast/visitor.dart';
12 import 'package:analyzer/dart/element/element.dart'; 12 import 'package:analyzer/dart/element/element.dart';
13 import 'package:analyzer/dart/element/type.dart'; 13 import 'package:analyzer/dart/element/type.dart';
14 import 'package:analyzer/file_system/memory_file_system.dart'; 14 import 'package:analyzer/file_system/memory_file_system.dart';
15 import 'package:analyzer/src/dart/element/builder.dart'; 15 import 'package:analyzer/src/dart/element/builder.dart';
16 import 'package:analyzer/src/dart/element/element.dart'; 16 import 'package:analyzer/src/dart/element/element.dart';
17 import 'package:analyzer/src/dart/element/type.dart'; 17 import 'package:analyzer/src/dart/element/type.dart';
18 import 'package:analyzer/src/error/codes.dart'; 18 import 'package:analyzer/src/error/codes.dart';
19 import 'package:analyzer/src/generated/engine.dart'; 19 import 'package:analyzer/src/generated/engine.dart';
20 import 'package:analyzer/src/generated/parser.dart' show ParserErrorCode; 20 import 'package:analyzer/src/generated/parser.dart' show ParserErrorCode;
21 import 'package:analyzer/src/generated/resolver.dart'; 21 import 'package:analyzer/src/generated/resolver.dart';
22 import 'package:analyzer/src/generated/source_io.dart'; 22 import 'package:analyzer/src/generated/source_io.dart';
23 import 'package:analyzer/src/generated/testing/ast_factory.dart'; 23 import 'package:analyzer/src/generated/testing/ast_test_factory.dart';
24 import 'package:analyzer/src/generated/testing/element_factory.dart'; 24 import 'package:analyzer/src/generated/testing/element_factory.dart';
25 import 'package:analyzer/src/generated/testing/test_type_provider.dart'; 25 import 'package:analyzer/src/generated/testing/test_type_provider.dart';
26 import 'package:analyzer/src/generated/utilities_dart.dart'; 26 import 'package:analyzer/src/generated/utilities_dart.dart';
27 import 'package:analyzer/src/source/source_resource.dart'; 27 import 'package:analyzer/src/source/source_resource.dart';
28 import 'package:test/test.dart'; 28 import 'package:test/test.dart';
29 import 'package:test_reflective_loader/test_reflective_loader.dart'; 29 import 'package:test_reflective_loader/test_reflective_loader.dart';
30 30
31 import 'analysis_context_factory.dart'; 31 import 'analysis_context_factory.dart';
32 import 'parser_test.dart'; 32 import 'parser_test.dart';
33 import 'resolver_test_case.dart'; 33 import 'resolver_test_case.dart';
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 .removedContainer(new SourceContainer_ChangeSetTest_test_toString()); 140 .removedContainer(new SourceContainer_ChangeSetTest_test_toString());
141 expect(changeSet.toString(), isNotNull); 141 expect(changeSet.toString(), isNotNull);
142 } 142 }
143 } 143 }
144 144
145 @reflectiveTest 145 @reflectiveTest
146 class EnclosedScopeTest extends ResolverTestCase { 146 class EnclosedScopeTest extends ResolverTestCase {
147 void test_define_duplicate() { 147 void test_define_duplicate() {
148 Scope rootScope = new _RootScope(); 148 Scope rootScope = new _RootScope();
149 EnclosedScope scope = new EnclosedScope(rootScope); 149 EnclosedScope scope = new EnclosedScope(rootScope);
150 SimpleIdentifier identifier = AstFactory.identifier3('v'); 150 SimpleIdentifier identifier = AstTestFactory.identifier3('v');
151 VariableElement element1 = ElementFactory.localVariableElement(identifier); 151 VariableElement element1 = ElementFactory.localVariableElement(identifier);
152 VariableElement element2 = ElementFactory.localVariableElement(identifier); 152 VariableElement element2 = ElementFactory.localVariableElement(identifier);
153 scope.define(element1); 153 scope.define(element1);
154 scope.define(element2); 154 scope.define(element2);
155 expect(scope.lookup(identifier, null), same(element1)); 155 expect(scope.lookup(identifier, null), same(element1));
156 } 156 }
157 } 157 }
158 158
159 @reflectiveTest 159 @reflectiveTest
160 class ErrorResolverTest extends ResolverTestCase { 160 class ErrorResolverTest extends ResolverTestCase {
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 250
251 @reflectiveTest 251 @reflectiveTest
252 class LibraryImportScopeTest extends ResolverTestCase { 252 class LibraryImportScopeTest extends ResolverTestCase {
253 void test_creation_empty() { 253 void test_creation_empty() {
254 new LibraryImportScope(createDefaultTestLibrary()); 254 new LibraryImportScope(createDefaultTestLibrary());
255 } 255 }
256 256
257 void test_creation_nonEmpty() { 257 void test_creation_nonEmpty() {
258 AnalysisContext context = AnalysisContextFactory.contextWithCore(); 258 AnalysisContext context = AnalysisContextFactory.contextWithCore();
259 String importedTypeName = "A"; 259 String importedTypeName = "A";
260 ClassElement importedType = 260 ClassElement importedType = new ClassElementImpl.forNode(
261 new ClassElementImpl.forNode(AstFactory.identifier3(importedTypeName)); 261 AstTestFactory.identifier3(importedTypeName));
262 LibraryElement importedLibrary = createTestLibrary(context, "imported"); 262 LibraryElement importedLibrary = createTestLibrary(context, "imported");
263 (importedLibrary.definingCompilationUnit as CompilationUnitElementImpl) 263 (importedLibrary.definingCompilationUnit as CompilationUnitElementImpl)
264 .types = <ClassElement>[importedType]; 264 .types = <ClassElement>[importedType];
265 LibraryElementImpl definingLibrary = 265 LibraryElementImpl definingLibrary =
266 createTestLibrary(context, "importing"); 266 createTestLibrary(context, "importing");
267 ImportElementImpl importElement = new ImportElementImpl(0); 267 ImportElementImpl importElement = new ImportElementImpl(0);
268 importElement.importedLibrary = importedLibrary; 268 importElement.importedLibrary = importedLibrary;
269 definingLibrary.imports = <ImportElement>[importElement]; 269 definingLibrary.imports = <ImportElement>[importElement];
270 Scope scope = new LibraryImportScope(definingLibrary); 270 Scope scope = new LibraryImportScope(definingLibrary);
271 expect( 271 expect(
272 scope.lookup(AstFactory.identifier3(importedTypeName), definingLibrary), 272 scope.lookup(
273 AstTestFactory.identifier3(importedTypeName), definingLibrary),
273 importedType); 274 importedType);
274 } 275 }
275 276
276 void test_prefixedAndNonPrefixed() { 277 void test_prefixedAndNonPrefixed() {
277 AnalysisContext context = AnalysisContextFactory.contextWithCore(); 278 AnalysisContext context = AnalysisContextFactory.contextWithCore();
278 String typeName = "C"; 279 String typeName = "C";
279 String prefixName = "p"; 280 String prefixName = "p";
280 ClassElement prefixedType = ElementFactory.classElement2(typeName); 281 ClassElement prefixedType = ElementFactory.classElement2(typeName);
281 ClassElement nonPrefixedType = ElementFactory.classElement2(typeName); 282 ClassElement nonPrefixedType = ElementFactory.classElement2(typeName);
282 LibraryElement prefixedLibrary = 283 LibraryElement prefixedLibrary =
283 createTestLibrary(context, "import.prefixed"); 284 createTestLibrary(context, "import.prefixed");
284 (prefixedLibrary.definingCompilationUnit as CompilationUnitElementImpl) 285 (prefixedLibrary.definingCompilationUnit as CompilationUnitElementImpl)
285 .types = <ClassElement>[prefixedType]; 286 .types = <ClassElement>[prefixedType];
286 ImportElementImpl prefixedImport = ElementFactory.importFor( 287 ImportElementImpl prefixedImport = ElementFactory.importFor(
287 prefixedLibrary, ElementFactory.prefix(prefixName)); 288 prefixedLibrary, ElementFactory.prefix(prefixName));
288 LibraryElement nonPrefixedLibrary = 289 LibraryElement nonPrefixedLibrary =
289 createTestLibrary(context, "import.nonPrefixed"); 290 createTestLibrary(context, "import.nonPrefixed");
290 (nonPrefixedLibrary.definingCompilationUnit as CompilationUnitElementImpl) 291 (nonPrefixedLibrary.definingCompilationUnit as CompilationUnitElementImpl)
291 .types = <ClassElement>[nonPrefixedType]; 292 .types = <ClassElement>[nonPrefixedType];
292 ImportElementImpl nonPrefixedImport = 293 ImportElementImpl nonPrefixedImport =
293 ElementFactory.importFor(nonPrefixedLibrary, null); 294 ElementFactory.importFor(nonPrefixedLibrary, null);
294 LibraryElementImpl importingLibrary = 295 LibraryElementImpl importingLibrary =
295 createTestLibrary(context, "importing"); 296 createTestLibrary(context, "importing");
296 importingLibrary.imports = <ImportElement>[ 297 importingLibrary.imports = <ImportElement>[
297 prefixedImport, 298 prefixedImport,
298 nonPrefixedImport 299 nonPrefixedImport
299 ]; 300 ];
300 Scope scope = new LibraryImportScope(importingLibrary); 301 Scope scope = new LibraryImportScope(importingLibrary);
301 Element prefixedElement = scope.lookup( 302 Element prefixedElement = scope.lookup(
302 AstFactory.identifier5(prefixName, typeName), importingLibrary); 303 AstTestFactory.identifier5(prefixName, typeName), importingLibrary);
303 expect(prefixedElement, same(prefixedType)); 304 expect(prefixedElement, same(prefixedType));
304 Element nonPrefixedElement = 305 Element nonPrefixedElement =
305 scope.lookup(AstFactory.identifier3(typeName), importingLibrary); 306 scope.lookup(AstTestFactory.identifier3(typeName), importingLibrary);
306 expect(nonPrefixedElement, same(nonPrefixedType)); 307 expect(nonPrefixedElement, same(nonPrefixedType));
307 } 308 }
308 } 309 }
309 310
310 @reflectiveTest 311 @reflectiveTest
311 class LibraryScopeTest extends ResolverTestCase { 312 class LibraryScopeTest extends ResolverTestCase {
312 void test_creation_empty() { 313 void test_creation_empty() {
313 new LibraryScope(createDefaultTestLibrary()); 314 new LibraryScope(createDefaultTestLibrary());
314 } 315 }
315 316
316 void test_creation_nonEmpty() { 317 void test_creation_nonEmpty() {
317 AnalysisContext context = AnalysisContextFactory.contextWithCore(); 318 AnalysisContext context = AnalysisContextFactory.contextWithCore();
318 String importedTypeName = "A"; 319 String importedTypeName = "A";
319 ClassElement importedType = 320 ClassElement importedType = new ClassElementImpl.forNode(
320 new ClassElementImpl.forNode(AstFactory.identifier3(importedTypeName)); 321 AstTestFactory.identifier3(importedTypeName));
321 LibraryElement importedLibrary = createTestLibrary(context, "imported"); 322 LibraryElement importedLibrary = createTestLibrary(context, "imported");
322 (importedLibrary.definingCompilationUnit as CompilationUnitElementImpl) 323 (importedLibrary.definingCompilationUnit as CompilationUnitElementImpl)
323 .types = <ClassElement>[importedType]; 324 .types = <ClassElement>[importedType];
324 LibraryElementImpl definingLibrary = 325 LibraryElementImpl definingLibrary =
325 createTestLibrary(context, "importing"); 326 createTestLibrary(context, "importing");
326 ImportElementImpl importElement = new ImportElementImpl(0); 327 ImportElementImpl importElement = new ImportElementImpl(0);
327 importElement.importedLibrary = importedLibrary; 328 importElement.importedLibrary = importedLibrary;
328 definingLibrary.imports = <ImportElement>[importElement]; 329 definingLibrary.imports = <ImportElement>[importElement];
329 Scope scope = new LibraryScope(definingLibrary); 330 Scope scope = new LibraryScope(definingLibrary);
330 expect( 331 expect(
331 scope.lookup(AstFactory.identifier3(importedTypeName), definingLibrary), 332 scope.lookup(
333 AstTestFactory.identifier3(importedTypeName), definingLibrary),
332 importedType); 334 importedType);
333 } 335 }
334 } 336 }
335 337
336 @reflectiveTest 338 @reflectiveTest
337 class PrefixedNamespaceTest extends ResolverTestCase { 339 class PrefixedNamespaceTest extends ResolverTestCase {
338 void test_lookup_missing() { 340 void test_lookup_missing() {
339 ClassElement element = ElementFactory.classElement2('A'); 341 ClassElement element = ElementFactory.classElement2('A');
340 PrefixedNamespace namespace = new PrefixedNamespace('p', _toMap([element])); 342 PrefixedNamespace namespace = new PrefixedNamespace('p', _toMap([element]));
341 expect(namespace.get('p.B'), isNull); 343 expect(namespace.get('p.B'), isNull);
(...skipping 17 matching lines...) Expand all
359 map[element.name] = element; 361 map[element.name] = element;
360 } 362 }
361 return map; 363 return map;
362 } 364 }
363 } 365 }
364 366
365 @reflectiveTest 367 @reflectiveTest
366 class ScopeTest extends ResolverTestCase { 368 class ScopeTest extends ResolverTestCase {
367 void test_define_duplicate() { 369 void test_define_duplicate() {
368 Scope scope = new _RootScope(); 370 Scope scope = new _RootScope();
369 SimpleIdentifier identifier = AstFactory.identifier3('v'); 371 SimpleIdentifier identifier = AstTestFactory.identifier3('v');
370 VariableElement element1 = ElementFactory.localVariableElement(identifier); 372 VariableElement element1 = ElementFactory.localVariableElement(identifier);
371 VariableElement element2 = ElementFactory.localVariableElement(identifier); 373 VariableElement element2 = ElementFactory.localVariableElement(identifier);
372 scope.define(element1); 374 scope.define(element1);
373 scope.define(element2); 375 scope.define(element2);
374 expect(scope.localLookup('v', null), same(element1)); 376 expect(scope.localLookup('v', null), same(element1));
375 } 377 }
376 378
377 void test_isPrivateName_nonPrivate() { 379 void test_isPrivateName_nonPrivate() {
378 expect(Scope.isPrivateName("Public"), isFalse); 380 expect(Scope.isPrivateName("Public"), isFalse);
379 } 381 }
(...skipping 2086 matching lines...) Expand 10 before | Expand all | Expand 10 after
2466 stackTraceType.element, 2468 stackTraceType.element,
2467 stringType.element, 2469 stringType.element,
2468 symbolType.element, 2470 symbolType.element,
2469 typeType.element 2471 typeType.element
2470 ]; 2472 ];
2471 CompilationUnitElementImpl asyncUnit = 2473 CompilationUnitElementImpl asyncUnit =
2472 new CompilationUnitElementImpl("async.dart"); 2474 new CompilationUnitElementImpl("async.dart");
2473 asyncUnit.types = <ClassElement>[futureType.element, streamType.element]; 2475 asyncUnit.types = <ClassElement>[futureType.element, streamType.element];
2474 AnalysisContext context = AnalysisEngine.instance.createAnalysisContext(); 2476 AnalysisContext context = AnalysisEngine.instance.createAnalysisContext();
2475 LibraryElementImpl coreLibrary = new LibraryElementImpl.forNode( 2477 LibraryElementImpl coreLibrary = new LibraryElementImpl.forNode(
2476 context, AstFactory.libraryIdentifier2(["dart.core"])); 2478 context, AstTestFactory.libraryIdentifier2(["dart.core"]));
2477 coreLibrary.definingCompilationUnit = coreUnit; 2479 coreLibrary.definingCompilationUnit = coreUnit;
2478 LibraryElementImpl asyncLibrary = new LibraryElementImpl.forNode( 2480 LibraryElementImpl asyncLibrary = new LibraryElementImpl.forNode(
2479 context, AstFactory.libraryIdentifier2(["dart.async"])); 2481 context, AstTestFactory.libraryIdentifier2(["dart.async"]));
2480 asyncLibrary.definingCompilationUnit = asyncUnit; 2482 asyncLibrary.definingCompilationUnit = asyncUnit;
2481 // 2483 //
2482 // Create a type provider and ensure that it can return the expected types. 2484 // Create a type provider and ensure that it can return the expected types.
2483 // 2485 //
2484 TypeProviderImpl provider = new TypeProviderImpl(coreLibrary, asyncLibrary); 2486 TypeProviderImpl provider = new TypeProviderImpl(coreLibrary, asyncLibrary);
2485 expect(provider.boolType, same(boolType)); 2487 expect(provider.boolType, same(boolType));
2486 expect(provider.bottomType, isNotNull); 2488 expect(provider.bottomType, isNotNull);
2487 expect(provider.doubleType, same(doubleType)); 2489 expect(provider.doubleType, same(doubleType));
2488 expect(provider.dynamicType, isNotNull); 2490 expect(provider.dynamicType, isNotNull);
2489 expect(provider.functionType, same(functionType)); 2491 expect(provider.functionType, same(functionType));
2490 expect(provider.futureType, same(futureType)); 2492 expect(provider.futureType, same(futureType));
2491 expect(provider.intType, same(intType)); 2493 expect(provider.intType, same(intType));
2492 expect(provider.listType, same(listType)); 2494 expect(provider.listType, same(listType));
2493 expect(provider.mapType, same(mapType)); 2495 expect(provider.mapType, same(mapType));
2494 expect(provider.objectType, same(objectType)); 2496 expect(provider.objectType, same(objectType));
2495 expect(provider.stackTraceType, same(stackTraceType)); 2497 expect(provider.stackTraceType, same(stackTraceType));
2496 expect(provider.streamType, same(streamType)); 2498 expect(provider.streamType, same(streamType));
2497 expect(provider.stringType, same(stringType)); 2499 expect(provider.stringType, same(stringType));
2498 expect(provider.symbolType, same(symbolType)); 2500 expect(provider.symbolType, same(symbolType));
2499 expect(provider.typeType, same(typeType)); 2501 expect(provider.typeType, same(typeType));
2500 } 2502 }
2501 2503
2502 ClassElement _classElement(String typeName, InterfaceType superclassType, 2504 ClassElement _classElement(String typeName, InterfaceType superclassType,
2503 [List<String> parameterNames]) { 2505 [List<String> parameterNames]) {
2504 ClassElementImpl element = 2506 ClassElementImpl element =
2505 new ClassElementImpl.forNode(AstFactory.identifier3(typeName)); 2507 new ClassElementImpl.forNode(AstTestFactory.identifier3(typeName));
2506 element.supertype = superclassType; 2508 element.supertype = superclassType;
2507 if (parameterNames != null) { 2509 if (parameterNames != null) {
2508 int count = parameterNames.length; 2510 int count = parameterNames.length;
2509 if (count > 0) { 2511 if (count > 0) {
2510 List<TypeParameterElementImpl> typeParameters = 2512 List<TypeParameterElementImpl> typeParameters =
2511 new List<TypeParameterElementImpl>(count); 2513 new List<TypeParameterElementImpl>(count);
2512 List<TypeParameterTypeImpl> typeArguments = 2514 List<TypeParameterTypeImpl> typeArguments =
2513 new List<TypeParameterTypeImpl>(count); 2515 new List<TypeParameterTypeImpl>(count);
2514 for (int i = 0; i < count; i++) { 2516 for (int i = 0; i < count; i++) {
2515 TypeParameterElementImpl typeParameter = 2517 TypeParameterElementImpl typeParameter =
2516 new TypeParameterElementImpl.forNode( 2518 new TypeParameterElementImpl.forNode(
2517 AstFactory.identifier3(parameterNames[i])); 2519 AstTestFactory.identifier3(parameterNames[i]));
2518 typeParameters[i] = typeParameter; 2520 typeParameters[i] = typeParameter;
2519 typeArguments[i] = new TypeParameterTypeImpl(typeParameter); 2521 typeArguments[i] = new TypeParameterTypeImpl(typeParameter);
2520 typeParameter.type = typeArguments[i]; 2522 typeParameter.type = typeArguments[i];
2521 } 2523 }
2522 element.typeParameters = typeParameters; 2524 element.typeParameters = typeParameters;
2523 } 2525 }
2524 } 2526 }
2525 return element; 2527 return element;
2526 } 2528 }
2527 } 2529 }
(...skipping 26 matching lines...) Expand all
2554 } 2556 }
2555 2557
2556 void fail_visitFunctionTypeAlias() { 2558 void fail_visitFunctionTypeAlias() {
2557 fail("Not yet tested"); 2559 fail("Not yet tested");
2558 _listener.assertNoErrors(); 2560 _listener.assertNoErrors();
2559 } 2561 }
2560 2562
2561 void fail_visitVariableDeclaration() { 2563 void fail_visitVariableDeclaration() {
2562 fail("Not yet tested"); 2564 fail("Not yet tested");
2563 ClassElement type = ElementFactory.classElement2("A"); 2565 ClassElement type = ElementFactory.classElement2("A");
2564 VariableDeclaration node = AstFactory.variableDeclaration("a"); 2566 VariableDeclaration node = AstTestFactory.variableDeclaration("a");
2565 AstFactory.variableDeclarationList(null, AstFactory.typeName(type), [node]); 2567 AstTestFactory
2568 .variableDeclarationList(null, AstTestFactory.typeName(type), [node]);
2566 //resolve(node); 2569 //resolve(node);
2567 expect(node.name.staticType, same(type.type)); 2570 expect(node.name.staticType, same(type.type));
2568 _listener.assertNoErrors(); 2571 _listener.assertNoErrors();
2569 } 2572 }
2570 2573
2571 void setUp() { 2574 void setUp() {
2572 _listener = new GatheringErrorListener(); 2575 _listener = new GatheringErrorListener();
2573 MemoryResourceProvider resourceProvider = new MemoryResourceProvider(); 2576 MemoryResourceProvider resourceProvider = new MemoryResourceProvider();
2574 InternalAnalysisContext context = AnalysisContextFactory.contextWithCore( 2577 InternalAnalysisContext context = AnalysisContextFactory.contextWithCore(
2575 resourceProvider: resourceProvider); 2578 resourceProvider: resourceProvider);
2576 Source librarySource = 2579 Source librarySource =
2577 new FileSource(resourceProvider.getFile("/lib.dart")); 2580 new FileSource(resourceProvider.getFile("/lib.dart"));
2578 LibraryElementImpl element = new LibraryElementImpl.forNode( 2581 LibraryElementImpl element = new LibraryElementImpl.forNode(
2579 context, AstFactory.libraryIdentifier2(["lib"])); 2582 context, AstTestFactory.libraryIdentifier2(["lib"]));
2580 element.definingCompilationUnit = 2583 element.definingCompilationUnit =
2581 new CompilationUnitElementImpl("lib.dart"); 2584 new CompilationUnitElementImpl("lib.dart");
2582 _typeProvider = new TestTypeProvider(); 2585 _typeProvider = new TestTypeProvider();
2583 libraryScope = new LibraryScope(element); 2586 libraryScope = new LibraryScope(element);
2584 _visitor = new TypeResolverVisitor( 2587 _visitor = new TypeResolverVisitor(
2585 element, librarySource, _typeProvider, _listener, 2588 element, librarySource, _typeProvider, _listener,
2586 nameScope: libraryScope); 2589 nameScope: libraryScope);
2587 } 2590 }
2588 2591
2589 void test_modeApi() { 2592 void test_modeApi() {
(...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after
2975 // The type of "v" is not resolved. 2978 // The type of "v" is not resolved.
2976 expect(v.variables.type.type, isNull); 2979 expect(v.variables.type.type, isNull);
2977 2980
2978 // The type of "v" initializer is resolved. 2981 // The type of "v" initializer is resolved.
2979 var vi = v.variables.variables[0].initializer as InstanceCreationExpression; 2982 var vi = v.variables.variables[0].initializer as InstanceCreationExpression;
2980 expect(vi.constructorName.type.type.toString(), 'A'); 2983 expect(vi.constructorName.type.type.toString(), 'A');
2981 } 2984 }
2982 2985
2983 void test_visitCatchClause_exception() { 2986 void test_visitCatchClause_exception() {
2984 // catch (e) 2987 // catch (e)
2985 CatchClause clause = AstFactory.catchClause("e"); 2988 CatchClause clause = AstTestFactory.catchClause("e");
2986 SimpleIdentifier exceptionParameter = clause.exceptionParameter; 2989 SimpleIdentifier exceptionParameter = clause.exceptionParameter;
2987 exceptionParameter.staticElement = 2990 exceptionParameter.staticElement =
2988 new LocalVariableElementImpl.forNode(exceptionParameter); 2991 new LocalVariableElementImpl.forNode(exceptionParameter);
2989 _resolveCatchClause(clause, _typeProvider.dynamicType, null); 2992 _resolveCatchClause(clause, _typeProvider.dynamicType, null);
2990 _listener.assertNoErrors(); 2993 _listener.assertNoErrors();
2991 } 2994 }
2992 2995
2993 void test_visitCatchClause_exception_stackTrace() { 2996 void test_visitCatchClause_exception_stackTrace() {
2994 // catch (e, s) 2997 // catch (e, s)
2995 CatchClause clause = AstFactory.catchClause2("e", "s"); 2998 CatchClause clause = AstTestFactory.catchClause2("e", "s");
2996 SimpleIdentifier exceptionParameter = clause.exceptionParameter; 2999 SimpleIdentifier exceptionParameter = clause.exceptionParameter;
2997 exceptionParameter.staticElement = 3000 exceptionParameter.staticElement =
2998 new LocalVariableElementImpl.forNode(exceptionParameter); 3001 new LocalVariableElementImpl.forNode(exceptionParameter);
2999 SimpleIdentifier stackTraceParameter = clause.stackTraceParameter; 3002 SimpleIdentifier stackTraceParameter = clause.stackTraceParameter;
3000 stackTraceParameter.staticElement = 3003 stackTraceParameter.staticElement =
3001 new LocalVariableElementImpl.forNode(stackTraceParameter); 3004 new LocalVariableElementImpl.forNode(stackTraceParameter);
3002 _resolveCatchClause( 3005 _resolveCatchClause(
3003 clause, _typeProvider.dynamicType, _typeProvider.stackTraceType); 3006 clause, _typeProvider.dynamicType, _typeProvider.stackTraceType);
3004 _listener.assertNoErrors(); 3007 _listener.assertNoErrors();
3005 } 3008 }
3006 3009
3007 void test_visitCatchClause_on_exception() { 3010 void test_visitCatchClause_on_exception() {
3008 // on E catch (e) 3011 // on E catch (e)
3009 ClassElement exceptionElement = ElementFactory.classElement2("E"); 3012 ClassElement exceptionElement = ElementFactory.classElement2("E");
3010 TypeName exceptionType = AstFactory.typeName(exceptionElement); 3013 TypeName exceptionType = AstTestFactory.typeName(exceptionElement);
3011 CatchClause clause = AstFactory.catchClause4(exceptionType, "e"); 3014 CatchClause clause = AstTestFactory.catchClause4(exceptionType, "e");
3012 SimpleIdentifier exceptionParameter = clause.exceptionParameter; 3015 SimpleIdentifier exceptionParameter = clause.exceptionParameter;
3013 exceptionParameter.staticElement = 3016 exceptionParameter.staticElement =
3014 new LocalVariableElementImpl.forNode(exceptionParameter); 3017 new LocalVariableElementImpl.forNode(exceptionParameter);
3015 _resolveCatchClause( 3018 _resolveCatchClause(
3016 clause, exceptionElement.type, null, [exceptionElement]); 3019 clause, exceptionElement.type, null, [exceptionElement]);
3017 _listener.assertNoErrors(); 3020 _listener.assertNoErrors();
3018 } 3021 }
3019 3022
3020 void test_visitCatchClause_on_exception_stackTrace() { 3023 void test_visitCatchClause_on_exception_stackTrace() {
3021 // on E catch (e, s) 3024 // on E catch (e, s)
3022 ClassElement exceptionElement = ElementFactory.classElement2("E"); 3025 ClassElement exceptionElement = ElementFactory.classElement2("E");
3023 TypeName exceptionType = AstFactory.typeName(exceptionElement); 3026 TypeName exceptionType = AstTestFactory.typeName(exceptionElement);
3024 (exceptionType.name as SimpleIdentifier).staticElement = exceptionElement; 3027 (exceptionType.name as SimpleIdentifier).staticElement = exceptionElement;
3025 CatchClause clause = AstFactory.catchClause5(exceptionType, "e", "s"); 3028 CatchClause clause = AstTestFactory.catchClause5(exceptionType, "e", "s");
3026 SimpleIdentifier exceptionParameter = clause.exceptionParameter; 3029 SimpleIdentifier exceptionParameter = clause.exceptionParameter;
3027 exceptionParameter.staticElement = 3030 exceptionParameter.staticElement =
3028 new LocalVariableElementImpl.forNode(exceptionParameter); 3031 new LocalVariableElementImpl.forNode(exceptionParameter);
3029 SimpleIdentifier stackTraceParameter = clause.stackTraceParameter; 3032 SimpleIdentifier stackTraceParameter = clause.stackTraceParameter;
3030 stackTraceParameter.staticElement = 3033 stackTraceParameter.staticElement =
3031 new LocalVariableElementImpl.forNode(stackTraceParameter); 3034 new LocalVariableElementImpl.forNode(stackTraceParameter);
3032 _resolveCatchClause(clause, exceptionElement.type, 3035 _resolveCatchClause(clause, exceptionElement.type,
3033 _typeProvider.stackTraceType, [exceptionElement]); 3036 _typeProvider.stackTraceType, [exceptionElement]);
3034 _listener.assertNoErrors(); 3037 _listener.assertNoErrors();
3035 } 3038 }
3036 3039
3037 void test_visitClassDeclaration() { 3040 void test_visitClassDeclaration() {
3038 // class A extends B with C implements D {} 3041 // class A extends B with C implements D {}
3039 // class B {} 3042 // class B {}
3040 // class C {} 3043 // class C {}
3041 // class D {} 3044 // class D {}
3042 ClassElement elementA = ElementFactory.classElement2("A"); 3045 ClassElement elementA = ElementFactory.classElement2("A");
3043 ClassElement elementB = ElementFactory.classElement2("B"); 3046 ClassElement elementB = ElementFactory.classElement2("B");
3044 ClassElement elementC = ElementFactory.classElement2("C"); 3047 ClassElement elementC = ElementFactory.classElement2("C");
3045 ClassElement elementD = ElementFactory.classElement2("D"); 3048 ClassElement elementD = ElementFactory.classElement2("D");
3046 ExtendsClause extendsClause = 3049 ExtendsClause extendsClause =
3047 AstFactory.extendsClause(AstFactory.typeName(elementB)); 3050 AstTestFactory.extendsClause(AstTestFactory.typeName(elementB));
3048 WithClause withClause = 3051 WithClause withClause =
3049 AstFactory.withClause([AstFactory.typeName(elementC)]); 3052 AstTestFactory.withClause([AstTestFactory.typeName(elementC)]);
3050 ImplementsClause implementsClause = 3053 ImplementsClause implementsClause =
3051 AstFactory.implementsClause([AstFactory.typeName(elementD)]); 3054 AstTestFactory.implementsClause([AstTestFactory.typeName(elementD)]);
3052 ClassDeclaration declaration = AstFactory.classDeclaration( 3055 ClassDeclaration declaration = AstTestFactory.classDeclaration(
3053 null, "A", null, extendsClause, withClause, implementsClause); 3056 null, "A", null, extendsClause, withClause, implementsClause);
3054 declaration.name.staticElement = elementA; 3057 declaration.name.staticElement = elementA;
3055 _resolveNode(declaration, [elementA, elementB, elementC, elementD]); 3058 _resolveNode(declaration, [elementA, elementB, elementC, elementD]);
3056 expect(elementA.supertype, same(elementB.type)); 3059 expect(elementA.supertype, same(elementB.type));
3057 List<InterfaceType> mixins = elementA.mixins; 3060 List<InterfaceType> mixins = elementA.mixins;
3058 expect(mixins, hasLength(1)); 3061 expect(mixins, hasLength(1));
3059 expect(mixins[0], same(elementC.type)); 3062 expect(mixins[0], same(elementC.type));
3060 List<InterfaceType> interfaces = elementA.interfaces; 3063 List<InterfaceType> interfaces = elementA.interfaces;
3061 expect(interfaces, hasLength(1)); 3064 expect(interfaces, hasLength(1));
3062 expect(interfaces[0], same(elementD.type)); 3065 expect(interfaces[0], same(elementD.type));
3063 _listener.assertNoErrors(); 3066 _listener.assertNoErrors();
3064 } 3067 }
3065 3068
3066 void test_visitClassDeclaration_instanceMemberCollidesWithClass() { 3069 void test_visitClassDeclaration_instanceMemberCollidesWithClass() {
3067 // class A {} 3070 // class A {}
3068 // class B extends A { 3071 // class B extends A {
3069 // void A() {} 3072 // void A() {}
3070 // } 3073 // }
3071 ClassElementImpl elementA = ElementFactory.classElement2("A"); 3074 ClassElementImpl elementA = ElementFactory.classElement2("A");
3072 ClassElementImpl elementB = ElementFactory.classElement2("B"); 3075 ClassElementImpl elementB = ElementFactory.classElement2("B");
3073 elementB.methods = <MethodElement>[ 3076 elementB.methods = <MethodElement>[
3074 ElementFactory.methodElement("A", VoidTypeImpl.instance) 3077 ElementFactory.methodElement("A", VoidTypeImpl.instance)
3075 ]; 3078 ];
3076 ExtendsClause extendsClause = 3079 ExtendsClause extendsClause =
3077 AstFactory.extendsClause(AstFactory.typeName(elementA)); 3080 AstTestFactory.extendsClause(AstTestFactory.typeName(elementA));
3078 ClassDeclaration declaration = 3081 ClassDeclaration declaration = AstTestFactory.classDeclaration(
3079 AstFactory.classDeclaration(null, "B", null, extendsClause, null, null); 3082 null, "B", null, extendsClause, null, null);
3080 declaration.name.staticElement = elementB; 3083 declaration.name.staticElement = elementB;
3081 _resolveNode(declaration, [elementA, elementB]); 3084 _resolveNode(declaration, [elementA, elementB]);
3082 expect(elementB.supertype, same(elementA.type)); 3085 expect(elementB.supertype, same(elementA.type));
3083 _listener.assertNoErrors(); 3086 _listener.assertNoErrors();
3084 } 3087 }
3085 3088
3086 void test_visitClassTypeAlias() { 3089 void test_visitClassTypeAlias() {
3087 // class A = B with C implements D; 3090 // class A = B with C implements D;
3088 ClassElement elementA = ElementFactory.classElement2("A"); 3091 ClassElement elementA = ElementFactory.classElement2("A");
3089 ClassElement elementB = ElementFactory.classElement2("B"); 3092 ClassElement elementB = ElementFactory.classElement2("B");
3090 ClassElement elementC = ElementFactory.classElement2("C"); 3093 ClassElement elementC = ElementFactory.classElement2("C");
3091 ClassElement elementD = ElementFactory.classElement2("D"); 3094 ClassElement elementD = ElementFactory.classElement2("D");
3092 WithClause withClause = 3095 WithClause withClause =
3093 AstFactory.withClause([AstFactory.typeName(elementC)]); 3096 AstTestFactory.withClause([AstTestFactory.typeName(elementC)]);
3094 ImplementsClause implementsClause = 3097 ImplementsClause implementsClause =
3095 AstFactory.implementsClause([AstFactory.typeName(elementD)]); 3098 AstTestFactory.implementsClause([AstTestFactory.typeName(elementD)]);
3096 ClassTypeAlias alias = AstFactory.classTypeAlias("A", null, null, 3099 ClassTypeAlias alias = AstTestFactory.classTypeAlias("A", null, null,
3097 AstFactory.typeName(elementB), withClause, implementsClause); 3100 AstTestFactory.typeName(elementB), withClause, implementsClause);
3098 alias.name.staticElement = elementA; 3101 alias.name.staticElement = elementA;
3099 _resolveNode(alias, [elementA, elementB, elementC, elementD]); 3102 _resolveNode(alias, [elementA, elementB, elementC, elementD]);
3100 expect(elementA.supertype, same(elementB.type)); 3103 expect(elementA.supertype, same(elementB.type));
3101 List<InterfaceType> mixins = elementA.mixins; 3104 List<InterfaceType> mixins = elementA.mixins;
3102 expect(mixins, hasLength(1)); 3105 expect(mixins, hasLength(1));
3103 expect(mixins[0], same(elementC.type)); 3106 expect(mixins[0], same(elementC.type));
3104 List<InterfaceType> interfaces = elementA.interfaces; 3107 List<InterfaceType> interfaces = elementA.interfaces;
3105 expect(interfaces, hasLength(1)); 3108 expect(interfaces, hasLength(1));
3106 expect(interfaces[0], same(elementD.type)); 3109 expect(interfaces[0], same(elementD.type));
3107 _listener.assertNoErrors(); 3110 _listener.assertNoErrors();
(...skipping 16 matching lines...) Expand all
3124 ElementFactory.constructorElement2(classB, 'c2', [classT.type]); 3127 ElementFactory.constructorElement2(classB, 'c2', [classT.type]);
3125 (constructorBc2.parameters[0] as ParameterElementImpl).parameterKind = 3128 (constructorBc2.parameters[0] as ParameterElementImpl).parameterKind =
3126 ParameterKind.POSITIONAL; 3129 ParameterKind.POSITIONAL;
3127 ConstructorElementImpl constructorBc3 = 3130 ConstructorElementImpl constructorBc3 =
3128 ElementFactory.constructorElement2(classB, 'c3', [classT.type]); 3131 ElementFactory.constructorElement2(classB, 'c3', [classT.type]);
3129 (constructorBc3.parameters[0] as ParameterElementImpl).parameterKind = 3132 (constructorBc3.parameters[0] as ParameterElementImpl).parameterKind =
3130 ParameterKind.NAMED; 3133 ParameterKind.NAMED;
3131 classB.constructors = [constructorBc1, constructorBc2, constructorBc3]; 3134 classB.constructors = [constructorBc1, constructorBc2, constructorBc3];
3132 ClassElement classM = ElementFactory.classElement2('M', []); 3135 ClassElement classM = ElementFactory.classElement2('M', []);
3133 WithClause withClause = 3136 WithClause withClause =
3134 AstFactory.withClause([AstFactory.typeName(classM, [])]); 3137 AstTestFactory.withClause([AstTestFactory.typeName(classM, [])]);
3135 ClassElement classC = ElementFactory.classTypeAlias2('C', []); 3138 ClassElement classC = ElementFactory.classTypeAlias2('C', []);
3136 ClassTypeAlias alias = AstFactory.classTypeAlias( 3139 ClassTypeAlias alias = AstTestFactory.classTypeAlias(
3137 'C', null, null, AstFactory.typeName(classB, []), withClause, null); 3140 'C', null, null, AstTestFactory.typeName(classB, []), withClause, null);
3138 alias.name.staticElement = classC; 3141 alias.name.staticElement = classC;
3139 _resolveNode(alias, [classT, classB, classM, classC]); 3142 _resolveNode(alias, [classT, classB, classM, classC]);
3140 expect(classC.constructors, hasLength(1)); 3143 expect(classC.constructors, hasLength(1));
3141 ConstructorElement constructor = classC.constructors[0]; 3144 ConstructorElement constructor = classC.constructors[0];
3142 expect(constructor.isFactory, isFalse); 3145 expect(constructor.isFactory, isFalse);
3143 expect(constructor.isSynthetic, isTrue); 3146 expect(constructor.isSynthetic, isTrue);
3144 expect(constructor.name, 'c1'); 3147 expect(constructor.name, 'c1');
3145 expect(constructor.functions, hasLength(0)); 3148 expect(constructor.functions, hasLength(0));
3146 expect(constructor.labels, hasLength(0)); 3149 expect(constructor.labels, hasLength(0));
3147 expect(constructor.localVariables, hasLength(0)); 3150 expect(constructor.localVariables, hasLength(0));
3148 expect(constructor.parameters, isEmpty); 3151 expect(constructor.parameters, isEmpty);
3149 } 3152 }
3150 3153
3151 void test_visitClassTypeAlias_constructorWithParams() { 3154 void test_visitClassTypeAlias_constructorWithParams() {
3152 // class T {} 3155 // class T {}
3153 // class B { 3156 // class B {
3154 // B(T a0); 3157 // B(T a0);
3155 // } 3158 // }
3156 // class M {} 3159 // class M {}
3157 // class C = B with M 3160 // class C = B with M
3158 ClassElement classT = ElementFactory.classElement2('T', []); 3161 ClassElement classT = ElementFactory.classElement2('T', []);
3159 ClassElementImpl classB = ElementFactory.classElement2('B', []); 3162 ClassElementImpl classB = ElementFactory.classElement2('B', []);
3160 ConstructorElementImpl constructorB = 3163 ConstructorElementImpl constructorB =
3161 ElementFactory.constructorElement2(classB, '', [classT.type]); 3164 ElementFactory.constructorElement2(classB, '', [classT.type]);
3162 classB.constructors = [constructorB]; 3165 classB.constructors = [constructorB];
3163 ClassElement classM = ElementFactory.classElement2('M', []); 3166 ClassElement classM = ElementFactory.classElement2('M', []);
3164 WithClause withClause = 3167 WithClause withClause =
3165 AstFactory.withClause([AstFactory.typeName(classM, [])]); 3168 AstTestFactory.withClause([AstTestFactory.typeName(classM, [])]);
3166 ClassElement classC = ElementFactory.classTypeAlias2('C', []); 3169 ClassElement classC = ElementFactory.classTypeAlias2('C', []);
3167 ClassTypeAlias alias = AstFactory.classTypeAlias( 3170 ClassTypeAlias alias = AstTestFactory.classTypeAlias(
3168 'C', null, null, AstFactory.typeName(classB, []), withClause, null); 3171 'C', null, null, AstTestFactory.typeName(classB, []), withClause, null);
3169 alias.name.staticElement = classC; 3172 alias.name.staticElement = classC;
3170 _resolveNode(alias, [classT, classB, classM, classC]); 3173 _resolveNode(alias, [classT, classB, classM, classC]);
3171 expect(classC.constructors, hasLength(1)); 3174 expect(classC.constructors, hasLength(1));
3172 ConstructorElement constructor = classC.constructors[0]; 3175 ConstructorElement constructor = classC.constructors[0];
3173 expect(constructor.isFactory, isFalse); 3176 expect(constructor.isFactory, isFalse);
3174 expect(constructor.isSynthetic, isTrue); 3177 expect(constructor.isSynthetic, isTrue);
3175 expect(constructor.name, ''); 3178 expect(constructor.name, '');
3176 expect(constructor.functions, hasLength(0)); 3179 expect(constructor.functions, hasLength(0));
3177 expect(constructor.labels, hasLength(0)); 3180 expect(constructor.labels, hasLength(0));
3178 expect(constructor.localVariables, hasLength(0)); 3181 expect(constructor.localVariables, hasLength(0));
3179 expect(constructor.parameters, hasLength(1)); 3182 expect(constructor.parameters, hasLength(1));
3180 expect(constructor.parameters[0].type, equals(classT.type)); 3183 expect(constructor.parameters[0].type, equals(classT.type));
3181 expect(constructor.parameters[0].name, 3184 expect(constructor.parameters[0].name,
3182 equals(constructorB.parameters[0].name)); 3185 equals(constructorB.parameters[0].name));
3183 } 3186 }
3184 3187
3185 void test_visitClassTypeAlias_defaultConstructor() { 3188 void test_visitClassTypeAlias_defaultConstructor() {
3186 // class B {} 3189 // class B {}
3187 // class M {} 3190 // class M {}
3188 // class C = B with M 3191 // class C = B with M
3189 ClassElementImpl classB = ElementFactory.classElement2('B', []); 3192 ClassElementImpl classB = ElementFactory.classElement2('B', []);
3190 ConstructorElementImpl constructorB = 3193 ConstructorElementImpl constructorB =
3191 ElementFactory.constructorElement2(classB, '', []); 3194 ElementFactory.constructorElement2(classB, '', []);
3192 constructorB.setModifier(Modifier.SYNTHETIC, true); 3195 constructorB.setModifier(Modifier.SYNTHETIC, true);
3193 classB.constructors = [constructorB]; 3196 classB.constructors = [constructorB];
3194 ClassElement classM = ElementFactory.classElement2('M', []); 3197 ClassElement classM = ElementFactory.classElement2('M', []);
3195 WithClause withClause = 3198 WithClause withClause =
3196 AstFactory.withClause([AstFactory.typeName(classM, [])]); 3199 AstTestFactory.withClause([AstTestFactory.typeName(classM, [])]);
3197 ClassElement classC = ElementFactory.classTypeAlias2('C', []); 3200 ClassElement classC = ElementFactory.classTypeAlias2('C', []);
3198 ClassTypeAlias alias = AstFactory.classTypeAlias( 3201 ClassTypeAlias alias = AstTestFactory.classTypeAlias(
3199 'C', null, null, AstFactory.typeName(classB, []), withClause, null); 3202 'C', null, null, AstTestFactory.typeName(classB, []), withClause, null);
3200 alias.name.staticElement = classC; 3203 alias.name.staticElement = classC;
3201 _resolveNode(alias, [classB, classM, classC]); 3204 _resolveNode(alias, [classB, classM, classC]);
3202 expect(classC.constructors, hasLength(1)); 3205 expect(classC.constructors, hasLength(1));
3203 ConstructorElement constructor = classC.constructors[0]; 3206 ConstructorElement constructor = classC.constructors[0];
3204 expect(constructor.isFactory, isFalse); 3207 expect(constructor.isFactory, isFalse);
3205 expect(constructor.isSynthetic, isTrue); 3208 expect(constructor.isSynthetic, isTrue);
3206 expect(constructor.name, ''); 3209 expect(constructor.name, '');
3207 expect(constructor.functions, hasLength(0)); 3210 expect(constructor.functions, hasLength(0));
3208 expect(constructor.labels, hasLength(0)); 3211 expect(constructor.labels, hasLength(0));
3209 expect(constructor.localVariables, hasLength(0)); 3212 expect(constructor.localVariables, hasLength(0));
3210 expect(constructor.parameters, isEmpty); 3213 expect(constructor.parameters, isEmpty);
3211 } 3214 }
3212 3215
3213 void test_visitFieldFormalParameter_functionType() { 3216 void test_visitFieldFormalParameter_functionType() {
3214 InterfaceType intType = _typeProvider.intType; 3217 InterfaceType intType = _typeProvider.intType;
3215 TypeName intTypeName = AstFactory.typeName4("int"); 3218 TypeName intTypeName = AstTestFactory.typeName4("int");
3216 String innerParameterName = "a"; 3219 String innerParameterName = "a";
3217 SimpleFormalParameter parameter = 3220 SimpleFormalParameter parameter =
3218 AstFactory.simpleFormalParameter3(innerParameterName); 3221 AstTestFactory.simpleFormalParameter3(innerParameterName);
3219 parameter.identifier.staticElement = 3222 parameter.identifier.staticElement =
3220 ElementFactory.requiredParameter(innerParameterName); 3223 ElementFactory.requiredParameter(innerParameterName);
3221 String outerParameterName = "p"; 3224 String outerParameterName = "p";
3222 FormalParameter node = AstFactory.fieldFormalParameter(null, intTypeName, 3225 FormalParameter node = AstTestFactory.fieldFormalParameter(
3223 outerParameterName, AstFactory.formalParameterList([parameter])); 3226 null,
3227 intTypeName,
3228 outerParameterName,
3229 AstTestFactory.formalParameterList([parameter]));
3224 node.identifier.staticElement = 3230 node.identifier.staticElement =
3225 ElementFactory.requiredParameter(outerParameterName); 3231 ElementFactory.requiredParameter(outerParameterName);
3226 DartType parameterType = _resolveFormalParameter(node, [intType.element]); 3232 DartType parameterType = _resolveFormalParameter(node, [intType.element]);
3227 EngineTestCase.assertInstanceOf( 3233 EngineTestCase.assertInstanceOf(
3228 (obj) => obj is FunctionType, FunctionType, parameterType); 3234 (obj) => obj is FunctionType, FunctionType, parameterType);
3229 FunctionType functionType = parameterType as FunctionType; 3235 FunctionType functionType = parameterType as FunctionType;
3230 expect(functionType.returnType, same(intType)); 3236 expect(functionType.returnType, same(intType));
3231 expect(functionType.parameters, hasLength(1)); 3237 expect(functionType.parameters, hasLength(1));
3232 _listener.assertNoErrors(); 3238 _listener.assertNoErrors();
3233 } 3239 }
3234 3240
3235 void test_visitFieldFormalParameter_noType() { 3241 void test_visitFieldFormalParameter_noType() {
3236 String parameterName = "p"; 3242 String parameterName = "p";
3237 FormalParameter node = 3243 FormalParameter node =
3238 AstFactory.fieldFormalParameter(Keyword.VAR, null, parameterName); 3244 AstTestFactory.fieldFormalParameter(Keyword.VAR, null, parameterName);
3239 node.identifier.staticElement = 3245 node.identifier.staticElement =
3240 ElementFactory.requiredParameter(parameterName); 3246 ElementFactory.requiredParameter(parameterName);
3241 expect(_resolveFormalParameter(node), same(_typeProvider.dynamicType)); 3247 expect(_resolveFormalParameter(node), same(_typeProvider.dynamicType));
3242 _listener.assertNoErrors(); 3248 _listener.assertNoErrors();
3243 } 3249 }
3244 3250
3245 void test_visitFieldFormalParameter_type() { 3251 void test_visitFieldFormalParameter_type() {
3246 InterfaceType intType = _typeProvider.intType; 3252 InterfaceType intType = _typeProvider.intType;
3247 TypeName intTypeName = AstFactory.typeName4("int"); 3253 TypeName intTypeName = AstTestFactory.typeName4("int");
3248 String parameterName = "p"; 3254 String parameterName = "p";
3249 FormalParameter node = 3255 FormalParameter node =
3250 AstFactory.fieldFormalParameter(null, intTypeName, parameterName); 3256 AstTestFactory.fieldFormalParameter(null, intTypeName, parameterName);
3251 node.identifier.staticElement = 3257 node.identifier.staticElement =
3252 ElementFactory.requiredParameter(parameterName); 3258 ElementFactory.requiredParameter(parameterName);
3253 expect(_resolveFormalParameter(node, [intType.element]), same(intType)); 3259 expect(_resolveFormalParameter(node, [intType.element]), same(intType));
3254 _listener.assertNoErrors(); 3260 _listener.assertNoErrors();
3255 } 3261 }
3256 3262
3257 void test_visitFunctionDeclaration() { 3263 void test_visitFunctionDeclaration() {
3258 // R f(P p) {} 3264 // R f(P p) {}
3259 // class R {} 3265 // class R {}
3260 // class P {} 3266 // class P {}
3261 ClassElement elementR = ElementFactory.classElement2('R'); 3267 ClassElement elementR = ElementFactory.classElement2('R');
3262 ClassElement elementP = ElementFactory.classElement2('P'); 3268 ClassElement elementP = ElementFactory.classElement2('P');
3263 FunctionElement elementF = ElementFactory.functionElement('f'); 3269 FunctionElement elementF = ElementFactory.functionElement('f');
3264 FunctionDeclaration declaration = AstFactory.functionDeclaration( 3270 FunctionDeclaration declaration = AstTestFactory.functionDeclaration(
3265 AstFactory.typeName4('R'), 3271 AstTestFactory.typeName4('R'),
3266 null, 3272 null,
3267 'f', 3273 'f',
3268 AstFactory.functionExpression2( 3274 AstTestFactory.functionExpression2(
3269 AstFactory.formalParameterList([ 3275 AstTestFactory.formalParameterList([
3270 AstFactory.simpleFormalParameter4(AstFactory.typeName4('P'), 'p') 3276 AstTestFactory.simpleFormalParameter4(
3277 AstTestFactory.typeName4('P'), 'p')
3271 ]), 3278 ]),
3272 null)); 3279 null));
3273 declaration.name.staticElement = elementF; 3280 declaration.name.staticElement = elementF;
3274 _resolveNode(declaration, [elementR, elementP]); 3281 _resolveNode(declaration, [elementR, elementP]);
3275 expect(declaration.returnType.type, elementR.type); 3282 expect(declaration.returnType.type, elementR.type);
3276 SimpleFormalParameter parameter = 3283 SimpleFormalParameter parameter =
3277 declaration.functionExpression.parameters.parameters[0]; 3284 declaration.functionExpression.parameters.parameters[0];
3278 expect(parameter.type.type, elementP.type); 3285 expect(parameter.type.type, elementP.type);
3279 _listener.assertNoErrors(); 3286 _listener.assertNoErrors();
3280 } 3287 }
3281 3288
3282 void test_visitFunctionDeclaration_typeParameter() { 3289 void test_visitFunctionDeclaration_typeParameter() {
3283 // E f<E>(E e) {} 3290 // E f<E>(E e) {}
3284 TypeParameterElement elementE = ElementFactory.typeParameterElement('E'); 3291 TypeParameterElement elementE = ElementFactory.typeParameterElement('E');
3285 FunctionElementImpl elementF = ElementFactory.functionElement('f'); 3292 FunctionElementImpl elementF = ElementFactory.functionElement('f');
3286 elementF.typeParameters = <TypeParameterElement>[elementE]; 3293 elementF.typeParameters = <TypeParameterElement>[elementE];
3287 FunctionDeclaration declaration = AstFactory.functionDeclaration( 3294 FunctionDeclaration declaration = AstTestFactory.functionDeclaration(
3288 AstFactory.typeName4('E'), 3295 AstTestFactory.typeName4('E'),
3289 null, 3296 null,
3290 'f', 3297 'f',
3291 AstFactory.functionExpression2( 3298 AstTestFactory.functionExpression2(
3292 AstFactory.formalParameterList([ 3299 AstTestFactory.formalParameterList([
3293 AstFactory.simpleFormalParameter4(AstFactory.typeName4('E'), 'e') 3300 AstTestFactory.simpleFormalParameter4(
3301 AstTestFactory.typeName4('E'), 'e')
3294 ]), 3302 ]),
3295 null)); 3303 null));
3296 declaration.name.staticElement = elementF; 3304 declaration.name.staticElement = elementF;
3297 _resolveNode(declaration, []); 3305 _resolveNode(declaration, []);
3298 expect(declaration.returnType.type, elementE.type); 3306 expect(declaration.returnType.type, elementE.type);
3299 SimpleFormalParameter parameter = 3307 SimpleFormalParameter parameter =
3300 declaration.functionExpression.parameters.parameters[0]; 3308 declaration.functionExpression.parameters.parameters[0];
3301 expect(parameter.type.type, elementE.type); 3309 expect(parameter.type.type, elementE.type);
3302 _listener.assertNoErrors(); 3310 _listener.assertNoErrors();
3303 } 3311 }
3304 3312
3305 void test_visitFunctionTypedFormalParameter() { 3313 void test_visitFunctionTypedFormalParameter() {
3306 // R f(R g(P p)) {} 3314 // R f(R g(P p)) {}
3307 // class R {} 3315 // class R {}
3308 // class P {} 3316 // class P {}
3309 ClassElement elementR = ElementFactory.classElement2('R'); 3317 ClassElement elementR = ElementFactory.classElement2('R');
3310 ClassElement elementP = ElementFactory.classElement2('P'); 3318 ClassElement elementP = ElementFactory.classElement2('P');
3311 FunctionElement elementF = ElementFactory.functionElement('f'); 3319 FunctionElement elementF = ElementFactory.functionElement('f');
3312 ParameterElementImpl requiredParameter = 3320 ParameterElementImpl requiredParameter =
3313 ElementFactory.requiredParameter('p'); 3321 ElementFactory.requiredParameter('p');
3314 FunctionTypedFormalParameter parameterDeclaration = AstFactory 3322 FunctionTypedFormalParameter parameterDeclaration = AstTestFactory
3315 .functionTypedFormalParameter(AstFactory.typeName4('R'), 'g', [ 3323 .functionTypedFormalParameter(AstTestFactory.typeName4('R'), 'g', [
3316 AstFactory.simpleFormalParameter4(AstFactory.typeName4('P'), 'p') 3324 AstTestFactory.simpleFormalParameter4(AstTestFactory.typeName4('P'), 'p')
3317 ]); 3325 ]);
3318 parameterDeclaration.identifier.staticElement = requiredParameter; 3326 parameterDeclaration.identifier.staticElement = requiredParameter;
3319 FunctionDeclaration declaration = AstFactory.functionDeclaration( 3327 FunctionDeclaration declaration = AstTestFactory.functionDeclaration(
3320 AstFactory.typeName4('R'), 3328 AstTestFactory.typeName4('R'),
3321 null, 3329 null,
3322 'f', 3330 'f',
3323 AstFactory.functionExpression2( 3331 AstTestFactory.functionExpression2(
3324 AstFactory.formalParameterList([parameterDeclaration]), null)); 3332 AstTestFactory.formalParameterList([parameterDeclaration]), null));
3325 declaration.name.staticElement = elementF; 3333 declaration.name.staticElement = elementF;
3326 _resolveNode(declaration, [elementR, elementP]); 3334 _resolveNode(declaration, [elementR, elementP]);
3327 expect(declaration.returnType.type, elementR.type); 3335 expect(declaration.returnType.type, elementR.type);
3328 FunctionTypedFormalParameter parameter = 3336 FunctionTypedFormalParameter parameter =
3329 declaration.functionExpression.parameters.parameters[0]; 3337 declaration.functionExpression.parameters.parameters[0];
3330 expect(parameter.returnType.type, elementR.type); 3338 expect(parameter.returnType.type, elementR.type);
3331 SimpleFormalParameter innerParameter = parameter.parameters.parameters[0]; 3339 SimpleFormalParameter innerParameter = parameter.parameters.parameters[0];
3332 expect(innerParameter.type.type, elementP.type); 3340 expect(innerParameter.type.type, elementP.type);
3333 _listener.assertNoErrors(); 3341 _listener.assertNoErrors();
3334 } 3342 }
3335 3343
3336 void test_visitFunctionTypedFormalParameter_typeParameter() { 3344 void test_visitFunctionTypedFormalParameter_typeParameter() {
3337 // R f(R g<E>(E e)) {} 3345 // R f(R g<E>(E e)) {}
3338 // class R {} 3346 // class R {}
3339 ClassElement elementR = ElementFactory.classElement2('R'); 3347 ClassElement elementR = ElementFactory.classElement2('R');
3340 TypeParameterElement elementE = ElementFactory.typeParameterElement('E'); 3348 TypeParameterElement elementE = ElementFactory.typeParameterElement('E');
3341 FunctionElement elementF = ElementFactory.functionElement('f'); 3349 FunctionElement elementF = ElementFactory.functionElement('f');
3342 ParameterElementImpl requiredParameter = 3350 ParameterElementImpl requiredParameter =
3343 ElementFactory.requiredParameter('g'); 3351 ElementFactory.requiredParameter('g');
3344 requiredParameter.typeParameters = <TypeParameterElement>[elementE]; 3352 requiredParameter.typeParameters = <TypeParameterElement>[elementE];
3345 FunctionTypedFormalParameter parameterDeclaration = AstFactory 3353 FunctionTypedFormalParameter parameterDeclaration = AstTestFactory
3346 .functionTypedFormalParameter(AstFactory.typeName4('R'), 'g', [ 3354 .functionTypedFormalParameter(AstTestFactory.typeName4('R'), 'g', [
3347 AstFactory.simpleFormalParameter4(AstFactory.typeName4('E'), 'e') 3355 AstTestFactory.simpleFormalParameter4(AstTestFactory.typeName4('E'), 'e')
3348 ]); 3356 ]);
3349 parameterDeclaration.identifier.staticElement = requiredParameter; 3357 parameterDeclaration.identifier.staticElement = requiredParameter;
3350 FunctionDeclaration declaration = AstFactory.functionDeclaration( 3358 FunctionDeclaration declaration = AstTestFactory.functionDeclaration(
3351 AstFactory.typeName4('R'), 3359 AstTestFactory.typeName4('R'),
3352 null, 3360 null,
3353 'f', 3361 'f',
3354 AstFactory.functionExpression2( 3362 AstTestFactory.functionExpression2(
3355 AstFactory.formalParameterList([parameterDeclaration]), null)); 3363 AstTestFactory.formalParameterList([parameterDeclaration]), null));
3356 declaration.name.staticElement = elementF; 3364 declaration.name.staticElement = elementF;
3357 _resolveNode(declaration, [elementR]); 3365 _resolveNode(declaration, [elementR]);
3358 expect(declaration.returnType.type, elementR.type); 3366 expect(declaration.returnType.type, elementR.type);
3359 FunctionTypedFormalParameter parameter = 3367 FunctionTypedFormalParameter parameter =
3360 declaration.functionExpression.parameters.parameters[0]; 3368 declaration.functionExpression.parameters.parameters[0];
3361 expect(parameter.returnType.type, elementR.type); 3369 expect(parameter.returnType.type, elementR.type);
3362 SimpleFormalParameter innerParameter = parameter.parameters.parameters[0]; 3370 SimpleFormalParameter innerParameter = parameter.parameters.parameters[0];
3363 expect(innerParameter.type.type, elementE.type); 3371 expect(innerParameter.type.type, elementE.type);
3364 _listener.assertNoErrors(); 3372 _listener.assertNoErrors();
3365 } 3373 }
3366 3374
3367 void test_visitMethodDeclaration() { 3375 void test_visitMethodDeclaration() {
3368 // class A { 3376 // class A {
3369 // R m(P p) {} 3377 // R m(P p) {}
3370 // } 3378 // }
3371 // class R {} 3379 // class R {}
3372 // class P {} 3380 // class P {}
3373 ClassElementImpl elementA = ElementFactory.classElement2('A'); 3381 ClassElementImpl elementA = ElementFactory.classElement2('A');
3374 ClassElement elementR = ElementFactory.classElement2('R'); 3382 ClassElement elementR = ElementFactory.classElement2('R');
3375 ClassElement elementP = ElementFactory.classElement2('P'); 3383 ClassElement elementP = ElementFactory.classElement2('P');
3376 MethodElement elementM = ElementFactory.methodElement('m', null); 3384 MethodElement elementM = ElementFactory.methodElement('m', null);
3377 elementA.methods = <MethodElement>[elementM]; 3385 elementA.methods = <MethodElement>[elementM];
3378 MethodDeclaration declaration = AstFactory.methodDeclaration( 3386 MethodDeclaration declaration = AstTestFactory.methodDeclaration(
3379 null, 3387 null,
3380 AstFactory.typeName4('R'), 3388 AstTestFactory.typeName4('R'),
3381 null, 3389 null,
3382 null, 3390 null,
3383 AstFactory.identifier3('m'), 3391 AstTestFactory.identifier3('m'),
3384 AstFactory.formalParameterList([ 3392 AstTestFactory.formalParameterList([
3385 AstFactory.simpleFormalParameter4(AstFactory.typeName4('P'), 'p') 3393 AstTestFactory.simpleFormalParameter4(
3394 AstTestFactory.typeName4('P'), 'p')
3386 ])); 3395 ]));
3387 declaration.name.staticElement = elementM; 3396 declaration.name.staticElement = elementM;
3388 _resolveNode(declaration, [elementA, elementR, elementP]); 3397 _resolveNode(declaration, [elementA, elementR, elementP]);
3389 expect(declaration.returnType.type, elementR.type); 3398 expect(declaration.returnType.type, elementR.type);
3390 SimpleFormalParameter parameter = declaration.parameters.parameters[0]; 3399 SimpleFormalParameter parameter = declaration.parameters.parameters[0];
3391 expect(parameter.type.type, elementP.type); 3400 expect(parameter.type.type, elementP.type);
3392 _listener.assertNoErrors(); 3401 _listener.assertNoErrors();
3393 } 3402 }
3394 3403
3395 void test_visitMethodDeclaration_typeParameter() { 3404 void test_visitMethodDeclaration_typeParameter() {
3396 // class A { 3405 // class A {
3397 // E m<E>(E e) {} 3406 // E m<E>(E e) {}
3398 // } 3407 // }
3399 ClassElementImpl elementA = ElementFactory.classElement2('A'); 3408 ClassElementImpl elementA = ElementFactory.classElement2('A');
3400 TypeParameterElement elementE = ElementFactory.typeParameterElement('E'); 3409 TypeParameterElement elementE = ElementFactory.typeParameterElement('E');
3401 MethodElementImpl elementM = ElementFactory.methodElement('m', null); 3410 MethodElementImpl elementM = ElementFactory.methodElement('m', null);
3402 elementM.typeParameters = <TypeParameterElement>[elementE]; 3411 elementM.typeParameters = <TypeParameterElement>[elementE];
3403 elementA.methods = <MethodElement>[elementM]; 3412 elementA.methods = <MethodElement>[elementM];
3404 MethodDeclaration declaration = AstFactory.methodDeclaration( 3413 MethodDeclaration declaration = AstTestFactory.methodDeclaration(
3405 null, 3414 null,
3406 AstFactory.typeName4('E'), 3415 AstTestFactory.typeName4('E'),
3407 null, 3416 null,
3408 null, 3417 null,
3409 AstFactory.identifier3('m'), 3418 AstTestFactory.identifier3('m'),
3410 AstFactory.formalParameterList([ 3419 AstTestFactory.formalParameterList([
3411 AstFactory.simpleFormalParameter4(AstFactory.typeName4('E'), 'e') 3420 AstTestFactory.simpleFormalParameter4(
3421 AstTestFactory.typeName4('E'), 'e')
3412 ])); 3422 ]));
3413 declaration.name.staticElement = elementM; 3423 declaration.name.staticElement = elementM;
3414 _resolveNode(declaration, [elementA]); 3424 _resolveNode(declaration, [elementA]);
3415 expect(declaration.returnType.type, elementE.type); 3425 expect(declaration.returnType.type, elementE.type);
3416 SimpleFormalParameter parameter = declaration.parameters.parameters[0]; 3426 SimpleFormalParameter parameter = declaration.parameters.parameters[0];
3417 expect(parameter.type.type, elementE.type); 3427 expect(parameter.type.type, elementE.type);
3418 _listener.assertNoErrors(); 3428 _listener.assertNoErrors();
3419 } 3429 }
3420 3430
3421 void test_visitSimpleFormalParameter_noType() { 3431 void test_visitSimpleFormalParameter_noType() {
3422 // p 3432 // p
3423 FormalParameter node = AstFactory.simpleFormalParameter3("p"); 3433 FormalParameter node = AstTestFactory.simpleFormalParameter3("p");
3424 node.identifier.staticElement = 3434 node.identifier.staticElement =
3425 new ParameterElementImpl.forNode(AstFactory.identifier3("p")); 3435 new ParameterElementImpl.forNode(AstTestFactory.identifier3("p"));
3426 expect(_resolveFormalParameter(node), same(_typeProvider.dynamicType)); 3436 expect(_resolveFormalParameter(node), same(_typeProvider.dynamicType));
3427 _listener.assertNoErrors(); 3437 _listener.assertNoErrors();
3428 } 3438 }
3429 3439
3430 void test_visitSimpleFormalParameter_type() { 3440 void test_visitSimpleFormalParameter_type() {
3431 // int p 3441 // int p
3432 InterfaceType intType = _typeProvider.intType; 3442 InterfaceType intType = _typeProvider.intType;
3433 ClassElement intElement = intType.element; 3443 ClassElement intElement = intType.element;
3434 FormalParameter node = 3444 FormalParameter node = AstTestFactory.simpleFormalParameter4(
3435 AstFactory.simpleFormalParameter4(AstFactory.typeName(intElement), "p"); 3445 AstTestFactory.typeName(intElement), "p");
3436 SimpleIdentifier identifier = node.identifier; 3446 SimpleIdentifier identifier = node.identifier;
3437 ParameterElementImpl element = new ParameterElementImpl.forNode(identifier); 3447 ParameterElementImpl element = new ParameterElementImpl.forNode(identifier);
3438 identifier.staticElement = element; 3448 identifier.staticElement = element;
3439 expect(_resolveFormalParameter(node, [intElement]), same(intType)); 3449 expect(_resolveFormalParameter(node, [intElement]), same(intType));
3440 _listener.assertNoErrors(); 3450 _listener.assertNoErrors();
3441 } 3451 }
3442 3452
3443 void test_visitTypeName_noParameters_noArguments() { 3453 void test_visitTypeName_noParameters_noArguments() {
3444 ClassElement classA = ElementFactory.classElement2("A"); 3454 ClassElement classA = ElementFactory.classElement2("A");
3445 TypeName typeName = AstFactory.typeName(classA); 3455 TypeName typeName = AstTestFactory.typeName(classA);
3446 typeName.type = null; 3456 typeName.type = null;
3447 _resolveNode(typeName, [classA]); 3457 _resolveNode(typeName, [classA]);
3448 expect(typeName.type, same(classA.type)); 3458 expect(typeName.type, same(classA.type));
3449 _listener.assertNoErrors(); 3459 _listener.assertNoErrors();
3450 } 3460 }
3451 3461
3452 void test_visitTypeName_noParameters_noArguments_undefined() { 3462 void test_visitTypeName_noParameters_noArguments_undefined() {
3453 SimpleIdentifier id = AstFactory.identifier3("unknown") 3463 SimpleIdentifier id = AstTestFactory.identifier3("unknown")
3454 ..staticElement = new _StaleElement(); 3464 ..staticElement = new _StaleElement();
3455 TypeName typeName = new TypeName(id, null); 3465 TypeName typeName = new TypeName(id, null);
3456 _resolveNode(typeName, []); 3466 _resolveNode(typeName, []);
3457 expect(typeName.type, UndefinedTypeImpl.instance); 3467 expect(typeName.type, UndefinedTypeImpl.instance);
3458 expect(typeName.name.staticElement, null); 3468 expect(typeName.name.staticElement, null);
3459 _listener.assertErrorsWithCodes([StaticWarningCode.UNDEFINED_CLASS]); 3469 _listener.assertErrorsWithCodes([StaticWarningCode.UNDEFINED_CLASS]);
3460 } 3470 }
3461 3471
3462 void test_visitTypeName_parameters_arguments() { 3472 void test_visitTypeName_parameters_arguments() {
3463 ClassElement classA = ElementFactory.classElement2("A", ["E"]); 3473 ClassElement classA = ElementFactory.classElement2("A", ["E"]);
3464 ClassElement classB = ElementFactory.classElement2("B"); 3474 ClassElement classB = ElementFactory.classElement2("B");
3465 TypeName typeName = 3475 TypeName typeName =
3466 AstFactory.typeName(classA, [AstFactory.typeName(classB)]); 3476 AstTestFactory.typeName(classA, [AstTestFactory.typeName(classB)]);
3467 typeName.type = null; 3477 typeName.type = null;
3468 _resolveNode(typeName, [classA, classB]); 3478 _resolveNode(typeName, [classA, classB]);
3469 InterfaceType resultType = typeName.type as InterfaceType; 3479 InterfaceType resultType = typeName.type as InterfaceType;
3470 expect(resultType.element, same(classA)); 3480 expect(resultType.element, same(classA));
3471 List<DartType> resultArguments = resultType.typeArguments; 3481 List<DartType> resultArguments = resultType.typeArguments;
3472 expect(resultArguments, hasLength(1)); 3482 expect(resultArguments, hasLength(1));
3473 expect(resultArguments[0], same(classB.type)); 3483 expect(resultArguments[0], same(classB.type));
3474 _listener.assertNoErrors(); 3484 _listener.assertNoErrors();
3475 } 3485 }
3476 3486
3477 void test_visitTypeName_parameters_noArguments() { 3487 void test_visitTypeName_parameters_noArguments() {
3478 ClassElement classA = ElementFactory.classElement2("A", ["E"]); 3488 ClassElement classA = ElementFactory.classElement2("A", ["E"]);
3479 TypeName typeName = AstFactory.typeName(classA); 3489 TypeName typeName = AstTestFactory.typeName(classA);
3480 typeName.type = null; 3490 typeName.type = null;
3481 _resolveNode(typeName, [classA]); 3491 _resolveNode(typeName, [classA]);
3482 InterfaceType resultType = typeName.type as InterfaceType; 3492 InterfaceType resultType = typeName.type as InterfaceType;
3483 expect(resultType.element, same(classA)); 3493 expect(resultType.element, same(classA));
3484 List<DartType> resultArguments = resultType.typeArguments; 3494 List<DartType> resultArguments = resultType.typeArguments;
3485 expect(resultArguments, hasLength(1)); 3495 expect(resultArguments, hasLength(1));
3486 expect(resultArguments[0], same(DynamicTypeImpl.instance)); 3496 expect(resultArguments[0], same(DynamicTypeImpl.instance));
3487 _listener.assertNoErrors(); 3497 _listener.assertNoErrors();
3488 } 3498 }
3489 3499
3490 void test_visitTypeName_prefixed_noParameters_noArguments_undefined() { 3500 void test_visitTypeName_prefixed_noParameters_noArguments_undefined() {
3491 SimpleIdentifier prefix = AstFactory.identifier3("unknownPrefix") 3501 SimpleIdentifier prefix = AstTestFactory.identifier3("unknownPrefix")
3492 ..staticElement = new _StaleElement(); 3502 ..staticElement = new _StaleElement();
3493 SimpleIdentifier suffix = AstFactory.identifier3("unknownSuffix") 3503 SimpleIdentifier suffix = AstTestFactory.identifier3("unknownSuffix")
3494 ..staticElement = new _StaleElement(); 3504 ..staticElement = new _StaleElement();
3495 TypeName typeName = 3505 TypeName typeName =
3496 new TypeName(AstFactory.identifier(prefix, suffix), null); 3506 new TypeName(AstTestFactory.identifier(prefix, suffix), null);
3497 _resolveNode(typeName, []); 3507 _resolveNode(typeName, []);
3498 expect(typeName.type, UndefinedTypeImpl.instance); 3508 expect(typeName.type, UndefinedTypeImpl.instance);
3499 expect(prefix.staticElement, null); 3509 expect(prefix.staticElement, null);
3500 expect(suffix.staticElement, null); 3510 expect(suffix.staticElement, null);
3501 _listener.assertErrorsWithCodes([StaticWarningCode.UNDEFINED_CLASS]); 3511 _listener.assertErrorsWithCodes([StaticWarningCode.UNDEFINED_CLASS]);
3502 } 3512 }
3503 3513
3504 void test_visitTypeName_void() { 3514 void test_visitTypeName_void() {
3505 ClassElement classA = ElementFactory.classElement2("A"); 3515 ClassElement classA = ElementFactory.classElement2("A");
3506 TypeName typeName = AstFactory.typeName4("void"); 3516 TypeName typeName = AstTestFactory.typeName4("void");
3507 _resolveNode(typeName, [classA]); 3517 _resolveNode(typeName, [classA]);
3508 expect(typeName.type, same(VoidTypeImpl.instance)); 3518 expect(typeName.type, same(VoidTypeImpl.instance));
3509 _listener.assertNoErrors(); 3519 _listener.assertNoErrors();
3510 } 3520 }
3511 3521
3512 /** 3522 /**
3513 * Analyze the given catch clause and assert that the types of the parameters have been set to the 3523 * Analyze the given catch clause and assert that the types of the parameters have been set to the
3514 * given types. The types can be null if the catch clause does not have the co rresponding 3524 * given types. The types can be null if the catch clause does not have the co rresponding
3515 * parameter. 3525 * parameter.
3516 * 3526 *
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
3623 */ 3633 */
3624 class _StaleElement extends ElementImpl { 3634 class _StaleElement extends ElementImpl {
3625 _StaleElement() : super("_StaleElement", -1); 3635 _StaleElement() : super("_StaleElement", -1);
3626 3636
3627 @override 3637 @override
3628 get kind => throw "_StaleElement's kind shouldn't be accessed"; 3638 get kind => throw "_StaleElement's kind shouldn't be accessed";
3629 3639
3630 @override 3640 @override
3631 accept(_) => throw "_StaleElement shouldn't be visited"; 3641 accept(_) => throw "_StaleElement shouldn't be visited";
3632 } 3642 }
OLDNEW
« no previous file with comments | « pkg/analyzer/test/generated/parser_test.dart ('k') | pkg/analyzer/test/generated/resolver_test_case.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698