UNPKG

@inst/vscode-bin-darwin

Version:

BINARY ONLY - VSCode binary deployment for macOS

1,460 lines 118 kB
/*--------------------------------------------------------- * Copyright (C) Microsoft Corporation. All rights reserved. *--------------------------------------------------------*/ 'use strict'; var $map = {}; function $load(name, factory) { var mod = { exports: {} }; var requireFunc = function (mod) { if ($map[mod]) { return $map[mod].exports; } return require(mod); }; factory.call(this, requireFunc, mod, mod.exports); $map[name] = mod; } //# sourceMappingURL=_prefix.js.map $load('./utils', function(require, module, exports) { /*--------------------------------------------------------- * Copyright (C) Microsoft Corporation. All rights reserved. *--------------------------------------------------------*/ 'use strict'; function clone(something) { return doClone(something); } exports.clone = clone; function doClone(something) { if (Array.isArray(something)) { return cloneArray(something); } if (typeof something === 'object') { return cloneObj(something); } return something; } function cloneArray(arr) { var r = []; for (var i = 0, len = arr.length; i < len; i++) { r[i] = doClone(arr[i]); } return r; } function cloneObj(obj) { var r = {}; for (var key in obj) { r[key] = doClone(obj[key]); } return r; } function mergeObjects(target) { var sources = []; for (var _i = 1; _i < arguments.length; _i++) { sources[_i - 1] = arguments[_i]; } sources.forEach(function (source) { for (var key in source) { target[key] = source[key]; } }); return target; } exports.mergeObjects = mergeObjects; var CAPTURING_REGEX_SOURCE = /\$(\d+)|\${(\d+):\/(downcase|upcase)}/; var RegexSource = (function () { function RegexSource() { } RegexSource.hasCaptures = function (regexSource) { return CAPTURING_REGEX_SOURCE.test(regexSource); }; RegexSource.replaceCaptures = function (regexSource, captureSource, captureIndices) { return regexSource.replace(CAPTURING_REGEX_SOURCE, function (match, index, commandIndex, command) { var capture = captureIndices[parseInt(index || commandIndex, 10)]; if (capture) { var result = captureSource.substring(capture.start, capture.end); // Remove leading dots that would make the selector invalid while (result[0] === '.') { result = result.substring(1); } switch (command) { case 'downcase': return result.toLowerCase(); case 'upcase': return result.toUpperCase(); default: return result; } } else { return match; } }); }; return RegexSource; }()); exports.RegexSource = RegexSource; //# sourceMappingURL=utils.js.map }); $load('./theme', function(require, module, exports) { /*--------------------------------------------------------- * Copyright (C) Microsoft Corporation. All rights reserved. *--------------------------------------------------------*/ 'use strict'; var ParsedThemeRule = (function () { function ParsedThemeRule(scope, parentScopes, index, fontStyle, foreground, background) { this.scope = scope; this.parentScopes = parentScopes; this.index = index; this.fontStyle = fontStyle; this.foreground = foreground; this.background = background; } return ParsedThemeRule; }()); exports.ParsedThemeRule = ParsedThemeRule; function isValidHexColor(hex) { if (/^#[0-9a-f]{6}$/i.test(hex)) { // #rrggbb return true; } if (/^#[0-9a-f]{8}$/i.test(hex)) { // #rrggbbaa return true; } if (/^#[0-9a-f]{3}$/i.test(hex)) { // #rgb return true; } if (/^#[0-9a-f]{4}$/i.test(hex)) { // #rgba return true; } return false; } /** * Parse a raw theme into rules. */ function parseTheme(source) { if (!source) { return []; } if (!source.settings || !Array.isArray(source.settings)) { return []; } var settings = source.settings; var result = [], resultLen = 0; for (var i = 0, len = settings.length; i < len; i++) { var entry = settings[i]; if (!entry.settings) { continue; } var scopes = void 0; if (typeof entry.scope === 'string') { var _scope = entry.scope; // remove leading commas _scope = _scope.replace(/^[,]+/, ''); // remove trailing commans _scope = _scope.replace(/[,]+$/, ''); scopes = _scope.split(','); } else if (Array.isArray(entry.scope)) { scopes = entry.scope; } else { scopes = ['']; } var fontStyle = -1 /* NotSet */; if (typeof entry.settings.fontStyle === 'string') { fontStyle = 0 /* None */; var segments = entry.settings.fontStyle.split(' '); for (var j = 0, lenJ = segments.length; j < lenJ; j++) { var segment = segments[j]; switch (segment) { case 'italic': fontStyle = fontStyle | 1 /* Italic */; break; case 'bold': fontStyle = fontStyle | 2 /* Bold */; break; case 'underline': fontStyle = fontStyle | 4 /* Underline */; break; } } } var foreground = null; if (typeof entry.settings.foreground === 'string' && isValidHexColor(entry.settings.foreground)) { foreground = entry.settings.foreground; } var background = null; if (typeof entry.settings.background === 'string' && isValidHexColor(entry.settings.background)) { background = entry.settings.background; } for (var j = 0, lenJ = scopes.length; j < lenJ; j++) { var _scope = scopes[j].trim(); var segments = _scope.split(' '); var scope = segments[segments.length - 1]; var parentScopes = null; if (segments.length > 1) { parentScopes = segments.slice(0, segments.length - 1); parentScopes.reverse(); } result[resultLen++] = new ParsedThemeRule(scope, parentScopes, i, fontStyle, foreground, background); } } return result; } exports.parseTheme = parseTheme; /** * Resolve rules (i.e. inheritance). */ function resolveParsedThemeRules(parsedThemeRules) { // Sort rules lexicographically, and then by index if necessary parsedThemeRules.sort(function (a, b) { var r = strcmp(a.scope, b.scope); if (r !== 0) { return r; } r = strArrCmp(a.parentScopes, b.parentScopes); if (r !== 0) { return r; } return a.index - b.index; }); // Determine defaults var defaultFontStyle = 0 /* None */; var defaultForeground = '#000000'; var defaultBackground = '#ffffff'; while (parsedThemeRules.length >= 1 && parsedThemeRules[0].scope === '') { var incomingDefaults = parsedThemeRules.shift(); if (incomingDefaults.fontStyle !== -1 /* NotSet */) { defaultFontStyle = incomingDefaults.fontStyle; } if (incomingDefaults.foreground !== null) { defaultForeground = incomingDefaults.foreground; } if (incomingDefaults.background !== null) { defaultBackground = incomingDefaults.background; } } var colorMap = new ColorMap(); var defaults = new ThemeTrieElementRule(0, null, defaultFontStyle, colorMap.getId(defaultForeground), colorMap.getId(defaultBackground)); var root = new ThemeTrieElement(new ThemeTrieElementRule(0, null, -1 /* NotSet */, 0, 0), []); for (var i = 0, len = parsedThemeRules.length; i < len; i++) { var rule = parsedThemeRules[i]; root.insert(0, rule.scope, rule.parentScopes, rule.fontStyle, colorMap.getId(rule.foreground), colorMap.getId(rule.background)); } return new Theme(colorMap, defaults, root); } var ColorMap = (function () { function ColorMap() { this._lastColorId = 0; this._id2color = []; this._color2id = Object.create(null); } ColorMap.prototype.getId = function (color) { if (color === null) { return 0; } color = color.toUpperCase(); var value = this._color2id[color]; if (value) { return value; } value = ++this._lastColorId; this._color2id[color] = value; this._id2color[value] = color; return value; }; ColorMap.prototype.getColorMap = function () { return this._id2color.slice(0); }; return ColorMap; }()); exports.ColorMap = ColorMap; var Theme = (function () { function Theme(colorMap, defaults, root) { this._colorMap = colorMap; this._root = root; this._defaults = defaults; this._cache = {}; } Theme.createFromRawTheme = function (source) { return this.createFromParsedTheme(parseTheme(source)); }; Theme.createFromParsedTheme = function (source) { return resolveParsedThemeRules(source); }; Theme.prototype.getColorMap = function () { return this._colorMap.getColorMap(); }; Theme.prototype.getDefaults = function () { return this._defaults; }; Theme.prototype.match = function (scopeName) { if (!this._cache.hasOwnProperty(scopeName)) { this._cache[scopeName] = this._root.match(scopeName); } return this._cache[scopeName]; }; return Theme; }()); exports.Theme = Theme; function strcmp(a, b) { if (a < b) { return -1; } if (a > b) { return 1; } return 0; } exports.strcmp = strcmp; function strArrCmp(a, b) { if (a === null && b === null) { return 0; } if (!a) { return -1; } if (!b) { return 1; } var len1 = a.length; var len2 = b.length; if (len1 === len2) { for (var i = 0; i < len1; i++) { var res = strcmp(a[i], b[i]); if (res !== 0) { return res; } } return 0; } return len1 - len2; } exports.strArrCmp = strArrCmp; var ThemeTrieElementRule = (function () { function ThemeTrieElementRule(scopeDepth, parentScopes, fontStyle, foreground, background) { this.scopeDepth = scopeDepth; this.parentScopes = parentScopes; this.fontStyle = fontStyle; this.foreground = foreground; this.background = background; } ThemeTrieElementRule.prototype.clone = function () { return new ThemeTrieElementRule(this.scopeDepth, this.parentScopes, this.fontStyle, this.foreground, this.background); }; ThemeTrieElementRule.cloneArr = function (arr) { var r = []; for (var i = 0, len = arr.length; i < len; i++) { r[i] = arr[i].clone(); } return r; }; ThemeTrieElementRule.prototype.acceptOverwrite = function (scopeDepth, fontStyle, foreground, background) { if (this.scopeDepth > scopeDepth) { console.log('how did this happen?'); } else { this.scopeDepth = scopeDepth; } // console.log('TODO -> my depth: ' + this.scopeDepth + ', overwriting depth: ' + scopeDepth); if (fontStyle !== -1 /* NotSet */) { this.fontStyle = fontStyle; } if (foreground !== 0) { this.foreground = foreground; } if (background !== 0) { this.background = background; } }; return ThemeTrieElementRule; }()); exports.ThemeTrieElementRule = ThemeTrieElementRule; var ThemeTrieElement = (function () { function ThemeTrieElement(mainRule, rulesWithParentScopes, children) { if (rulesWithParentScopes === void 0) { rulesWithParentScopes = []; } if (children === void 0) { children = {}; } this._mainRule = mainRule; this._rulesWithParentScopes = rulesWithParentScopes; this._children = children; } ThemeTrieElement._sortBySpecificity = function (arr) { if (arr.length === 1) { return arr; } arr.sort(this._cmpBySpecificity); return arr; }; ThemeTrieElement._cmpBySpecificity = function (a, b) { if (a.scopeDepth === b.scopeDepth) { var aParentScopes = a.parentScopes; var bParentScopes = b.parentScopes; var aParentScopesLen = aParentScopes === null ? 0 : aParentScopes.length; var bParentScopesLen = bParentScopes === null ? 0 : bParentScopes.length; if (aParentScopesLen === bParentScopesLen) { for (var i = 0; i < aParentScopesLen; i++) { var aLen = aParentScopes[i].length; var bLen = bParentScopes[i].length; if (aLen !== bLen) { return bLen - aLen; } } } return bParentScopesLen - aParentScopesLen; } return b.scopeDepth - a.scopeDepth; }; ThemeTrieElement.prototype.match = function (scope) { if (scope === '') { return ThemeTrieElement._sortBySpecificity([].concat(this._mainRule).concat(this._rulesWithParentScopes)); } var dotIndex = scope.indexOf('.'); var head; var tail; if (dotIndex === -1) { head = scope; tail = ''; } else { head = scope.substring(0, dotIndex); tail = scope.substring(dotIndex + 1); } if (this._children.hasOwnProperty(head)) { return this._children[head].match(tail); } return ThemeTrieElement._sortBySpecificity([].concat(this._mainRule).concat(this._rulesWithParentScopes)); }; ThemeTrieElement.prototype.insert = function (scopeDepth, scope, parentScopes, fontStyle, foreground, background) { if (scope === '') { this._doInsertHere(scopeDepth, parentScopes, fontStyle, foreground, background); return; } var dotIndex = scope.indexOf('.'); var head; var tail; if (dotIndex === -1) { head = scope; tail = ''; } else { head = scope.substring(0, dotIndex); tail = scope.substring(dotIndex + 1); } var child; if (this._children.hasOwnProperty(head)) { child = this._children[head]; } else { child = new ThemeTrieElement(this._mainRule.clone(), ThemeTrieElementRule.cloneArr(this._rulesWithParentScopes)); this._children[head] = child; } child.insert(scopeDepth + 1, tail, parentScopes, fontStyle, foreground, background); }; ThemeTrieElement.prototype._doInsertHere = function (scopeDepth, parentScopes, fontStyle, foreground, background) { if (parentScopes === null) { // Merge into the main rule this._mainRule.acceptOverwrite(scopeDepth, fontStyle, foreground, background); return; } // Try to merge into existing rule for (var i = 0, len = this._rulesWithParentScopes.length; i < len; i++) { var rule = this._rulesWithParentScopes[i]; if (strArrCmp(rule.parentScopes, parentScopes) === 0) { // bingo! => we get to merge this into an existing one rule.acceptOverwrite(scopeDepth, fontStyle, foreground, background); return; } } // Must add a new rule // Inherit from main rule if (fontStyle === -1 /* NotSet */) { fontStyle = this._mainRule.fontStyle; } if (foreground === 0) { foreground = this._mainRule.foreground; } if (background === 0) { background = this._mainRule.background; } this._rulesWithParentScopes.push(new ThemeTrieElementRule(scopeDepth, parentScopes, fontStyle, foreground, background)); }; return ThemeTrieElement; }()); exports.ThemeTrieElement = ThemeTrieElement; //# sourceMappingURL=theme.js.map }); $load('./matcher', function(require, module, exports) { /*--------------------------------------------------------- * Copyright (C) Microsoft Corporation. All rights reserved. *--------------------------------------------------------*/ 'use strict'; function createMatchers(selector, matchesName) { var results = []; var tokenizer = newTokenizer(selector); var token = tokenizer.next(); while (token !== null) { var priority = 0; if (token.length === 2 && token.charAt(1) === ':') { switch (token.charAt(0)) { case 'R': priority = 1; break; case 'L': priority = -1; break; default: console.log("Unknown priority " + token + " in scope selector"); } token = tokenizer.next(); } var matcher = parseConjunction(); if (matcher) { results.push({ matcher: matcher, priority: priority }); } if (token !== ',') { break; } token = tokenizer.next(); } return results; function parseOperand() { if (token === '-') { token = tokenizer.next(); var expressionToNegate = parseOperand(); return function (matcherInput) { return expressionToNegate && !expressionToNegate(matcherInput); }; } if (token === '(') { token = tokenizer.next(); var expressionInParents = parseInnerExpression(); if (token === ')') { token = tokenizer.next(); } return expressionInParents; } if (isIdentifier(token)) { var identifiers = []; do { identifiers.push(token); token = tokenizer.next(); } while (isIdentifier(token)); return function (matcherInput) { return matchesName(identifiers, matcherInput); }; } return null; } function parseConjunction() { var matchers = []; var matcher = parseOperand(); while (matcher) { matchers.push(matcher); matcher = parseOperand(); } return function (matcherInput) { return matchers.every(function (matcher) { return matcher(matcherInput); }); }; // and } function parseInnerExpression() { var matchers = []; var matcher = parseConjunction(); while (matcher) { matchers.push(matcher); if (token === '|' || token === ',') { do { token = tokenizer.next(); } while (token === '|' || token === ','); // ignore subsequent commas } else { break; } matcher = parseConjunction(); } return function (matcherInput) { return matchers.some(function (matcher) { return matcher(matcherInput); }); }; // or } } exports.createMatchers = createMatchers; function isIdentifier(token) { return token && token.match(/[\w\.:]+/); } function newTokenizer(input) { var regex = /([LR]:|[\w\.:]+|[\,\|\-\(\)])/g; var match = regex.exec(input); return { next: function () { if (!match) { return null; } var res = match[0]; match = regex.exec(input); return res; } }; } //# sourceMappingURL=matcher.js.map }); $load('./debug', function(require, module, exports) { /*--------------------------------------------------------- * Copyright (C) Microsoft Corporation. All rights reserved. *--------------------------------------------------------*/ 'use strict'; exports.CAPTURE_METADATA = !!process.env['VSCODE_TEXTMATE_DEBUG']; exports.IN_DEBUG_MODE = !!process.env['VSCODE_TEXTMATE_DEBUG']; //# sourceMappingURL=debug.js.map }); $load('./json', function(require, module, exports) { /*--------------------------------------------------------- * Copyright (C) Microsoft Corporation. All rights reserved. *--------------------------------------------------------*/ 'use strict'; function doFail(streamState, msg) { // console.log('Near offset ' + streamState.pos + ': ' + msg + ' ~~~' + streamState.source.substr(streamState.pos, 50) + '~~~'); throw new Error('Near offset ' + streamState.pos + ': ' + msg + ' ~~~' + streamState.source.substr(streamState.pos, 50) + '~~~'); } function parse(source, filename, withMetadata) { var streamState = new JSONStreamState(source); var token = new JSONToken(); var state = 0 /* ROOT_STATE */; var cur = null; var stateStack = []; var objStack = []; function pushState() { stateStack.push(state); objStack.push(cur); } function popState() { state = stateStack.pop(); cur = objStack.pop(); } function fail(msg) { doFail(streamState, msg); } while (nextJSONToken(streamState, token)) { if (state === 0 /* ROOT_STATE */) { if (cur !== null) { fail('too many constructs in root'); } if (token.type === 3 /* LEFT_CURLY_BRACKET */) { cur = {}; if (withMetadata) { cur.$vscodeTextmateLocation = token.toLocation(filename); } pushState(); state = 1 /* DICT_STATE */; continue; } if (token.type === 2 /* LEFT_SQUARE_BRACKET */) { cur = []; pushState(); state = 4 /* ARR_STATE */; continue; } fail('unexpected token in root'); } if (state === 2 /* DICT_STATE_COMMA */) { if (token.type === 5 /* RIGHT_CURLY_BRACKET */) { popState(); continue; } if (token.type === 7 /* COMMA */) { state = 3 /* DICT_STATE_NO_CLOSE */; continue; } fail('expected , or }'); } if (state === 1 /* DICT_STATE */ || state === 3 /* DICT_STATE_NO_CLOSE */) { if (state === 1 /* DICT_STATE */ && token.type === 5 /* RIGHT_CURLY_BRACKET */) { popState(); continue; } if (token.type === 1 /* STRING */) { var keyValue = token.value; if (!nextJSONToken(streamState, token) || token.type !== 6 /* COLON */) { fail('expected colon'); } if (!nextJSONToken(streamState, token)) { fail('expected value'); } state = 2 /* DICT_STATE_COMMA */; if (token.type === 1 /* STRING */) { cur[keyValue] = token.value; continue; } if (token.type === 8 /* NULL */) { cur[keyValue] = null; continue; } if (token.type === 9 /* TRUE */) { cur[keyValue] = true; continue; } if (token.type === 10 /* FALSE */) { cur[keyValue] = false; continue; } if (token.type === 11 /* NUMBER */) { cur[keyValue] = parseFloat(token.value); continue; } if (token.type === 2 /* LEFT_SQUARE_BRACKET */) { var newArr = []; cur[keyValue] = newArr; pushState(); state = 4 /* ARR_STATE */; cur = newArr; continue; } if (token.type === 3 /* LEFT_CURLY_BRACKET */) { var newDict = {}; if (withMetadata) { newDict.$vscodeTextmateLocation = token.toLocation(filename); } cur[keyValue] = newDict; pushState(); state = 1 /* DICT_STATE */; cur = newDict; continue; } } fail('unexpected token in dict'); } if (state === 5 /* ARR_STATE_COMMA */) { if (token.type === 4 /* RIGHT_SQUARE_BRACKET */) { popState(); continue; } if (token.type === 7 /* COMMA */) { state = 6 /* ARR_STATE_NO_CLOSE */; continue; } fail('expected , or ]'); } if (state === 4 /* ARR_STATE */ || state === 6 /* ARR_STATE_NO_CLOSE */) { if (state === 4 /* ARR_STATE */ && token.type === 4 /* RIGHT_SQUARE_BRACKET */) { popState(); continue; } state = 5 /* ARR_STATE_COMMA */; if (token.type === 1 /* STRING */) { cur.push(token.value); continue; } if (token.type === 8 /* NULL */) { cur.push(null); continue; } if (token.type === 9 /* TRUE */) { cur.push(true); continue; } if (token.type === 10 /* FALSE */) { cur.push(false); continue; } if (token.type === 11 /* NUMBER */) { cur.push(parseFloat(token.value)); continue; } if (token.type === 2 /* LEFT_SQUARE_BRACKET */) { var newArr = []; cur.push(newArr); pushState(); state = 4 /* ARR_STATE */; cur = newArr; continue; } if (token.type === 3 /* LEFT_CURLY_BRACKET */) { var newDict = {}; if (withMetadata) { newDict.$vscodeTextmateLocation = token.toLocation(filename); } cur.push(newDict); pushState(); state = 1 /* DICT_STATE */; cur = newDict; continue; } fail('unexpected token in array'); } fail('unknown state'); } if (objStack.length !== 0) { fail('unclosed constructs'); } return cur; } exports.parse = parse; var JSONStreamState = (function () { function JSONStreamState(source) { this.source = source; this.pos = 0; this.len = source.length; this.line = 1; this.char = 0; } return JSONStreamState; }()); var JSONToken = (function () { function JSONToken() { this.value = null; this.offset = -1; this.len = -1; this.line = -1; this.char = -1; } JSONToken.prototype.toLocation = function (filename) { return { filename: filename, line: this.line, char: this.char }; }; return JSONToken; }()); /** * precondition: the string is known to be valid JSON (https://www.ietf.org/rfc/rfc4627.txt) */ function nextJSONToken(_state, _out) { _out.value = null; _out.type = 0 /* UNKNOWN */; _out.offset = -1; _out.len = -1; _out.line = -1; _out.char = -1; var source = _state.source; var pos = _state.pos; var len = _state.len; var line = _state.line; var char = _state.char; //------------------------ skip whitespace var chCode; do { if (pos >= len) { return false; /*EOS*/ } chCode = source.charCodeAt(pos); if (chCode === 32 /* SPACE */ || chCode === 9 /* HORIZONTAL_TAB */ || chCode === 13 /* CARRIAGE_RETURN */) { // regular whitespace pos++; char++; continue; } if (chCode === 10 /* LINE_FEED */) { // newline pos++; line++; char = 0; continue; } // not whitespace break; } while (true); _out.offset = pos; _out.line = line; _out.char = char; if (chCode === 34 /* QUOTATION_MARK */) { //------------------------ strings _out.type = 1 /* STRING */; pos++; char++; do { if (pos >= len) { return false; /*EOS*/ } chCode = source.charCodeAt(pos); pos++; char++; if (chCode === 92 /* BACKSLASH */) { // skip next char pos++; char++; continue; } if (chCode === 34 /* QUOTATION_MARK */) { // end of the string break; } } while (true); _out.value = source.substring(_out.offset + 1, pos - 1).replace(/\\u([0-9A-Fa-f]{4})/g, function (_, m0) { return String.fromCodePoint(parseInt(m0, 16)); }).replace(/\\(.)/g, function (_, m0) { switch (m0) { case '"': return '"'; case '\\': return '\\'; case '/': return '/'; case 'b': return '\b'; case 'f': return '\f'; case 'n': return '\n'; case 'r': return '\r'; case 't': return '\t'; default: doFail(_state, 'invalid escape sequence'); } }); } else if (chCode === 91 /* LEFT_SQUARE_BRACKET */) { _out.type = 2 /* LEFT_SQUARE_BRACKET */; pos++; char++; } else if (chCode === 123 /* LEFT_CURLY_BRACKET */) { _out.type = 3 /* LEFT_CURLY_BRACKET */; pos++; char++; } else if (chCode === 93 /* RIGHT_SQUARE_BRACKET */) { _out.type = 4 /* RIGHT_SQUARE_BRACKET */; pos++; char++; } else if (chCode === 125 /* RIGHT_CURLY_BRACKET */) { _out.type = 5 /* RIGHT_CURLY_BRACKET */; pos++; char++; } else if (chCode === 58 /* COLON */) { _out.type = 6 /* COLON */; pos++; char++; } else if (chCode === 44 /* COMMA */) { _out.type = 7 /* COMMA */; pos++; char++; } else if (chCode === 110 /* n */) { //------------------------ null _out.type = 8 /* NULL */; pos++; char++; chCode = source.charCodeAt(pos); if (chCode !== 117 /* u */) { return false; /* INVALID */ } pos++; char++; chCode = source.charCodeAt(pos); if (chCode !== 108 /* l */) { return false; /* INVALID */ } pos++; char++; chCode = source.charCodeAt(pos); if (chCode !== 108 /* l */) { return false; /* INVALID */ } pos++; char++; } else if (chCode === 116 /* t */) { //------------------------ true _out.type = 9 /* TRUE */; pos++; char++; chCode = source.charCodeAt(pos); if (chCode !== 114 /* r */) { return false; /* INVALID */ } pos++; char++; chCode = source.charCodeAt(pos); if (chCode !== 117 /* u */) { return false; /* INVALID */ } pos++; char++; chCode = source.charCodeAt(pos); if (chCode !== 101 /* e */) { return false; /* INVALID */ } pos++; char++; } else if (chCode === 102 /* f */) { //------------------------ false _out.type = 10 /* FALSE */; pos++; char++; chCode = source.charCodeAt(pos); if (chCode !== 97 /* a */) { return false; /* INVALID */ } pos++; char++; chCode = source.charCodeAt(pos); if (chCode !== 108 /* l */) { return false; /* INVALID */ } pos++; char++; chCode = source.charCodeAt(pos); if (chCode !== 115 /* s */) { return false; /* INVALID */ } pos++; char++; chCode = source.charCodeAt(pos); if (chCode !== 101 /* e */) { return false; /* INVALID */ } pos++; char++; } else { //------------------------ numbers _out.type = 11 /* NUMBER */; do { if (pos >= len) { return false; /*EOS*/ } chCode = source.charCodeAt(pos); if (chCode === 46 /* DOT */ || (chCode >= 48 /* D0 */ && chCode <= 57 /* D9 */) || (chCode === 101 /* e */ || chCode === 69 /* E */) || (chCode === 45 /* MINUS */ || chCode === 43 /* PLUS */)) { // looks like a piece of a number pos++; char++; continue; } // pos--; char--; break; } while (true); } _out.len = pos - _out.offset; if (_out.value === null) { _out.value = source.substr(_out.offset, _out.len); } _state.pos = pos; _state.line = line; _state.char = char; // console.log('PRODUCING TOKEN: ', _out.value, JSONTokenType[_out.type]); return true; } //# sourceMappingURL=json.js.map }); $load('./grammarReader', function(require, module, exports) { /*--------------------------------------------------------- * Copyright (C) Microsoft Corporation. All rights reserved. *--------------------------------------------------------*/ 'use strict'; var fs = require("fs"); var plist = require("fast-plist"); var debug_1 = require("./debug"); var json_1 = require("./json"); function readGrammar(filePath, callback) { var reader = new AsyncGrammarReader(filePath, getGrammarParser(filePath)); reader.load(callback); } exports.readGrammar = readGrammar; function readGrammarSync(filePath) { var reader = new SyncGrammarReader(filePath, getGrammarParser(filePath)); return reader.load(); } exports.readGrammarSync = readGrammarSync; var AsyncGrammarReader = (function () { function AsyncGrammarReader(filePath, parser) { this._filePath = filePath; this._parser = parser; } AsyncGrammarReader.prototype.load = function (callback) { var _this = this; fs.readFile(this._filePath, function (err, contents) { if (err) { callback(err, null); return; } var r; try { r = _this._parser(contents.toString(), _this._filePath); } catch (err) { callback(err, null); return; } callback(null, r); }); }; return AsyncGrammarReader; }()); var SyncGrammarReader = (function () { function SyncGrammarReader(filePath, parser) { this._filePath = filePath; this._parser = parser; } SyncGrammarReader.prototype.load = function () { try { var contents = fs.readFileSync(this._filePath); try { return this._parser(contents.toString(), this._filePath); } catch (e) { throw new Error("Error parsing " + this._filePath + ": " + e.message + "."); } } catch (e) { throw new Error("Error reading " + this._filePath + ": " + e.message + "."); } }; return SyncGrammarReader; }()); function getGrammarParser(filePath) { if (/\.json$/.test(filePath)) { return parseJSONGrammar; } return parsePLISTGrammar; } function parseJSONGrammar(contents, filename) { if (debug_1.CAPTURE_METADATA) { return json_1.parse(contents, filename, true); } return JSON.parse(contents); } function parsePLISTGrammar(contents, filename) { if (debug_1.CAPTURE_METADATA) { return plist.parseWithLocation(contents, filename, '$vscodeTextmateLocation'); } return plist.parse(contents); } //# sourceMappingURL=grammarReader.js.map }); $load('./rule', function(require, module, exports) { /*--------------------------------------------------------- * Copyright (C) Microsoft Corporation. All rights reserved. *--------------------------------------------------------*/ 'use strict'; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var path = require("path"); var utils_1 = require("./utils"); var HAS_BACK_REFERENCES = /\\(\d+)/; var BACK_REFERENCING_END = /\\(\d+)/g; var Rule = (function () { function Rule($location, id, name, contentName) { this.$location = $location; this.id = id; this._name = name || null; this._nameIsCapturing = utils_1.RegexSource.hasCaptures(this._name); this._contentName = contentName || null; this._contentNameIsCapturing = utils_1.RegexSource.hasCaptures(this._contentName); } Object.defineProperty(Rule.prototype, "debugName", { get: function () { return this.constructor.name + "#" + this.id + " @ " + path.basename(this.$location.filename) + ":" + this.$location.line; }, enumerable: true, configurable: true }); Rule.prototype.getName = function (lineText, captureIndices) { if (!this._nameIsCapturing) { return this._name; } return utils_1.RegexSource.replaceCaptures(this._name, lineText, captureIndices); }; Rule.prototype.getContentName = function (lineText, captureIndices) { if (!this._contentNameIsCapturing) { return this._contentName; } return utils_1.RegexSource.replaceCaptures(this._contentName, lineText, captureIndices); }; Rule.prototype.collectPatternsRecursive = function (grammar, out, isFirst) { throw new Error('Implement me!'); }; Rule.prototype.compile = function (grammar, endRegexSource, allowA, allowG) { throw new Error('Implement me!'); }; return Rule; }()); exports.Rule = Rule; var CaptureRule = (function (_super) { __extends(CaptureRule, _super); function CaptureRule($location, id, name, contentName, retokenizeCapturedWithRuleId) { var _this = _super.call(this, $location, id, name, contentName) || this; _this.retokenizeCapturedWithRuleId = retokenizeCapturedWithRuleId; return _this; } return CaptureRule; }(Rule)); exports.CaptureRule = CaptureRule; var RegExpSource = (function () { function RegExpSource(regExpSource, ruleId, handleAnchors) { if (handleAnchors === void 0) { handleAnchors = true; } if (handleAnchors) { this._handleAnchors(regExpSource); } else { this.source = regExpSource; this.hasAnchor = false; } if (this.hasAnchor) { this._anchorCache = this._buildAnchorCache(); } this.ruleId = ruleId; this.hasBackReferences = HAS_BACK_REFERENCES.test(this.source); // console.log('input: ' + regExpSource + ' => ' + this.source + ', ' + this.hasAnchor); } RegExpSource.prototype.clone = function () { return new RegExpSource(this.source, this.ruleId, true); }; RegExpSource.prototype.setSource = function (newSource) { if (this.source === newSource) { return; } this.source = newSource; if (this.hasAnchor) { this._anchorCache = this._buildAnchorCache(); } }; RegExpSource.prototype._handleAnchors = function (regExpSource) { if (regExpSource) { var pos = void 0, len = void 0, ch = void 0, nextCh = void 0, lastPushedPos = 0, output = []; var hasAnchor = false; for (pos = 0, len = regExpSource.length; pos < len; pos++) { ch = regExpSource.charAt(pos); if (ch === '\\') { if (pos + 1 < len) { nextCh = regExpSource.charAt(pos + 1); if (nextCh === 'z') { output.push(regExpSource.substring(lastPushedPos, pos)); output.push('$(?!\\n)(?<!\\n)'); lastPushedPos = pos + 2; } else if (nextCh === 'A' || nextCh === 'G') { hasAnchor = true; } pos++; } } } this.hasAnchor = hasAnchor; if (lastPushedPos === 0) { // No \z hit this.source = regExpSource; } else { output.push(regExpSource.substring(lastPushedPos, len)); this.source = output.join(''); } } else { this.hasAnchor = false; this.source = regExpSource; } }; RegExpSource.prototype.resolveBackReferences = function (lineText, captureIndices) { var capturedValues = captureIndices.map(function (capture) { return lineText.substring(capture.start, capture.end); }); BACK_REFERENCING_END.lastIndex = 0; return this.source.replace(BACK_REFERENCING_END, function (match, g1) { return escapeRegExpCharacters(capturedValues[parseInt(g1, 10)] || ''); }); }; RegExpSource.prototype._buildAnchorCache = function () { var A0_G0_result = []; var A0_G1_result = []; var A1_G0_result = []; var A1_G1_result = []; var pos, len, ch, nextCh; for (pos = 0, len = this.source.length; pos < len; pos++) { ch = this.source.charAt(pos); A0_G0_result[pos] = ch; A0_G1_result[pos] = ch; A1_G0_result[pos] = ch; A1_G1_result[pos] = ch; if (ch === '\\') { if (pos + 1 < len) { nextCh = this.source.charAt(pos + 1); if (nextCh === 'A') { A0_G0_result[pos + 1] = '\uFFFF'; A0_G1_result[pos + 1] = '\uFFFF'; A1_G0_result[pos + 1] = 'A'; A1_G1_result[pos + 1] = 'A'; } else if (nextCh === 'G') { A0_G0_result[pos + 1] = '\uFFFF'; A0_G1_result[pos + 1] = 'G'; A1_G0_result[pos + 1] = '\uFFFF'; A1_G1_result[pos + 1] = 'G'; } else { A0_G0_result[pos + 1] = nextCh; A0_G1_result[pos + 1] = nextCh; A1_G0_result[pos + 1] = nextCh; A1_G1_result[pos + 1] = nextCh; } pos++; } } } return { A0_G0: A0_G0_result.join(''), A0_G1: A0_G1_result.join(''), A1_G0: A1_G0_result.join(''), A1_G1: A1_G1_result.join('') }; }; RegExpSource.prototype.resolveAnchors = function (allowA, allowG) { if (!this.hasAnchor) { return this.source; } if (allowA) { if (allowG) { return this._anchorCache.A1_G1; } else { return this._anchorCache.A1_G0; } } else { if (allowG) { return this._anchorCache.A0_G1; } else { return this._anchorCache.A0_G0; } } }; return RegExpSource; }()); exports.RegExpSource = RegExpSource; var getOnigModule = (function () { var onigurumaModule = null; return function () { if (!onigurumaModule) { onigurumaModule = require('oniguruma'); } return onigurumaModule; }; })(); function createOnigScanner(sources) { var onigurumaModule = getOnigModule(); return new onigurumaModule.OnigScanner(sources); } function createOnigString(sources) { var onigurumaModule = getOnigModule(); var r = new onigurumaModule.OnigString(sources); r.$str = sources; return r; } exports.createOnigString = createOnigString; function getString(str) { return str.$str; } exports.getString = getString; var RegExpSourceList = (function () { function RegExpSourceList() { this._items = []; this._hasAnchors = false; this._cached = null; this._cachedSources = null; this._anchorCache = { A0_G0: null, A0_G1: null, A1_G0: null, A1_G1: null }; } RegExpSourceList.prototype.push = function (item) { this._items.push(item); this._hasAnchors = this._hasAnchors || item.hasAnchor; }; RegExpSourceList.prototype.unshift = function (item) { this._items.unshift(item); this._hasAnchors = this._hasAnchors || item.hasAnchor; }; RegExpSourceList.prototype.length = function () { return this._items.length; }; RegExpSourceList.prototype.setSource = function (index, newSource) { if (this._items[index].source !== newSource) { // bust the cache this._cached = null; this._anchorCache.A0_G0 = null; this._anchorCache.A0_G1 = null; this._anchorCache.A1_G0 = null; this._anchorCache.A1_G1 = null; this._items[index].setSource(newSource); } }; RegExpSourceList.prototype.compile = function (grammar, allowA, allowG) { if (!this._hasAnchors) { if (!this._cached) { var regExps = this._items.map(function (e) { return e.source; }); this._cached = { scanner: createOnigScanner(regExps), rules: this._items.map(function (e) { return e.ruleId; }), debugRegExps: regExps }; } return this._cached; } else { this._anchorCache = { A0_G0: this._anchorCache.A0_G0 || (allowA === false && allowG === false ? this._resolveAnchors(allowA, allowG) : null), A0_G1: this._anchorCache.A0_G1 || (allowA === false && allowG === true ? this._resolveAnchors(allowA, allowG) : null), A1_G0: this._anchorCache.A1_G0 || (allowA === true && allowG === false ? this._resolveAnchors(allowA, allowG) : null), A1_G1: this._anchorCache.A1_G1 || (allowA === true && allowG === true ? this._resolveAnchors(allowA, allowG) : null), }; if (allowA) { if (allowG) { return this._anchorCache.A1_G1; } else { return this._anchorCache.A1_G0; } } else { if (allowG) { return this._anchorCache.A0_G1; } else { return this._anchorCache.A0_G0; } } } }; RegExpSourceList.prototype._resolveAnchors = function (allowA, allowG) { var regExps = this._items.map(function (e) { return e.resolveAnchors(allowA, allowG); }); return { scanner: createOnigScanner(regExps), rules: this._items.map(function (e) { return e.ruleId; }), debugRegExps: regExps }; }; return RegExpSourceList; }()); exports.RegExpSourceList = RegExpSourceList; var MatchRule = (function (_super) { __extends(MatchRule, _super); function MatchRule($location, id, name, match, captures) { var _this = _super.call(this, $location, id, name, null) || this; _this._match = new RegExpSource(match, _this.id); _this.captures = captures; _this._cachedCompiledPatterns = null; return _this; } Object.defineProperty(MatchRule.prototype, "debugMatchRegExp", { get: function () { return "" + this._match.source; }, enumerable: true, configurable: true }); MatchRule.prototype.collectPatternsRecursive = function (grammar, out, isFirst) { out.push(this._match); }; MatchRule.prototype.compile = function (grammar, endRegexSource, allowA, allowG) { if (!this._cachedCompiledPatterns) { this._cachedCompiledPatterns = new RegExpSourceList(); this.collectPatternsRecursive(grammar, this._cachedCompiledPatterns, true); } return this._cachedCompiledPatterns.compile(grammar, allowA, allowG); }; return MatchRule; }(Rule)); exports.MatchRule = MatchRule; var IncludeOnlyRule = (function (_super) { __extends(IncludeOnlyRule, _sup