@@ -158,7 +158,65 @@ window.initSearch = function(rawSearchIndex) {
158
158
}
159
159
160
160
/**
161
- * Executes the query and returns a list of results for each results tab.
161
+ * Executes the query and builds an index of results
162
+ *
163
+ * The supported syntax by this parser is as follow:
164
+ *
165
+ * ident = *1(ALPHA / DIGIT)
166
+ * path = ident *WS *(DOUBLE-COLON *WS ident)
167
+ * arg = path *WS [generics]
168
+ * nonempty-arg-list = arg *WS *(COMMA *WS arg)
169
+ * generics = OPEN-ANGLE-BRACKET *WS nonempty-arg-list *WS CLOSE-ANGLE-BRACKET
170
+ * function-args = OPEN-PAREN *WS [nonempty-arg-list] *WS END-PAREN
171
+ * return-args = RETURN-ARROW *WS function-args
172
+ *
173
+ * exact-search = [type-filter *WS COLON] *WS QUOTE ident QUOTE *WS [generics]
174
+ * type-search = [type-filter *WS COLON] *WS path *WS generics
175
+ * function-search = path *WS function-args *WS [return-args]
176
+ *
177
+ * query = *WS (exact-search / type-search / function-search / return-args) *WS
178
+ *
179
+ * type-filter = (
180
+ * "mod" /
181
+ * "externcrate" /
182
+ * "import" /
183
+ * "struct" /
184
+ * "enum" /
185
+ * "fn" /
186
+ * "type" /
187
+ * "static" /
188
+ * "trait" /
189
+ * "impl" /
190
+ * "tymethod" /
191
+ * "method" /
192
+ * "structfield" /
193
+ * "variant" /
194
+ * "macro" /
195
+ * "primitive" /
196
+ * "associatedtype" /
197
+ * "constant" /
198
+ * "associatedconstant" /
199
+ * "union" /
200
+ * "foreigntype" /
201
+ * "keyword" /
202
+ * "existential" /
203
+ * "attr" /
204
+ * "derive" /
205
+ * "traitalias")
206
+ *
207
+ * OPEN-ANGLE-BRACKET = "<"
208
+ * CLOSE-ANGLE-BRACKET = ">"
209
+ * OPEN-PAREN = "("
210
+ * END-PAREN = ")"
211
+ * COLON = ":"
212
+ * DOUBLE-COLON = "::"
213
+ * QUOTE = %x22
214
+ * COMMA = ","
215
+ * RETURN-ARROW = "->"
216
+ *
217
+ * ALPHA = %x41-5A / %x61-7A ; A-Z / a-z
218
+ * DIGIT = %x30-39
219
+ * WS = %x09 / " "
162
220
*
163
221
* @param {string } val - The user query
164
222
* @return {ParsedQuery } - The parsed query
@@ -606,7 +664,8 @@ window.initSearch = function(rawSearchIndex) {
606
664
* This function checks if the object (`obj`) generics match the given type (`val`)
607
665
* generics. If there are no generics on `obj`, `defaultLev` is returned.
608
666
*
609
- * @param {Object } obj - The object to check.
667
+ * @param {Row } obj - The object to check.
668
+ * @param {QueryElement } val - The element from the parsed query.
610
669
* @param {integer } defaultLev - This is the value to return in case there are no generics.
611
670
*
612
671
* @return {integer } - Returns the best match (if any) or `MAX_LEV_DISTANCE + 1`.
@@ -662,8 +721,8 @@ window.initSearch = function(rawSearchIndex) {
662
721
* This function checks if the object (`obj`) matches the given type (`val`) and its
663
722
* generics (if any).
664
723
*
665
- * @param {Object } obj
666
- * @param {Object } val
724
+ * @param {Row } obj
725
+ * @param {QueryElement } val - The element from the parsed query.
667
726
*
668
727
* @return {integer } - Returns a Levenshtein distance to the best match.
669
728
*/
@@ -756,8 +815,8 @@ window.initSearch = function(rawSearchIndex) {
756
815
/**
757
816
* This function checks if the object (`obj`) has an argument with the given type (`val`).
758
817
*
759
- * @param {Object } obj
760
- * @param {Object } val
818
+ * @param {Row } obj
819
+ * @param {QueryElement } val - The element from the parsed query.
761
820
* @param {integer } typeFilter
762
821
*
763
822
* @return {integer } - Returns a Levenshtein distance to the best match. If there is no
@@ -784,8 +843,8 @@ window.initSearch = function(rawSearchIndex) {
784
843
}
785
844
786
845
/**
787
- * @param {Object } obj
788
- * @param {Object } val
846
+ * @param {Row } obj
847
+ * @param {QueryElement } val - The element from the parsed query.
789
848
* @param {integer } typeFilter
790
849
*
791
850
* @return {integer } - Returns a Levenshtein distance to the best match. If there is no
@@ -978,9 +1037,9 @@ window.initSearch = function(rawSearchIndex) {
978
1037
/**
979
1038
* This function is called in case the query is only one element (with or without generics).
980
1039
*
981
- * @param {Object } ty
982
- * @param {integer } pos - Position in the `searchIndex`.
983
- * @param {Object } elem - The element from the parsed query.
1040
+ * @param {Row } ty
1041
+ * @param {integer } pos - Position in the `searchIndex`.
1042
+ * @param {QueryElement } elem - The element from the parsed query.
984
1043
*/
985
1044
function handleSingleArg ( ty , pos , elem ) {
986
1045
if ( ! ty || ( filterCrates !== null && ty . crate !== filterCrates ) ) {
@@ -1477,7 +1536,7 @@ window.initSearch = function(rawSearchIndex) {
1477
1536
}
1478
1537
1479
1538
if ( ! forced && query . id === currentResults ) {
1480
- if ( query . val . length > 0 ) {
1539
+ if ( query . userQuery . length > 0 ) {
1481
1540
putBackSearch ( ) ;
1482
1541
}
1483
1542
return ;
0 commit comments