4
4
5
5
import 'dart:async' ;
6
6
7
- import 'package:analyzer/dart/analysis/results.dart' ;
8
- import 'package:analyzer/dart/analysis/session.dart' ;
9
7
import 'package:analyzer/dart/ast/ast.dart' ;
10
8
import 'package:analyzer/dart/element/element.dart' ;
11
- import 'package:analyzer/src/dart/analysis/driver.dart' ;
12
9
import 'package:analyzer/src/generated/sdk.dart' ;
13
10
import 'package:analyzer/src/generated/source.dart' ;
14
11
import 'package:analyzer/src/generated/source_io.dart' ;
@@ -24,10 +21,9 @@ import 'package:dartdoc/src/tuple.dart';
24
21
import 'package:dartdoc/src/warnings.dart' ;
25
22
26
23
class PackageGraph {
27
- PackageGraph .UninitializedPackageGraph (this .config, this .driver, this .sdk,
28
- this .hasEmbedderSdk, this .rendererFactory)
29
- : packageMeta = config.topLevelPackageMeta,
30
- session = driver.currentSession {
24
+ PackageGraph .UninitializedPackageGraph (
25
+ this .config, this .sdk, this .hasEmbedderSdk, this .rendererFactory)
26
+ : packageMeta = config.topLevelPackageMeta {
31
27
_packageWarningCounter = PackageWarningCounter (this );
32
28
// Make sure the default package exists, even if it has no libraries.
33
29
// This can happen for packages that only contain embedder SDKs.
@@ -39,23 +35,23 @@ class PackageGraph {
39
35
/// Libraries added in this manner are assumed to be part of documented
40
36
/// packages, even if includes or embedder.yaml files cause these to
41
37
/// span packages.
42
- void addLibraryToGraph (ResolvedLibraryResult result ) {
38
+ void addLibraryToGraph (DartDocResolvedLibrary resolvedLibrary ) {
43
39
assert (! allLibrariesAdded);
44
- var element = result .element;
40
+ var element = resolvedLibrary .element;
45
41
var packageMeta = PackageMeta .fromElement (element, config.sdkDir);
46
42
var lib = Library .fromLibraryResult (
47
- result , this , Package .fromPackageMeta (packageMeta, this ));
43
+ resolvedLibrary , this , Package .fromPackageMeta (packageMeta, this ));
48
44
packageMap[packageMeta.name].libraries.add (lib);
49
45
allLibraries[element] = lib;
50
46
}
51
47
52
48
/// Call during initialization to add a library possibly containing
53
49
/// special/non-documented elements to this [PackageGraph] . Must be called
54
50
/// after any normal libraries.
55
- void addSpecialLibraryToGraph (ResolvedLibraryResult result ) {
51
+ void addSpecialLibraryToGraph (DartDocResolvedLibrary resolvedLibrary ) {
56
52
allLibrariesAdded = true ;
57
53
assert (! _localDocumentationBuilt);
58
- findOrCreateLibraryFor (result );
54
+ findOrCreateLibraryFor (resolvedLibrary );
59
55
}
60
56
61
57
/// Call after all libraries are added.
@@ -234,9 +230,6 @@ class PackageGraph {
234
230
/// Map of package name to Package.
235
231
final Map <String , Package > packageMap = {};
236
232
237
- /// TODO(brianwilkerson) Replace the driver with the session.
238
- final AnalysisDriver driver;
239
- final AnalysisSession session;
240
233
final DartSdk sdk;
241
234
242
235
Map <Source , SdkLibrary > _sdkLibrarySources;
@@ -842,22 +835,23 @@ class PackageGraph {
842
835
/// This is used when we might need a Library object that isn't actually
843
836
/// a documentation entry point (for elements that have no Library within the
844
837
/// set of canonical Libraries).
845
- Library findOrCreateLibraryFor (ResolvedLibraryResult result) {
838
+ Library findOrCreateLibraryFor (DartDocResolvedLibrary resolvedLibrary) {
839
+ final elementLibrary = resolvedLibrary.library;
846
840
// This is just a cache to avoid creating lots of libraries over and over.
847
- if (allLibraries.containsKey (result.element.library )) {
848
- return allLibraries[result.element.library ];
841
+ if (allLibraries.containsKey (elementLibrary )) {
842
+ return allLibraries[elementLibrary ];
849
843
}
850
844
// can be null if e is for dynamic
851
- if (result.element.library == null ) {
845
+ if (elementLibrary == null ) {
852
846
return null ;
853
847
}
854
848
var foundLibrary = Library .fromLibraryResult (
855
- result ,
849
+ resolvedLibrary ,
856
850
this ,
857
851
Package .fromPackageMeta (
858
- PackageMeta .fromElement (result.element.library , config.sdkDir),
852
+ PackageMeta .fromElement (elementLibrary , config.sdkDir),
859
853
packageGraph));
860
- allLibraries[result.element.library ] = foundLibrary;
854
+ allLibraries[elementLibrary ] = foundLibrary;
861
855
return foundLibrary;
862
856
}
863
857
0 commit comments