@@ -43,9 +43,11 @@ base mixin PubDevSupport on ToolsSupport {
43
43
try {
44
44
result = jsonDecode (await _client.read (searchUrl));
45
45
46
- final packageNames = dig <List >(result, [
47
- 'packages' ,
48
- ]).take (_resultsLimit).map ((p) => dig <String >(p, ['package' ])).toList ();
46
+ final packageNames =
47
+ dig <List >(result, ['packages' ])
48
+ .take (_resultsLimit)
49
+ .map ((p) => dig <String >(p, ['package' ]))
50
+ .toList ();
49
51
50
52
if (packageNames.isEmpty) {
51
53
return CallToolResult (
@@ -69,17 +71,18 @@ base mixin PubDevSupport on ToolsSupport {
69
71
}
70
72
71
73
// Retrieve information about all the packages in parallel.
72
- final subQueryFutures = packageNames
73
- .map (
74
- (packageName) => (
75
- versionListing: retrieve ('api/packages/$packageName ' ),
76
- score: retrieve ('api/packages/$packageName /score' ),
77
- docIndex: retrieve (
78
- 'documentation/$packageName /latest/index.json' ,
79
- ),
80
- ),
81
- )
82
- .toList ();
74
+ final subQueryFutures =
75
+ packageNames
76
+ .map (
77
+ (packageName) => (
78
+ versionListing: retrieve ('api/packages/$packageName ' ),
79
+ score: retrieve ('api/packages/$packageName /score' ),
80
+ docIndex: retrieve (
81
+ 'documentation/$packageName /latest/index.json' ,
82
+ ),
83
+ ),
84
+ )
85
+ .toList ();
83
86
84
87
// Aggregate the retrieved information about each package into a
85
88
// TextContent.
@@ -94,10 +97,11 @@ base mixin PubDevSupport on ToolsSupport {
94
97
? .cast <Map <String , Object ?>>() ??
95
98
< Map <String , Object ?>> [])
96
99
if (! object.containsKey ('enclosedBy' ))
97
- object['name' ] as String : Uri .https (
98
- 'pub.dev' ,
99
- 'documentation/$packageName /latest/${object ['href' ]}' ,
100
- ).toString (),
100
+ object['name' ] as String :
101
+ Uri .https (
102
+ 'pub.dev' ,
103
+ 'documentation/$packageName /latest/${object ['href' ]}' ,
104
+ ).toString (),
101
105
};
102
106
results.add (
103
107
TextContent (
@@ -108,26 +112,34 @@ base mixin PubDevSupport on ToolsSupport {
108
112
'latest' ,
109
113
'version' ,
110
114
]),
111
- 'description' : ? dig <String ?>(versionListing, [
112
- 'latest' ,
113
- 'pubspec' ,
114
- 'description' ,
115
- ]),
116
- 'homepage' : ? dig <String ?>(versionListing, [
117
- 'latest' ,
118
- 'pubspec' ,
119
- 'homepage' ,
120
- ]),
121
- 'repository' : ? dig <String ?>(versionListing, [
122
- 'latest' ,
123
- 'pubspec' ,
124
- 'repository' ,
125
- ]),
126
- 'documentation' : ? dig <String ?>(versionListing, [
127
- 'latest' ,
128
- 'pubspec' ,
129
- 'documentation' ,
130
- ]),
115
+ if (dig <String ?>(versionListing, [
116
+ 'latest' ,
117
+ 'pubspec' ,
118
+ 'description' ,
119
+ ])
120
+ case final description? )
121
+ 'description' : description,
122
+ if (dig <String ?>(versionListing, [
123
+ 'latest' ,
124
+ 'pubspec' ,
125
+ 'homepage' ,
126
+ ])
127
+ case final homepage? )
128
+ 'homepage' : homepage,
129
+ if (dig <String ?>(versionListing, [
130
+ 'latest' ,
131
+ 'pubspec' ,
132
+ 'repository' ,
133
+ ])
134
+ case final repository? )
135
+ 'repository' : repository,
136
+ if (dig <String ?>(versionListing, [
137
+ 'latest' ,
138
+ 'pubspec' ,
139
+ 'documentation' ,
140
+ ])
141
+ case final documentation? )
142
+ 'documentation' : documentation,
131
143
},
132
144
if (libraryDocs.isNotEmpty) ...{'libraries' : libraryDocs},
133
145
if (scoreResult != null ) ...{
@@ -139,15 +151,19 @@ base mixin PubDevSupport on ToolsSupport {
139
151
'downloadCount30Days' ,
140
152
]),
141
153
},
142
- 'topics' : dig <List >(scoreResult, [
143
- 'tags' ,
144
- ]).where ((t) => (t as String ).startsWith ('topic:' )).toList (),
145
- 'licenses' : dig <List >(scoreResult, [
146
- 'tags' ,
147
- ]).where ((t) => (t as String ).startsWith ('license' )).toList (),
148
- 'publisher' : dig <List >(scoreResult, ['tags' ])
149
- .where ((t) => (t as String ).startsWith ('publisher:' ))
150
- .firstOrNull,
154
+ 'topics' :
155
+ dig <List >(
156
+ scoreResult,
157
+ ['tags' ],
158
+ ).where ((t) => (t as String ).startsWith ('topic:' )).toList (),
159
+ 'licenses' :
160
+ dig <List >(scoreResult, ['tags' ])
161
+ .where ((t) => (t as String ).startsWith ('license' ))
162
+ .toList (),
163
+ 'publisher' :
164
+ dig <List >(scoreResult, ['tags' ])
165
+ .where ((t) => (t as String ).startsWith ('publisher:' ))
166
+ .firstOrNull,
151
167
},
152
168
}),
153
169
),
0 commit comments