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

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

Issue 2622303006: Reapply "Add support for generic function type syntax, part 1" (Closed)
Patch Set: Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 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:async'; 7 import 'dart:async';
8 import 'dart:collection'; 8 import 'dart:collection';
9 9
10 import 'package:analyzer/dart/ast/ast.dart'; 10 import 'package:analyzer/dart/ast/ast.dart';
(...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after
405 */ 405 */
406 List<Expression> _unresolvedExpressions = new List<Expression>(); 406 List<Expression> _unresolvedExpressions = new List<Expression>();
407 407
408 /** 408 /**
409 * A list containing all of the AST Expression nodes for which a propagated ty pe was computed but 409 * A list containing all of the AST Expression nodes for which a propagated ty pe was computed but
410 * where that type was not more specific than the static type. 410 * where that type was not more specific than the static type.
411 */ 411 */
412 List<Expression> _invalidlyPropagatedExpressions = new List<Expression>(); 412 List<Expression> _invalidlyPropagatedExpressions = new List<Expression>();
413 413
414 /** 414 /**
415 * A list containing all of the AST TypeName nodes that were not resolved. 415 * The TypeAnnotation nodes that were not resolved.
416 */ 416 */
417 List<TypeName> _unresolvedTypes = new List<TypeName>(); 417 List<TypeAnnotation> _unresolvedTypes = new List<TypeAnnotation>();
418 418
419 /** 419 /**
420 * Counter for the number of Expression nodes visited that are resolved. 420 * Counter for the number of Expression nodes visited that are resolved.
421 */ 421 */
422 int _resolvedExpressionCount = 0; 422 int _resolvedExpressionCount = 0;
423 423
424 /** 424 /**
425 * Counter for the number of Expression nodes visited that have propagated typ e information. 425 * Counter for the number of Expression nodes visited that have propagated typ e information.
426 */ 426 */
427 int _propagatedExpressionCount = 0; 427 int _propagatedExpressionCount = 0;
428 428
429 /** 429 /**
430 * Counter for the number of TypeName nodes visited that are resolved. 430 * Counter for the number of TypeName nodes visited that are resolved.
431 */ 431 */
432 int _resolvedTypeCount = 0; 432 int _resolvedTypeCount = 0;
433 433
434 /** 434 /**
435 * Assert that all of the visited nodes have a static type associated with the m. 435 * Assert that all of the visited nodes have a static type associated with the m.
436 */ 436 */
437 void assertResolved() { 437 void assertResolved() {
438 if (!_unresolvedExpressions.isEmpty || !_unresolvedTypes.isEmpty) { 438 if (!_unresolvedExpressions.isEmpty || !_unresolvedTypes.isEmpty) {
439 StringBuffer buffer = new StringBuffer(); 439 StringBuffer buffer = new StringBuffer();
440 int unresolvedTypeCount = _unresolvedTypes.length; 440 int unresolvedTypeCount = _unresolvedTypes.length;
441 if (unresolvedTypeCount > 0) { 441 if (unresolvedTypeCount > 0) {
442 buffer.write("Failed to resolve "); 442 buffer.write("Failed to resolve ");
443 buffer.write(unresolvedTypeCount); 443 buffer.write(unresolvedTypeCount);
444 buffer.write(" of "); 444 buffer.write(" of ");
445 buffer.write(_resolvedTypeCount + unresolvedTypeCount); 445 buffer.write(_resolvedTypeCount + unresolvedTypeCount);
446 buffer.writeln(" type names:"); 446 buffer.writeln(" type names:");
447 for (TypeName identifier in _unresolvedTypes) { 447 for (TypeAnnotation identifier in _unresolvedTypes) {
448 buffer.write(" "); 448 buffer.write(" ");
449 buffer.write(identifier.toString()); 449 buffer.write(identifier.toString());
450 buffer.write(" ("); 450 buffer.write(" (");
451 buffer.write(_getFileName(identifier)); 451 buffer.write(_getFileName(identifier));
452 buffer.write(" : "); 452 buffer.write(" : ");
453 buffer.write(identifier.offset); 453 buffer.write(identifier.offset);
454 buffer.writeln(")"); 454 buffer.writeln(")");
455 } 455 }
456 } 456 }
457 int unresolvedExpressionCount = _unresolvedExpressions.length; 457 int unresolvedExpressionCount = _unresolvedExpressions.length;
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
571 identical(node, parent.fieldName)) { 571 identical(node, parent.fieldName)) {
572 return null; 572 return null;
573 } else if (node.staticElement is PrefixElement) { 573 } else if (node.staticElement is PrefixElement) {
574 // Prefixes don't have a type. 574 // Prefixes don't have a type.
575 return null; 575 return null;
576 } 576 }
577 return super.visitSimpleIdentifier(node); 577 return super.visitSimpleIdentifier(node);
578 } 578 }
579 579
580 @override 580 @override
581 Object visitTypeAnnotation(TypeAnnotation node) {
582 if (node.type == null) {
583 _unresolvedTypes.add(node);
584 } else {
585 _resolvedTypeCount++;
586 }
587 return super.visitTypeAnnotation(node);
588 }
589
590 @override
581 Object visitTypeName(TypeName node) { 591 Object visitTypeName(TypeName node) {
582 // Note: do not visit children from this node, the child SimpleIdentifier in 592 // Note: do not visit children from this node, the child SimpleIdentifier in
583 // TypeName (i.e. "String") does not have a static type defined. 593 // TypeName (i.e. "String") does not have a static type defined.
594 // TODO(brianwilkerson) Not visiting the children means that we won't catch
595 // type arguments that were not resolved.
584 if (node.type == null) { 596 if (node.type == null) {
585 _unresolvedTypes.add(node); 597 _unresolvedTypes.add(node);
586 } else { 598 } else {
587 _resolvedTypeCount++; 599 _resolvedTypeCount++;
588 } 600 }
589 return null; 601 return null;
590 } 602 }
591 603
592 String _getFileName(AstNode node) { 604 String _getFileName(AstNode node) {
593 // TODO (jwren) there are two copies of this method, one here and one in 605 // TODO (jwren) there are two copies of this method, one here and one in
(...skipping 2996 matching lines...) Expand 10 before | Expand all | Expand 10 after
3590 */ 3602 */
3591 class _StaleElement extends ElementImpl { 3603 class _StaleElement extends ElementImpl {
3592 _StaleElement() : super("_StaleElement", -1); 3604 _StaleElement() : super("_StaleElement", -1);
3593 3605
3594 @override 3606 @override
3595 get kind => throw "_StaleElement's kind shouldn't be accessed"; 3607 get kind => throw "_StaleElement's kind shouldn't be accessed";
3596 3608
3597 @override 3609 @override
3598 /*=T*/ accept/*<T>*/(_) => throw "_StaleElement shouldn't be visited"; 3610 /*=T*/ accept/*<T>*/(_) => throw "_StaleElement shouldn't be visited";
3599 } 3611 }
OLDNEW
« no previous file with comments | « pkg/analyzer/test/generated/parser_test.dart ('k') | pkg/analyzer/test/generated/utilities_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698