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

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

Issue 1460123002: Clean-up the registration of plugins (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 5 years, 1 month 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 engine.test_support; 5 library engine.test_support;
6 6
7 import 'dart:collection'; 7 import 'dart:collection';
8 8
9 import 'package:analyzer/src/generated/ast.dart' show AstNode, NodeLocator; 9 import 'package:analyzer/src/generated/ast.dart' show AstNode, NodeLocator;
10 import 'package:analyzer/src/generated/element.dart'; 10 import 'package:analyzer/src/generated/element.dart';
11 import 'package:analyzer/src/generated/engine.dart'; 11 import 'package:analyzer/src/generated/engine.dart';
12 import 'package:analyzer/src/generated/error.dart'; 12 import 'package:analyzer/src/generated/error.dart';
13 import 'package:analyzer/src/generated/java_core.dart'; 13 import 'package:analyzer/src/generated/java_core.dart';
14 import 'package:analyzer/src/generated/java_engine.dart'; 14 import 'package:analyzer/src/generated/java_engine.dart';
15 import 'package:analyzer/src/generated/source.dart'; 15 import 'package:analyzer/src/generated/source.dart';
16 import 'package:plugin/manager.dart';
16 import 'package:unittest/unittest.dart'; 17 import 'package:unittest/unittest.dart';
17 18
18 import 'resolver_test.dart'; 19 import 'resolver_test.dart';
19 20
20 /** 21 /**
21 * The class `EngineTestCase` defines utility methods for making assertions. 22 * The class `EngineTestCase` defines utility methods for making assertions.
22 */ 23 */
23 class EngineTestCase { 24 class EngineTestCase {
24 /** 25 /**
25 * Assert that the given collection has the same number of elements as the num ber of specified 26 * Assert that the given collection has the same number of elements as the num ber of specified
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 MethodElement getMethod(InterfaceType type, String methodName) { 85 MethodElement getMethod(InterfaceType type, String methodName) {
85 for (MethodElement method in type.element.methods) { 86 for (MethodElement method in type.element.methods) {
86 if (method.name == methodName) { 87 if (method.name == methodName) {
87 return method; 88 return method;
88 } 89 }
89 } 90 }
90 fail("Could not find method named $methodName in ${type.displayName}"); 91 fail("Could not find method named $methodName in ${type.displayName}");
91 return null; 92 return null;
92 } 93 }
93 94
94 void setUp() {} 95 void setUp() {
96 new ExtensionManager()
97 .processPlugins(AnalysisEngine.instance.supportedPlugins);
98 }
95 99
96 void tearDown() {} 100 void tearDown() {}
97 101
98 /** 102 /**
99 * Assert that the given object is an instance of the expected class. 103 * Assert that the given object is an instance of the expected class.
100 * 104 *
101 * @param expectedClass the class that the object is expected to be an instanc e of 105 * @param expectedClass the class that the object is expected to be an instanc e of
102 * @param object the object being tested 106 * @param object the object being tested
103 * @return the object that was being tested 107 * @return the object that was being tested
104 * @throws Exception if the object is not an instance of the expected class 108 * @throws Exception if the object is not an instance of the expected class
(...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after
550 String _contents; 554 String _contents;
551 int _modificationStamp = 0; 555 int _modificationStamp = 0;
552 bool exists2 = true; 556 bool exists2 = true;
553 557
554 /** 558 /**
555 * A flag indicating whether an exception should be generated when an attempt 559 * A flag indicating whether an exception should be generated when an attempt
556 * is made to access the contents of this source. 560 * is made to access the contents of this source.
557 */ 561 */
558 bool generateExceptionOnRead = false; 562 bool generateExceptionOnRead = false;
559 563
560 @override
561 int get modificationStamp =>
562 generateExceptionOnRead ? -1 : _modificationStamp;
563
564 /** 564 /**
565 * The number of times that the contents of this source have been requested. 565 * The number of times that the contents of this source have been requested.
566 */ 566 */
567 int readCount = 0; 567 int readCount = 0;
568 568
569 TestSource([this._name = '/test.dart', this._contents]); 569 TestSource([this._name = '/test.dart', this._contents]);
570 570
571 TimestampedData<String> get contents { 571 TimestampedData<String> get contents {
572 readCount++; 572 readCount++;
573 if (generateExceptionOnRead) { 573 if (generateExceptionOnRead) {
574 String msg = "I/O Exception while getting the contents of " + _name; 574 String msg = "I/O Exception while getting the contents of " + _name;
575 throw new Exception(msg); 575 throw new Exception(msg);
576 } 576 }
577 return new TimestampedData<String>(0, _contents); 577 return new TimestampedData<String>(0, _contents);
578 } 578 }
579 579
580 String get encoding { 580 String get encoding {
581 throw new UnsupportedOperationException(); 581 throw new UnsupportedOperationException();
582 } 582 }
583 583
584 String get fullName { 584 String get fullName {
585 return _name; 585 return _name;
586 } 586 }
587 587
588 int get hashCode => 0; 588 int get hashCode => 0;
589
589 bool get isInSystemLibrary { 590 bool get isInSystemLibrary {
590 return false; 591 return false;
591 } 592 }
592 593
594 @override
595 int get modificationStamp =>
596 generateExceptionOnRead ? -1 : _modificationStamp;
597
593 String get shortName { 598 String get shortName {
594 return _name; 599 return _name;
595 } 600 }
596 601
597 Uri get uri { 602 Uri get uri {
598 throw new UnsupportedOperationException(); 603 throw new UnsupportedOperationException();
599 } 604 }
600 605
601 UriKind get uriKind { 606 UriKind get uriKind {
602 throw new UnsupportedOperationException(); 607 throw new UnsupportedOperationException();
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
653 if (other is TestSource) { 658 if (other is TestSource) {
654 return other.uri == uri; 659 return other.uri == uri;
655 } 660 }
656 return false; 661 return false;
657 } 662 }
658 663
659 Uri resolveRelativeUri(Uri uri) { 664 Uri resolveRelativeUri(Uri uri) {
660 return this.uri.resolveUri(uri); 665 return this.uri.resolveUri(uri);
661 } 666 }
662 } 667 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698