Vergleich admin/jscripts/codemirror/mode/javascript/test.js - 1.8.5 - 1.8.38

  Keine Änderungen   Hinzugefügt   Modifiziert   Entfernt
Zeile 6Zeile 6
  function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1)); }

MT("locals",

  function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1)); }

MT("locals",

     "[keyword function] [variable foo]([def a], [def b]) { [keyword var] [def c] [operator =] [number 10]; [keyword return] [variable-2 a] [operator +] [variable-2 c] [operator +] [variable d]; }");

     "[keyword function] [def foo]([def a], [def b]) { [keyword var] [def c] [operator =] [number 10]; [keyword return] [variable-2 a] [operator +] [variable-2 c] [operator +] [variable d]; }");


MT("comma-and-binop",
"[keyword function](){ [keyword var] [def x] [operator =] [number 1] [operator +] [number 2], [def y]; }");


MT("comma-and-binop",
"[keyword function](){ [keyword var] [def x] [operator =] [number 1] [operator +] [number 2], [def y]; }");

Zeile 16Zeile 16
     "  [keyword let] {[def d], [property foo]: [def c][operator =][number 10], [def x]} [operator =] [variable foo]([variable-2 a]);",
" [[[variable-2 c], [variable y] ]] [operator =] [variable-2 c];",
"})();");

     "  [keyword let] {[def d], [property foo]: [def c][operator =][number 10], [def x]} [operator =] [variable foo]([variable-2 a]);",
" [[[variable-2 c], [variable y] ]] [operator =] [variable-2 c];",
"})();");

 

MT("destructure_trailing_comma",
"[keyword let] {[def a], [def b],} [operator =] [variable foo];",
"[keyword let] [def c];"); // Parser still in good state?


MT("class_body",


MT("class_body",

     "[keyword class] [variable Foo] {",

     "[keyword class] [def Foo] {",

     "  [property constructor]() {}",
" [property sayName]() {",
" [keyword return] [string-2 `foo${][variable foo][string-2 }oo`];",

     "  [property constructor]() {}",
" [property sayName]() {",
" [keyword return] [string-2 `foo${][variable foo][string-2 }oo`];",

     "  }",
"}");


     "  }",
"}");


  MT("class",

  MT("class",

     "[keyword class] [variable Point] [keyword extends] [variable SuperThing] {",
" [property get] [property prop]() { [keyword return] [number 24]; }",

     "[keyword class] [def Point] [keyword extends] [variable SuperThing] {",
" [keyword get] [property prop]() { [keyword return] [number 24]; }",

     "  [property constructor]([def x], [def y]) {",
" [keyword super]([string 'something']);",
" [keyword this].[property x] [operator =] [variable-2 x];",

     "  [property constructor]([def x], [def y]) {",
" [keyword super]([string 'something']);",
" [keyword this].[property x] [operator =] [variable-2 x];",

     "  }",
"}");

MT("module",
"[keyword module] [string 'foo'] {",
" [keyword export] [keyword let] [def x] [operator =] [number 42];",
" [keyword export] [keyword *] [keyword from] [string 'somewhere'];",
"}");












     "  }",
"}");

MT("anonymous_class_expression",
"[keyword const] [def Adder] [operator =] [keyword class] [keyword extends] [variable Arithmetic] {",
" [property add]([def a], [def b]) {}",
"};");

MT("named_class_expression",
"[keyword const] [def Subber] [operator =] [keyword class] [def Subtract] {",
" [property sub]([def a], [def b]) {}",
"};");

MT("class_async_method",
"[keyword class] [def Foo] {",
" [property sayName1]() {}",
" [keyword async] [property sayName2]() {}",
"}");


  MT("import",

  MT("import",

     "[keyword function] [variable foo]() {",

     "[keyword function] [def foo]() {",

     "  [keyword import] [def $] [keyword from] [string 'jquery'];",

     "  [keyword import] [def $] [keyword from] [string 'jquery'];",

     "  [keyword module] [def crypto] [keyword from] [string 'crypto'];",

 
     "  [keyword import] { [def encrypt], [def decrypt] } [keyword from] [string 'crypto'];",
"}");

     "  [keyword import] { [def encrypt], [def decrypt] } [keyword from] [string 'crypto'];",
"}");

 

MT("import_trailing_comma",
"[keyword import] {[def foo], [def bar],} [keyword from] [string 'baz']")


MT("const",


MT("const",

     "[keyword function] [variable f]() {",

     "[keyword function] [def f]() {",

     "  [keyword const] [[ [def a], [def b] ]] [operator =] [[ [number 1], [number 2] ]];",
"}");

MT("for/of",

     "  [keyword const] [[ [def a], [def b] ]] [operator =] [[ [number 1], [number 2] ]];",
"}");

MT("for/of",

     "[keyword for]([keyword let] [variable of] [keyword of] [variable something]) {}");

     "[keyword for]([keyword let] [def of] [keyword of] [variable something]) {}");


