Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
coopwire-hypothesis
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
孙灵跃 Leon Sun
coopwire-hypothesis
Commits
d84e5ed1
Commit
d84e5ed1
authored
Dec 14, 2023
by
Robert Knight
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Unify runtime and typecheck-time field lists
parent
160feeb8
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
28 deletions
+13
-28
query-parser.ts
src/sidebar/helpers/query-parser.ts
+13
-28
No files found.
src/sidebar/helpers/query-parser.ts
View file @
d84e5ed1
/**
* Names of supported fields that can be specified via `{filename}:{term}`
* in {@link parseFilterQuery}.
*/
export
type
FilterField
=
|
'cfi'
|
'quote'
|
'page'
|
'since'
|
'tag'
|
'text'
|
'uri'
|
'user'
;
const
filterFields
:
FilterField
[]
=
[
const
filterFields
=
[
'cfi'
,
'quote'
,
'page'
,
...
...
@@ -21,22 +7,21 @@ const filterFields: FilterField[] = [
'text'
,
'uri'
,
'user'
,
];
]
as
const
;
/**
* Names of supported fields that can be specified via `{filename}:{term}`
* in {@link parseFilterQuery}.
*/
export
type
FilterField
=
(
typeof
filterFields
)[
number
];
const
searchFields
=
[
'group'
,
'quote'
,
'tag'
,
'text'
,
'uri'
,
'user'
]
as
const
;
/**
* Names of fields that can be used in `{field}:{term}` queries with
* {@link parseHypothesisSearchQuery}.
*/
export
type
SearchField
=
'group'
|
'quote'
|
'tag'
|
'text'
|
'uri'
|
'user'
;
const
searchFields
:
SearchField
[]
=
[
'group'
,
'quote'
,
'tag'
,
'text'
,
'uri'
,
'user'
,
];
export
type
SearchField
=
(
typeof
searchFields
)[
number
];
/**
* Splits a search term into filter and data.
...
...
@@ -49,7 +34,7 @@ const searchFields: SearchField[] = [
*/
function
splitTerm
(
term
:
string
,
fieldNames
:
string
[],
fieldNames
:
readonly
string
[],
):
[
null
|
string
,
string
]
{
const
filter
=
term
.
slice
(
0
,
term
.
indexOf
(
':'
));
if
(
!
filter
)
{
...
...
@@ -91,7 +76,7 @@ function removeSurroundingQuotes(text: string) {
* within quotes are split on whitespace. Terms inside single or double quotes
* are returned as whole tokens, with the surrounding quotes removed.
*/
function
tokenize
(
query
:
string
,
fieldNames
:
string
[]):
string
[]
{
function
tokenize
(
query
:
string
,
fieldNames
:
readonly
string
[]):
string
[]
{
const
tokenMatches
=
query
.
match
(
/
(?:[^\s
"'
]
+|"
[^
"
]
*"|'
[^
'
]
*'
)
+/g
);
if
(
!
tokenMatches
)
{
return
[];
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment