mirror of
https://github.com/react/react-native-devtools-frontend.git
synced 2026-10-10 13:44:39 +08:00
- Updates stylelint to 13.8.0 - Updates ESLint to 7.14.0 - Updates @typescript-eslint to 4.9.0 DISABLE_THIRD_PARTY_CHECK=NPM update R=jacktfranklin@chromium.org Change-Id: I207e204607ede782710e042c17d6510c7f696905 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2566806 Reviewed-by: Jack Franklin <jacktfranklin@chromium.org> Commit-Queue: Tim van der Lippe <tvanderlippe@chromium.org>
100 lines
2.0 KiB
JavaScript
100 lines
2.0 KiB
JavaScript
exports.tokenize = tokenizeCodeIndented
|
||
exports.resolve = resolveCodeIndented
|
||
|
||
var markdownLineEnding = require('../character/markdown-line-ending')
|
||
|
||
var chunkedSplice = require('../util/chunked-splice')
|
||
var prefixSize = require('../util/prefix-size')
|
||
var createSpace = require('./factory-space')
|
||
|
||
var continuedIndent = {tokenize: tokenizeContinuedIndent, partial: true}
|
||
|
||
function resolveCodeIndented(events, context) {
|
||
var code = {
|
||
type: 'codeIndented',
|
||
start: events[0][1].start,
|
||
end: events[events.length - 1][1].end
|
||
}
|
||
|
||
chunkedSplice(events, 0, 0, [['enter', code, context]])
|
||
chunkedSplice(events, events.length, 0, [['exit', code, context]])
|
||
|
||
return events
|
||
}
|
||
|
||
function tokenizeCodeIndented(effects, ok, nok) {
|
||
var self = this
|
||
|
||
return createSpace(
|
||
effects,
|
||
afterInitial,
|
||
'linePrefix',
|
||
|
||
4 + 1
|
||
)
|
||
|
||
function afterInitial(code) {
|
||
// Flow checks blank lines first, so we don’t have EOL/EOF.
|
||
|
||
if (prefixSize(self.events, 'linePrefix') < 4) {
|
||
return nok(code)
|
||
}
|
||
|
||
effects.enter('codeFlowValue')
|
||
return content(code)
|
||
}
|
||
|
||
function afterPrefix(code) {
|
||
if (code === null) {
|
||
return ok(code)
|
||
}
|
||
|
||
if (markdownLineEnding(code)) {
|
||
return effects.attempt(continuedIndent, afterPrefix, ok)(code)
|
||
}
|
||
|
||
effects.enter('codeFlowValue')
|
||
return content(code)
|
||
}
|
||
|
||
function content(code) {
|
||
if (code === null || markdownLineEnding(code)) {
|
||
effects.exit('codeFlowValue')
|
||
return afterPrefix(code)
|
||
}
|
||
|
||
effects.consume(code)
|
||
return content
|
||
}
|
||
}
|
||
|
||
function tokenizeContinuedIndent(effects, ok, nok) {
|
||
var self = this
|
||
|
||
return createSpace(
|
||
effects,
|
||
afterPrefix,
|
||
'linePrefix',
|
||
|
||
4 + 1
|
||
)
|
||
|
||
function afterPrefix(code) {
|
||
if (markdownLineEnding(code)) {
|
||
effects.enter('lineEnding')
|
||
effects.consume(code)
|
||
effects.exit('lineEnding')
|
||
|
||
return createSpace(
|
||
effects,
|
||
afterPrefix,
|
||
'linePrefix',
|
||
|
||
4 + 1
|
||
)
|
||
}
|
||
|
||
return prefixSize(self.events, 'linePrefix') < 4 ? nok(code) : ok(code)
|
||
}
|
||
}
|