codemirror-rails 5.6 → 5.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/codemirror/rails/version.rb +2 -2
- data/vendor/assets/javascripts/codemirror.js +30 -17
- data/vendor/assets/javascripts/codemirror/addons/display/placeholder.js +3 -1
- data/vendor/assets/javascripts/codemirror/addons/edit/closebrackets.js +10 -0
- data/vendor/assets/javascripts/codemirror/addons/lint/lint.js +21 -3
- data/vendor/assets/javascripts/codemirror/addons/search/search.js +29 -14
- data/vendor/assets/javascripts/codemirror/keymaps/sublime.js +11 -3
- data/vendor/assets/javascripts/codemirror/modes/clike.js +15 -0
- data/vendor/assets/javascripts/codemirror/modes/coffeescript.js +14 -17
- data/vendor/assets/javascripts/codemirror/modes/css.js +66 -15
- data/vendor/assets/javascripts/codemirror/modes/elm.js +1 -1
- data/vendor/assets/javascripts/codemirror/modes/gfm.js +23 -17
- data/vendor/assets/javascripts/codemirror/modes/haxe.js +68 -80
- data/vendor/assets/javascripts/codemirror/modes/htmlmixed.js +125 -96
- data/vendor/assets/javascripts/codemirror/modes/javascript.js +14 -5
- data/vendor/assets/javascripts/codemirror/modes/markdown.js +40 -29
- data/vendor/assets/javascripts/codemirror/modes/mscgen.js +169 -0
- data/vendor/assets/javascripts/codemirror/modes/oz.js +252 -0
- data/vendor/assets/javascripts/codemirror/modes/php.js +6 -3
- data/vendor/assets/javascripts/codemirror/modes/ruby.js +1 -1
- data/vendor/assets/javascripts/codemirror/modes/vhdl.js +1 -1
- data/vendor/assets/javascripts/codemirror/modes/vue.js +69 -0
- data/vendor/assets/stylesheets/codemirror/themes/icecoder.css +1 -0
- metadata +6 -3
@@ -28,7 +28,8 @@ CodeMirror.defineMode("css", function(config, parserConfig) {
|
|
28
28
|
counterDescriptors = parserConfig.counterDescriptors || {},
|
29
29
|
colorKeywords = parserConfig.colorKeywords || {},
|
30
30
|
valueKeywords = parserConfig.valueKeywords || {},
|
31
|
-
allowNested = parserConfig.allowNested
|
31
|
+
allowNested = parserConfig.allowNested,
|
32
|
+
supportsAtComponent = parserConfig.supportsAtComponent === true;
|
32
33
|
|
33
34
|
var type, override;
|
34
35
|
function ret(style, tp) { type = tp; return style; }
|
@@ -122,13 +123,14 @@ CodeMirror.defineMode("css", function(config, parserConfig) {
|
|
122
123
|
this.prev = prev;
|
123
124
|
}
|
124
125
|
|
125
|
-
function pushContext(state, stream, type) {
|
126
|
-
state.context = new Context(type, stream.indentation() + indentUnit, state.context);
|
126
|
+
function pushContext(state, stream, type, indent) {
|
127
|
+
state.context = new Context(type, stream.indentation() + (indent === false ? 0 : indentUnit), state.context);
|
127
128
|
return type;
|
128
129
|
}
|
129
130
|
|
130
131
|
function popContext(state) {
|
131
|
-
|
132
|
+
if (state.context.prev)
|
133
|
+
state.context = state.context.prev;
|
132
134
|
return state.context.type;
|
133
135
|
}
|
134
136
|
|
@@ -160,9 +162,13 @@ CodeMirror.defineMode("css", function(config, parserConfig) {
|
|
160
162
|
return pushContext(state, stream, "block");
|
161
163
|
} else if (type == "}" && state.context.prev) {
|
162
164
|
return popContext(state);
|
163
|
-
} else if (/@
|
165
|
+
} else if (supportsAtComponent && /@component/.test(type)) {
|
166
|
+
return pushContext(state, stream, "atComponentBlock");
|
167
|
+
} else if (/^@(-moz-)?document$/.test(type)) {
|
168
|
+
return pushContext(state, stream, "documentTypes");
|
169
|
+
} else if (/^@(media|supports|(-moz-)?document|import)$/.test(type)) {
|
164
170
|
return pushContext(state, stream, "atBlock");
|
165
|
-
} else if (
|
171
|
+
} else if (/^@(font-face|counter-style)/.test(type)) {
|
166
172
|
state.stateArg = type;
|
167
173
|
return "restricted_atBlock_before";
|
168
174
|
} else if (/^@(-(moz|ms|o|webkit)-)?keyframes$/.test(type)) {
|
@@ -255,17 +261,24 @@ CodeMirror.defineMode("css", function(config, parserConfig) {
|
|
255
261
|
return pass(type, stream, state);
|
256
262
|
};
|
257
263
|
|
264
|
+
states.documentTypes = function(type, stream, state) {
|
265
|
+
if (type == "word" && documentTypes.hasOwnProperty(stream.current())) {
|
266
|
+
override = "tag";
|
267
|
+
return state.context.type;
|
268
|
+
} else {
|
269
|
+
return states.atBlock(type, stream, state);
|
270
|
+
}
|
271
|
+
};
|
272
|
+
|
258
273
|
states.atBlock = function(type, stream, state) {
|
259
274
|
if (type == "(") return pushContext(state, stream, "atBlock_parens");
|
260
|
-
if (type == "}") return popAndPass(type, stream, state);
|
275
|
+
if (type == "}" || type == ";") return popAndPass(type, stream, state);
|
261
276
|
if (type == "{") return popContext(state) && pushContext(state, stream, allowNested ? "block" : "top");
|
262
277
|
|
263
278
|
if (type == "word") {
|
264
279
|
var word = stream.current().toLowerCase();
|
265
280
|
if (word == "only" || word == "not" || word == "and" || word == "or")
|
266
281
|
override = "keyword";
|
267
|
-
else if (documentTypes.hasOwnProperty(word))
|
268
|
-
override = "tag";
|
269
282
|
else if (mediaTypes.hasOwnProperty(word))
|
270
283
|
override = "attribute";
|
271
284
|
else if (mediaFeatures.hasOwnProperty(word))
|
@@ -286,6 +299,16 @@ CodeMirror.defineMode("css", function(config, parserConfig) {
|
|
286
299
|
return state.context.type;
|
287
300
|
};
|
288
301
|
|
302
|
+
states.atComponentBlock = function(type, stream, state) {
|
303
|
+
if (type == "}")
|
304
|
+
return popAndPass(type, stream, state);
|
305
|
+
if (type == "{")
|
306
|
+
return popContext(state) && pushContext(state, stream, allowNested ? "block" : "top", false);
|
307
|
+
if (type == "word")
|
308
|
+
override = "error";
|
309
|
+
return state.context.type;
|
310
|
+
};
|
311
|
+
|
289
312
|
states.atBlock_parens = function(type, stream, state) {
|
290
313
|
if (type == ")") return popContext(state);
|
291
314
|
if (type == "{" || type == "}") return popAndPass(type, stream, state, 2);
|
@@ -364,12 +387,18 @@ CodeMirror.defineMode("css", function(config, parserConfig) {
|
|
364
387
|
var cx = state.context, ch = textAfter && textAfter.charAt(0);
|
365
388
|
var indent = cx.indent;
|
366
389
|
if (cx.type == "prop" && (ch == "}" || ch == ")")) cx = cx.prev;
|
367
|
-
if (cx.prev
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
390
|
+
if (cx.prev) {
|
391
|
+
if (ch == "}" && (cx.type == "block" || cx.type == "top" ||
|
392
|
+
cx.type == "interpolation" || cx.type == "restricted_atBlock")) {
|
393
|
+
// Resume indentation from parent context.
|
394
|
+
cx = cx.prev;
|
395
|
+
indent = cx.indent;
|
396
|
+
} else if (ch == ")" && (cx.type == "parens" || cx.type == "atBlock_parens") ||
|
397
|
+
ch == "{" && (cx.type == "at" || cx.type == "atBlock")) {
|
398
|
+
// Dedent relative to current context.
|
399
|
+
indent = Math.max(0, cx.indent - indentUnit);
|
400
|
+
cx = cx.prev;
|
401
|
+
}
|
373
402
|
}
|
374
403
|
return indent;
|
375
404
|
},
|
@@ -769,4 +798,26 @@ CodeMirror.defineMode("css", function(config, parserConfig) {
|
|
769
798
|
helperType: "less"
|
770
799
|
});
|
771
800
|
|
801
|
+
CodeMirror.defineMIME("text/x-gss", {
|
802
|
+
documentTypes: documentTypes,
|
803
|
+
mediaTypes: mediaTypes,
|
804
|
+
mediaFeatures: mediaFeatures,
|
805
|
+
propertyKeywords: propertyKeywords,
|
806
|
+
nonStandardPropertyKeywords: nonStandardPropertyKeywords,
|
807
|
+
fontProperties: fontProperties,
|
808
|
+
counterDescriptors: counterDescriptors,
|
809
|
+
colorKeywords: colorKeywords,
|
810
|
+
valueKeywords: valueKeywords,
|
811
|
+
supportsAtComponent: true,
|
812
|
+
tokenHooks: {
|
813
|
+
"/": function(stream, state) {
|
814
|
+
if (!stream.eat("*")) return false;
|
815
|
+
state.tokenize = tokenCComment;
|
816
|
+
return tokenCComment(stream, state);
|
817
|
+
}
|
818
|
+
},
|
819
|
+
name: "css",
|
820
|
+
helperType: "gss"
|
821
|
+
});
|
822
|
+
|
772
823
|
});
|
@@ -11,6 +11,8 @@
|
|
11
11
|
})(function(CodeMirror) {
|
12
12
|
"use strict";
|
13
13
|
|
14
|
+
var urlRE = /^((?:(?:aaas?|about|acap|adiumxtra|af[ps]|aim|apt|attachment|aw|beshare|bitcoin|bolo|callto|cap|chrome(?:-extension)?|cid|coap|com-eventbrite-attendee|content|crid|cvs|data|dav|dict|dlna-(?:playcontainer|playsingle)|dns|doi|dtn|dvb|ed2k|facetime|feed|file|finger|fish|ftp|geo|gg|git|gizmoproject|go|gopher|gtalk|h323|hcp|https?|iax|icap|icon|im|imap|info|ipn|ipp|irc[6s]?|iris(?:\.beep|\.lwz|\.xpc|\.xpcs)?|itms|jar|javascript|jms|keyparc|lastfm|ldaps?|magnet|mailto|maps|market|message|mid|mms|ms-help|msnim|msrps?|mtqp|mumble|mupdate|mvn|news|nfs|nih?|nntp|notes|oid|opaquelocktoken|palm|paparazzi|platform|pop|pres|proxy|psyc|query|res(?:ource)?|rmi|rsync|rtmp|rtsp|secondlife|service|session|sftp|sgn|shttp|sieve|sips?|skype|sm[bs]|snmp|soap\.beeps?|soldat|spotify|ssh|steam|svn|tag|teamspeak|tel(?:net)?|tftp|things|thismessage|tip|tn3270|tv|udp|unreal|urn|ut2004|vemmi|ventrilo|view-source|webcal|wss?|wtai|wyciwyg|xcon(?:-userid)?|xfire|xmlrpc\.beeps?|xmpp|xri|ymsgr|z39\.50[rs]?):(?:\/{1,3}|[a-z0-9%])|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}\/)(?:[^\s()<>]|\([^\s()<>]*\))+(?:\([^\s()<>]*\)|[^\s`*!()\[\]{};:'".,<>?«»“”‘’]))/i
|
15
|
+
|
14
16
|
CodeMirror.defineMode("gfm", function(config, modeConfig) {
|
15
17
|
var codeDepth = 0;
|
16
18
|
function blankLine(state) {
|
@@ -37,7 +39,7 @@ CodeMirror.defineMode("gfm", function(config, modeConfig) {
|
|
37
39
|
|
38
40
|
// Hack to prevent formatting override inside code blocks (block and inline)
|
39
41
|
if (state.codeBlock) {
|
40
|
-
if (stream.match(
|
42
|
+
if (stream.match(/^```+/)) {
|
41
43
|
state.codeBlock = false;
|
42
44
|
return null;
|
43
45
|
}
|
@@ -47,7 +49,7 @@ CodeMirror.defineMode("gfm", function(config, modeConfig) {
|
|
47
49
|
if (stream.sol()) {
|
48
50
|
state.code = false;
|
49
51
|
}
|
50
|
-
if (stream.sol() && stream.match(
|
52
|
+
if (stream.sol() && stream.match(/^```+/)) {
|
51
53
|
stream.skipToEnd();
|
52
54
|
state.codeBlock = true;
|
53
55
|
return null;
|
@@ -78,25 +80,29 @@ CodeMirror.defineMode("gfm", function(config, modeConfig) {
|
|
78
80
|
}
|
79
81
|
if (stream.sol() || state.ateSpace) {
|
80
82
|
state.ateSpace = false;
|
81
|
-
if(
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
83
|
+
if (modeConfig.gitHubSpice !== false) {
|
84
|
+
if(stream.match(/^(?:[a-zA-Z0-9\-_]+\/)?(?:[a-zA-Z0-9\-_]+@)?(?:[a-f0-9]{7,40}\b)/)) {
|
85
|
+
// User/Project@SHA
|
86
|
+
// User@SHA
|
87
|
+
// SHA
|
88
|
+
state.combineTokens = true;
|
89
|
+
return "link";
|
90
|
+
} else if (stream.match(/^(?:[a-zA-Z0-9\-_]+\/)?(?:[a-zA-Z0-9\-_]+)?#[0-9]+\b/)) {
|
91
|
+
// User/Project#Num
|
92
|
+
// User#Num
|
93
|
+
// #Num
|
94
|
+
state.combineTokens = true;
|
95
|
+
return "link";
|
96
|
+
}
|
93
97
|
}
|
94
98
|
}
|
95
|
-
if (stream.match(
|
96
|
-
|
99
|
+
if (stream.match(urlRE) &&
|
100
|
+
stream.string.slice(stream.start - 2, stream.start) != "](" &&
|
101
|
+
(stream.start == 0 || /\W/.test(stream.string.charAt(stream.start - 1)))) {
|
97
102
|
// URLs
|
98
103
|
// Taken from http://daringfireball.net/2010/07/improved_regex_for_matching_urls
|
99
104
|
// And then (issue #1160) simplified to make it not crash the Chrome Regexp engine
|
105
|
+
// And then limited url schemes to the CommonMark list, so foo:bar isn't matched as a URL
|
100
106
|
state.combineTokens = true;
|
101
107
|
return "link";
|
102
108
|
}
|
@@ -109,7 +115,7 @@ CodeMirror.defineMode("gfm", function(config, modeConfig) {
|
|
109
115
|
var markdownConfig = {
|
110
116
|
underscoresBreakWords: false,
|
111
117
|
taskLists: true,
|
112
|
-
fencedCodeBlocks:
|
118
|
+
fencedCodeBlocks: '```',
|
113
119
|
strikethrough: true
|
114
120
|
};
|
115
121
|
for (var attr in modeConfig) {
|
@@ -16,23 +16,21 @@ CodeMirror.defineMode("haxe", function(config, parserConfig) {
|
|
16
16
|
|
17
17
|
// Tokenizer
|
18
18
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
var operator = kw("operator"), atom = {type: "atom", style: "atom"}, attribute = {type:"attribute", style: "attribute"};
|
19
|
+
function kw(type) {return {type: type, style: "keyword"};}
|
20
|
+
var A = kw("keyword a"), B = kw("keyword b"), C = kw("keyword c");
|
21
|
+
var operator = kw("operator"), atom = {type: "atom", style: "atom"}, attribute = {type:"attribute", style: "attribute"};
|
23
22
|
var type = kw("typedef");
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
23
|
+
var keywords = {
|
24
|
+
"if": A, "while": A, "else": B, "do": B, "try": B,
|
25
|
+
"return": C, "break": C, "continue": C, "new": C, "throw": C,
|
26
|
+
"var": kw("var"), "inline":attribute, "static": attribute, "using":kw("import"),
|
28
27
|
"public": attribute, "private": attribute, "cast": kw("cast"), "import": kw("import"), "macro": kw("macro"),
|
29
|
-
|
30
|
-
|
31
|
-
|
28
|
+
"function": kw("function"), "catch": kw("catch"), "untyped": kw("untyped"), "callback": kw("cb"),
|
29
|
+
"for": kw("for"), "switch": kw("switch"), "case": kw("case"), "default": kw("default"),
|
30
|
+
"in": operator, "never": kw("property_access"), "trace":kw("trace"),
|
32
31
|
"class": type, "abstract":type, "enum":type, "interface":type, "typedef":type, "extends":type, "implements":type, "dynamic":type,
|
33
|
-
|
34
|
-
|
35
|
-
}();
|
32
|
+
"true": atom, "false": atom, "null": atom
|
33
|
+
};
|
36
34
|
|
37
35
|
var isOperatorChar = /[+\-*&%=<>!?|]/;
|
38
36
|
|
@@ -41,14 +39,13 @@ CodeMirror.defineMode("haxe", function(config, parserConfig) {
|
|
41
39
|
return f(stream, state);
|
42
40
|
}
|
43
41
|
|
44
|
-
function
|
42
|
+
function toUnescaped(stream, end) {
|
45
43
|
var escaped = false, next;
|
46
44
|
while ((next = stream.next()) != null) {
|
47
45
|
if (next == end && !escaped)
|
48
|
-
return
|
46
|
+
return true;
|
49
47
|
escaped = !escaped && next == "\\";
|
50
48
|
}
|
51
|
-
return escaped;
|
52
49
|
}
|
53
50
|
|
54
51
|
// Used as scratch variables to communicate multiple values without
|
@@ -61,70 +58,58 @@ CodeMirror.defineMode("haxe", function(config, parserConfig) {
|
|
61
58
|
|
62
59
|
function haxeTokenBase(stream, state) {
|
63
60
|
var ch = stream.next();
|
64
|
-
if (ch == '"' || ch == "'")
|
61
|
+
if (ch == '"' || ch == "'") {
|
65
62
|
return chain(stream, state, haxeTokenString(ch));
|
66
|
-
else if (/[\[\]{}\(\),;\:\.]/.test(ch))
|
63
|
+
} else if (/[\[\]{}\(\),;\:\.]/.test(ch)) {
|
67
64
|
return ret(ch);
|
68
|
-
else if (ch == "0" && stream.eat(/x/i)) {
|
65
|
+
} else if (ch == "0" && stream.eat(/x/i)) {
|
69
66
|
stream.eatWhile(/[\da-f]/i);
|
70
67
|
return ret("number", "number");
|
71
|
-
}
|
72
|
-
|
73
|
-
stream.match(/^\d*(?:\.\d*)?(?:[eE][+\-]?\d+)?/);
|
68
|
+
} else if (/\d/.test(ch) || ch == "-" && stream.eat(/\d/)) {
|
69
|
+
stream.match(/^\d*(?:\.\d*(?!\.))?(?:[eE][+\-]?\d+)?/);
|
74
70
|
return ret("number", "number");
|
75
|
-
}
|
76
|
-
|
77
|
-
nextUntilUnescaped(stream, "/");
|
71
|
+
} else if (state.reAllowed && (ch == "~" && stream.eat(/\//))) {
|
72
|
+
toUnescaped(stream, "/");
|
78
73
|
stream.eatWhile(/[gimsu]/);
|
79
74
|
return ret("regexp", "string-2");
|
80
|
-
}
|
81
|
-
else if (ch == "/") {
|
75
|
+
} else if (ch == "/") {
|
82
76
|
if (stream.eat("*")) {
|
83
77
|
return chain(stream, state, haxeTokenComment);
|
84
|
-
}
|
85
|
-
else if (stream.eat("/")) {
|
78
|
+
} else if (stream.eat("/")) {
|
86
79
|
stream.skipToEnd();
|
87
80
|
return ret("comment", "comment");
|
88
|
-
}
|
89
|
-
else {
|
81
|
+
} else {
|
90
82
|
stream.eatWhile(isOperatorChar);
|
91
83
|
return ret("operator", null, stream.current());
|
92
84
|
}
|
93
|
-
}
|
94
|
-
else if (ch == "#") {
|
85
|
+
} else if (ch == "#") {
|
95
86
|
stream.skipToEnd();
|
96
87
|
return ret("conditional", "meta");
|
97
|
-
}
|
98
|
-
else if (ch == "@") {
|
88
|
+
} else if (ch == "@") {
|
99
89
|
stream.eat(/:/);
|
100
90
|
stream.eatWhile(/[\w_]/);
|
101
91
|
return ret ("metadata", "meta");
|
102
|
-
}
|
103
|
-
else if (isOperatorChar.test(ch)) {
|
92
|
+
} else if (isOperatorChar.test(ch)) {
|
104
93
|
stream.eatWhile(isOperatorChar);
|
105
94
|
return ret("operator", null, stream.current());
|
106
|
-
}
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
return ret("type", "variable-3", word);
|
114
|
-
}
|
115
|
-
else
|
116
|
-
{
|
95
|
+
} else {
|
96
|
+
var word;
|
97
|
+
if(/[A-Z]/.test(ch)) {
|
98
|
+
stream.eatWhile(/[\w_<>]/);
|
99
|
+
word = stream.current();
|
100
|
+
return ret("type", "variable-3", word);
|
101
|
+
} else {
|
117
102
|
stream.eatWhile(/[\w_]/);
|
118
103
|
var word = stream.current(), known = keywords.propertyIsEnumerable(word) && keywords[word];
|
119
104
|
return (known && state.kwAllowed) ? ret(known.type, known.style, word) :
|
120
105
|
ret("variable", "variable", word);
|
121
|
-
|
106
|
+
}
|
122
107
|
}
|
123
108
|
}
|
124
109
|
|
125
110
|
function haxeTokenString(quote) {
|
126
111
|
return function(stream, state) {
|
127
|
-
if (
|
112
|
+
if (toUnescaped(stream, quote))
|
128
113
|
state.tokenize = haxeTokenBase;
|
129
114
|
return ret("string", "string");
|
130
115
|
};
|
@@ -176,27 +161,25 @@ CodeMirror.defineMode("haxe", function(config, parserConfig) {
|
|
176
161
|
cc.pop()();
|
177
162
|
if (cx.marked) return cx.marked;
|
178
163
|
if (type == "variable" && inScope(state, content)) return "variable-2";
|
179
|
-
|
164
|
+
if (type == "variable" && imported(state, content)) return "variable-3";
|
180
165
|
return style;
|
181
166
|
}
|
182
167
|
}
|
183
168
|
}
|
184
169
|
|
185
|
-
function imported(state, typename)
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
if(state.importedtypes[i]==typename) return true;
|
170
|
+
function imported(state, typename) {
|
171
|
+
if (/[a-z]/.test(typename.charAt(0)))
|
172
|
+
return false;
|
173
|
+
var len = state.importedtypes.length;
|
174
|
+
for (var i = 0; i<len; i++)
|
175
|
+
if(state.importedtypes[i]==typename) return true;
|
192
176
|
}
|
193
177
|
|
194
|
-
|
195
178
|
function registerimport(importname) {
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
179
|
+
var state = cx.state;
|
180
|
+
for (var t = state.importedtypes; t; t = t.next)
|
181
|
+
if(t.name == importname) return;
|
182
|
+
state.importedtypes = { name: importname, next: state.importedtypes };
|
200
183
|
}
|
201
184
|
// Combinator utils
|
202
185
|
|
@@ -229,6 +212,7 @@ CodeMirror.defineMode("haxe", function(config, parserConfig) {
|
|
229
212
|
cx.state.localVars = cx.state.context.vars;
|
230
213
|
cx.state.context = cx.state.context.prev;
|
231
214
|
}
|
215
|
+
popcontext.lex = true;
|
232
216
|
function pushlex(type, info) {
|
233
217
|
var result = function() {
|
234
218
|
var state = cx.state;
|
@@ -252,7 +236,7 @@ CodeMirror.defineMode("haxe", function(config, parserConfig) {
|
|
252
236
|
if (type == wanted) return cont();
|
253
237
|
else if (wanted == ";") return pass();
|
254
238
|
else return cont(f);
|
255
|
-
}
|
239
|
+
}
|
256
240
|
return f;
|
257
241
|
}
|
258
242
|
|
@@ -266,25 +250,26 @@ CodeMirror.defineMode("haxe", function(config, parserConfig) {
|
|
266
250
|
if (type == "attribute") return cont(maybeattribute);
|
267
251
|
if (type == "function") return cont(functiondef);
|
268
252
|
if (type == "for") return cont(pushlex("form"), expect("("), pushlex(")"), forspec1, expect(")"),
|
269
|
-
|
253
|
+
poplex, statement, poplex);
|
270
254
|
if (type == "variable") return cont(pushlex("stat"), maybelabel);
|
271
255
|
if (type == "switch") return cont(pushlex("form"), expression, pushlex("}", "switch"), expect("{"),
|
272
|
-
|
256
|
+
block, poplex, poplex);
|
273
257
|
if (type == "case") return cont(expression, expect(":"));
|
274
258
|
if (type == "default") return cont(expect(":"));
|
275
259
|
if (type == "catch") return cont(pushlex("form"), pushcontext, expect("("), funarg, expect(")"),
|
276
|
-
|
260
|
+
statement, poplex, popcontext);
|
277
261
|
if (type == "import") return cont(importdef, expect(";"));
|
278
262
|
if (type == "typedef") return cont(typedef);
|
279
263
|
return pass(pushlex("stat"), expression, expect(";"), poplex);
|
280
264
|
}
|
281
265
|
function expression(type) {
|
282
266
|
if (atomicTypes.hasOwnProperty(type)) return cont(maybeoperator);
|
267
|
+
if (type == "type" ) return cont(maybeoperator);
|
283
268
|
if (type == "function") return cont(functiondef);
|
284
269
|
if (type == "keyword c") return cont(maybeexpression);
|
285
270
|
if (type == "(") return cont(pushlex(")"), maybeexpression, expect(")"), poplex, maybeoperator);
|
286
271
|
if (type == "operator") return cont(expression);
|
287
|
-
if (type == "[") return cont(pushlex("]"), commasep(
|
272
|
+
if (type == "[") return cont(pushlex("]"), commasep(maybeexpression, "]"), poplex, maybeoperator);
|
288
273
|
if (type == "{") return cont(pushlex("}"), commasep(objprop, "}"), poplex, maybeoperator);
|
289
274
|
return cont();
|
290
275
|
}
|
@@ -318,14 +303,14 @@ CodeMirror.defineMode("haxe", function(config, parserConfig) {
|
|
318
303
|
}
|
319
304
|
|
320
305
|
function importdef (type, value) {
|
321
|
-
|
322
|
-
|
306
|
+
if(type == "variable" && /[A-Z]/.test(value.charAt(0))) { registerimport(value); return cont(); }
|
307
|
+
else if(type == "variable" || type == "property" || type == "." || value == "*") return cont(importdef);
|
323
308
|
}
|
324
309
|
|
325
310
|
function typedef (type, value)
|
326
311
|
{
|
327
|
-
|
328
|
-
|
312
|
+
if(type == "variable" && /[A-Z]/.test(value.charAt(0))) { registerimport(value); return cont(); }
|
313
|
+
else if (type == "type" && /[A-Z]/.test(value.charAt(0))) { return cont(); }
|
329
314
|
}
|
330
315
|
|
331
316
|
function maybelabel(type) {
|
@@ -363,16 +348,19 @@ CodeMirror.defineMode("haxe", function(config, parserConfig) {
|
|
363
348
|
if (type == ",") return cont(vardef1);
|
364
349
|
}
|
365
350
|
function forspec1(type, value) {
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
351
|
+
if (type == "variable") {
|
352
|
+
register(value);
|
353
|
+
return cont(forin, expression)
|
354
|
+
} else {
|
355
|
+
return pass()
|
356
|
+
}
|
370
357
|
}
|
371
358
|
function forin(_type, value) {
|
372
359
|
if (value == "in") return cont();
|
373
360
|
}
|
374
361
|
function functiondef(type, value) {
|
375
|
-
|
362
|
+
//function names starting with upper-case letters are recognised as types, so cludging them together here.
|
363
|
+
if (type == "variable" || type == "type") {register(value); return cont(functiondef);}
|
376
364
|
if (value == "new") return cont(functiondef);
|
377
365
|
if (type == "(") return cont(pushlex(")"), pushcontext, commasep(funarg, ")"), poplex, typeuse, statement, popcontext);
|
378
366
|
}
|
@@ -395,7 +383,7 @@ CodeMirror.defineMode("haxe", function(config, parserConfig) {
|
|
395
383
|
|
396
384
|
return {
|
397
385
|
startState: function(basecolumn) {
|
398
|
-
|
386
|
+
var defaulttypes = ["Int", "Float", "String", "Void", "Std", "Bool", "Dynamic", "Array"];
|
399
387
|
return {
|
400
388
|
tokenize: haxeTokenBase,
|
401
389
|
reAllowed: true,
|
@@ -403,7 +391,7 @@ CodeMirror.defineMode("haxe", function(config, parserConfig) {
|
|
403
391
|
cc: [],
|
404
392
|
lexical: new HaxeLexical((basecolumn || 0) - indentUnit, 0, "block", false),
|
405
393
|
localVars: parserConfig.localVars,
|
406
|
-
|
394
|
+
importedtypes: defaulttypes,
|
407
395
|
context: parserConfig.localVars && {vars: parserConfig.localVars},
|
408
396
|
indented: 0
|
409
397
|
};
|