Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
renovate
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
SmartDataLab
public
applications
renovate
Commits
5716077f
Unverified
Commit
5716077f
authored
Apr 23, 2021
by
Sergei Zharinov
Committed by
GitHub
Apr 23, 2021
Browse files
Options
Downloads
Patches
Plain Diff
refactor: Cache moo lexer instances (#9697)
parent
37a8e282
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
lib/manager/bazel/extract.ts
+3
-3
3 additions, 3 deletions
lib/manager/bazel/extract.ts
lib/manager/cake/index.ts
+2
-3
2 additions, 3 deletions
lib/manager/cake/index.ts
lib/manager/gradle-lite/tokenizer.ts
+2
-3
2 additions, 3 deletions
lib/manager/gradle-lite/tokenizer.ts
with
7 additions
and
9 deletions
lib/manager/bazel/extract.ts
+
3
−
3
View file @
5716077f
...
...
@@ -53,7 +53,7 @@ function parseUrl(urlString: string): UrlParsedResult | null {
return
null
;
}
const
dummyL
exer
=
{
const
l
exer
=
moo
.
states
(
{
main
:
{
lineComment
:
{
match
:
/#.*
?
$/
},
leftParen
:
{
match
:
'
(
'
},
...
...
@@ -103,11 +103,11 @@ const dummyLexer = {
stringFinish
:
{
match
:
"
'
"
,
pop
:
1
},
char
:
{
match
:
/
[^]
/
,
lineBreaks
:
true
},
},
};
}
)
;
function
parseContent
(
content
:
string
):
string
[]
{
const
lexer
=
moo
.
states
(
dummyLexer
);
lexer
.
reset
(
content
);
let
balance
=
0
;
let
def
:
null
|
string
=
null
;
...
...
This diff is collapsed.
Click to expand it.
lib/manager/cake/index.ts
+
2
−
3
View file @
5716077f
...
...
@@ -10,7 +10,7 @@ export const defaultConfig = {
fileMatch
:
[
'
\\
.cake$
'
],
};
const
lexer
S
tates
=
{
const
lexer
=
moo
.
s
tates
(
{
main
:
{
lineComment
:
{
match
:
/
\/\/
.*
?
$/
},
multiLineComment
:
{
match
:
/
\/\*[^]
*
?\*\/
/
,
lineBreaks
:
true
},
...
...
@@ -23,7 +23,7 @@ const lexerStates = {
},
unknown
:
{
match
:
/
[^]
/
,
lineBreaks
:
true
},
},
};
}
)
;
function
parseDependencyLine
(
line
:
string
):
PackageDependency
|
null
{
try
{
...
...
@@ -54,7 +54,6 @@ function parseDependencyLine(line: string): PackageDependency | null {
export
function
extractPackageFile
(
content
:
string
):
PackageFile
{
const
deps
=
[];
const
lexer
=
moo
.
states
(
lexerStates
);
lexer
.
reset
(
content
);
let
token
=
lexer
.
next
();
while
(
token
)
{
...
...
This diff is collapsed.
Click to expand it.
lib/manager/gradle-lite/tokenizer.ts
+
2
−
3
View file @
5716077f
...
...
@@ -19,7 +19,7 @@ const escapedChars = {
},
};
export
const
rawL
exer
=
{
const
l
exer
=
moo
.
states
(
{
// Top-level Groovy lexemes
main
:
{
[
TokenType
.
LineComment
]:
{
match
:
/
\/\/
.*
?
$/
},
...
...
@@ -104,7 +104,7 @@ export const rawLexer = {
[
TokenType
.
RightBrace
]:
{
match
:
'
}
'
,
pop
:
1
},
[
TokenType
.
UnknownLexeme
]:
{
match
:
/
[^]
/
,
lineBreaks
:
true
},
},
};
}
)
;
/*
Turn UnknownLexeme chars to UnknownFragment strings
...
...
@@ -213,7 +213,6 @@ function filterTokens({ type }: Token): boolean {
}
export
function
extractRawTokens
(
input
:
string
):
Token
[]
{
const
lexer
=
moo
.
states
(
rawLexer
);
lexer
.
reset
(
input
);
return
Array
.
from
(
lexer
).
map
(
({
type
,
offset
,
value
})
=>
({
type
,
offset
,
value
}
as
Token
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
sign in
to comment