Skip to content

Commit 1a8403e

Browse files
authored
Rank libraries lower than classes and class members (#3446)
1 parent 793d575 commit 1a8403e

File tree

2 files changed

+21
-21
lines changed

2 files changed

+21
-21
lines changed

lib/src/search.dart

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -153,27 +153,27 @@ class IndexItem {
153153
/// This is not the lexical scope of identifiers in Dart code, but similar in
154154
/// a very loose sense.
155155
int get _scope => switch (kind) {
156-
// Root- and package-level items.
157-
Kind.library => 0,
158-
Kind.package => 0,
159-
Kind.topic => 0,
160-
161156
// Library members.
162-
Kind.class_ => 1,
163-
Kind.enum_ => 1,
164-
Kind.extension => 1,
165-
Kind.mixin => 1,
166-
Kind.topLevelConstant => 1,
167-
Kind.topLevelProperty => 1,
168-
Kind.typedef => 1,
157+
Kind.class_ => 0,
158+
Kind.enum_ => 0,
159+
Kind.extension => 0,
160+
Kind.mixin => 0,
161+
Kind.topLevelConstant => 0,
162+
Kind.topLevelProperty => 0,
163+
Kind.typedef => 0,
169164

170165
// Container members.
171-
Kind.accessor => 2,
172-
Kind.constant => 2,
173-
Kind.constructor => 2,
174-
Kind.function => 2,
175-
Kind.method => 2,
176-
Kind.property => 2,
166+
Kind.accessor => 1,
167+
Kind.constant => 1,
168+
Kind.constructor => 1,
169+
Kind.function => 1,
170+
Kind.method => 1,
171+
Kind.property => 1,
172+
173+
// Root- and package-level items.
174+
Kind.library => 2,
175+
Kind.package => 2,
176+
Kind.topic => 2,
177177

178178
// Others.
179179
Kind.dynamic => 3,

test/search_test.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ class SearchTest {
106106
void test_prefersHigherPackages() {
107107
expect(
108108
matchNames('foo'),
109-
containsAllInOrder(['FOO', 'foo.FOO', 'foo', 'foo.Foo']),
109+
containsAllInOrder(['foo.FOO', 'FOO', 'foo.Foo', 'foo']),
110110
);
111111
}
112112

@@ -119,10 +119,10 @@ class SearchTest {
119119
);
120120
}
121121

122-
void test_prefersOuterScopes() {
122+
void test_prefersLibraryScoped() {
123123
expect(
124124
matchNames('foo'),
125-
containsAllInOrder(['foo', 'foo.Foo', 'bar.Bar.foo']),
125+
containsAllInOrder(['foo.Foo', 'bar.Bar.foo', 'foo']),
126126
);
127127
}
128128

0 commit comments

Comments
 (0)