Index: third_party/WebKit/Source/devtools/front_end/cm_modes/clike.js |
diff --git a/third_party/WebKit/Source/devtools/front_end/cm_modes/clike.js b/third_party/WebKit/Source/devtools/front_end/cm_modes/clike.js |
index 3e253624b48236cc9927401f5d9f6ac0b5b2b1b5..a37921fdae7eda419b2f429189efaac1df4b4510 100644 |
--- a/third_party/WebKit/Source/devtools/front_end/cm_modes/clike.js |
+++ b/third_party/WebKit/Source/devtools/front_end/cm_modes/clike.js |
@@ -11,19 +11,63 @@ |
})(function(CodeMirror) { |
"use strict"; |
+function Context(indented, column, type, info, align, prev) { |
+ this.indented = indented; |
+ this.column = column; |
+ this.type = type; |
+ this.info = info; |
+ this.align = align; |
+ this.prev = prev; |
+} |
+function pushContext(state, col, type, info) { |
+ var indent = state.indented; |
+ if (state.context && state.context.type != "statement" && type != "statement") |
+ indent = state.context.indented; |
+ return state.context = new Context(indent, col, type, info, null, state.context); |
+} |
+function popContext(state) { |
+ var t = state.context.type; |
+ if (t == ")" || t == "]" || t == "}") |
+ state.indented = state.context.indented; |
+ return state.context = state.context.prev; |
+} |
+ |
+function typeBefore(stream, state, pos) { |
+ if (state.prevToken == "variable" || state.prevToken == "variable-3") return true; |
+ if (/\S(?:[^- ]>|[*\]])\s*$|\*$/.test(stream.string.slice(0, pos))) return true; |
+ if (state.typeAtEndOfLine && stream.column() == stream.indentation()) return true; |
+} |
+ |
+function isTopScope(context) { |
+ for (;;) { |
+ if (!context || context.type == "top") return true; |
+ if (context.type == "}" && context.prev.info != "namespace") return false; |
+ context = context.prev; |
+ } |
+} |
+ |
CodeMirror.defineMode("clike", function(config, parserConfig) { |
var indentUnit = config.indentUnit, |
statementIndentUnit = parserConfig.statementIndentUnit || indentUnit, |
dontAlignCalls = parserConfig.dontAlignCalls, |
keywords = parserConfig.keywords || {}, |
+ types = parserConfig.types || {}, |
builtin = parserConfig.builtin || {}, |
blockKeywords = parserConfig.blockKeywords || {}, |
+ defKeywords = parserConfig.defKeywords || {}, |
atoms = parserConfig.atoms || {}, |
hooks = parserConfig.hooks || {}, |
- multiLineStrings = parserConfig.multiLineStrings; |
- var isOperatorChar = /[+\-*&%=<>!?|\/]/; |
+ multiLineStrings = parserConfig.multiLineStrings, |
+ indentStatements = parserConfig.indentStatements !== false, |
+ indentSwitch = parserConfig.indentSwitch !== false, |
+ namespaceSeparator = parserConfig.namespaceSeparator, |
+ isPunctuationChar = parserConfig.isPunctuationChar || /[\[\]{}\(\),;\:\.]/, |
+ numberStart = parserConfig.numberStart || /[\d\.]/, |
+ number = parserConfig.number || /^(?:0x[a-f\d]+|0b[01]+|(?:\d+\.?\d*|\.\d+)(?:e[-+]?\d+)?)(u|ll?|l|f)?/i, |
+ isOperatorChar = parserConfig.isOperatorChar || /[+\-*&%=<>!?|\/]/, |
+ endStatement = parserConfig.endStatement || /^[;:,]$/; |
- var curPunc; |
+ var curPunc, isDefKeyword; |
function tokenBase(stream, state) { |
var ch = stream.next(); |
@@ -35,13 +79,14 @@ CodeMirror.defineMode("clike", function(config, parserConfig) { |
state.tokenize = tokenString(ch); |
return state.tokenize(stream, state); |
} |
- if (/[\[\]{}\(\),;\:\.]/.test(ch)) { |
+ if (isPunctuationChar.test(ch)) { |
curPunc = ch; |
return null; |
} |
- if (/\d/.test(ch)) { |
- stream.eatWhile(/[\w\.]/); |
- return "number"; |
+ if (numberStart.test(ch)) { |
+ stream.backUp(1) |
+ if (stream.match(number)) return "number" |
+ stream.next() |
} |
if (ch == "/") { |
if (stream.eat("*")) { |
@@ -54,20 +99,25 @@ CodeMirror.defineMode("clike", function(config, parserConfig) { |
} |
} |
if (isOperatorChar.test(ch)) { |
- stream.eatWhile(isOperatorChar); |
+ while (!stream.match(/^\/[\/*]/, false) && stream.eat(isOperatorChar)) {} |
return "operator"; |
} |
- stream.eatWhile(/[\w\$_]/); |
+ stream.eatWhile(/[\w\$_\xa1-\uffff]/); |
+ if (namespaceSeparator) while (stream.match(namespaceSeparator)) |
+ stream.eatWhile(/[\w\$_\xa1-\uffff]/); |
+ |
var cur = stream.current(); |
- if (keywords.propertyIsEnumerable(cur)) { |
- if (blockKeywords.propertyIsEnumerable(cur)) curPunc = "newstatement"; |
+ if (contains(keywords, cur)) { |
+ if (contains(blockKeywords, cur)) curPunc = "newstatement"; |
+ if (contains(defKeywords, cur)) isDefKeyword = true; |
return "keyword"; |
} |
- if (builtin.propertyIsEnumerable(cur)) { |
- if (blockKeywords.propertyIsEnumerable(cur)) curPunc = "newstatement"; |
+ if (contains(types, cur)) return "variable-3"; |
+ if (contains(builtin, cur)) { |
+ if (contains(blockKeywords, cur)) curPunc = "newstatement"; |
return "builtin"; |
} |
- if (atoms.propertyIsEnumerable(cur)) return "atom"; |
+ if (contains(atoms, cur)) return "atom"; |
return "variable"; |
} |
@@ -96,24 +146,9 @@ CodeMirror.defineMode("clike", function(config, parserConfig) { |
return "comment"; |
} |
- function Context(indented, column, type, align, prev) { |
- this.indented = indented; |
- this.column = column; |
- this.type = type; |
- this.align = align; |
- this.prev = prev; |
- } |
- function pushContext(state, col, type) { |
- var indent = state.indented; |
- if (state.context && state.context.type == "statement") |
- indent = state.context.indented; |
- return state.context = new Context(indent, col, type, null, state.context); |
- } |
- function popContext(state) { |
- var t = state.context.type; |
- if (t == ")" || t == "]" || t == "}") |
- state.indented = state.context.indented; |
- return state.context = state.context.prev; |
+ function maybeEOL(stream, state) { |
+ if (parserConfig.typeFirstDefinitions && stream.eol() && isTopScope(state.context)) |
+ state.typeAtEndOfLine = typeBefore(stream, state, stream.pos) |
} |
// Interface |
@@ -122,9 +157,10 @@ CodeMirror.defineMode("clike", function(config, parserConfig) { |
startState: function(basecolumn) { |
return { |
tokenize: null, |
- context: new Context((basecolumn || 0) - indentUnit, 0, "top", false), |
+ context: new Context((basecolumn || 0) - indentUnit, 0, "top", null, false), |
indented: 0, |
- startOfLine: true |
+ startOfLine: true, |
+ prevToken: null |
}; |
}, |
@@ -135,13 +171,13 @@ CodeMirror.defineMode("clike", function(config, parserConfig) { |
state.indented = stream.indentation(); |
state.startOfLine = true; |
} |
- if (stream.eatSpace()) return null; |
- curPunc = null; |
+ if (stream.eatSpace()) { maybeEOL(stream, state); return null; } |
+ curPunc = isDefKeyword = null; |
var style = (state.tokenize || tokenBase)(stream, state); |
if (style == "comment" || style == "meta") return style; |
if (ctx.align == null) ctx.align = true; |
- if ((curPunc == ";" || curPunc == ":" || curPunc == ",") && ctx.type == "statement") popContext(state); |
+ if (endStatement.test(curPunc)) while (state.context.type == "statement") popContext(state); |
else if (curPunc == "{") pushContext(state, stream.column(), "}"); |
else if (curPunc == "[") pushContext(state, stream.column(), "]"); |
else if (curPunc == "(") pushContext(state, stream.column(), ")"); |
@@ -151,24 +187,60 @@ CodeMirror.defineMode("clike", function(config, parserConfig) { |
while (ctx.type == "statement") ctx = popContext(state); |
} |
else if (curPunc == ctx.type) popContext(state); |
- else if (((ctx.type == "}" || ctx.type == "top") && curPunc != ';') || (ctx.type == "statement" && curPunc == "newstatement")) |
- pushContext(state, stream.column(), "statement"); |
+ else if (indentStatements && |
+ (((ctx.type == "}" || ctx.type == "top") && curPunc != ";") || |
+ (ctx.type == "statement" && curPunc == "newstatement"))) { |
+ pushContext(state, stream.column(), "statement", stream.current()); |
+ } |
+ |
+ if (style == "variable" && |
+ ((state.prevToken == "def" || |
+ (parserConfig.typeFirstDefinitions && typeBefore(stream, state, stream.start) && |
+ isTopScope(state.context) && stream.match(/^\s*\(/, false))))) |
+ style = "def"; |
+ |
+ if (hooks.token) { |
+ var result = hooks.token(stream, state, style); |
+ if (result !== undefined) style = result; |
+ } |
+ |
+ if (style == "def" && parserConfig.styleDefs === false) style = "variable"; |
+ |
state.startOfLine = false; |
+ state.prevToken = isDefKeyword ? "def" : style || curPunc; |
+ maybeEOL(stream, state); |
return style; |
}, |
indent: function(state, textAfter) { |
- if (state.tokenize != tokenBase && state.tokenize != null) return CodeMirror.Pass; |
+ if (state.tokenize != tokenBase && state.tokenize != null || state.typeAtEndOfLine) return CodeMirror.Pass; |
var ctx = state.context, firstChar = textAfter && textAfter.charAt(0); |
if (ctx.type == "statement" && firstChar == "}") ctx = ctx.prev; |
+ if (parserConfig.dontIndentStatements) |
+ while (ctx.type == "statement" && parserConfig.dontIndentStatements.test(ctx.info)) |
+ ctx = ctx.prev |
+ if (hooks.indent) { |
+ var hook = hooks.indent(state, ctx, textAfter); |
+ if (typeof hook == "number") return hook |
+ } |
var closing = firstChar == ctx.type; |
- if (ctx.type == "statement") return ctx.indented + (firstChar == "{" ? 0 : statementIndentUnit); |
- else if (ctx.align && (!dontAlignCalls || ctx.type != ")")) return ctx.column + (closing ? 0 : 1); |
- else if (ctx.type == ")" && !closing) return ctx.indented + statementIndentUnit; |
- else return ctx.indented + (closing ? 0 : indentUnit); |
+ var switchBlock = ctx.prev && ctx.prev.info == "switch"; |
+ if (parserConfig.allmanIndentation && /[{(]/.test(firstChar)) { |
+ while (ctx.type != "top" && ctx.type != "}") ctx = ctx.prev |
+ return ctx.indented |
+ } |
+ if (ctx.type == "statement") |
+ return ctx.indented + (firstChar == "{" ? 0 : statementIndentUnit); |
+ if (ctx.align && (!dontAlignCalls || ctx.type != ")")) |
+ return ctx.column + (closing ? 0 : 1); |
+ if (ctx.type == ")" && !closing) |
+ return ctx.indented + statementIndentUnit; |
+ |
+ return ctx.indented + (closing ? 0 : indentUnit) + |
+ (!closing && switchBlock && !/^(?:case|default)\b/.test(textAfter) ? indentUnit : 0); |
}, |
- electricChars: "{}", |
+ electricInput: indentSwitch ? /^\s*(?:case .*?:|default:|\{\}?|\})$/ : /^\s*[{}]$/, |
blockCommentStart: "/*", |
blockCommentEnd: "*/", |
lineComment: "//", |
@@ -181,26 +253,40 @@ CodeMirror.defineMode("clike", function(config, parserConfig) { |
for (var i = 0; i < words.length; ++i) obj[words[i]] = true; |
return obj; |
} |
- var cKeywords = "auto if break int case long char register continue return default short do sizeof " + |
- "double static else struct entry switch extern typedef float union for unsigned " + |
- "goto while enum void const signed volatile"; |
+ function contains(words, word) { |
+ if (typeof words === "function") { |
+ return words(word); |
+ } else { |
+ return words.propertyIsEnumerable(word); |
+ } |
+ } |
+ var cKeywords = "auto if break case register continue return default do sizeof " + |
+ "static else struct switch extern typedef union for goto while enum const volatile"; |
+ var cTypes = "int long char short double float unsigned signed void size_t ptrdiff_t"; |
function cppHook(stream, state) { |
- if (!state.startOfLine) return false; |
- for (;;) { |
- if (stream.skipTo("\\")) { |
- stream.next(); |
- if (stream.eol()) { |
- state.tokenize = cppHook; |
- break; |
- } |
- } else { |
- stream.skipToEnd(); |
- state.tokenize = null; |
- break; |
+ if (!state.startOfLine) return false |
+ for (var ch, next = null; ch = stream.peek();) { |
+ if (ch == "\\" && stream.match(/^.$/)) { |
+ next = cppHook |
+ break |
+ } else if (ch == "/" && stream.match(/^\/[\/\*]/, false)) { |
+ break |
} |
+ stream.next() |
} |
- return "meta"; |
+ state.tokenize = next |
+ return "meta" |
+ } |
+ |
+ function pointerHook(_stream, state) { |
+ if (state.prevToken == "variable-3") return "variable-3"; |
+ return false; |
+ } |
+ |
+ function cpp14Literal(stream) { |
+ stream.eatWhile(/[\w\.']/); |
+ return "number"; |
} |
function cpp11StringHook(stream, state) { |
@@ -227,6 +313,11 @@ CodeMirror.defineMode("clike", function(config, parserConfig) { |
return false; |
} |
+ function cppLooksLikeConstructor(word) { |
+ var lastTwo = /(\w+)::(\w+)$/.exec(word); |
+ return lastTwo && lastTwo[1] == lastTwo[2]; |
+ } |
+ |
// C#-style strings where "" escapes a quote. |
function tokenAtString(stream, state) { |
var next; |
@@ -260,6 +351,7 @@ CodeMirror.defineMode("clike", function(config, parserConfig) { |
words.push(prop); |
} |
add(mode.keywords); |
+ add(mode.types); |
add(mode.builtin); |
add(mode.atoms); |
if (words.length) { |
@@ -274,39 +366,74 @@ CodeMirror.defineMode("clike", function(config, parserConfig) { |
def(["text/x-csrc", "text/x-c", "text/x-chdr"], { |
name: "clike", |
keywords: words(cKeywords), |
+ types: words(cTypes + " bool _Complex _Bool float_t double_t intptr_t intmax_t " + |
+ "int8_t int16_t int32_t int64_t uintptr_t uintmax_t uint8_t uint16_t " + |
+ "uint32_t uint64_t"), |
blockKeywords: words("case do else for if switch while struct"), |
- atoms: words("null"), |
- hooks: {"#": cppHook}, |
+ defKeywords: words("struct"), |
+ typeFirstDefinitions: true, |
+ atoms: words("null true false"), |
+ hooks: {"#": cppHook, "*": pointerHook}, |
modeProps: {fold: ["brace", "include"]} |
}); |
def(["text/x-c++src", "text/x-c++hdr"], { |
name: "clike", |
- keywords: words(cKeywords + " asm dynamic_cast namespace reinterpret_cast try bool explicit new " + |
+ keywords: words(cKeywords + " asm dynamic_cast namespace reinterpret_cast try explicit new " + |
"static_cast typeid catch operator template typename class friend private " + |
"this using const_cast inline public throw virtual delete mutable protected " + |
- "wchar_t alignas alignof constexpr decltype nullptr noexcept thread_local final " + |
+ "alignas alignof constexpr decltype nullptr noexcept thread_local final " + |
"static_assert override"), |
+ types: words(cTypes + " bool wchar_t"), |
blockKeywords: words("catch class do else finally for if struct switch try while"), |
+ defKeywords: words("class namespace struct enum union"), |
+ typeFirstDefinitions: true, |
atoms: words("true false null"), |
+ dontIndentStatements: /^template$/, |
hooks: { |
"#": cppHook, |
+ "*": pointerHook, |
"u": cpp11StringHook, |
"U": cpp11StringHook, |
"L": cpp11StringHook, |
- "R": cpp11StringHook |
+ "R": cpp11StringHook, |
+ "0": cpp14Literal, |
+ "1": cpp14Literal, |
+ "2": cpp14Literal, |
+ "3": cpp14Literal, |
+ "4": cpp14Literal, |
+ "5": cpp14Literal, |
+ "6": cpp14Literal, |
+ "7": cpp14Literal, |
+ "8": cpp14Literal, |
+ "9": cpp14Literal, |
+ token: function(stream, state, style) { |
+ if (style == "variable" && stream.peek() == "(" && |
+ (state.prevToken == ";" || state.prevToken == null || |
+ state.prevToken == "}") && |
+ cppLooksLikeConstructor(stream.current())) |
+ return "def"; |
+ } |
}, |
+ namespaceSeparator: "::", |
modeProps: {fold: ["brace", "include"]} |
}); |
+ |
def("text/x-java", { |
name: "clike", |
- keywords: words("abstract assert boolean break byte case catch char class const continue default " + |
- "do double else enum extends final finally float for goto if implements import " + |
- "instanceof int interface long native new package private protected public " + |
- "return short static strictfp super switch synchronized this throw throws transient " + |
- "try void volatile while"), |
+ keywords: words("abstract assert break case catch class const continue default " + |
+ "do else enum extends final finally float for goto if implements import " + |
+ "instanceof interface native new package private protected public " + |
+ "return static strictfp super switch synchronized this throw throws transient " + |
+ "try volatile while"), |
+ types: words("byte short int long float double boolean char void Boolean Byte Character Double Float " + |
+ "Integer Long Number Object Short String StringBuffer StringBuilder Void"), |
blockKeywords: words("catch class do else finally for if switch try while"), |
+ defKeywords: words("class interface package enum"), |
+ typeFirstDefinitions: true, |
atoms: words("true false null"), |
+ endStatement: /^[;:]$/, |
+ number: /^(?:0x[a-f\d_]+|0b[01_]+|(?:[\d_]+\.?\d*|\.\d+)(?:e[-+]?[\d_]+)?)(u|ll?|l|f)?/i, |
hooks: { |
"@": function(stream) { |
stream.eatWhile(/[\w\$_]/); |
@@ -315,20 +442,23 @@ CodeMirror.defineMode("clike", function(config, parserConfig) { |
}, |
modeProps: {fold: ["brace", "import"]} |
}); |
+ |
def("text/x-csharp", { |
name: "clike", |
- keywords: words("abstract as base break case catch checked class const continue" + |
+ keywords: words("abstract as async await base break case catch checked class const continue" + |
" default delegate do else enum event explicit extern finally fixed for" + |
" foreach goto if implicit in interface internal is lock namespace new" + |
" operator out override params private protected public readonly ref return sealed" + |
" sizeof stackalloc static struct switch this throw try typeof unchecked" + |
" unsafe using virtual void volatile while add alias ascending descending dynamic from get" + |
" global group into join let orderby partial remove select set value var yield"), |
+ types: words("Action Boolean Byte Char DateTime DateTimeOffset Decimal Double Func" + |
+ " Guid Int16 Int32 Int64 Object SByte Single String Task TimeSpan UInt16 UInt32" + |
+ " UInt64 bool byte char decimal double short int long object" + |
+ " sbyte float string ushort uint ulong"), |
blockKeywords: words("catch class do else finally for foreach if struct switch try while"), |
- builtin: words("Boolean Byte Char DateTime DateTimeOffset Decimal Double" + |
- " Guid Int16 Int32 Int64 Object SByte Single String TimeSpan UInt16 UInt32" + |
- " UInt64 bool byte char decimal double short int long object" + |
- " sbyte float string ushort uint ulong"), |
+ defKeywords: words("class interface namespace struct var"), |
+ typeFirstDefinitions: true, |
atoms: words("true false null"), |
hooks: { |
"@": function(stream, state) { |
@@ -341,58 +471,149 @@ CodeMirror.defineMode("clike", function(config, parserConfig) { |
} |
} |
}); |
+ |
+ function tokenTripleString(stream, state) { |
+ var escaped = false; |
+ while (!stream.eol()) { |
+ if (!escaped && stream.match('"""')) { |
+ state.tokenize = null; |
+ break; |
+ } |
+ escaped = stream.next() == "\\" && !escaped; |
+ } |
+ return "string"; |
+ } |
+ |
def("text/x-scala", { |
name: "clike", |
keywords: words( |
/* scala */ |
- "abstract case catch class def do else extends false final finally for forSome if " + |
+ "abstract case catch class def do else extends final finally for forSome if " + |
"implicit import lazy match new null object override package private protected return " + |
- "sealed super this throw trait try trye type val var while with yield _ : = => <- <: " + |
+ "sealed super this throw trait try type val var while with yield _ : = => <- <: " + |
"<% >: # @ " + |
/* package scala */ |
"assert assume require print println printf readLine readBoolean readByte readShort " + |
"readChar readInt readLong readFloat readDouble " + |
+ ":: #:: " |
+ ), |
+ types: words( |
"AnyVal App Application Array BufferedIterator BigDecimal BigInt Char Console Either " + |
- "Enumeration Equiv Error Exception Fractional Function IndexedSeq Integral Iterable " + |
+ "Enumeration Equiv Error Exception Fractional Function IndexedSeq Int Integral Iterable " + |
"Iterator List Map Numeric Nil NotNull Option Ordered Ordering PartialFunction PartialOrdering " + |
"Product Proxy Range Responder Seq Serializable Set Specializable Stream StringBuilder " + |
- "StringContext Symbol Throwable Traversable TraversableOnce Tuple Unit Vector :: #:: " + |
+ "StringContext Symbol Throwable Traversable TraversableOnce Tuple Unit Vector " + |
/* package java.lang */ |
"Boolean Byte Character CharSequence Class ClassLoader Cloneable Comparable " + |
"Compiler Double Exception Float Integer Long Math Number Object Package Pair Process " + |
"Runtime Runnable SecurityManager Short StackTraceElement StrictMath String " + |
"StringBuffer System Thread ThreadGroup ThreadLocal Throwable Triple Void" |
- |
- |
), |
+ multiLineStrings: true, |
blockKeywords: words("catch class do else finally for forSome if match switch try while"), |
+ defKeywords: words("class def object package trait type val var"), |
atoms: words("true false null"), |
+ indentStatements: false, |
+ indentSwitch: false, |
hooks: { |
"@": function(stream) { |
stream.eatWhile(/[\w\$_]/); |
return "meta"; |
+ }, |
+ '"': function(stream, state) { |
+ if (!stream.match('""')) return false; |
+ state.tokenize = tokenTripleString; |
+ return state.tokenize(stream, state); |
+ }, |
+ "'": function(stream) { |
+ stream.eatWhile(/[\w\$_\xa1-\uffff]/); |
+ return "atom"; |
+ }, |
+ "=": function(stream, state) { |
+ var cx = state.context |
+ if (cx.type == "}" && cx.align && stream.eat(">")) { |
+ state.context = new Context(cx.indented, cx.column, cx.type, cx.info, null, cx.prev) |
+ return "operator" |
+ } else { |
+ return false |
+ } |
+ } |
+ }, |
+ modeProps: {closeBrackets: {triples: '"'}} |
+ }); |
+ |
+ function tokenKotlinString(tripleString){ |
+ return function (stream, state) { |
+ var escaped = false, next, end = false; |
+ while (!stream.eol()) { |
+ if (!tripleString && !escaped && stream.match('"') ) {end = true; break;} |
+ if (tripleString && stream.match('"""')) {end = true; break;} |
+ next = stream.next(); |
+ if(!escaped && next == "$" && stream.match('{')) |
+ stream.skipTo("}"); |
+ escaped = !escaped && next == "\\" && !tripleString; |
} |
+ if (end || !tripleString) |
+ state.tokenize = null; |
+ return "string"; |
} |
+ } |
+ |
+ def("text/x-kotlin", { |
+ name: "clike", |
+ keywords: words( |
+ /*keywords*/ |
+ "package as typealias class interface this super val " + |
+ "var fun for is in This throw return " + |
+ "break continue object if else while do try when !in !is as? " + |
+ |
+ /*soft keywords*/ |
+ "file import where by get set abstract enum open inner override private public internal " + |
+ "protected catch finally out final vararg reified dynamic companion constructor init " + |
+ "sealed field property receiver param sparam lateinit data inline noinline tailrec " + |
+ "external annotation crossinline const operator infix" |
+ ), |
+ types: words( |
+ /* package java.lang */ |
+ "Boolean Byte Character CharSequence Class ClassLoader Cloneable Comparable " + |
+ "Compiler Double Exception Float Integer Long Math Number Object Package Pair Process " + |
+ "Runtime Runnable SecurityManager Short StackTraceElement StrictMath String " + |
+ "StringBuffer System Thread ThreadGroup ThreadLocal Throwable Triple Void" |
+ ), |
+ intendSwitch: false, |
+ indentStatements: false, |
+ multiLineStrings: true, |
+ blockKeywords: words("catch class do else finally for if where try while enum"), |
+ defKeywords: words("class val var object package interface fun"), |
+ atoms: words("true false null this"), |
+ hooks: { |
+ '"': function(stream, state) { |
+ state.tokenize = tokenKotlinString(stream.match('""')); |
+ return state.tokenize(stream, state); |
+ } |
+ }, |
+ modeProps: {closeBrackets: {triples: '"'}} |
}); |
+ |
def(["x-shader/x-vertex", "x-shader/x-fragment"], { |
name: "clike", |
- keywords: words("float int bool void " + |
- "vec2 vec3 vec4 ivec2 ivec3 ivec4 bvec2 bvec3 bvec4 " + |
- "mat2 mat3 mat4 " + |
- "sampler1D sampler2D sampler3D samplerCube " + |
- "sampler1DShadow sampler2DShadow" + |
+ keywords: words("sampler1D sampler2D sampler3D samplerCube " + |
+ "sampler1DShadow sampler2DShadow " + |
"const attribute uniform varying " + |
"break continue discard return " + |
"for while do if else struct " + |
"in out inout"), |
+ types: words("float int bool void " + |
+ "vec2 vec3 vec4 ivec2 ivec3 ivec4 bvec2 bvec3 bvec4 " + |
+ "mat2 mat3 mat4"), |
blockKeywords: words("for while do if else struct"), |
builtin: words("radians degrees sin cos tan asin acos atan " + |
"pow exp log exp2 sqrt inversesqrt " + |
- "abs sign floor ceil fract mod min max clamp mix step smootstep " + |
+ "abs sign floor ceil fract mod min max clamp mix step smoothstep " + |
"length distance dot cross normalize ftransform faceforward " + |
"reflect refract matrixCompMult " + |
"lessThan lessThanEqual greaterThan greaterThanEqual " + |
@@ -409,12 +630,12 @@ CodeMirror.defineMode("clike", function(config, parserConfig) { |
"gl_FragColor gl_SecondaryColor gl_Normal gl_Vertex " + |
"gl_MultiTexCoord0 gl_MultiTexCoord1 gl_MultiTexCoord2 gl_MultiTexCoord3 " + |
"gl_MultiTexCoord4 gl_MultiTexCoord5 gl_MultiTexCoord6 gl_MultiTexCoord7 " + |
- "gl_FogCoord " + |
+ "gl_FogCoord gl_PointCoord " + |
"gl_Position gl_PointSize gl_ClipVertex " + |
"gl_FrontColor gl_BackColor gl_FrontSecondaryColor gl_BackSecondaryColor " + |
"gl_TexCoord gl_FogFragCoord " + |
"gl_FragCoord gl_FrontFacing " + |
- "gl_FragColor gl_FragData gl_FragDepth " + |
+ "gl_FragData gl_FragDepth " + |
"gl_ModelViewMatrix gl_ProjectionMatrix gl_ModelViewProjectionMatrix " + |
"gl_TextureMatrix gl_NormalMatrix gl_ModelViewMatrixInverse " + |
"gl_ProjectionMatrixInverse gl_ModelViewProjectionMatrixInverse " + |
@@ -432,8 +653,134 @@ CodeMirror.defineMode("clike", function(config, parserConfig) { |
"gl_MaxVertexTextureImageUnits gl_MaxTextureImageUnits " + |
"gl_MaxFragmentUniformComponents gl_MaxCombineTextureImageUnits " + |
"gl_MaxDrawBuffers"), |
+ indentSwitch: false, |
+ hooks: {"#": cppHook}, |
+ modeProps: {fold: ["brace", "include"]} |
+ }); |
+ |
+ def("text/x-nesc", { |
+ name: "clike", |
+ keywords: words(cKeywords + "as atomic async call command component components configuration event generic " + |
+ "implementation includes interface module new norace nx_struct nx_union post provides " + |
+ "signal task uses abstract extends"), |
+ types: words(cTypes), |
+ blockKeywords: words("case do else for if switch while struct"), |
+ atoms: words("null true false"), |
hooks: {"#": cppHook}, |
modeProps: {fold: ["brace", "include"]} |
}); |
+ def("text/x-objectivec", { |
+ name: "clike", |
+ keywords: words(cKeywords + "inline restrict _Bool _Complex _Imaginary BOOL Class bycopy byref id IMP in " + |
+ "inout nil oneway out Protocol SEL self super atomic nonatomic retain copy readwrite readonly"), |
+ types: words(cTypes), |
+ atoms: words("YES NO NULL NILL ON OFF true false"), |
+ hooks: { |
+ "@": function(stream) { |
+ stream.eatWhile(/[\w\$]/); |
+ return "keyword"; |
+ }, |
+ "#": cppHook, |
+ indent: function(_state, ctx, textAfter) { |
+ if (ctx.type == "statement" && /^@\w/.test(textAfter)) return ctx.indented |
+ } |
+ }, |
+ modeProps: {fold: "brace"} |
+ }); |
+ |
+ def("text/x-squirrel", { |
+ name: "clike", |
+ keywords: words("base break clone continue const default delete enum extends function in class" + |
+ " foreach local resume return this throw typeof yield constructor instanceof static"), |
+ types: words(cTypes), |
+ blockKeywords: words("case catch class else for foreach if switch try while"), |
+ defKeywords: words("function local class"), |
+ typeFirstDefinitions: true, |
+ atoms: words("true false null"), |
+ hooks: {"#": cppHook}, |
+ modeProps: {fold: ["brace", "include"]} |
+ }); |
+ |
+ // Ceylon Strings need to deal with interpolation |
+ var stringTokenizer = null; |
+ function tokenCeylonString(type) { |
+ return function(stream, state) { |
+ var escaped = false, next, end = false; |
+ while (!stream.eol()) { |
+ if (!escaped && stream.match('"') && |
+ (type == "single" || stream.match('""'))) { |
+ end = true; |
+ break; |
+ } |
+ if (!escaped && stream.match('``')) { |
+ stringTokenizer = tokenCeylonString(type); |
+ end = true; |
+ break; |
+ } |
+ next = stream.next(); |
+ escaped = type == "single" && !escaped && next == "\\"; |
+ } |
+ if (end) |
+ state.tokenize = null; |
+ return "string"; |
+ } |
+ } |
+ |
+ def("text/x-ceylon", { |
+ name: "clike", |
+ keywords: words("abstracts alias assembly assert assign break case catch class continue dynamic else" + |
+ " exists extends finally for function given if import in interface is let module new" + |
+ " nonempty object of out outer package return satisfies super switch then this throw" + |
+ " try value void while"), |
+ types: function(word) { |
+ // In Ceylon all identifiers that start with an uppercase are types |
+ var first = word.charAt(0); |
+ return (first === first.toUpperCase() && first !== first.toLowerCase()); |
+ }, |
+ blockKeywords: words("case catch class dynamic else finally for function if interface module new object switch try while"), |
+ defKeywords: words("class dynamic function interface module object package value"), |
+ builtin: words("abstract actual aliased annotation by default deprecated doc final formal late license" + |
+ " native optional sealed see serializable shared suppressWarnings tagged throws variable"), |
+ isPunctuationChar: /[\[\]{}\(\),;\:\.`]/, |
+ isOperatorChar: /[+\-*&%=<>!?|^~:\/]/, |
+ numberStart: /[\d#$]/, |
+ number: /^(?:#[\da-fA-F_]+|\$[01_]+|[\d_]+[kMGTPmunpf]?|[\d_]+\.[\d_]+(?:[eE][-+]?\d+|[kMGTPmunpf]|)|)/i, |
+ multiLineStrings: true, |
+ typeFirstDefinitions: true, |
+ atoms: words("true false null larger smaller equal empty finished"), |
+ indentSwitch: false, |
+ styleDefs: false, |
+ hooks: { |
+ "@": function(stream) { |
+ stream.eatWhile(/[\w\$_]/); |
+ return "meta"; |
+ }, |
+ '"': function(stream, state) { |
+ state.tokenize = tokenCeylonString(stream.match('""') ? "triple" : "single"); |
+ return state.tokenize(stream, state); |
+ }, |
+ '`': function(stream, state) { |
+ if (!stringTokenizer || !stream.match('`')) return false; |
+ state.tokenize = stringTokenizer; |
+ stringTokenizer = null; |
+ return state.tokenize(stream, state); |
+ }, |
+ "'": function(stream) { |
+ stream.eatWhile(/[\w\$_\xa1-\uffff]/); |
+ return "atom"; |
+ }, |
+ token: function(_stream, state, style) { |
+ if ((style == "variable" || style == "variable-3") && |
+ state.prevToken == ".") { |
+ return "variable-2"; |
+ } |
+ } |
+ }, |
+ modeProps: { |
+ fold: ["brace", "import"], |
+ closeBrackets: {triples: '"'} |
+ } |
+ }); |
+ |
}); |