| 1 |
ace.define("ace/mode/graphqlschema_highlight_rules",["require","exports","module","ace/lib/oop","ace/mode/text_highlight_rules"], function(require, exports, module){"use strict"; |
| 2 |
var oop = require("../lib/oop"); |
| 3 |
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; |
| 4 |
var GraphQLSchemaHighlightRules = function () { |
| 5 |
var keywords = ("type|interface|union|enum|schema|input|implements|extends|scalar"); |
| 6 |
var dataTypes = ("Int|Float|String|ID|Boolean"); |
| 7 |
var keywordMapper = this.createKeywordMapper({ |
| 8 |
"keyword": keywords, |
| 9 |
"storage.type": dataTypes |
| 10 |
}, "identifier"); |
| 11 |
this.$rules = { |
| 12 |
"start": [{ |
| 13 |
token: "comment", |
| 14 |
regex: "#.*$" |
| 15 |
}, { |
| 16 |
token: "paren.lparen", |
| 17 |
regex: /[\[({]/, |
| 18 |
next: "start" |
| 19 |
}, { |
| 20 |
token: "paren.rparen", |
| 21 |
regex: /[\])}]/ |
| 22 |
}, { |
| 23 |
token: keywordMapper, |
| 24 |
regex: "[a-zA-Z_$][a-zA-Z0-9_$]*\\b" |
| 25 |
}] |
| 26 |
}; |
| 27 |
this.normalizeRules(); |
| 28 |
}; |
| 29 |
oop.inherits(GraphQLSchemaHighlightRules, TextHighlightRules); |
| 30 |
exports.GraphQLSchemaHighlightRules = GraphQLSchemaHighlightRules; |
| 31 |
|
| 32 |
}); |
| 33 |
|
| 34 |
ace.define("ace/mode/folding/cstyle",["require","exports","module","ace/lib/oop","ace/range","ace/mode/folding/fold_mode"], function(require, exports, module){"use strict"; |
| 35 |
var oop = require("../../lib/oop"); |
| 36 |
var Range = require("../../range").Range; |
| 37 |
var BaseFoldMode = require("./fold_mode").FoldMode; |
| 38 |
var FoldMode = exports.FoldMode = function (commentRegex) { |
| 39 |
if (commentRegex) { |
| 40 |
this.foldingStartMarker = new RegExp(this.foldingStartMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.start)); |
| 41 |
this.foldingStopMarker = new RegExp(this.foldingStopMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.end)); |
| 42 |
} |
| 43 |
}; |
| 44 |
oop.inherits(FoldMode, BaseFoldMode); |
| 45 |
(function () { |
| 46 |
this.foldingStartMarker = /([\{\[\(])[^\}\]\)]*$|^\s*(\/\*)/; |
| 47 |
this.foldingStopMarker = /^[^\[\{\(]*([\}\]\)])|^[\s\*]*(\*\/)/; |
| 48 |
this.singleLineBlockCommentRe = /^\s*(\/\*).*\*\/\s*$/; |
| 49 |
this.tripleStarBlockCommentRe = /^\s*(\/\*\*\*).*\*\/\s*$/; |
| 50 |
this.startRegionRe = /^\s*(\/\*|\/\/)#?region\b/; |
| 51 |
this._getFoldWidgetBase = this.getFoldWidget; |
| 52 |
this.getFoldWidget = function (session, foldStyle, row) { |
| 53 |
var line = session.getLine(row); |
| 54 |
if (this.singleLineBlockCommentRe.test(line)) { |
| 55 |
if (!this.startRegionRe.test(line) && !this.tripleStarBlockCommentRe.test(line)) |
| 56 |
return ""; |
| 57 |
} |
| 58 |
var fw = this._getFoldWidgetBase(session, foldStyle, row); |
| 59 |
if (!fw && this.startRegionRe.test(line)) |
| 60 |
return "start"; |
| 61 |
return fw; |
| 62 |
}; |
| 63 |
this.getFoldWidgetRange = function (session, foldStyle, row, forceMultiline) { |
| 64 |
var line = session.getLine(row); |
| 65 |
if (this.startRegionRe.test(line)) |
| 66 |
return this.getCommentRegionBlock(session, line, row); |
| 67 |
var match = line.match(this.foldingStartMarker); |
| 68 |
if (match) { |
| 69 |
var i = match.index; |
| 70 |
if (match[1]) |
| 71 |
return this.openingBracketBlock(session, match[1], row, i); |
| 72 |
var range = session.getCommentFoldRange(row, i + match[0].length, 1); |
| 73 |
if (range && !range.isMultiLine()) { |
| 74 |
if (forceMultiline) { |
| 75 |
range = this.getSectionRange(session, row); |
| 76 |
} |
| 77 |
else if (foldStyle != "all") |
| 78 |
range = null; |
| 79 |
} |
| 80 |
return range; |
| 81 |
} |
| 82 |
if (foldStyle === "markbegin") |
| 83 |
return; |
| 84 |
var match = line.match(this.foldingStopMarker); |
| 85 |
if (match) { |
| 86 |
var i = match.index + match[0].length; |
| 87 |
if (match[1]) |
| 88 |
return this.closingBracketBlock(session, match[1], row, i); |
| 89 |
return session.getCommentFoldRange(row, i, -1); |
| 90 |
} |
| 91 |
}; |
| 92 |
this.getSectionRange = function (session, row) { |
| 93 |
var line = session.getLine(row); |
| 94 |
var startIndent = line.search(/\S/); |
| 95 |
var startRow = row; |
| 96 |
var startColumn = line.length; |
| 97 |
row = row + 1; |
| 98 |
var endRow = row; |
| 99 |
var maxRow = session.getLength(); |
| 100 |
while (++row < maxRow) { |
| 101 |
line = session.getLine(row); |
| 102 |
var indent = line.search(/\S/); |
| 103 |
if (indent === -1) |
| 104 |
continue; |
| 105 |
if (startIndent > indent) |
| 106 |
break; |
| 107 |
var subRange = this.getFoldWidgetRange(session, "all", row); |
| 108 |
if (subRange) { |
| 109 |
if (subRange.start.row <= startRow) { |
| 110 |
break; |
| 111 |
} |
| 112 |
else if (subRange.isMultiLine()) { |
| 113 |
row = subRange.end.row; |
| 114 |
} |
| 115 |
else if (startIndent == indent) { |
| 116 |
break; |
| 117 |
} |
| 118 |
} |
| 119 |
endRow = row; |
| 120 |
} |
| 121 |
return new Range(startRow, startColumn, endRow, session.getLine(endRow).length); |
| 122 |
}; |
| 123 |
this.getCommentRegionBlock = function (session, line, row) { |
| 124 |
var startColumn = line.search(/\s*$/); |
| 125 |
var maxRow = session.getLength(); |
| 126 |
var startRow = row; |
| 127 |
var re = /^\s*(?:\/\*|\/\/|--)#?(end)?region\b/; |
| 128 |
var depth = 1; |
| 129 |
while (++row < maxRow) { |
| 130 |
line = session.getLine(row); |
| 131 |
var m = re.exec(line); |
| 132 |
if (!m) |
| 133 |
continue; |
| 134 |
if (m[1]) |
| 135 |
depth--; |
| 136 |
else |
| 137 |
depth++; |
| 138 |
if (!depth) |
| 139 |
break; |
| 140 |
} |
| 141 |
var endRow = row; |
| 142 |
if (endRow > startRow) { |
| 143 |
return new Range(startRow, startColumn, endRow, line.length); |
| 144 |
} |
| 145 |
}; |
| 146 |
}).call(FoldMode.prototype); |
| 147 |
|
| 148 |
}); |
| 149 |
|
| 150 |
ace.define("ace/mode/graphqlschema",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/graphqlschema_highlight_rules","ace/mode/folding/cstyle"], function(require, exports, module){"use strict"; |
| 151 |
var oop = require("../lib/oop"); |
| 152 |
var TextMode = require("./text").Mode; |
| 153 |
var GraphQLSchemaHighlightRules = require("./graphqlschema_highlight_rules").GraphQLSchemaHighlightRules; |
| 154 |
var FoldMode = require("./folding/cstyle").FoldMode; |
| 155 |
var Mode = function () { |
| 156 |
this.HighlightRules = GraphQLSchemaHighlightRules; |
| 157 |
this.foldingRules = new FoldMode(); |
| 158 |
}; |
| 159 |
oop.inherits(Mode, TextMode); |
| 160 |
(function () { |
| 161 |
this.lineCommentStart = "#"; |
| 162 |
this.$id = "ace/mode/graphqlschema"; |
| 163 |
this.snippetFileId = "ace/snippets/graphqlschema"; |
| 164 |
}).call(Mode.prototype); |
| 165 |
exports.Mode = Mode; |
| 166 |
|
| 167 |
}); (function() { |
| 168 |
ace.require(["ace/mode/graphqlschema"], function(m) { |
| 169 |
if (typeof module == "object" && typeof exports == "object" && module) { |
| 170 |
module.exports = m; |
| 171 |
} |
| 172 |
}); |
| 173 |
})(); |
| 174 |
|