@@ -25,6 +25,7 @@ import 'package:linter/src/io.dart';
25
25
import 'package:linter/src/linter.dart' ;
26
26
import 'package:linter/src/project.dart' ;
27
27
import 'package:linter/src/rules.dart' ;
28
+ import 'package:linter/src/sdk.dart' ;
28
29
import 'package:package_config/packages.dart' show Packages;
29
30
import 'package:package_config/packages_file.dart' as pkgfile show parse;
30
31
import 'package:package_config/src/packages_impl.dart' show MapPackages;
@@ -62,8 +63,12 @@ class AnalysisDriver {
62
63
int get numSourcesAnalyzed => _sourcesAnalyzed.length;
63
64
64
65
List <UriResolver > get resolvers {
65
- DartSdk sdk = new DirectoryBasedDartSdk (new JavaFile (sdkDir));
66
+ DartSdk sdk = options.useMockSdk
67
+ ? new MockSdk ()
68
+ : new DirectoryBasedDartSdk (new JavaFile (sdkDir));
69
+
66
70
List <UriResolver > resolvers = [new DartUriResolver (sdk)];
71
+
67
72
if (options.packageRootPath != null ) {
68
73
JavaFile packageDirectory = new JavaFile (options.packageRootPath);
69
74
resolvers.add (new PackageUriResolver ([packageDirectory]));
@@ -78,6 +83,7 @@ class AnalysisDriver {
78
83
PhysicalResourceProvider .INSTANCE , packageMap));
79
84
}
80
85
}
86
+
81
87
// File URI resolver must come last so that files inside "/lib" are
82
88
// are analyzed via "package:" URI's.
83
89
resolvers.add (new FileUriResolver ());
@@ -211,16 +217,19 @@ class DriverOptions {
211
217
/// The path to the package root.
212
218
String packageRootPath;
213
219
220
+ /// If non-null, the function to use to run pub list. This is used to mock
221
+ /// out executions of pub list when testing the linter.
222
+ RunPubList runPubList = null ;
223
+
214
224
/// Whether to show SDK warnings.
215
225
bool showSdkWarnings = false ;
216
226
227
+ /// Whether to use a mock SDK (to speed up testing).
228
+ bool useMockSdk = false ;
229
+
217
230
/// Whether to show lints for the transitive closure of imported and exported
218
231
/// libraries.
219
232
bool visitTransitiveClosure = false ;
220
-
221
- /// If non-null, the function to use to run pub list. This is used to mock
222
- /// out executions of pub list when testing the linter.
223
- RunPubList runPubList = null ;
224
233
}
225
234
226
235
/// Prints logging information comments to the [outSink] and error messages to
0 commit comments