@@ -43,9 +43,11 @@ base mixin PubDevSupport on ToolsSupport {
4343 try {
4444 result = jsonDecode (await _client.read (searchUrl));
4545
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 ();
4951
5052 if (packageNames.isEmpty) {
5153 return CallToolResult (
@@ -69,17 +71,18 @@ base mixin PubDevSupport on ToolsSupport {
6971 }
7072
7173 // 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 ();
8386
8487 // Aggregate the retrieved information about each package into a
8588 // TextContent.
@@ -94,10 +97,11 @@ base mixin PubDevSupport on ToolsSupport {
9497 ? .cast <Map <String , Object ?>>() ??
9598 < Map <String , Object ?>> [])
9699 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 (),
101105 };
102106 results.add (
103107 TextContent (
@@ -108,26 +112,34 @@ base mixin PubDevSupport on ToolsSupport {
108112 'latest' ,
109113 'version' ,
110114 ]),
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,
131143 },
132144 if (libraryDocs.isNotEmpty) ...{'libraries' : libraryDocs},
133145 if (scoreResult != null ) ...{
@@ -139,15 +151,19 @@ base mixin PubDevSupport on ToolsSupport {
139151 'downloadCount30Days' ,
140152 ]),
141153 },
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,
151167 },
152168 }),
153169 ),
0 commit comments