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

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

Issue 1696193003: Fix cache corruption in incremental resolver (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: post-review cleanup Created 4 years, 10 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.src.generated.incremental_resolution_validator; 5 library analyzer.src.generated.incremental_resolution_validator;
6 6
7 import 'package:analyzer/dart/ast/ast.dart'; 7 import 'package:analyzer/dart/ast/ast.dart';
8 import 'package:analyzer/dart/element/element.dart'; 8 import 'package:analyzer/dart/element/element.dart';
9 import 'package:analyzer/dart/element/type.dart'; 9 import 'package:analyzer/dart/element/type.dart';
10 import 'package:analyzer/src/dart/element/element.dart'; 10 import 'package:analyzer/src/dart/element/element.dart';
(...skipping 10 matching lines...) Expand all
21 actual.accept(validator); 21 actual.accept(validator);
22 } 22 }
23 23
24 /** 24 /**
25 * This exception is thrown when a mismatch between actual and expected AST 25 * This exception is thrown when a mismatch between actual and expected AST
26 * or resolution is found. 26 * or resolution is found.
27 */ 27 */
28 class IncrementalResolutionMismatch { 28 class IncrementalResolutionMismatch {
29 final String message; 29 final String message;
30 IncrementalResolutionMismatch(this.message); 30 IncrementalResolutionMismatch(this.message);
31
32 @override
33 String toString() => "IncrementalResolutionMismatch: $message";
31 } 34 }
32 35
33 class _SameResolutionValidator implements AstVisitor { 36 class _SameResolutionValidator implements AstVisitor {
34 final bool validateTypes; 37 final bool validateTypes;
38
39 /// The expected node to compare with the visted node.
35 AstNode other; 40 AstNode other;
36 41
37 _SameResolutionValidator(this.validateTypes, this.other); 42 _SameResolutionValidator(this.validateTypes, this.other);
38 43
39 @override 44 @override
40 visitAdjacentStrings(AdjacentStrings node) {} 45 visitAdjacentStrings(AdjacentStrings node) {}
41 46
42 @override 47 @override
43 visitAnnotation(Annotation node) { 48 visitAnnotation(Annotation node) {
44 Annotation other = this.other; 49 Annotation other = this.other;
(...skipping 835 matching lines...) Expand 10 before | Expand all | Expand 10 after
880 885
881 void _visitExpression(Expression a, Expression b) { 886 void _visitExpression(Expression a, Expression b) {
882 // print('[${a.offset}] |$a| vs. [${b.offset}] |$b|'); 887 // print('[${a.offset}] |$a| vs. [${b.offset}] |$b|');
883 _verifyType(a.staticType, b.staticType); 888 _verifyType(a.staticType, b.staticType);
884 _verifyType(a.propagatedType, b.propagatedType); 889 _verifyType(a.propagatedType, b.propagatedType);
885 _verifyElement(a.staticParameterElement, b.staticParameterElement); 890 _verifyElement(a.staticParameterElement, b.staticParameterElement);
886 _verifyElement(a.propagatedParameterElement, b.propagatedParameterElement); 891 _verifyElement(a.propagatedParameterElement, b.propagatedParameterElement);
887 _assertNode(a, b); 892 _assertNode(a, b);
888 } 893 }
889 894
890 void _visitList(NodeList nodeList, NodeList otherList) { 895 void _visitList(NodeList nodeList, NodeList expected) {
891 int length = nodeList.length; 896 int length = nodeList.length;
892 _expectLength(otherList, length); 897 _expectLength(nodeList, expected.length);
893 for (int i = 0; i < length; i++) { 898 for (int i = 0; i < length; i++) {
894 _visitNode(nodeList[i], otherList[i]); 899 _visitNode(nodeList[i], expected[i]);
895 } 900 }
896 } 901 }
897 902
898 void _visitNode(AstNode node, AstNode other) { 903 void _visitNode(AstNode node, AstNode other) {
899 if (node == null) { 904 if (node == null) {
900 _expectIsNull(other); 905 _expectIsNull(other);
901 } else { 906 } else {
902 this.other = other; 907 this.other = other;
903 _assertNode(node, other); 908 _assertNode(node, other);
904 node.accept(this); 909 node.accept(this);
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
952 * package:project/my_lib.dart -> my_lib.dart 957 * package:project/my_lib.dart -> my_lib.dart
953 */ 958 */
954 static String _getShortElementLocationUri(String uri) { 959 static String _getShortElementLocationUri(String uri) {
955 int index = uri.lastIndexOf('/'); 960 int index = uri.lastIndexOf('/');
956 if (index == -1) { 961 if (index == -1) {
957 return uri; 962 return uri;
958 } 963 }
959 return uri.substring(index + 1); 964 return uri.substring(index + 1);
960 } 965 }
961 } 966 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698