MT("generator",


MT("generator",

     "[keyword function*] [variable repeat]([def n]) {",

     "[keyword function*] [def repeat]([def n]) {",

     "  [keyword for]([keyword var] [def i] [operator =] [number 0]; [variable-2 i] [operator <] [variable-2 n]; [operator ++][variable-2 i])",
" [keyword yield] [variable-2 i];",
"}");

MT("quotedStringAddition",

     "  [keyword for]([keyword var] [def i] [operator =] [number 0]; [variable-2 i] [operator <] [variable-2 n]; [operator ++][variable-2 i])",
" [keyword yield] [variable-2 i];",
"}");

MT("quotedStringAddition",

     "[keyword let] [variable f] [operator =] [variable a] [operator +] [string 'fatarrow'] [operator +] [variable c];");

     "[keyword let] [def f] [operator =] [variable a] [operator +] [string 'fatarrow'] [operator +] [variable c];");


MT("quotedFatArrow",


MT("quotedFatArrow",

     "[keyword let] [variable f] [operator =] [variable a] [operator +] [string '=>'] [operator +] [variable c];");

     "[keyword let] [def f] [operator =] [variable a] [operator +] [string '=>'] [operator +] [variable c];");


MT("fatArrow",
"[variable array].[property filter]([def a] [operator =>] [variable-2 a] [operator +] [number 1]);",
"[variable a];", // No longer in scope


MT("fatArrow",
"[variable array].[property filter]([def a] [operator =>] [variable-2 a] [operator +] [number 1]);",
"[variable a];", // No longer in scope

     "[keyword let] [variable f] [operator =] ([[ [def a], [def b] ]], [def c]) [operator =>] [variable-2 a] [operator +] [variable-2 c];",

     "[keyword let] [def f] [operator =] ([[ [def a], [def b] ]], [def c]) [operator =>] [variable-2 a] [operator +] [variable-2 c];",

     "[variable c];");

MT("spread",

     "[variable c];");

MT("spread",

     "[keyword function] [variable f]([def a], [meta ...][def b]) {",

     "[keyword function] [def f]([def a], [meta ...][def b]) {",

     "  [variable something]([variable-2 a], [meta ...][variable-2 b]);",

     "  [variable something]([variable-2 a], [meta ...][variable-2 b]);",

     "}");

MT("comprehension",
"[keyword function] [variable f]() {",
" [[([variable x] [operator +] [number 1]) [keyword for] ([keyword var] [def x] [keyword in] [variable y]) [keyword if] [variable pred]([variable-2 x]) ]];",
" ([variable u] [keyword for] ([keyword var] [def u] [keyword of] [variable generateValues]()) [keyword if] ([variable-2 u].[property color] [operator ===] [string 'blue']));",

 
     "}");

MT("quasi",

     "}");

MT("quasi",

Zeile 91Zeile 101
     "[variable x] [operator =] [string-2 `fofdlakj${][variable x] [operator +] [string-2 `foo`] [operator +] [number 1][string-2 }fdsa`] [operator +] [number 2]");

MT("indent_statement",

     "[variable x] [operator =] [string-2 `fofdlakj${][variable x] [operator +] [string-2 `foo`] [operator +] [number 1][string-2 }fdsa`] [operator +] [number 2]");

MT("indent_statement",

     "[keyword var] [variable x] [operator =] [number 10]",

     "[keyword var] [def x] [operator =] [number 10]",

     "[variable x] [operator +=] [variable y] [operator +]",
" [atom Infinity]",
"[keyword debugger];");

     "[variable x] [operator +=] [variable y] [operator +]",
" [atom Infinity]",
"[keyword debugger];");

Zeile 112Zeile 122
     "}");

MT("indent_for",

     "}");

MT("indent_for",

     "[keyword for] ([keyword var] [variable i] [operator =] [number 0];",

     "[keyword for] ([keyword var] [def i] [operator =] [number 0];",

     "     [variable i] [operator <] [number 100];",
" [variable i][operator ++])",
" [variable doSomething]([variable i]);",
"[keyword debugger];");

MT("indent_c_style",

     "     [variable i] [operator <] [number 100];",
" [variable i][operator ++])",
" [variable doSomething]([variable i]);",
"[keyword debugger];");

MT("indent_c_style",

     "[keyword function] [variable foo]()",

     "[keyword function] [def foo]()",

     "{",
" [keyword debugger];",
"}");

     "{",
" [keyword debugger];",
"}");

Zeile 145Zeile 155
     "  [keyword if] ([variable foo])",
