ext-beautify-a9a73514.js.map 19 KB

1
  1. {"version":3,"file":"ext-beautify-a9a73514.js","sources":["../../node_modules/ace-builds/src-noconflict/ext-beautify.js"],"sourcesContent":["ace.define(\"ace/ext/beautify\",[\"require\",\"exports\",\"module\",\"ace/token_iterator\"], function(require, exports, module){// [WIP]\n\"use strict\";\nvar TokenIterator = require(\"../token_iterator\").TokenIterator;\nfunction is(token, type) {\n return token.type.lastIndexOf(type + \".xml\") > -1;\n}\nexports.singletonTags = [\"area\", \"base\", \"br\", \"col\", \"command\", \"embed\", \"hr\", \"html\", \"img\", \"input\", \"keygen\", \"link\", \"meta\", \"param\", \"source\", \"track\", \"wbr\"];\nexports.blockTags = [\"article\", \"aside\", \"blockquote\", \"body\", \"div\", \"dl\", \"fieldset\", \"footer\", \"form\", \"head\", \"header\", \"html\", \"nav\", \"ol\", \"p\", \"script\", \"section\", \"style\", \"table\", \"tbody\", \"tfoot\", \"thead\", \"ul\"];\nexports.formatOptions = {\n lineBreaksAfterCommasInCurlyBlock: true\n};\nexports.beautify = function (session) {\n var iterator = new TokenIterator(session, 0, 0);\n var token = iterator.getCurrentToken();\n var tabString = session.getTabString();\n var singletonTags = exports.singletonTags;\n var blockTags = exports.blockTags;\n var formatOptions = exports.formatOptions || {};\n var nextToken;\n var breakBefore = false;\n var spaceBefore = false;\n var spaceAfter = false;\n var code = \"\";\n var value = \"\";\n var tagName = \"\";\n var depth = 0;\n var lastDepth = 0;\n var lastIndent = 0;\n var indent = 0;\n var unindent = 0;\n var roundDepth = 0;\n var curlyDepth = 0;\n var row;\n var curRow = 0;\n var rowsToAdd = 0;\n var rowTokens = [];\n var abort = false;\n var i;\n var indentNextLine = false;\n var inTag = false;\n var inCSS = false;\n var inBlock = false;\n var levels = { 0: 0 };\n var parents = [];\n var caseBody = false;\n var trimNext = function () {\n if (nextToken && nextToken.value && nextToken.type !== 'string.regexp')\n nextToken.value = nextToken.value.replace(/^\\s*/, \"\");\n };\n var trimLine = function () {\n var end = code.length - 1;\n while (true) {\n if (end == 0)\n break;\n if (code[end] !== \" \")\n break;\n end = end - 1;\n }\n code = code.slice(0, end + 1);\n };\n var trimCode = function () {\n code = code.trimRight();\n breakBefore = false;\n };\n while (token !== null) {\n curRow = iterator.getCurrentTokenRow();\n rowTokens = iterator.$rowTokens;\n nextToken = iterator.stepForward();\n if (typeof token !== \"undefined\") {\n value = token.value;\n unindent = 0;\n inCSS = (tagName === \"style\" || session.$modeId === \"ace/mode/css\");\n if (is(token, \"tag-open\")) {\n inTag = true;\n if (nextToken)\n inBlock = (blockTags.indexOf(nextToken.value) !== -1);\n if (value === \"</\") {\n if (inBlock && !breakBefore && rowsToAdd < 1)\n rowsToAdd++;\n if (inCSS)\n rowsToAdd = 1;\n unindent = 1;\n inBlock = false;\n }\n }\n else if (is(token, \"tag-close\")) {\n inTag = false;\n }\n else if (is(token, \"comment.start\")) {\n inBlock = true;\n }\n else if (is(token, \"comment.end\")) {\n inBlock = false;\n }\n if (!inTag && !rowsToAdd && token.type === \"paren.rparen\" && token.value.substr(0, 1) === \"}\") {\n rowsToAdd++;\n }\n if (curRow !== row) {\n rowsToAdd = curRow;\n if (row)\n rowsToAdd -= row;\n }\n if (rowsToAdd) {\n trimCode();\n for (; rowsToAdd > 0; rowsToAdd--)\n code += \"\\n\";\n breakBefore = true;\n if (!is(token, \"comment\") && !token.type.match(/^(comment|string)$/))\n value = value.trimLeft();\n }\n if (value) {\n if (token.type === \"keyword\" && value.match(/^(if|else|elseif|for|foreach|while|switch)$/)) {\n parents[depth] = value;\n trimNext();\n spaceAfter = true;\n if (value.match(/^(else|elseif)$/)) {\n if (code.match(/\\}[\\s]*$/)) {\n trimCode();\n spaceBefore = true;\n }\n }\n }\n else if (token.type === \"paren.lparen\") {\n trimNext();\n if (value.substr(-1) === \"{\") {\n spaceAfter = true;\n indentNextLine = false;\n if (!inTag)\n rowsToAdd = 1;\n }\n if (value.substr(0, 1) === \"{\") {\n spaceBefore = true;\n if (code.substr(-1) !== '[' && code.trimRight().substr(-1) === '[') {\n trimCode();\n spaceBefore = false;\n }\n else if (code.trimRight().substr(-1) === ')') {\n trimCode();\n }\n else {\n trimLine();\n }\n }\n }\n else if (token.type === \"paren.rparen\") {\n unindent = 1;\n if (value.substr(0, 1) === \"}\") {\n if (parents[depth - 1] === 'case')\n unindent++;\n if (code.trimRight().substr(-1) === '{') {\n trimCode();\n }\n else {\n spaceBefore = true;\n if (inCSS)\n rowsToAdd += 2;\n }\n }\n if (value.substr(0, 1) === \"]\") {\n if (code.substr(-1) !== '}' && code.trimRight().substr(-1) === '}') {\n spaceBefore = false;\n indent++;\n trimCode();\n }\n }\n if (value.substr(0, 1) === \")\") {\n if (code.substr(-1) !== '(' && code.trimRight().substr(-1) === '(') {\n spaceBefore = false;\n indent++;\n trimCode();\n }\n }\n trimLine();\n }\n else if ((token.type === \"keyword.operator\" || token.type === \"keyword\") && value.match(/^(=|==|===|!=|!==|&&|\\|\\||and|or|xor|\\+=|.=|>|>=|<|<=|=>)$/)) {\n trimCode();\n trimNext();\n spaceBefore = true;\n spaceAfter = true;\n }\n else if (token.type === \"punctuation.operator\" && value === ';') {\n trimCode();\n trimNext();\n spaceAfter = true;\n if (inCSS)\n rowsToAdd++;\n }\n else if (token.type === \"punctuation.operator\" && value.match(/^(:|,)$/)) {\n trimCode();\n trimNext();\n if (value.match(/^(,)$/) && curlyDepth > 0 && roundDepth === 0 && formatOptions.lineBreaksAfterCommasInCurlyBlock) {\n rowsToAdd++;\n }\n else {\n spaceAfter = true;\n breakBefore = false;\n }\n }\n else if (token.type === \"support.php_tag\" && value === \"?>\" && !breakBefore) {\n trimCode();\n spaceBefore = true;\n }\n else if (is(token, \"attribute-name\") && code.substr(-1).match(/^\\s$/)) {\n spaceBefore = true;\n }\n else if (is(token, \"attribute-equals\")) {\n trimLine();\n trimNext();\n }\n else if (is(token, \"tag-close\")) {\n trimLine();\n if (value === \"/>\")\n spaceBefore = true;\n }\n else if (token.type === \"keyword\" && value.match(/^(case|default)$/)) {\n if (caseBody)\n unindent = 1;\n }\n if (breakBefore && !(token.type.match(/^(comment)$/) && !value.substr(0, 1).match(/^[/#]$/)) && !(token.type.match(/^(string)$/) && !value.substr(0, 1).match(/^['\"@]$/))) {\n indent = lastIndent;\n if (depth > lastDepth) {\n indent++;\n for (i = depth; i > lastDepth; i--)\n levels[i] = indent;\n }\n else if (depth < lastDepth)\n indent = levels[depth];\n lastDepth = depth;\n lastIndent = indent;\n if (unindent)\n indent -= unindent;\n if (indentNextLine && !roundDepth) {\n indent++;\n indentNextLine = false;\n }\n for (i = 0; i < indent; i++)\n code += tabString;\n }\n if (token.type === \"keyword\" && value.match(/^(case|default)$/)) {\n if (caseBody === false) {\n parents[depth] = value;\n depth++;\n caseBody = true;\n }\n }\n else if (token.type === \"keyword\" && value.match(/^(break)$/)) {\n if (parents[depth - 1] && parents[depth - 1].match(/^(case|default)$/)) {\n depth--;\n caseBody = false;\n }\n }\n if (token.type === \"paren.lparen\") {\n roundDepth += (value.match(/\\(/g) || []).length;\n curlyDepth += (value.match(/\\{/g) || []).length;\n depth += value.length;\n }\n if (token.type === \"keyword\" && value.match(/^(if|else|elseif|for|while)$/)) {\n indentNextLine = true;\n roundDepth = 0;\n }\n else if (!roundDepth && value.trim() && token.type !== \"comment\")\n indentNextLine = false;\n if (token.type === \"paren.rparen\") {\n roundDepth -= (value.match(/\\)/g) || []).length;\n curlyDepth -= (value.match(/\\}/g) || []).length;\n for (i = 0; i < value.length; i++) {\n depth--;\n if (value.substr(i, 1) === '}' && parents[depth] === 'case') {\n depth--;\n }\n }\n }\n if (token.type == \"text\")\n value = value.replace(/\\s+$/, \" \");\n if (spaceBefore && !breakBefore) {\n trimLine();\n if (code.substr(-1) !== \"\\n\")\n code += \" \";\n }\n code += value;\n if (spaceAfter)\n code += \" \";\n breakBefore = false;\n spaceBefore = false;\n spaceAfter = false;\n if ((is(token, \"tag-close\") && (inBlock || blockTags.indexOf(tagName) !== -1)) || (is(token, \"doctype\") && value === \">\")) {\n if (inBlock && nextToken && nextToken.value === \"</\")\n rowsToAdd = -1;\n else\n rowsToAdd = 1;\n }\n if (nextToken && singletonTags.indexOf(nextToken.value) === -1) {\n if (is(token, \"tag-open\") && value === \"</\") {\n depth--;\n }\n else if (is(token, \"tag-open\") && value === \"<\") {\n depth++;\n }\n else if (is(token, \"tag-close\") && value === \"/>\") {\n depth--;\n }\n }\n if (is(token, \"tag-name\")) {\n tagName = value;\n }\n row = curRow;\n }\n }\n token = nextToken;\n }\n code = code.trim();\n session.doc.setValue(code);\n};\nexports.commands = [{\n name: \"beautify\",\n description: \"Format selection (Beautify)\",\n exec: function (editor) {\n exports.beautify(editor.session);\n },\n bindKey: \"Ctrl-Shift-B\"\n }];\n\n}); (function() {\n ace.require([\"ace/ext/beautify\"], function(m) {\n if (typeof module == \"object\" && typeof exports == \"object\" && module) {\n module.exports = m;\n }\n });\n })();\n "],"names":["require","exports","module","TokenIterator","is","token","type","session","iterator","tabString","singletonTags","blockTags","formatOptions","nextToken","breakBefore","spaceBefore","spaceAfter","code","value","tagName","depth","lastDepth","lastIndent","indent","unindent","roundDepth","curlyDepth","row","curRow","rowsToAdd","i","indentNextLine","inTag","inCSS","inBlock","levels","parents","caseBody","trimNext","trimLine","end","trimCode","editor","m"],"mappings":"gaAAA,IAAI,OAAO,mBAAmB,CAAC,UAAU,UAAU,SAAS,oBAAoB,EAAG,SAASA,EAASC,EAASC,EAAO,CAErH,IAAIC,EAAgBH,EAAQ,mBAAmB,EAAE,cACjD,SAASI,EAAGC,EAAOC,EAAM,CACrB,OAAOD,EAAM,KAAK,YAAYC,EAAO,MAAM,EAAI,EAClD,CACDL,EAAQ,cAAgB,CAAC,OAAQ,OAAQ,KAAM,MAAO,UAAW,QAAS,KAAM,OAAQ,MAAO,QAAS,SAAU,OAAQ,OAAQ,QAAS,SAAU,QAAS,KAAK,EACnKA,EAAQ,UAAY,CAAC,UAAW,QAAS,aAAc,OAAQ,MAAO,KAAM,WAAY,SAAU,OAAQ,O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