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

Side by Side Diff: pkg/analyzer_experimental/test/generated/test_support.dart

Issue 12604020: analyzer_experimental checkpoint and AnalysisContext example. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Don't mark Source as 'changed'. Created 7 years, 9 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 // This code was auto-generated, is not intended to be edited, and is subject to 1 // This code was auto-generated, is not intended to be edited, and is subject to
2 // significant change. Please see the README file for more information. 2 // significant change. Please see the README file for more information.
3 3
4 library engine.test_support; 4 library engine.test_support;
5 5
6 import 'dart:collection'; 6 import 'dart:collection';
7 import 'dart:uri'; 7 import 'dart:uri';
8 import 'package:analyzer_experimental/src/generated/java_core.dart'; 8 import 'package:analyzer_experimental/src/generated/java_core.dart';
9 import 'package:analyzer_experimental/src/generated/java_engine.dart'; 9 import 'package:analyzer_experimental/src/generated/java_engine.dart';
10 import 'package:analyzer_experimental/src/generated/java_junit.dart'; 10 import 'package:analyzer_experimental/src/generated/java_junit.dart';
11 import 'package:analyzer_experimental/src/generated/source.dart'; 11 import 'package:analyzer_experimental/src/generated/source.dart';
12 import 'package:analyzer_experimental/src/generated/error.dart'; 12 import 'package:analyzer_experimental/src/generated/error.dart';
13 import 'package:analyzer_experimental/src/generated/scanner.dart'; 13 import 'package:analyzer_experimental/src/generated/scanner.dart';
14 import 'package:analyzer_experimental/src/generated/element.dart' show Interface Type, MethodElement, PropertyAccessorElement; 14 import 'package:analyzer_experimental/src/generated/element.dart' show Interface Type, MethodElement, PropertyAccessorElement;
15 import 'package:analyzer_experimental/src/generated/engine.dart' show AnalysisCo ntext;
15 import 'package:unittest/unittest.dart' as _ut; 16 import 'package:unittest/unittest.dart' as _ut;
16 17
17 /** 18 /**
18 * Instances of the class {@code GatheringErrorListener} implement an error list ener that collects 19 * Instances of the class {@code GatheringErrorListener} implement an error list ener that collects
19 * all of the errors passed to it for later examination. 20 * all of the errors passed to it for later examination.
20 */ 21 */
21 class GatheringErrorListener implements AnalysisErrorListener { 22 class GatheringErrorListener implements AnalysisErrorListener {
22 /** 23 /**
23 * The source being parsed. 24 * The source being parsed.
24 */ 25 */
(...skipping 12 matching lines...) Expand all
37 */ 38 */
38 Map<Source, LineInfo> _lineInfoMap = new Map<Source, LineInfo>(); 39 Map<Source, LineInfo> _lineInfoMap = new Map<Source, LineInfo>();
39 /** 40 /**
40 * An empty array of errors used when no errors are expected. 41 * An empty array of errors used when no errors are expected.
41 */ 42 */
42 static List<AnalysisError> _NO_ERRORS = new List<AnalysisError>(0); 43 static List<AnalysisError> _NO_ERRORS = new List<AnalysisError>(0);
43 /** 44 /**
44 * Initialize a newly created error listener to collect errors. 45 * Initialize a newly created error listener to collect errors.
45 */ 46 */
46 GatheringErrorListener() : super() { 47 GatheringErrorListener() : super() {
47 _jtd_constructor_315_impl(); 48 _jtd_constructor_317_impl();
48 } 49 }
49 _jtd_constructor_315_impl() { 50 _jtd_constructor_317_impl() {
50 } 51 }
51 /** 52 /**
52 * Initialize a newly created error listener to collect errors. 53 * Initialize a newly created error listener to collect errors.
53 */ 54 */
54 GatheringErrorListener.con1(String rawSource2) { 55 GatheringErrorListener.con1(String rawSource2) {
55 _jtd_constructor_316_impl(rawSource2); 56 _jtd_constructor_318_impl(rawSource2);
56 } 57 }
57 _jtd_constructor_316_impl(String rawSource2) { 58 _jtd_constructor_318_impl(String rawSource2) {
58 this._rawSource = rawSource2; 59 this._rawSource = rawSource2;
59 this._markedSource = rawSource2; 60 this._markedSource = rawSource2;
60 } 61 }
61 /** 62 /**
62 * Assert that the number of errors that have been gathered matches the number of errors that are 63 * Assert that the number of errors that have been gathered matches the number of errors that are
63 * given and that they have the expected error codes and locations. The order in which the errors 64 * given and that they have the expected error codes and locations. The order in which the errors
64 * were gathered is ignored. 65 * were gathered is ignored.
65 * @param errorCodes the errors that should have been gathered 66 * @param errorCodes the errors that should have been gathered
66 * @throws AssertionFailedError if a different number of errors have been gath ered than were 67 * @throws AssertionFailedError if a different number of errors have been gath ered than were
67 * expected or if they do not have the same codes and locations 68 * expected or if they do not have the same codes and locations
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 * is ignored. 268 * is ignored.
268 * @param errorCodes the errors that should have been gathered 269 * @param errorCodes the errors that should have been gathered
269 * @throws AssertionFailedError with 270 * @throws AssertionFailedError with
270 */ 271 */
271 void fail(List<AnalysisError> expectedErrors) { 272 void fail(List<AnalysisError> expectedErrors) {
272 PrintStringWriter writer = new PrintStringWriter(); 273 PrintStringWriter writer = new PrintStringWriter();
273 writer.print("Expected "); 274 writer.print("Expected ");
274 writer.print(expectedErrors.length); 275 writer.print(expectedErrors.length);
275 writer.print(" errors:"); 276 writer.print(" errors:");
276 for (AnalysisError error in expectedErrors) { 277 for (AnalysisError error in expectedErrors) {
277 Source source11 = error.source; 278 Source source13 = error.source;
278 LineInfo lineInfo = _lineInfoMap[source11]; 279 LineInfo lineInfo = _lineInfoMap[source13];
279 writer.println(); 280 writer.println();
280 if (lineInfo == null) { 281 if (lineInfo == null) {
281 int offset10 = error.offset; 282 int offset10 = error.offset;
282 writer.printf(" %s %s (%d..%d)", [source11 == null ? "" : source11.shor tName, error.errorCode, offset10, offset10 + error.length]); 283 writer.printf(" %s %s (%d..%d)", [source13 == null ? "" : source13.shor tName, error.errorCode, offset10, offset10 + error.length]);
283 } else { 284 } else {
284 LineInfo_Location location = lineInfo.getLocation(error.offset); 285 LineInfo_Location location = lineInfo.getLocation(error.offset);
285 writer.printf(" %s %s (%d, %d/%d)", [source11 == null ? "" : source11.s hortName, error.errorCode, location.lineNumber, location.columnNumber, error.len gth]); 286 writer.printf(" %s %s (%d, %d/%d)", [source13 == null ? "" : source13.s hortName, error.errorCode, location.lineNumber, location.columnNumber, error.len gth]);
286 } 287 }
287 } 288 }
288 writer.println(); 289 writer.println();
289 writer.print("found "); 290 writer.print("found ");
290 writer.print(_errors.length); 291 writer.print(_errors.length);
291 writer.print(" errors:"); 292 writer.print(" errors:");
292 for (AnalysisError error in _errors) { 293 for (AnalysisError error in _errors) {
293 Source source12 = error.source; 294 Source source14 = error.source;
294 LineInfo lineInfo = _lineInfoMap[source12]; 295 LineInfo lineInfo = _lineInfoMap[source14];
295 writer.println(); 296 writer.println();
296 if (lineInfo == null) { 297 if (lineInfo == null) {
297 int offset11 = error.offset; 298 int offset11 = error.offset;
298 writer.printf(" %s %s (%d..%d): %s", [source12 == null ? "" : source12. shortName, error.errorCode, offset11, offset11 + error.length, error.message]); 299 writer.printf(" %s %s (%d..%d): %s", [source14 == null ? "" : source14. shortName, error.errorCode, offset11, offset11 + error.length, error.message]);
299 } else { 300 } else {
300 LineInfo_Location location = lineInfo.getLocation(error.offset); 301 LineInfo_Location location = lineInfo.getLocation(error.offset);
301 writer.printf(" %s %s (%d, %d/%d): %s", [source12 == null ? "" : source 12.shortName, error.errorCode, location.lineNumber, location.columnNumber, error .length, error.message]); 302 writer.printf(" %s %s (%d, %d/%d): %s", [source14 == null ? "" : source 14.shortName, error.errorCode, location.lineNumber, location.columnNumber, error .length, error.message]);
302 } 303 }
303 } 304 }
304 JUnitTestCase.fail(writer.toString()); 305 JUnitTestCase.fail(writer.toString());
305 } 306 }
306 /** 307 /**
307 * Search through the given list of errors for an error that is equal to the t arget error. If one 308 * Search through the given list of errors for an error that is equal to the t arget error. If one
308 * is found, remove it from the list and return {@code true}, otherwise return {@code false}without modifying the list. 309 * is found, remove it from the list and return {@code true}, otherwise return {@code false}without modifying the list.
309 * @param errors the errors through which we are searching 310 * @param errors the errors through which we are searching
310 * @param targetError the error being searched for 311 * @param targetError the error being searched for
311 * @return {@code true} if the error is found and removed from the list 312 * @return {@code true} if the error is found and removed from the list
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after
601 }); 602 });
602 } 603 }
603 } 604 }
604 main() { 605 main() {
605 } 606 }
606 607
607 class TestSource implements Source { 608 class TestSource implements Source {
608 bool operator ==(Object object) { 609 bool operator ==(Object object) {
609 return this == object; 610 return this == object;
610 } 611 }
612 AnalysisContext get context {
613 throw new UnsupportedOperationException();
614 }
611 void getContents(Source_ContentReceiver receiver) { 615 void getContents(Source_ContentReceiver receiver) {
612 throw new UnsupportedOperationException(); 616 throw new UnsupportedOperationException();
613 } 617 }
614 String get fullName { 618 String get fullName {
615 throw new UnsupportedOperationException(); 619 throw new UnsupportedOperationException();
616 } 620 }
617 String get shortName { 621 String get shortName {
618 throw new UnsupportedOperationException(); 622 throw new UnsupportedOperationException();
619 } 623 }
620 String get encoding { 624 String get encoding {
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
655 return trampoline(target, arguments[0], arguments[1]); 659 return trampoline(target, arguments[0], arguments[1]);
656 case 3: 660 case 3:
657 return trampoline(target, arguments[0], arguments[1], arguments[2]); 661 return trampoline(target, arguments[0], arguments[1], arguments[2]);
658 case 4: 662 case 4:
659 return trampoline(target, arguments[0], arguments[1], arguments[2], argu ments[3]); 663 return trampoline(target, arguments[0], arguments[1], arguments[2], argu ments[3]);
660 default: 664 default:
661 throw new IllegalArgumentException("Not implemented for > 4 arguments"); 665 throw new IllegalArgumentException("Not implemented for > 4 arguments");
662 } 666 }
663 } 667 }
664 } 668 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698