@@ -17,6 +17,7 @@ import 'license.dart';
17
17
import 'logging.dart' ;
18
18
import 'messages.dart' as messages;
19
19
import 'package_analyzer.dart' show InspectOptions;
20
+ import 'pana_cache.dart' ;
20
21
import 'pkg_resolution.dart' ;
21
22
import 'pubspec.dart' ;
22
23
import 'pubspec_io.dart' ;
@@ -32,28 +33,29 @@ import 'utils.dart' show listFocusDirs;
32
33
/// External systems that may be independent of the archive content may be
33
34
/// stored here, e.g. repository and URL verification.
34
35
class SharedAnalysisContext {
36
+ final PanaCache panaCache;
35
37
final ToolEnvironment toolEnvironment;
36
38
final InspectOptions options;
37
39
final UrlChecker _urlChecker;
38
40
39
41
SharedAnalysisContext ({
42
+ PanaCache ? panaCache,
40
43
required this .toolEnvironment,
41
44
InspectOptions ? options,
42
45
UrlChecker ? urlChecker,
43
- }) : options = options ?? InspectOptions (),
46
+ }) : panaCache = panaCache ?? PanaCache (),
47
+ options = options ?? InspectOptions (),
44
48
_urlChecker = urlChecker ?? UrlChecker ();
45
49
46
50
Future <UrlStatus > checkUrlStatus (String url) async {
47
51
final cacheType = 'url' ;
48
52
final cacheKey = url;
49
- final cachedData =
50
- await toolEnvironment.panaCache.readData (cacheType, cacheKey);
53
+ final cachedData = await panaCache.readData (cacheType, cacheKey);
51
54
if (cachedData != null ) {
52
55
return UrlStatus .fromJson (cachedData);
53
56
}
54
57
final status = await _urlChecker.checkStatus (url);
55
- await toolEnvironment.panaCache
56
- .writeData (cacheType, cacheKey, status.toJson ());
58
+ await panaCache.writeData (cacheType, cacheKey, status.toJson ());
57
59
return status;
58
60
}
59
61
@@ -66,8 +68,7 @@ class SharedAnalysisContext {
66
68
}
67
69
final cacheType = 'repository' ;
68
70
final cacheKey = '$package /$repositoryOrHomepage ' ;
69
- final cachedData =
70
- await toolEnvironment.panaCache.readData (cacheType, cacheKey);
71
+ final cachedData = await panaCache.readData (cacheType, cacheKey);
71
72
if (cachedData != null ) {
72
73
return VerifiedRepository .fromJson (cachedData);
73
74
}
@@ -77,8 +78,7 @@ class SharedAnalysisContext {
77
78
sourceUrl: repositoryOrHomepage,
78
79
);
79
80
if (repository != null ) {
80
- await toolEnvironment.panaCache
81
- .writeData (cacheType, cacheKey, repository.toJson ());
81
+ await panaCache.writeData (cacheType, cacheKey, repository.toJson ());
82
82
}
83
83
return repository;
84
84
}
0 commit comments