cbc9092524363d014f77a62f36ff1540.js 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  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. 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";
  33. var oop = require("../../lib/oop");
  34. var Range = require("../../range").Range;
  35. var BaseFoldMode = require("./fold_mode").FoldMode;
  36. var FoldMode = exports.FoldMode = function (commentRegex) {
  37. if (commentRegex) {
  38. this.foldingStartMarker = new RegExp(this.foldingStartMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.start));
  39. this.foldingStopMarker = new RegExp(this.foldingStopMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.end));
  40. }
  41. };
  42. oop.inherits(FoldMode, BaseFoldMode);
  43. (function () {
  44. this.foldingStartMarker = /([\{\[\(])[^\}\]\)]*$|^\s*(\/\*)/;
  45. this.foldingStopMarker = /^[^\[\{\(]*([\}\]\)])|^[\s\*]*(\*\/)/;
  46. this.singleLineBlockCommentRe = /^\s*(\/\*).*\*\/\s*$/;
  47. this.tripleStarBlockCommentRe = /^\s*(\/\*\*\*).*\*\/\s*$/;
  48. this.startRegionRe = /^\s*(\/\*|\/\/)#?region\b/;
  49. this._getFoldWidgetBase = this.getFoldWidget;
  50. this.getFoldWidget = function (session, foldStyle, row) {
  51. var line = session.getLine(row);
  52. if (this.singleLineBlockCommentRe.test(line)) {
  53. if (!this.startRegionRe.test(line) && !this.tripleStarBlockCommentRe.test(line))
  54. return "";
  55. }
  56. var fw = this._getFoldWidgetBase(session, foldStyle, row);
  57. if (!fw && this.startRegionRe.test(line))
  58. return "start"; // lineCommentRegionStart
  59. return fw;
  60. };
  61. this.getFoldWidgetRange = function (session, foldStyle, row, forceMultiline) {
  62. var line = session.getLine(row);
  63. if (this.startRegionRe.test(line))
  64. return this.getCommentRegionBlock(session, line, row);
  65. var match = line.match(this.foldingStartMarker);
  66. if (match) {
  67. var i = match.index;
  68. if (match[1])
  69. return this.openingBracketBlock(session, match[1], row, i);
  70. var range = session.getCommentFoldRange(row, i + match[0].length, 1);
  71. if (range && !range.isMultiLine()) {
  72. if (forceMultiline) {
  73. range = this.getSectionRange(session, row);
  74. }
  75. else if (foldStyle != "all")
  76. range = null;
  77. }
  78. return range;
  79. }
  80. if (foldStyle === "markbegin")
  81. return;
  82. var match = line.match(this.foldingStopMarker);
  83. if (match) {
  84. var i = match.index + match[0].length;
  85. if (match[1])
  86. return this.closingBracketBlock(session, match[1], row, i);
  87. return session.getCommentFoldRange(row, i, -1);
  88. }
  89. };
  90. this.getSectionRange = function (session, row) {
  91. var line = session.getLine(row);
  92. var startIndent = line.search(/\S/);
  93. var startRow = row;
  94. var startColumn = line.length;
  95. row = row + 1;
  96. var endRow = row;
  97. var maxRow = session.getLength();
  98. while (++row < maxRow) {
  99. line = session.getLine(row);
  100. var indent = line.search(/\S/);
  101. if (indent === -1)
  102. continue;
  103. if (startIndent > indent)
  104. break;
  105. var subRange = this.getFoldWidgetRange(session, "all", row);
  106. if (subRange) {
  107. if (subRange.start.row <= startRow) {
  108. break;
  109. }
  110. else if (subRange.isMultiLine()) {
  111. row = subRange.end.row;
  112. }
  113. else if (startIndent == indent) {
  114. break;
  115. }
  116. }
  117. endRow = row;
  118. }
  119. return new Range(startRow, startColumn, endRow, session.getLine(endRow).length);
  120. };
  121. this.getCommentRegionBlock = function (session, line, row) {
  122. var startColumn = line.search(/\s*$/);
  123. var maxRow = session.getLength();
  124. var startRow = row;
  125. var re = /^\s*(?:\/\*|\/\/|--)#?(end)?region\b/;
  126. var depth = 1;
  127. while (++row < maxRow) {
  128. line = session.getLine(row);
  129. var m = re.exec(line);
  130. if (!m)
  131. continue;
  132. if (m[1])
  133. depth--;
  134. else
  135. depth++;
  136. if (!depth)
  137. break;
  138. }
  139. var endRow = row;
  140. if (endRow > startRow) {
  141. return new Range(startRow, startColumn, endRow, line.length);
  142. }
  143. };
  144. }).call(FoldMode.prototype);
  145. });
  146. 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";
  147. var oop = require("../lib/oop");
  148. var TextMode = require("./text").Mode;
  149. var GraphQLSchemaHighlightRules = require("./graphqlschema_highlight_rules").GraphQLSchemaHighlightRules;
  150. var FoldMode = require("./folding/cstyle").FoldMode;
  151. var Mode = function () {
  152. this.HighlightRules = GraphQLSchemaHighlightRules;
  153. this.foldingRules = new FoldMode();
  154. };
  155. oop.inherits(Mode, TextMode);
  156. (function () {
  157. this.lineCommentStart = "#";
  158. this.$id = "ace/mode/graphqlschema";
  159. this.snippetFileId = "ace/snippets/graphqlschema";
  160. }).call(Mode.prototype);
  161. exports.Mode = Mode;
  162. }); (function() {
  163. ace.require(["ace/mode/graphqlschema"], function(m) {
  164. if (typeof module == "object" && typeof exports == "object" && module) {
  165. module.exports = m;
  166. }
  167. });
  168. })();