" [number 1];",
"[number 2];");

     "  [keyword if] ([variable foo])",
" [number 1];",
"[number 2];");

 

MT("indent_semicolonless_if",
"[keyword function] [def foo]() {",
" [keyword if] ([variable x])",
" [variable foo]()",
"}")

MT("indent_semicolonless_if_with_statement",
"[keyword function] [def foo]() {",
" [keyword if] ([variable x])",
" [variable foo]()",
" [variable bar]()",
"}")


MT("multilinestring",


MT("multilinestring",

     "[keyword var] [variable x] [operator =] [string 'foo\\]",

     "[keyword var] [def x] [operator =] [string 'foo\\]",

     "[string bar'];");

     "[string bar'];");





  MT("scary_regexp",
"[string-2 /foo[[/]]bar/];");

  MT("scary_regexp",
"[string-2 /foo[[/]]bar/];");





  MT("indent_strange_array",

  MT("indent_strange_array",

     "[keyword var] [variable x] [operator =] [[",

     "[keyword var] [def x] [operator =] [[",

     "  [number 1],,",
" [number 2],",
"]];",
"[number 10];");

     "  [number 1],,",
" [number 2],",
"]];",
"[number 10];");

 

MT("param_default",
"[keyword function] [def foo]([def x] [operator =] [string-2 `foo${][number 10][string-2 }bar`]) {",
" [keyword return] [variable-2 x];",
"}");

MT("new_target",
"[keyword function] [def F]([def target]) {",
" [keyword if] ([variable-2 target] [operator &&] [keyword new].[keyword target].[property name]) {",
" [keyword return] [keyword new]",
" .[keyword target];",
" }",
"}");

MT("async",
"[keyword async] [keyword function] [def foo]([def args]) { [keyword return] [atom true]; }");

MT("async_assignment",
"[keyword const] [def foo] [operator =] [keyword async] [keyword function] ([def args]) { [keyword return] [atom true]; };");

MT("async_object",
"[keyword let] [def obj] [operator =] { [property async]: [atom false] };");

// async be highlighet as keyword and foo as def, but it requires potentially expensive look-ahead. See #4173
MT("async_object_function",
"[keyword let] [def obj] [operator =] { [property async] [property foo]([def args]) { [keyword return] [atom true]; } };");

MT("async_object_properties",
"[keyword let] [def obj] [operator =] {",
" [property prop1]: [keyword async] [keyword function] ([def args]) { [keyword return] [atom true]; },",
" [property prop2]: [keyword async] [keyword function] ([def args]) { [keyword return] [atom true]; },",
" [property prop3]: [keyword async] [keyword function] [def prop3]([def args]) { [keyword return] [atom true]; },",
"};");

MT("async_arrow",
"[keyword const] [def foo] [operator =] [keyword async] ([def args]) [operator =>] { [keyword return] [atom true]; };");

MT("async_jquery",
"[variable $].[property ajax]({",
" [property url]: [variable url],",
" [property async]: [atom true],",
" [property method]: [string 'GET']",
"});");

MT("async_variable",
"[keyword const] [def async] [operator =] {[property a]: [number 1]};",
"[keyword const] [def foo] [operator =] [string-2 `bar ${][variable async].[property a][string-2 }`];")

MT("indent_switch",
"[keyword switch] ([variable x]) {",
" [keyword default]:",
" [keyword return] [number 2]",
"}")

MT("regexp_corner_case",
"[operator +]{} [operator /] [atom undefined];",
"[[[meta ...][string-2 /\\//] ]];",
"[keyword void] [string-2 /\\//];",
"[keyword do] [string-2 /\\//]; [keyword while] ([number 0]);",
"[keyword if] ([number 0]) {} [keyword else] [string-2 /\\//];",
"[string-2 `${][variable async][operator ++][string-2 }//`];",
"[string-2 `${]{} [operator /] [string-2 /\\//}`];")

var ts_mode = CodeMirror.getMode({indentUnit: 2}, "application/typescript")
function TS(name) {
test.mode(name, ts_mode, Array.prototype.slice.call(arguments, 1))
}

TS("typescript_extend_type",
"[keyword class] [def Foo] [keyword extends] [type Some][operator <][type Type][operator >] {}")

TS("typescript_arrow_type",
"[keyword let] [def x]: ([variable arg]: [type Type]) [operator =>] [type ReturnType]")

TS("typescript_class",
"[keyword class] [def Foo] {",
" [keyword public] [keyword static] [property main]() {}",
" [keyword private] [property _foo]: [type string];",
"}")

