Skip to content

Commit ca58385

Browse files
authored
Merge SDK index weights (#8766)
1 parent 1c11ea9 commit ca58385

File tree

4 files changed

+16
-24
lines changed

4 files changed

+16
-24
lines changed

app/lib/search/dart_sdk_mem_index.dart

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,6 @@ import 'sdk_mem_index.dart';
1010

1111
final _logger = Logger('search.dart_sdk_mem_index');
1212

13-
/// Results from these libraries are ranked with lower score and
14-
/// will be displayed only if the query has the library name, or
15-
/// there are not other results that could match the query.
16-
const dartSdkLibraryWeights = <String, double>{
17-
'dart:html': 0.7,
18-
};
19-
2013
/// Sets the Dart SDK in-memory index.
2114
void registerDartSdkMemIndex(SdkMemIndex? index) {
2215
if (index != null) {

app/lib/search/flutter_sdk_mem_index.dart

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,6 @@ const flutterSdkAllowedLibraries = <String>{
3232
'flutter_web_plugins',
3333
};
3434

35-
const flutterApiPageDirWeights = <String, double>{
36-
'cupertino/CupertinoIcons': 0.25,
37-
'material/Icons': 0.25,
38-
};
39-
4035
final _logger = Logger('search.flutter_sdk_mem_index');
4136

4237
/// Sets the Flutter SDK in-memory index.

app/lib/search/sdk_mem_index.dart

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import 'package:meta/meta.dart';
88
// ignore: implementation_imports
99
import 'package:pana/src/dartdoc/dartdoc_index.dart';
1010
import 'package:path/path.dart' as p;
11-
import 'package:pub_dev/search/dart_sdk_mem_index.dart';
1211
import 'package:pub_dev/search/flutter_sdk_mem_index.dart';
1312

1413
import '../shared/versions.dart';
@@ -17,6 +16,21 @@ import 'token_index.dart';
1716

1817
export 'package:pana/src/dartdoc/dartdoc_index.dart';
1918

19+
/// Results from these libraries are ranked with lower score and
20+
/// will be displayed only if the query has the library name, or
21+
/// there are not other results that could match the query.
22+
const _libraryWeights = {
23+
'dart:html': 0.7,
24+
};
25+
26+
/// Results from these API pages are ranked with lower score and
27+
/// will be displayed only if the query has the library and the page
28+
/// name, or there are not other results that could match the query.
29+
const _defaultApiPageDirWeights = {
30+
'cupertino/CupertinoIcons': 0.25,
31+
'material/Icons': 0.25,
32+
};
33+
2034
/// In-memory index for SDK library search queries.
2135
class SdkMemIndex {
2236
final String _sdk;
@@ -25,7 +39,6 @@ class SdkMemIndex {
2539
final _tokensPerLibrary = <String, TokenIndex<String>>{};
2640
final _baseUriPerLibrary = <String, String>{};
2741
final _descriptionPerLibrary = <String, String>{};
28-
final Map<String, double> _libraryWeights;
2942
final Map<String, double> _apiPageDirWeights;
3043

3144
SdkMemIndex({
@@ -34,13 +47,11 @@ class SdkMemIndex {
3447
required Uri baseUri,
3548
required DartdocIndex index,
3649
Set<String>? allowedLibraries,
37-
Map<String, double>? libraryWeights,
3850
Map<String, double>? apiPageDirWeights,
3951
}) : _sdk = sdk,
4052
_version = version,
4153
_baseUri = baseUri,
42-
_libraryWeights = libraryWeights ?? const {},
43-
_apiPageDirWeights = apiPageDirWeights ?? const {} {
54+
_apiPageDirWeights = apiPageDirWeights ?? _defaultApiPageDirWeights {
4455
_addDartdocIndex(index, allowedLibraries);
4556
}
4657

@@ -50,7 +61,6 @@ class SdkMemIndex {
5061
version: runtimeSdkVersion,
5162
baseUri: Uri.parse('https://api.dart.dev/stable/latest/'),
5263
index: index,
53-
libraryWeights: dartSdkLibraryWeights,
5464
);
5565
}
5666

@@ -61,7 +71,6 @@ class SdkMemIndex {
6171
baseUri: Uri.parse('https://api.flutter.dev/flutter/'),
6272
index: index,
6373
allowedLibraries: flutterSdkAllowedLibraries,
64-
apiPageDirWeights: flutterApiPageDirWeights,
6574
);
6675
}
6776

app/test/search/sdk_mem_index_test.dart

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
import 'dart:convert';
66

7-
import 'package:pub_dev/search/dart_sdk_mem_index.dart';
87
import 'package:pub_dev/search/sdk_mem_index.dart';
98
import 'package:test/test.dart';
109

@@ -17,10 +16,6 @@ void main() {
1716
sdk: 'dart',
1817
version: '',
1918
baseUri: Uri.parse('https://api.dart.dev/x/'),
20-
libraryWeights: dartSdkLibraryWeights,
21-
apiPageDirWeights: {
22-
'dart:html/FakeIcons': 0.7,
23-
},
2419
index: DartdocIndex.fromJsonList([
2520
{
2621
'name': 'dart:async',

0 commit comments

Comments
 (0)