Debian Codegraph @

extensions/CodeEditor/modules/lib/ace/mode-gherkin.js

raw symbols SCIP
1 ace.define("ace/mode/gherkin_highlight_rules",["require","exports","module","ace/lib/oop","ace/mode/text_highlight_rules"], function(require, exports, module){var oop = require("../lib/oop");
2 var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
3 var stringEscape = "\\\\(x[0-9A-Fa-f]{2}|[0-7]{3}|[\\\\abfnrtv'\"]|U[0-9A-Fa-f]{8}|u[0-9A-Fa-f]{4})";
4 var GherkinHighlightRules = function () {
5 var languages = [{
6 name: "en",
7 labels: "Feature|Background|Scenario(?: Outline)?|Examples",
8 keywords: "Given|When|Then|And|But"
9 }
10 ];
11 var labels = languages.map(function (l) {
12 return l.labels;
13 }).join("|");
14 var keywords = languages.map(function (l) {
15 return l.keywords;
16 }).join("|");
17 this.$rules = {
18 start: [{
19 token: "constant.numeric",
20 regex: "(?:(?:[1-9]\\d*)|(?:0))"
21 }, {
22 token: "comment",
23 regex: "#.*$"
24 }, {
25 token: "keyword",
26 regex: "(?:" + labels + "):|(?:" + keywords + ")\\b"
27 }, {
28 token: "keyword",
29 regex: "\\*"
30 }, {
31 token: "string", // multi line """ string start
32 regex: '"{3}',
33 next: "qqstring3"
34 }, {
35 token: "string", // " string
36 regex: '"',
37 next: "qqstring"
38 }, {
39 token: "text",
40 regex: "^\\s*(?=@[\\w])",
41 next: [{
42 token: "text",
43 regex: "\\s+"
44 }, {
45 token: "variable.parameter",
46 regex: "@[\\w]+"
47 }, {
48 token: "empty",
49 regex: "",
50 next: "start"
51 }]
52 }, {
53 token: "comment",
54 regex: "<[^>]+>"
55 }, {
56 token: "comment",
57 regex: "\\|(?=.)",
58 next: "table-item"
59 }, {
60 token: "comment",
61 regex: "\\|$",
62 next: "start"
63 }],
64 "qqstring3": [{
65 token: "constant.language.escape",
66 regex: stringEscape
67 }, {
68 token: "string", // multi line """ string end
69 regex: '"{3}',
70 next: "start"
71 }, {
72 defaultToken: "string"
73 }],
74 "qqstring": [{
75 token: "constant.language.escape",
76 regex: stringEscape
77 }, {
78 token: "string",
79 regex: "\\\\$",
80 next: "qqstring"
81 }, {
82 token: "string",
83 regex: '"|$',
84 next: "start"
85 }, {
86 defaultToken: "string"
87 }],
88 "table-item": [{
89 token: "comment",
90 regex: /$/,
91 next: "start"
92 }, {
93 token: "comment",
94 regex: /\|/
95 }, {
96 token: "string",
97 regex: /\\./
98 }, {
99 defaultToken: "string"
100 }]
101 };
102 this.normalizeRules();
103 };
104 oop.inherits(GherkinHighlightRules, TextHighlightRules);
105 exports.GherkinHighlightRules = GherkinHighlightRules;
106
107 });
108
109 ace.define("ace/mode/gherkin",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/gherkin_highlight_rules"], function(require, exports, module){var oop = require("../lib/oop");
110 var TextMode = require("./text").Mode;
111 var GherkinHighlightRules = require("./gherkin_highlight_rules").GherkinHighlightRules;
112 var Mode = function () {
113 this.HighlightRules = GherkinHighlightRules;
114 this.$behaviour = this.$defaultBehaviour;
115 };
116 oop.inherits(Mode, TextMode);
117 (function () {
118 this.lineCommentStart = "#";
119 this.$id = "ace/mode/gherkin";
120 this.getNextLineIndent = function (state, line, tab) {
121 var indent = this.$getIndent(line);
122 var space2 = " ";
123 var tokenizedLine = this.getTokenizer().getLineTokens(line, state);
124 var tokens = tokenizedLine.tokens;
125 if (line.match("[ ]*\\|")) {
126 indent += "| ";
127 }
128 if (tokens.length && tokens[tokens.length - 1].type == "comment") {
129 return indent;
130 }
131 if (state == "start") {
132 if (line.match("Scenario:|Feature:|Scenario Outline:|Background:")) {
133 indent += space2;
134 }
135 else if (line.match("(Given|Then).+(:)$|Examples:")) {
136 indent += space2;
137 }
138 else if (line.match("\\*.+")) {
139 indent += "* ";
140 }
141 }
142 return indent;
143 };
144 }).call(Mode.prototype);
145 exports.Mode = Mode;
146
147 }); (function() {
148 ace.require(["ace/mode/gherkin"], function(m) {
149 if (typeof module == "object" && typeof exports == "object" && module) {
150 module.exports = m;
151 }
152 });
153 })();
154