OLD | NEW |
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.src.task.strong_mode; | 5 library analyzer.src.task.strong_mode; |
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/visitor.dart'; | 10 import 'package:analyzer/dart/ast/visitor.dart'; |
(...skipping 588 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
599 void visitAssignmentExpression(AssignmentExpression node) { | 599 void visitAssignmentExpression(AssignmentExpression node) { |
600 isValid = false; | 600 isValid = false; |
601 } | 601 } |
602 | 602 |
603 @override | 603 @override |
604 void visitCascadeExpression(CascadeExpression node) { | 604 void visitCascadeExpression(CascadeExpression node) { |
605 node.target.accept(this); | 605 node.target.accept(this); |
606 } | 606 } |
607 | 607 |
608 @override | 608 @override |
| 609 void visitFunctionExpression(FunctionExpression node) { |
| 610 FunctionBody body = node.body; |
| 611 if (body is ExpressionFunctionBody) { |
| 612 body.accept(this); |
| 613 } else { |
| 614 isValid = false; |
| 615 } |
| 616 } |
| 617 |
| 618 @override |
| 619 void visitFunctionExpressionInvocation(FunctionExpressionInvocation node) { |
| 620 node.function?.accept(this); |
| 621 } |
| 622 |
| 623 @override |
| 624 void visitIndexExpression(IndexExpression node) { |
| 625 isValid = false; |
| 626 } |
| 627 |
| 628 @override |
| 629 void visitInstanceCreationExpression(InstanceCreationExpression node) { |
| 630 ConstructorElement constructor = node.staticElement; |
| 631 if (constructor != null) { |
| 632 ClassElement clazz = constructor?.enclosingElement; |
| 633 if (clazz.typeParameters.isNotEmpty && |
| 634 node.constructorName.type.typeArguments == null) { |
| 635 isValid = false; |
| 636 return; |
| 637 } |
| 638 } |
| 639 } |
| 640 |
| 641 @override |
| 642 void visitListLiteral(ListLiteral node) { |
| 643 if (node.typeArguments == null) { |
| 644 super.visitListLiteral(node); |
| 645 } |
| 646 } |
| 647 |
| 648 @override |
| 649 void visitMapLiteral(MapLiteral node) { |
| 650 if (node.typeArguments == null) { |
| 651 super.visitMapLiteral(node); |
| 652 } |
| 653 } |
| 654 |
| 655 @override |
| 656 void visitMethodInvocation(MethodInvocation node) { |
| 657 Element element = node.methodName.staticElement; |
| 658 if (element is ExecutableElement) { |
| 659 if (element.type.typeFormals.isNotEmpty && node.typeArguments == null) { |
| 660 isValid = false; |
| 661 return; |
| 662 } |
| 663 } |
| 664 node.target?.accept(this); |
| 665 } |
| 666 |
| 667 @override |
609 void visitSimpleIdentifier(SimpleIdentifier node) { | 668 void visitSimpleIdentifier(SimpleIdentifier node) { |
610 Element element = node.staticElement; | 669 Element element = node.staticElement; |
611 if (element == null) { | 670 if (element == null) { |
612 AstNode parent = node.parent; | 671 AstNode parent = node.parent; |
613 if (parent is PropertyAccess && parent.propertyName == node || | 672 if (parent is PropertyAccess && parent.propertyName == node || |
614 parent is PrefixedIdentifier && parent.identifier == node) { | 673 parent is PrefixedIdentifier && parent.identifier == node) { |
615 isValid = false; | 674 isValid = false; |
616 } | 675 } |
617 } else if (element is PropertyAccessorElement && !element.isStatic) { | 676 } else if (element is PropertyAccessorElement && !element.isStatic) { |
618 isValid = false; | 677 isValid = false; |
619 } | 678 } |
620 } | 679 } |
621 } | 680 } |
OLD | NEW |