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

Side by Side Diff: pkg/analyzer/lib/src/generated/incremental_resolution_validator.dart

Issue 834383005: Don't perform incremental resolution if curly brackets are not balanced. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 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 | Annotate | Revision Log
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 engine.incremental_resolution_validator; 5 library engine.incremental_resolution_validator;
6 6
7 import 'package:analyzer/src/generated/ast.dart'; 7 import 'package:analyzer/src/generated/ast.dart';
8 import 'package:analyzer/src/generated/element.dart'; 8 import 'package:analyzer/src/generated/element.dart';
9 9
10 10
(...skipping 763 matching lines...) Expand 10 before | Expand all | Expand 10 after
774 WithClause other = this.other; 774 WithClause other = this.other;
775 _visitList(node.mixinTypes, other.mixinTypes); 775 _visitList(node.mixinTypes, other.mixinTypes);
776 } 776 }
777 777
778 @override 778 @override
779 visitYieldStatement(YieldStatement node) { 779 visitYieldStatement(YieldStatement node) {
780 YieldStatement other = this.other; 780 YieldStatement other = this.other;
781 _visitNode(node.expression, other.expression); 781 _visitNode(node.expression, other.expression);
782 } 782 }
783 783
784 void _assertNode(AstNode a, AstNode b) {
785 _expectEquals(a.offset, b.offset);
786 _expectEquals(a.length, b.length);
787 }
788
784 void _expectEquals(actual, expected) { 789 void _expectEquals(actual, expected) {
785 if (actual != expected) { 790 if (actual != expected) {
786 String message = ''; 791 String message = '';
787 message += 'Expected: $expected\n'; 792 message += 'Expected: $expected\n';
788 message += ' Actual: $actual\n'; 793 message += ' Actual: $actual\n';
789 _fail(message); 794 _fail(message);
790 } 795 }
791 } 796 }
792 797
793 void _expectIsNull(obj) { 798 void _expectIsNull(obj) {
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
856 _verifyElement(node.element, other.element); 861 _verifyElement(node.element, other.element);
857 _visitAnnotatedNode(node, other); 862 _visitAnnotatedNode(node, other);
858 } 863 }
859 864
860 _visitDirective(Directive node, Directive other) { 865 _visitDirective(Directive node, Directive other) {
861 _verifyElement(node.element, other.element); 866 _verifyElement(node.element, other.element);
862 _visitAnnotatedNode(node, other); 867 _visitAnnotatedNode(node, other);
863 } 868 }
864 869
865 void _visitExpression(Expression a, Expression b) { 870 void _visitExpression(Expression a, Expression b) {
871 // print('[${a.offset}] |$a| vs. [${b.offset}] |$b|');
866 _verifyType(a.staticType, b.staticType); 872 _verifyType(a.staticType, b.staticType);
867 _verifyType(a.propagatedType, b.propagatedType); 873 _verifyType(a.propagatedType, b.propagatedType);
868 _verifyElement(a.staticParameterElement, b.staticParameterElement); 874 _verifyElement(a.staticParameterElement, b.staticParameterElement);
869 _verifyElement(a.propagatedParameterElement, b.propagatedParameterElement); 875 _verifyElement(a.propagatedParameterElement, b.propagatedParameterElement);
876 _assertNode(a, b);
870 } 877 }
871 878
872 void _visitList(NodeList nodeList, NodeList otherList) { 879 void _visitList(NodeList nodeList, NodeList otherList) {
873 int length = nodeList.length; 880 int length = nodeList.length;
874 _expectLength(otherList, length); 881 _expectLength(otherList, length);
875 for (int i = 0; i < length; i++) { 882 for (int i = 0; i < length; i++) {
876 _visitNode(nodeList[i], otherList[i]); 883 _visitNode(nodeList[i], otherList[i]);
877 } 884 }
878 } 885 }
879 886
880 void _visitNode(AstNode node, AstNode other) { 887 void _visitNode(AstNode node, AstNode other) {
881 if (node == null) { 888 if (node == null) {
882 _expectIsNull(other); 889 _expectIsNull(other);
883 } else { 890 } else {
884 this.other = other; 891 this.other = other;
885 _expectEquals(node.offset, other.offset); 892 _assertNode(node, other);
886 _expectEquals(node.length, other.length);
887 node.accept(this); 893 node.accept(this);
888 } 894 }
889 } 895 }
890 896
891 void _visitNormalFormalParameter(NormalFormalParameter node, 897 void _visitNormalFormalParameter(NormalFormalParameter node,
892 NormalFormalParameter other) { 898 NormalFormalParameter other) {
893 _verifyElement(node.element, other.element); 899 _verifyElement(node.element, other.element);
894 _visitNode(node.documentationComment, other.documentationComment); 900 _visitNode(node.documentationComment, other.documentationComment);
895 _visitList(node.metadata, other.metadata); 901 _visitList(node.metadata, other.metadata);
896 _visitNode(node.identifier, other.identifier); 902 _visitNode(node.identifier, other.identifier);
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
935 * package:project/my_lib.dart -> my_lib.dart 941 * package:project/my_lib.dart -> my_lib.dart
936 */ 942 */
937 static String _getShortElementLocationUri(String uri) { 943 static String _getShortElementLocationUri(String uri) {
938 int index = uri.lastIndexOf('/'); 944 int index = uri.lastIndexOf('/');
939 if (index == -1) { 945 if (index == -1) {
940 return uri; 946 return uri;
941 } 947 }
942 return uri.substring(index + 1); 948 return uri.substring(index + 1);
943 } 949 }
944 } 950 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698