TS("typescript_literal_types",
"[keyword import] [keyword *] [keyword as] [def Sequelize] [keyword from] [string 'sequelize'];",
"[keyword interface] [def MyAttributes] {",
" [property truthy]: [string 'true'] [operator |] [number 1] [operator |] [atom true];",
" [property falsy]: [string 'false'] [operator |] [number 0] [operator |] [atom false];",
"}",
"[keyword interface] [def MyInstance] [keyword extends] [type Sequelize].[type Instance] [operator <] [type MyAttributes] [operator >] {",
" [property rawAttributes]: [type MyAttributes];",
" [property truthy]: [string 'true'] [operator |] [number 1] [operator |] [atom true];",
" [property falsy]: [string 'false'] [operator |] [number 0] [operator |] [atom false];",
"}")

TS("typescript_extend_operators",
"[keyword export] [keyword interface] [def UserModel] [keyword extends]",
" [type Sequelize].[type Model] [operator <] [type UserInstance], [type UserAttributes] [operator >] {",
" [property findById]: (",
" [variable userId]: [type number]",
" ) [operator =>] [type Promise] [operator <] [type Array] [operator <] { [property id], [property name] } [operator >>];",
" [property updateById]: (",
" [variable userId]: [type number],",
" [variable isActive]: [type boolean]",
" ) [operator =>] [type Promise] [operator <] [type AccountHolderNotificationPreferenceInstance] [operator >];",
" }")

TS("typescript_interface_with_const",
"[keyword const] [def hello]: {",
" [property prop1][operator ?]: [type string];",
" [property prop2][operator ?]: [type string];",
"} [operator =] {};")

TS("typescript_double_extend",
"[keyword export] [keyword interface] [def UserAttributes] {",
" [property id][operator ?]: [type number];",
" [property createdAt][operator ?]: [type Date];",
"}",
"[keyword export] [keyword interface] [def UserInstance] [keyword extends] [type Sequelize].[type Instance][operator <][type UserAttributes][operator >], [type UserAttributes] {",
" [property id]: [type number];",
" [property createdAt]: [type Date];",
"}");

TS("typescript_index_signature",
"[keyword interface] [def A] {",
" [[ [variable prop]: [type string] ]]: [type any];",
" [property prop1]: [type any];",
"}");

TS("typescript_generic_class",
"[keyword class] [def Foo][operator <][type T][operator >] {",
" [property bar]() {}",
" [property foo](): [type Foo] {}",
"}")

TS("typescript_type_when_keyword",
"[keyword export] [keyword type] [type AB] [operator =] [type A] [operator |] [type B];",
"[keyword type] [type Flags] [operator =] {",
" [property p1]: [type string];",
" [property p2]: [type boolean];",
"};")

TS("typescript_type_when_not_keyword",
"[keyword class] [def HasType] {",
" [property type]: [type string];",
" [property constructor]([def type]: [type string]) {",
" [keyword this].[property type] [operator =] [variable-2 type];",
" }",
" [property setType]({ [def type] }: { [property type]: [type string]; }) {",
" [keyword this].[property type] [operator =] [variable-2 type];",
" }",
"}")

TS("typescript_function_generics",
"[keyword function] [def a]() {}",
"[keyword function] [def b][operator <][type IA] [keyword extends] [type object], [type IB] [keyword extends] [type object][operator >]() {}",
"[keyword function] [def c]() {}")

TS("typescript_complex_return_type",
"[keyword function] [def A]() {",
" [keyword return] [keyword this].[property property];",
"}",
"[keyword function] [def B](): [type Promise][operator <]{ [[ [variable key]: [type string] ]]: [type any] } [operator |] [atom null][operator >] {",
" [keyword return] [keyword this].[property property];",
"}")

TS("typescript_complex_type_casting",
"[keyword const] [def giftpay] [operator =] [variable config].[property get]([string 'giftpay']) [keyword as] { [[ [variable platformUuid]: [type string] ]]: { [property version]: [type number]; [property apiCode]: [type string]; } };")

TS("typescript_keyof",
"[keyword function] [def x][operator <][type T] [keyword extends] [keyword keyof] [type X][operator >]([def a]: [type T]) {",
" [keyword return]")

TS("typescript_new_typeargs",
"[keyword let] [def x] [operator =] [keyword new] [variable Map][operator <][type string], [type Date][operator >]([string-2 `foo${][variable bar][string-2 }`])")

TS("modifiers",
"[keyword class] [def Foo] {",
" [keyword public] [keyword abstract] [property bar]() {}",
" [property constructor]([keyword readonly] [keyword private] [def x]) {}",
"}")

TS("arrow prop",
"({[property a]: [def p] [operator =>] [variable-2 p]})")


var jsonld_mode = CodeMirror.getMode(
{indentUnit: 2},


var jsonld_mode = CodeMirror.getMode(
{indentUnit: 2},