@vap/shiki
Version:
shiki, stripped of assets + browser only
1,356 lines (1,351 loc) • 191 kB
JavaScript
var FontStyle
;(function (FontStyle) {
FontStyle[(FontStyle['NotSet'] = -1)] = 'NotSet'
FontStyle[(FontStyle['None'] = 0)] = 'None'
FontStyle[(FontStyle['Italic'] = 1)] = 'Italic'
FontStyle[(FontStyle['Bold'] = 2)] = 'Bold'
FontStyle[(FontStyle['Underline'] = 4)] = 'Underline'
})(FontStyle || (FontStyle = {}))
class StackElementMetadata {
static toBinaryStr(metadata) {
let r = metadata.toString(2)
while (r.length < 32) {
r = '0' + r
}
return r
}
static printMetadata(metadata) {
let languageId = StackElementMetadata.getLanguageId(metadata)
let tokenType = StackElementMetadata.getTokenType(metadata)
let fontStyle = StackElementMetadata.getFontStyle(metadata)
let foreground = StackElementMetadata.getForeground(metadata)
let background = StackElementMetadata.getBackground(metadata)
console.log({
languageId: languageId,
tokenType: tokenType,
fontStyle: fontStyle,
foreground: foreground,
background: background
})
}
static getLanguageId(metadata) {
return (
(metadata & 255) /* MetadataConsts.LANGUAGEID_MASK */ >>>
0 /* MetadataConsts.LANGUAGEID_OFFSET */
)
}
static getTokenType(metadata) {
return (
(metadata & 1792) /* MetadataConsts.TOKEN_TYPE_MASK */ >>>
8 /* MetadataConsts.TOKEN_TYPE_OFFSET */
)
}
static getFontStyle(metadata) {
return (
(metadata & 14336) /* MetadataConsts.FONT_STYLE_MASK */ >>>
11 /* MetadataConsts.FONT_STYLE_OFFSET */
)
}
static getForeground(metadata) {
return (
(metadata & 8372224) /* MetadataConsts.FOREGROUND_MASK */ >>>
14 /* MetadataConsts.FOREGROUND_OFFSET */
)
}
static getBackground(metadata) {
return (
(metadata & 4286578688) /* MetadataConsts.BACKGROUND_MASK */ >>>
23 /* MetadataConsts.BACKGROUND_OFFSET */
)
}
static set(metadata, languageId, tokenType, fontStyle, foreground, background) {
let _languageId = StackElementMetadata.getLanguageId(metadata)
let _tokenType = StackElementMetadata.getTokenType(metadata)
let _fontStyle = StackElementMetadata.getFontStyle(metadata)
let _foreground = StackElementMetadata.getForeground(metadata)
let _background = StackElementMetadata.getBackground(metadata)
if (languageId !== 0) {
_languageId = languageId
}
if (tokenType !== 0 /* TemporaryStandardTokenType.Other */) {
_tokenType =
tokenType === 8 /* TemporaryStandardTokenType.MetaEmbedded */
? 0 /* StandardTokenType.Other */
: tokenType
}
if (fontStyle !== FontStyle.NotSet) {
_fontStyle = fontStyle
}
if (foreground !== 0) {
_foreground = foreground
}
if (background !== 0) {
_background = background
}
return (
((_languageId << 0) /* MetadataConsts.LANGUAGEID_OFFSET */ |
(_tokenType << 8) /* MetadataConsts.TOKEN_TYPE_OFFSET */ |
(_fontStyle << 11) /* MetadataConsts.FONT_STYLE_OFFSET */ |
(_foreground << 14) /* MetadataConsts.FOREGROUND_OFFSET */ |
(_background << 23) /* MetadataConsts.BACKGROUND_OFFSET */) >>>
0
)
}
}
/*---------------------------------------------------------
* Copyright (C) Microsoft Corporation. All rights reserved.
*--------------------------------------------------------*/
class Resolver {
constructor(onigLibPromise, onigLibName) {
this.languagesPath = 'languages/'
this.languageMap = {}
this.scopeToLangMap = {}
this._onigLibPromise = onigLibPromise
this._onigLibName = onigLibName
}
get onigLib() {
return this._onigLibPromise
}
getOnigLibName() {
return this._onigLibName
}
getLangRegistration(langIdOrAlias) {
return this.languageMap[langIdOrAlias]
}
async loadGrammar(scopeName) {
const lang = this.scopeToLangMap[scopeName]
if (!lang) {
return null
}
if (lang.grammar) {
return lang.grammar
}
return null
}
addLanguage(l) {
this.languageMap[l.id] = l
if (l.aliases) {
l.aliases.forEach(a => {
this.languageMap[a] = l
})
}
this.scopeToLangMap[l.scopeName] = l
}
}
var commonjsGlobal =
typeof globalThis !== 'undefined'
? globalThis
: typeof window !== 'undefined'
? window
: typeof global !== 'undefined'
? global
: typeof self !== 'undefined'
? self
: {}
var main$1 = { exports: {} }
;(function (module, exports) {
!(function (e, t) {
module.exports = t()
})(commonjsGlobal, function () {
return (function (e) {
var t = {}
function n(r) {
if (t[r]) return t[r].exports
var i = (t[r] = { i: r, l: !1, exports: {} })
return e[r].call(i.exports, i, i.exports, n), (i.l = !0), i.exports
}
return (
(n.m = e),
(n.c = t),
(n.d = function (e, t, r) {
n.o(e, t) || Object.defineProperty(e, t, { enumerable: !0, get: r })
}),
(n.r = function (e) {
'undefined' != typeof Symbol &&
Symbol.toStringTag &&
Object.defineProperty(e, Symbol.toStringTag, { value: 'Module' }),
Object.defineProperty(e, '__esModule', { value: !0 })
}),
(n.t = function (e, t) {
if ((1 & t && (e = n(e)), 8 & t)) return e
if (4 & t && 'object' == typeof e && e && e.__esModule) return e
var r = Object.create(null)
if (
(n.r(r),
Object.defineProperty(r, 'default', { enumerable: !0, value: e }),
2 & t && 'string' != typeof e)
)
for (var i in e)
n.d(
r,
i,
function (t) {
return e[t]
}.bind(null, i)
)
return r
}),
(n.n = function (e) {
var t =
e && e.__esModule
? function () {
return e.default
}
: function () {
return e
}
return n.d(t, 'a', t), t
}),
(n.o = function (e, t) {
return Object.prototype.hasOwnProperty.call(e, t)
}),
(n.p = ''),
n((n.s = 3))
)
})([
function (e, t, n) {
Object.defineProperty(t, '__esModule', { value: !0 })
var r = n(1),
i = n(5),
o = n(6),
s = n(2),
a =
'undefined' == typeof performance
? function () {
return Date.now()
}
: function () {
return performance.now()
}
t.createGrammar = function (e, t, n, r, i, o) {
return new v(e, t, n, r, i, o)
}
var c = function (e) {
this.scopeName = e
}
t.FullScopeDependency = c
var u = (function () {
function e(e, t) {
;(this.scopeName = e), (this.include = t)
}
return (
(e.prototype.toKey = function () {
return this.scopeName + '#' + this.include
}),
e
)
})()
t.PartialScopeDependency = u
var l = (function () {
function e() {
;(this.full = []),
(this.partial = []),
(this.visitedRule = new Set()),
(this._seenFull = new Set()),
(this._seenPartial = new Set())
}
return (
(e.prototype.add = function (e) {
e instanceof c
? this._seenFull.has(e.scopeName) ||
(this._seenFull.add(e.scopeName), this.full.push(e))
: this._seenPartial.has(e.toKey()) ||
(this._seenPartial.add(e.toKey()), this.partial.push(e))
}),
e
)
})()
function h(e, t, n, i, o) {
for (var s = 0, a = i; s < a.length; s++) {
var l = a[s]
if (!e.visitedRule.has(l)) {
e.visitedRule.add(l)
var d = l.repository ? r.mergeObjects({}, o, l.repository) : o
Array.isArray(l.patterns) && h(e, t, n, l.patterns, d)
var g = l.include
if (g)
if ('$base' === g || g === t.scopeName) f(e, t, t)
else if ('$self' === g || g === n.scopeName) f(e, t, n)
else if ('#' === g.charAt(0)) p(e, t, n, g.substring(1), d)
else {
var m = g.indexOf('#')
if (m >= 0) {
var _ = g.substring(0, m),
y = g.substring(m + 1)
_ === t.scopeName
? p(e, t, t, y, d)
: _ === n.scopeName
? p(e, t, n, y, d)
: e.add(new u(_, g.substring(m + 1)))
} else e.add(new c(g))
}
}
}
}
function p(e, t, n, r, i) {
;(void 0 === i && (i = n.repository), i && i[r]) && h(e, t, n, [i[r]], i)
}
function f(e, t, n) {
if (
(n.patterns && Array.isArray(n.patterns) && h(e, t, n, n.patterns, n.repository),
n.injections)
) {
var r = []
for (var i in n.injections) r.push(n.injections[i])
h(e, t, n, r, n.repository)
}
}
function d(e, t) {
if (!e) return !1
if (e === t) return !0
var n = t.length
return e.length > n && e.substr(0, n) === t && '.' === e[n]
}
function g(e, t) {
if (t.length < e.length) return !1
var n = 0
return e.every(function (e) {
for (var r = n; r < t.length; r++) if (d(t[r], e)) return (n = r + 1), !0
return !1
})
}
function m(e, t, n, r, s) {
for (
var a = o.createMatchers(t, g),
c = i.RuleFactory.getCompiledRuleId(n, r, s.repository),
u = 0,
l = a;
u < l.length;
u++
) {
var h = l[u]
e.push({ matcher: h.matcher, ruleId: c, grammar: s, priority: h.priority })
}
}
;(t.ScopeDependencyCollector = l),
(t.collectSpecificDependencies = p),
(t.collectDependencies = f)
var _ = function (e, t, n, r) {
;(this.scopeName = e), (this.languageId = t), (this.tokenType = n), (this.themeData = r)
}
t.ScopeMetadata = _
var y = (function () {
function e(t, n, r) {
if (
((this._initialLanguage = t),
(this._themeProvider = n),
(this._cache = new Map()),
(this._defaultMetaData = new _('', this._initialLanguage, 0, [
this._themeProvider.getDefaults()
])),
(this._embeddedLanguages = Object.create(null)),
r)
)
for (var i = Object.keys(r), o = 0, s = i.length; o < s; o++) {
var a = i[o],
c = r[a]
'number' == typeof c && 0 !== c
? (this._embeddedLanguages[a] = c)
: console.warn(
'Invalid embedded language found at scope ' + a + ': <<' + c + '>>'
)
}
var u = Object.keys(this._embeddedLanguages).map(function (t) {
return e._escapeRegExpCharacters(t)
})
0 === u.length
? (this._embeddedLanguagesRegex = null)
: (u.sort(),
u.reverse(),
(this._embeddedLanguagesRegex = new RegExp(
'^((' + u.join(')|(') + '))($|\\.)',
''
)))
}
return (
(e.prototype.onDidChangeTheme = function () {
;(this._cache = new Map()),
(this._defaultMetaData = new _('', this._initialLanguage, 0, [
this._themeProvider.getDefaults()
]))
}),
(e.prototype.getDefaultMetadata = function () {
return this._defaultMetaData
}),
(e._escapeRegExpCharacters = function (e) {
return e.replace(/[\-\\\{\}\*\+\?\|\^\$\.\,\[\]\(\)\#\s]/g, '\\$&')
}),
(e.prototype.getMetadataForScope = function (t) {
if (null === t) return e._NULL_SCOPE_METADATA
var n = this._cache.get(t)
return n || ((n = this._doGetMetadataForScope(t)), this._cache.set(t, n), n)
}),
(e.prototype._doGetMetadataForScope = function (e) {
var t = this._scopeToLanguage(e),
n = this._toStandardTokenType(e),
r = this._themeProvider.themeMatch(e)
return new _(e, t, n, r)
}),
(e.prototype._scopeToLanguage = function (e) {
if (!e) return 0
if (!this._embeddedLanguagesRegex) return 0
var t = e.match(this._embeddedLanguagesRegex)
if (!t) return 0
var n = this._embeddedLanguages[t[1]] || 0
return n || 0
}),
(e.prototype._toStandardTokenType = function (t) {
var n = t.match(e.STANDARD_TOKEN_TYPE_REGEXP)
if (!n) return 0
switch (n[1]) {
case 'comment':
return 1
case 'string':
return 2
case 'regex':
return 4
case 'meta.embedded':
return 8
}
throw new Error('Unexpected match for standard token type!')
}),
(e._NULL_SCOPE_METADATA = new _('', 0, 0, null)),
(e.STANDARD_TOKEN_TYPE_REGEXP = /\b(comment|string|regex|meta\.embedded)\b/),
e
)
})(),
v = (function () {
function e(e, t, n, r, i, s) {
if (
((this._scopeMetadataProvider = new y(t, i, n)),
(this._onigLib = s),
(this._rootId = -1),
(this._lastRuleId = 0),
(this._ruleId2desc = [null]),
(this._includedGrammars = {}),
(this._grammarRepository = i),
(this._grammar = C(e, null)),
(this._injections = null),
(this._tokenTypeMatchers = []),
r)
)
for (var a = 0, c = Object.keys(r); a < c.length; a++)
for (var u = c[a], l = 0, h = o.createMatchers(u, g); l < h.length; l++) {
var p = h[l]
this._tokenTypeMatchers.push({ matcher: p.matcher, type: r[u] })
}
}
return (
(e.prototype.dispose = function () {
for (var e = 0, t = this._ruleId2desc; e < t.length; e++) {
var n = t[e]
n && n.dispose()
}
}),
(e.prototype.createOnigScanner = function (e) {
return this._onigLib.createOnigScanner(e)
}),
(e.prototype.createOnigString = function (e) {
return this._onigLib.createOnigString(e)
}),
(e.prototype.onDidChangeTheme = function () {
this._scopeMetadataProvider.onDidChangeTheme()
}),
(e.prototype.getMetadataForScope = function (e) {
return this._scopeMetadataProvider.getMetadataForScope(e)
}),
(e.prototype.getInjections = function () {
var e = this
if (null === this._injections) {
this._injections = []
var t = this._grammar.injections
if (t) for (var n in t) m(this._injections, n, t[n], this, this._grammar)
if (this._grammarRepository) {
var r = this._grammarRepository.injections(this._grammar.scopeName)
r &&
r.forEach(function (t) {
var n = e.getExternalGrammar(t)
if (n) {
var r = n.injectionSelector
r && m(e._injections, r, n, e, n)
}
})
}
this._injections.sort(function (e, t) {
return e.priority - t.priority
})
}
return this._injections
}),
(e.prototype.registerRule = function (e) {
var t = ++this._lastRuleId,
n = e(t)
return (this._ruleId2desc[t] = n), n
}),
(e.prototype.getRule = function (e) {
return this._ruleId2desc[e]
}),
(e.prototype.getExternalGrammar = function (e, t) {
if (this._includedGrammars[e]) return this._includedGrammars[e]
if (this._grammarRepository) {
var n = this._grammarRepository.lookup(e)
if (n)
return (
(this._includedGrammars[e] = C(n, t && t.$base)), this._includedGrammars[e]
)
}
return null
}),
(e.prototype.tokenizeLine = function (e, t) {
var n = this._tokenize(e, t, !1)
return {
tokens: n.lineTokens.getResult(n.ruleStack, n.lineLength),
ruleStack: n.ruleStack
}
}),
(e.prototype.tokenizeLine2 = function (e, t) {
var n = this._tokenize(e, t, !0)
return {
tokens: n.lineTokens.getBinaryResult(n.ruleStack, n.lineLength),
ruleStack: n.ruleStack
}
}),
(e.prototype._tokenize = function (e, t, n) {
var r
if (
(-1 === this._rootId &&
(this._rootId = i.RuleFactory.getCompiledRuleId(
this._grammar.repository.$self,
this,
this._grammar.repository
)),
t && t !== I.NULL)
)
(r = !1), t.reset()
else {
r = !0
var o = this._scopeMetadataProvider.getDefaultMetadata(),
s = o.themeData[0],
a = P.set(
0,
o.languageId,
o.tokenType,
s.fontStyle,
s.foreground,
s.background
),
c = this.getRule(this._rootId).getName(null, null),
u = this._scopeMetadataProvider.getMetadataForScope(c),
l = x.mergeMetadata(a, null, u),
h = new x(null, null === c ? 'unknown' : c, l)
t = new I(null, this._rootId, -1, -1, !1, null, h, h)
}
e += '\n'
var p = this.createOnigString(e),
f = p.content.length,
d = new T(n, e, this._tokenTypeMatchers),
g = S(this, p, r, 0, t, d, !0)
return b(p), { lineLength: f, lineTokens: d, ruleStack: g }
}),
e
)
})()
function b(e) {
'function' == typeof e.dispose && e.dispose()
}
function C(e, t) {
return (
((e = r.clone(e)).repository = e.repository || {}),
(e.repository.$self = {
$vscodeTextmateLocation: e.$vscodeTextmateLocation,
patterns: e.patterns,
name: e.scopeName
}),
(e.repository.$base = t || e.repository.$self),
e
)
}
function w(e, t, n, r, i, o, s) {
if (0 !== o.length) {
for (
var a = t.content, c = Math.min(o.length, s.length), u = [], l = s[0].end, h = 0;
h < c;
h++
) {
var p = o[h]
if (null !== p) {
var f = s[h]
if (0 !== f.length) {
if (f.start > l) break
for (; u.length > 0 && u[u.length - 1].endPos <= f.start; )
i.produceFromScopes(u[u.length - 1].scopes, u[u.length - 1].endPos), u.pop()
if (
(u.length > 0
? i.produceFromScopes(u[u.length - 1].scopes, f.start)
: i.produce(r, f.start),
p.retokenizeCapturedWithRuleId)
) {
var d = p.getName(a, s),
g = r.contentNameScopesList.push(e, d),
m = p.getContentName(a, s),
_ = g.push(e, m),
y = r.push(p.retokenizeCapturedWithRuleId, f.start, -1, !1, null, g, _),
v = e.createOnigString(a.substring(0, f.end))
S(e, v, n && 0 === f.start, f.start, y, i, !1), b(v)
} else {
var C = p.getName(a, s)
if (null !== C) {
var w = (
u.length > 0 ? u[u.length - 1].scopes : r.contentNameScopesList
).push(e, C)
u.push(new A(w, f.end))
}
}
}
}
}
for (; u.length > 0; )
i.produceFromScopes(u[u.length - 1].scopes, u[u.length - 1].endPos), u.pop()
}
}
function k(e) {
for (var t = [], n = 0, r = e.rules.length; n < r; n++)
t.push(' - ' + e.rules[n] + ': ' + e.debugRegExps[n])
return t.join('\n')
}
function R(e, t, n, r, i, o) {
var c = (function (e, t, n, r, i, o) {
var c = i.getRule(e),
u = c.compile(e, i.endRule, n, r === o),
l = 0
s.DebugFlags.InDebugMode && (l = a())
var h = u.scanner.findNextMatchSync(t, r)
if (s.DebugFlags.InDebugMode) {
var p = a() - l
p > 5 &&
console.warn(
'Rule ' +
c.debugName +
' (' +
c.id +
') matching took ' +
p +
" against '" +
t +
"'"
),
h &&
console.log(
'matched rule id: ' +
u.rules[h.index] +
' from ' +
h.captureIndices[0].start +
' to ' +
h.captureIndices[0].end
)
}
return h
? { captureIndices: h.captureIndices, matchedRuleId: u.rules[h.index] }
: null
})(e, t, n, r, i, o),
u = e.getInjections()
if (0 === u.length) return c
var l = (function (e, t, n, r, i, o, a) {
for (
var c,
u = Number.MAX_VALUE,
l = null,
h = 0,
p = o.contentNameScopesList.generateScopes(),
f = 0,
d = e.length;
f < d;
f++
) {
var g = e[f]
if (g.matcher(p)) {
var m = t.getRule(g.ruleId).compile(t, null, r, i === a),
_ = m.scanner.findNextMatchSync(n, i)
if (
(s.DebugFlags.InDebugMode &&
(console.log(' scanning for injections'), console.log(k(m))),
_)
) {
var y = _.captureIndices[0].start
if (
!(y >= u) &&
((u = y),
(l = _.captureIndices),
(c = m.rules[_.index]),
(h = g.priority),
u === i)
)
break
}
}
}
return l ? { priorityMatch: -1 === h, captureIndices: l, matchedRuleId: c } : null
})(u, e, t, n, r, i, o)
if (!l) return c
if (!c) return l
var h = c.captureIndices[0].start,
p = l.captureIndices[0].start
return p < h || (l.priorityMatch && p === h) ? l : c
}
function S(e, t, n, r, o, a, c) {
var u = t.content.length,
l = !1,
h = -1
if (c) {
var p = (function (e, t, n, r, o, a) {
for (var c = o.beginRuleCapturedEOL ? 0 : -1, u = [], l = o; l; l = l.pop()) {
var h = l.getRule(e)
h instanceof i.BeginWhileRule && u.push({ rule: h, stack: l })
}
for (var p = u.pop(); p; p = u.pop()) {
var f = p.rule.compileWhile(e, p.stack.endRule, n, c === r),
d = f.scanner.findNextMatchSync(t, r)
if (
(s.DebugFlags.InDebugMode &&
(console.log(' scanning for while rule'), console.log(k(f))),
!d)
) {
s.DebugFlags.InDebugMode &&
console.log(' popping ' + p.rule.debugName + ' - ' + p.rule.debugWhileRegExp),
(o = p.stack.pop())
break
}
if (-2 !== f.rules[d.index]) {
o = p.stack.pop()
break
}
d.captureIndices &&
d.captureIndices.length &&
(a.produce(p.stack, d.captureIndices[0].start),
w(e, t, n, p.stack, a, p.rule.whileCaptures, d.captureIndices),
a.produce(p.stack, d.captureIndices[0].end),
(c = d.captureIndices[0].end),
d.captureIndices[0].end > r && ((r = d.captureIndices[0].end), (n = !1)))
}
return { stack: o, linePos: r, anchorPosition: c, isFirstLine: n }
})(e, t, n, r, o, a)
;(o = p.stack), (r = p.linePos), (n = p.isFirstLine), (h = p.anchorPosition)
}
for (; !l; ) f()
function f() {
s.DebugFlags.InDebugMode &&
(console.log(''),
console.log(
'@@scanNext ' + r + ': |' + t.content.substr(r).replace(/\n$/, '\\n') + '|'
))
var c = R(e, t, n, r, o, h)
if (!c)
return (
s.DebugFlags.InDebugMode && console.log(' no more matches.'),
a.produce(o, u),
void (l = !0)
)
var p = c.captureIndices,
f = c.matchedRuleId,
d = !!(p && p.length > 0) && p[0].end > r
if (-1 === f) {
var g = o.getRule(e)
s.DebugFlags.InDebugMode &&
console.log(' popping ' + g.debugName + ' - ' + g.debugEndRegExp),
a.produce(o, p[0].start),
(o = o.setContentNameScopesList(o.nameScopesList)),
w(e, t, n, o, a, g.endCaptures, p),
a.produce(o, p[0].end)
var m = o
if (((o = o.pop()), (h = m.getAnchorPos()), !d && m.getEnterPos() === r))
return (
s.DebugFlags.InDebugMode &&
console.error(
'[1] - Grammar is in an endless loop - Grammar pushed & popped a rule without advancing'
),
(o = m),
a.produce(o, u),
void (l = !0)
)
} else {
var _ = e.getRule(f)
a.produce(o, p[0].start)
var y = o,
v = _.getName(t.content, p),
b = o.contentNameScopesList.push(e, v)
if (
((o = o.push(f, r, h, p[0].end === u, null, b, b)), _ instanceof i.BeginEndRule)
) {
var C = _
s.DebugFlags.InDebugMode &&
console.log(' pushing ' + C.debugName + ' - ' + C.debugBeginRegExp),
w(e, t, n, o, a, C.beginCaptures, p),
a.produce(o, p[0].end),
(h = p[0].end)
var k = C.getContentName(t.content, p),
S = b.push(e, k)
if (
((o = o.setContentNameScopesList(S)),
C.endHasBackReferences &&
(o = o.setEndRule(C.getEndWithResolvedBackReferences(t.content, p))),
!d && y.hasSameRuleAs(o))
)
return (
s.DebugFlags.InDebugMode &&
console.error(
'[2] - Grammar is in an endless loop - Grammar pushed the same rule without advancing'
),
(o = o.pop()),
a.produce(o, u),
void (l = !0)
)
} else if (_ instanceof i.BeginWhileRule) {
C = _
s.DebugFlags.InDebugMode && console.log(' pushing ' + C.debugName),
w(e, t, n, o, a, C.beginCaptures, p),
a.produce(o, p[0].end),
(h = p[0].end)
;(k = C.getContentName(t.content, p)), (S = b.push(e, k))
if (
((o = o.setContentNameScopesList(S)),
C.whileHasBackReferences &&
(o = o.setEndRule(C.getWhileWithResolvedBackReferences(t.content, p))),
!d && y.hasSameRuleAs(o))
)
return (
s.DebugFlags.InDebugMode &&
console.error(
'[3] - Grammar is in an endless loop - Grammar pushed the same rule without advancing'
),
(o = o.pop()),
a.produce(o, u),
void (l = !0)
)
} else {
var P = _
if (
(s.DebugFlags.InDebugMode &&
console.log(' matched ' + P.debugName + ' - ' + P.debugMatchRegExp),
w(e, t, n, o, a, P.captures, p),
a.produce(o, p[0].end),
(o = o.pop()),
!d)
)
return (
s.DebugFlags.InDebugMode &&
console.error(
'[4] - Grammar is in an endless loop - Grammar is not advancing, nor is it pushing/popping'
),
(o = o.safePop()),
a.produce(o, u),
void (l = !0)
)
}
}
p[0].end > r && ((r = p[0].end), (n = !1))
}
return o
}
t.Grammar = v
var P = (function () {
function e() {}
return (
(e.toBinaryStr = function (e) {
for (var t = e.toString(2); t.length < 32; ) t = '0' + t
return t
}),
(e.printMetadata = function (t) {
var n = e.getLanguageId(t),
r = e.getTokenType(t),
i = e.getFontStyle(t),
o = e.getForeground(t),
s = e.getBackground(t)
console.log({
languageId: n,
tokenType: r,
fontStyle: i,
foreground: o,
background: s
})
}),
(e.getLanguageId = function (e) {
return (255 & e) >>> 0
}),
(e.getTokenType = function (e) {
return (1792 & e) >>> 8
}),
(e.getFontStyle = function (e) {
return (14336 & e) >>> 11
}),
(e.getForeground = function (e) {
return (8372224 & e) >>> 14
}),
(e.getBackground = function (e) {
return (4286578688 & e) >>> 23
}),
(e.set = function (t, n, r, i, o, s) {
var a = e.getLanguageId(t),
c = e.getTokenType(t),
u = e.getFontStyle(t),
l = e.getForeground(t),
h = e.getBackground(t)
return (
0 !== n && (a = n),
0 !== r && (c = 8 === r ? 0 : r),
-1 !== i && (u = i),
0 !== o && (l = o),
0 !== s && (h = s),
((a << 0) | (c << 8) | (u << 11) | (l << 14) | (h << 23)) >>> 0
)
}),
e
)
})()
t.StackElementMetadata = P
var x = (function () {
function e(e, t, n) {
;(this.parent = e), (this.scope = t), (this.metadata = n)
}
return (
(e._equals = function (e, t) {
for (;;) {
if (e === t) return !0
if (!e && !t) return !0
if (!e || !t) return !1
if (e.scope !== t.scope || e.metadata !== t.metadata) return !1
;(e = e.parent), (t = t.parent)
}
}),
(e.prototype.equals = function (t) {
return e._equals(this, t)
}),
(e._matchesScope = function (e, t, n) {
return t === e || e.substring(0, n.length) === n
}),
(e._matches = function (e, t) {
if (null === t) return !0
for (var n = t.length, r = 0, i = t[r], o = i + '.'; e; ) {
if (this._matchesScope(e.scope, i, o)) {
if (++r === n) return !0
o = (i = t[r]) + '.'
}
e = e.parent
}
return !1
}),
(e.mergeMetadata = function (e, t, n) {
if (null === n) return e
var r = -1,
i = 0,
o = 0
if (null !== n.themeData)
for (var s = 0, a = n.themeData.length; s < a; s++) {
var c = n.themeData[s]
if (this._matches(t, c.parentScopes)) {
;(r = c.fontStyle), (i = c.foreground), (o = c.background)
break
}
}
return P.set(e, n.languageId, n.tokenType, r, i, o)
}),
(e._push = function (t, n, r) {
for (var i = 0, o = r.length; i < o; i++) {
var s = r[i],
a = n.getMetadataForScope(s),
c = e.mergeMetadata(t.metadata, t, a)
t = new e(t, s, c)
}
return t
}),
(e.prototype.push = function (t, n) {
return null === n
? this
: n.indexOf(' ') >= 0
? e._push(this, t, n.split(/ /g))
: e._push(this, t, [n])
}),
(e._generateScopes = function (e) {
for (var t = [], n = 0; e; ) (t[n++] = e.scope), (e = e.parent)
return t.reverse(), t
}),
(e.prototype.generateScopes = function () {
return e._generateScopes(this)
}),
e
)
})()
t.ScopeListElement = x
var I = (function () {
function e(e, t, n, r, i, o, s, a) {
;(this.parent = e),
(this.depth = this.parent ? this.parent.depth + 1 : 1),
(this.ruleId = t),
(this._enterPos = n),
(this._anchorPos = r),
(this.beginRuleCapturedEOL = i),
(this.endRule = o),
(this.nameScopesList = s),
(this.contentNameScopesList = a)
}
return (
(e._structuralEquals = function (e, t) {
for (;;) {
if (e === t) return !0
if (!e && !t) return !0
if (!e || !t) return !1
if (e.depth !== t.depth || e.ruleId !== t.ruleId || e.endRule !== t.endRule)
return !1
;(e = e.parent), (t = t.parent)
}
}),
(e._equals = function (e, t) {
return (
e === t ||
(!!this._structuralEquals(e, t) &&
e.contentNameScopesList.equals(t.contentNameScopesList))
)
}),
(e.prototype.clone = function () {
return this
}),
(e.prototype.equals = function (t) {
return null !== t && e._equals(this, t)
}),
(e._reset = function (e) {
for (; e; ) (e._enterPos = -1), (e._anchorPos = -1), (e = e.parent)
}),
(e.prototype.reset = function () {
e._reset(this)
}),
(e.prototype.pop = function () {
return this.parent
}),
(e.prototype.safePop = function () {
return this.parent ? this.parent : this
}),
(e.prototype.push = function (t, n, r, i, o, s, a) {
return new e(this, t, n, r, i, o, s, a)
}),
(e.prototype.getEnterPos = function () {
return this._enterPos
}),
(e.prototype.getAnchorPos = function () {
return this._anchorPos
}),
(e.prototype.getRule = function (e) {
return e.getRule(this.ruleId)
}),
(e.prototype._writeString = function (e, t) {
return (
this.parent && (t = this.parent._writeString(e, t)),
(e[t++] =
'(' +
this.ruleId +
', TODO-' +
this.nameScopesList +
', TODO-' +
this.contentNameScopesList +
')'),
t
)
}),
(e.prototype.toString = function () {
var e = []
return this._writeString(e, 0), '[' + e.join(',') + ']'
}),
(e.prototype.setContentNameScopesList = function (e) {
return this.contentNameScopesList === e
? this
: this.parent.push(
this.ruleId,
this._enterPos,
this._anchorPos,
this.beginRuleCapturedEOL,
this.endRule,
this.nameScopesList,
e
)
}),
(e.prototype.setEndRule = function (t) {
return this.endRule === t
? this
: new e(
this.parent,
this.ruleId,
this._enterPos,
this._anchorPos,
this.beginRuleCapturedEOL,
t,
this.nameScopesList,
this.contentNameScopesList
)
}),
(e.prototype.hasSameRuleAs = function (e) {
return this.ruleId === e.ruleId
}),
(e.NULL = new e(null, 0, 0, 0, !1, null, null, null)),
e
)
})()
t.StackElement = I
var A = function (e, t) {
;(this.scopes = e), (this.endPos = t)
}
t.LocalStackElement = A
var T = (function () {
function e(e, t, n) {
;(this._emitBinaryTokens = e),
(this._tokenTypeOverrides = n),
s.DebugFlags.InDebugMode ? (this._lineText = t) : (this._lineText = null),
(this._tokens = []),
(this._binaryTokens = []),
(this._lastTokenEndIndex = 0)
}
return (
(e.prototype.produce = function (e, t) {
this.produceFromScopes(e.contentNameScopesList, t)
}),
(e.prototype.produceFromScopes = function (e, t) {
if (!(this._lastTokenEndIndex >= t)) {
if (this._emitBinaryTokens) {
for (var n = e.metadata, r = 0, i = this._tokenTypeOverrides; r < i.length; r++) {
var o = i[r]
o.matcher(e.generateScopes()) && (n = P.set(n, 0, L(o.type), -1, 0, 0))
}
return (
(this._binaryTokens.length > 0 &&
this._binaryTokens[this._binaryTokens.length - 1] === n) ||
(this._binaryTokens.push(this._lastTokenEndIndex),
this._binaryTokens.push(n)),
void (this._lastTokenEndIndex = t)
)
}
var a = e.generateScopes()
if (s.DebugFlags.InDebugMode) {
console.log(
' token: |' +
this._lineText.substring(this._lastTokenEndIndex, t).replace(/\n$/, '\\n') +
'|'
)
for (var c = 0; c < a.length; c++) console.log(' * ' + a[c])
}
this._tokens.push({ startIndex: this._lastTokenEndIndex, endIndex: t, scopes: a }),
(this._lastTokenEndIndex = t)
}
}),
(e.prototype.getResult = function (e, t) {
return (
this._tokens.length > 0 &&
this._tokens[this._tokens.length - 1].startIndex === t - 1 &&
this._tokens.pop(),
0 === this._tokens.length &&
((this._lastTokenEndIndex = -1),
this.produce(e, t),
(this._tokens[this._tokens.length - 1].startIndex = 0)),
this._tokens
)
}),
(e.prototype.getBinaryResult = function (e, t) {
this._binaryTokens.length > 0 &&
this._binaryTokens[this._binaryTokens.length - 2] === t - 1 &&
(this._binaryTokens.pop(), this._binaryTokens.pop()),
0 === this._binaryTokens.length &&
((this._lastTokenEndIndex = -1),
this.produce(e, t),
(this._binaryTokens[this._binaryTokens.length - 2] = 0))
for (
var n = new Uint32Array(this._binaryTokens.length),
r = 0,
i = this._binaryTokens.length;
r < i;
r++
)
n[r] = this._binaryTokens[r]
return n
}),
e
)
})()
function L(e) {
switch (e) {
case 4:
return 4
case 2:
return 2
case 1:
return 1
case 0:
default:
return 8
}
}
},
function (e, t, n) {
function r(e) {
return Array.isArray(e)
? (function (e) {
for (var t = [], n = 0, i = e.length; n < i; n++) t[n] = r(e[n])
return t
})(e)
: 'object' == typeof e
? (function (e) {
var t = {}
for (var n in e) t[n] = r(e[n])
return t
})(e)
: e
}
Object.defineProperty(t, '__esModule', { value: !0 }),
(t.clone = function (e) {
return r(e)
}),
(t.mergeObjects = function (e) {
for (var t = [], n = 1; n < arguments.length; n++) t[n - 1] = arguments[n]
return (
t.forEach(function (t) {
for (var n in t) e[n] = t[n]
}),
e
)
}),
(t.basename = function e(t) {
var n = ~t.lastIndexOf('/') || ~t.lastIndexOf('\\')
return 0 === n
? t
: ~n == t.length - 1
? e(t.substring(0, t.length - 1))
: t.substr(1 + ~n)
})
var i = /\$(\d+)|\${(\d+):\/(downcase|upcase)}/,
o = (function () {
function e() {}
return (
(e.hasCaptures = function (e) {
return null !== e && i.test(e)
}),
(e.replaceCaptures = function (e, t, n) {
return e.replace(i, function (e, r, i, o) {
var s = n[parseInt(r || i, 10)]
if (!s) return e
for (var a = t.substring(s.start, s.end); '.' === a[0]; ) a = a.substring(1)
switch (o) {
case 'downcase':
return a.toLowerCase()
case 'upcase':
return a.toUpperCase()
default:
return a
}
})
}),
e
)
})()
t.RegexSource = o
},
function (e, t, n) {
;(function (e) {
Object.defineProperty(t, '__esModule', { value: !0 }),
(t.DebugFlags = { InDebugMode: void 0 !== e && !!e.env.VSCODE_TEXTMATE_DEBUG })
}.call(this, n(7)))
},
function (e, t, n) {
var r =
(this && this.__awaiter) ||
function (e, t, n, r) {
return new (n || (n = Promise))(function (i, o) {
function s(e) {
try {
c(r.next(e))
} catch (e) {
o(e)
}
}
function a(e) {
try {
c(r.throw(e))
} catch (e) {
o(e)
}
}
function c(e) {
var t
e.done
? i(e.value)
: ((t = e.value),
t instanceof n
? t
: new n(function (e) {
e(t)
})).then(s, a)
}
c((r = r.apply(e, t || [])).next())
})
},
i =
(this && this.__generator) ||
function (e, t) {
var n,
r,
i,
o,
s = {
label: 0,
sent: function () {
if (1 & i[0]) throw i[1]
return i[1]
},
trys: [],
ops: []
}
return (
(o = { next: a(0), throw: a(1), return: a(2) }),
'function' == typeof Symbol &&
(o[Symbol.iterator] = function () {
return this
}),
o
)
function a(o) {
return function (a) {
return (function (o) {
if (n) throw new TypeError('Generator is already executing.')
for (; s; )
try {
if (
((n = 1),
r &&
(i =
2 & o[0]
? r.return
: o[0]
? r.throw || ((i = r.return) && i.call(r), 0)
: r.next) &&
!(i = i.call(r, o[1])).done)
)
return i
switch (((r = 0), i && (o = [2 & o[0], i.value]), o[0])) {
case 0:
case 1:
i = o
break
case 4:
return s.label++, { value: o[1], done: !1 }
case 5:
s.label++, (r = o[1]), (o = [0])
continue
case 7:
;(o = s.ops.pop()), s.trys.pop()
continue
default:
if (
!((i = s.trys),
(i = i.length > 0 && i[i.length - 1]) || (6 !== o[0] && 2 !== o[0]))
) {
s = 0
continue
}
if (3 === o[0] && (!i || (o[1] > i[0] && o[1] < i[3]))) {
s.label = o[1]
break
}