[ Index ] |
PHP Cross Reference of MyBB 1.8.38 |
[Summary view] [Print] [Text view]
1 // CodeMirror, copyright (c) by Marijn Haverbeke and others 2 // Distributed under an MIT license: http://codemirror.net/LICENSE 3 4 (function() { 5 var mode = CodeMirror.getMode({indentUnit: 2}, "javascript"); 6 function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1)); } 7 8 MT("locals", 9 "[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]; }"); 10 11 MT("comma-and-binop", 12 "[keyword function](){ [keyword var] [def x] [operator =] [number 1] [operator +] [number 2], [def y]; }"); 13 14 MT("destructuring", 15 "([keyword function]([def a], [[[def b], [def c] ]]) {", 16 " [keyword let] {[def d], [property foo]: [def c][operator =][number 10], [def x]} [operator =] [variable foo]([variable-2 a]);", 17 " [[[variable-2 c], [variable y] ]] [operator =] [variable-2 c];", 18 "})();"); 19 20 MT("destructure_trailing_comma", 21 "[keyword let] {[def a], [def b],} [operator =] [variable foo];", 22 "[keyword let] [def c];"); // Parser still in good state? 23 24 MT("class_body", 25 "[keyword class] [def Foo] {", 26 " [property constructor]() {}", 27 " [property sayName]() {", 28 " [keyword return] [string-2 `foo${][variable foo][string-2 }oo`];", 29 " }", 30 "}"); 31 32 MT("class", 33 "[keyword class] [def Point] [keyword extends] [variable SuperThing] {", 34 " [keyword get] [property prop]() { [keyword return] [number 24]; }", 35 " [property constructor]([def x], [def y]) {", 36 " [keyword super]([string 'something']);", 37 " [keyword this].[property x] [operator =] [variable-2 x];", 38 " }", 39 "}"); 40 41 MT("anonymous_class_expression", 42 "[keyword const] [def Adder] [operator =] [keyword class] [keyword extends] [variable Arithmetic] {", 43 " [property add]([def a], [def b]) {}", 44 "};"); 45 46 MT("named_class_expression", 47 "[keyword const] [def Subber] [operator =] [keyword class] [def Subtract] {", 48 " [property sub]([def a], [def b]) {}", 49 "};"); 50 51 MT("class_async_method", 52 "[keyword class] [def Foo] {", 53 " [property sayName1]() {}", 54 " [keyword async] [property sayName2]() {}", 55 "}"); 56 57 MT("import", 58 "[keyword function] [def foo]() {", 59 " [keyword import] [def $] [keyword from] [string 'jquery'];", 60 " [keyword import] { [def encrypt], [def decrypt] } [keyword from] [string 'crypto'];", 61 "}"); 62 63 MT("import_trailing_comma", 64 "[keyword import] {[def foo], [def bar],} [keyword from] [string 'baz']") 65 66 MT("const", 67 "[keyword function] [def f]() {", 68 " [keyword const] [[ [def a], [def b] ]] [operator =] [[ [number 1], [number 2] ]];", 69 "}"); 70 71 MT("for/of", 72 "[keyword for]([keyword let] [def of] [keyword of] [variable something]) {}"); 73 74 MT("generator", 75 "[keyword function*] [def repeat]([def n]) {", 76 " [keyword for]([keyword var] [def i] [operator =] [number 0]; [variable-2 i] [operator <] [variable-2 n]; [operator ++][variable-2 i])", 77 " [keyword yield] [variable-2 i];", 78 "}"); 79 80 MT("quotedStringAddition", 81 "[keyword let] [def f] [operator =] [variable a] [operator +] [string 'fatarrow'] [operator +] [variable c];"); 82 83 MT("quotedFatArrow", 84 "[keyword let] [def f] [operator =] [variable a] [operator +] [string '=>'] [operator +] [variable c];"); 85 86 MT("fatArrow", 87 "[variable array].[property filter]([def a] [operator =>] [variable-2 a] [operator +] [number 1]);", 88 "[variable a];", // No longer in scope 89 "[keyword let] [def f] [operator =] ([[ [def a], [def b] ]], [def c]) [operator =>] [variable-2 a] [operator +] [variable-2 c];", 90 "[variable c];"); 91 92 MT("spread", 93 "[keyword function] [def f]([def a], [meta ...][def b]) {", 94 " [variable something]([variable-2 a], [meta ...][variable-2 b]);", 95 "}"); 96 97 MT("quasi", 98 "[variable re][string-2 `fofdlakj${][variable x] [operator +] ([variable re][string-2 `foo`]) [operator +] [number 1][string-2 }fdsa`] [operator +] [number 2]"); 99 100 MT("quasi_no_function", 101 "[variable x] [operator =] [string-2 `fofdlakj${][variable x] [operator +] [string-2 `foo`] [operator +] [number 1][string-2 }fdsa`] [operator +] [number 2]"); 102 103 MT("indent_statement", 104 "[keyword var] [def x] [operator =] [number 10]", 105 "[variable x] [operator +=] [variable y] [operator +]", 106 " [atom Infinity]", 107 "[keyword debugger];"); 108 109 MT("indent_if", 110 "[keyword if] ([number 1])", 111 " [keyword break];", 112 "[keyword else] [keyword if] ([number 2])", 113 " [keyword continue];", 114 "[keyword else]", 115 " [number 10];", 116 "[keyword if] ([number 1]) {", 117 " [keyword break];", 118 "} [keyword else] [keyword if] ([number 2]) {", 119 " [keyword continue];", 120 "} [keyword else] {", 121 " [number 10];", 122 "}"); 123 124 MT("indent_for", 125 "[keyword for] ([keyword var] [def i] [operator =] [number 0];", 126 " [variable i] [operator <] [number 100];", 127 " [variable i][operator ++])", 128 " [variable doSomething]([variable i]);", 129 "[keyword debugger];"); 130 131 MT("indent_c_style", 132 "[keyword function] [def foo]()", 133 "{", 134 " [keyword debugger];", 135 "}"); 136 137 MT("indent_else", 138 "[keyword for] (;;)", 139 " [keyword if] ([variable foo])", 140 " [keyword if] ([variable bar])", 141 " [number 1];", 142 " [keyword else]", 143 " [number 2];", 144 " [keyword else]", 145 " [number 3];"); 146 147 MT("indent_funarg", 148 "[variable foo]([number 10000],", 149 " [keyword function]([def a]) {", 150 " [keyword debugger];", 151 "};"); 152 153 MT("indent_below_if", 154 "[keyword for] (;;)", 155 " [keyword if] ([variable foo])", 156 " [number 1];", 157 "[number 2];"); 158 159 MT("indent_semicolonless_if", 160 "[keyword function] [def foo]() {", 161 " [keyword if] ([variable x])", 162 " [variable foo]()", 163 "}") 164 165 MT("indent_semicolonless_if_with_statement", 166 "[keyword function] [def foo]() {", 167 " [keyword if] ([variable x])", 168 " [variable foo]()", 169 " [variable bar]()", 170 "}") 171 172 MT("multilinestring", 173 "[keyword var] [def x] [operator =] [string 'foo\\]", 174 "[string bar'];"); 175 176 MT("scary_regexp", 177 "[string-2 /foo[[/]]bar/];"); 178 179 MT("indent_strange_array", 180 "[keyword var] [def x] [operator =] [[", 181 " [number 1],,", 182 " [number 2],", 183 "]];", 184 "[number 10];"); 185 186 MT("param_default", 187 "[keyword function] [def foo]([def x] [operator =] [string-2 `foo${][number 10][string-2 }bar`]) {", 188 " [keyword return] [variable-2 x];", 189 "}"); 190 191 MT("new_target", 192 "[keyword function] [def F]([def target]) {", 193 " [keyword if] ([variable-2 target] [operator &&] [keyword new].[keyword target].[property name]) {", 194 " [keyword return] [keyword new]", 195 " .[keyword target];", 196 " }", 197 "}"); 198 199 MT("async", 200 "[keyword async] [keyword function] [def foo]([def args]) { [keyword return] [atom true]; }"); 201 202 MT("async_assignment", 203 "[keyword const] [def foo] [operator =] [keyword async] [keyword function] ([def args]) { [keyword return] [atom true]; };"); 204 205 MT("async_object", 206 "[keyword let] [def obj] [operator =] { [property async]: [atom false] };"); 207 208 // async be highlighet as keyword and foo as def, but it requires potentially expensive look-ahead. See #4173 209 MT("async_object_function", 210 "[keyword let] [def obj] [operator =] { [property async] [property foo]([def args]) { [keyword return] [atom true]; } };"); 211 212 MT("async_object_properties", 213 "[keyword let] [def obj] [operator =] {", 214 " [property prop1]: [keyword async] [keyword function] ([def args]) { [keyword return] [atom true]; },", 215 " [property prop2]: [keyword async] [keyword function] ([def args]) { [keyword return] [atom true]; },", 216 " [property prop3]: [keyword async] [keyword function] [def prop3]([def args]) { [keyword return] [atom true]; },", 217 "};"); 218 219 MT("async_arrow", 220 "[keyword const] [def foo] [operator =] [keyword async] ([def args]) [operator =>] { [keyword return] [atom true]; };"); 221 222 MT("async_jquery", 223 "[variable $].[property ajax]({", 224 " [property url]: [variable url],", 225 " [property async]: [atom true],", 226 " [property method]: [string 'GET']", 227 "});"); 228 229 MT("async_variable", 230 "[keyword const] [def async] [operator =] {[property a]: [number 1]};", 231 "[keyword const] [def foo] [operator =] [string-2 `bar ${][variable async].[property a][string-2 }`];") 232 233 MT("indent_switch", 234 "[keyword switch] ([variable x]) {", 235 " [keyword default]:", 236 " [keyword return] [number 2]", 237 "}") 238 239 MT("regexp_corner_case", 240 "[operator +]{} [operator /] [atom undefined];", 241 "[[[meta ...][string-2 /\\//] ]];", 242 "[keyword void] [string-2 /\\//];", 243 "[keyword do] [string-2 /\\//]; [keyword while] ([number 0]);", 244 "[keyword if] ([number 0]) {} [keyword else] [string-2 /\\//];", 245 "[string-2 `${][variable async][operator ++][string-2 }//`];", 246 "[string-2 `${]{} [operator /] [string-2 /\\//}`];") 247 248 var ts_mode = CodeMirror.getMode({indentUnit: 2}, "application/typescript") 249 function TS(name) { 250 test.mode(name, ts_mode, Array.prototype.slice.call(arguments, 1)) 251 } 252 253 TS("typescript_extend_type", 254 "[keyword class] [def Foo] [keyword extends] [type Some][operator <][type Type][operator >] {}") 255 256 TS("typescript_arrow_type", 257 "[keyword let] [def x]: ([variable arg]: [type Type]) [operator =>] [type ReturnType]") 258 259 TS("typescript_class", 260 "[keyword class] [def Foo] {", 261 " [keyword public] [keyword static] [property main]() {}", 262 " [keyword private] [property _foo]: [type string];", 263 "}") 264 265 TS("typescript_literal_types", 266 "[keyword import] [keyword *] [keyword as] [def Sequelize] [keyword from] [string 'sequelize'];", 267 "[keyword interface] [def MyAttributes] {", 268 " [property truthy]: [string 'true'] [operator |] [number 1] [operator |] [atom true];", 269 " [property falsy]: [string 'false'] [operator |] [number 0] [operator |] [atom false];", 270 "}", 271 "[keyword interface] [def MyInstance] [keyword extends] [type Sequelize].[type Instance] [operator <] [type MyAttributes] [operator >] {", 272 " [property rawAttributes]: [type MyAttributes];", 273 " [property truthy]: [string 'true'] [operator |] [number 1] [operator |] [atom true];", 274 " [property falsy]: [string 'false'] [operator |] [number 0] [operator |] [atom false];", 275 "}") 276 277 TS("typescript_extend_operators", 278 "[keyword export] [keyword interface] [def UserModel] [keyword extends]", 279 " [type Sequelize].[type Model] [operator <] [type UserInstance], [type UserAttributes] [operator >] {", 280 " [property findById]: (", 281 " [variable userId]: [type number]", 282 " ) [operator =>] [type Promise] [operator <] [type Array] [operator <] { [property id], [property name] } [operator >>];", 283 " [property updateById]: (", 284 " [variable userId]: [type number],", 285 " [variable isActive]: [type boolean]", 286 " ) [operator =>] [type Promise] [operator <] [type AccountHolderNotificationPreferenceInstance] [operator >];", 287 " }") 288 289 TS("typescript_interface_with_const", 290 "[keyword const] [def hello]: {", 291 " [property prop1][operator ?]: [type string];", 292 " [property prop2][operator ?]: [type string];", 293 "} [operator =] {};") 294 295 TS("typescript_double_extend", 296 "[keyword export] [keyword interface] [def UserAttributes] {", 297 " [property id][operator ?]: [type number];", 298 " [property createdAt][operator ?]: [type Date];", 299 "}", 300 "[keyword export] [keyword interface] [def UserInstance] [keyword extends] [type Sequelize].[type Instance][operator <][type UserAttributes][operator >], [type UserAttributes] {", 301 " [property id]: [type number];", 302 " [property createdAt]: [type Date];", 303 "}"); 304 305 TS("typescript_index_signature", 306 "[keyword interface] [def A] {", 307 " [[ [variable prop]: [type string] ]]: [type any];", 308 " [property prop1]: [type any];", 309 "}"); 310 311 TS("typescript_generic_class", 312 "[keyword class] [def Foo][operator <][type T][operator >] {", 313 " [property bar]() {}", 314 " [property foo](): [type Foo] {}", 315 "}") 316 317 TS("typescript_type_when_keyword", 318 "[keyword export] [keyword type] [type AB] [operator =] [type A] [operator |] [type B];", 319 "[keyword type] [type Flags] [operator =] {", 320 " [property p1]: [type string];", 321 " [property p2]: [type boolean];", 322 "};") 323 324 TS("typescript_type_when_not_keyword", 325 "[keyword class] [def HasType] {", 326 " [property type]: [type string];", 327 " [property constructor]([def type]: [type string]) {", 328 " [keyword this].[property type] [operator =] [variable-2 type];", 329 " }", 330 " [property setType]({ [def type] }: { [property type]: [type string]; }) {", 331 " [keyword this].[property type] [operator =] [variable-2 type];", 332 " }", 333 "}") 334 335 TS("typescript_function_generics", 336 "[keyword function] [def a]() {}", 337 "[keyword function] [def b][operator <][type IA] [keyword extends] [type object], [type IB] [keyword extends] [type object][operator >]() {}", 338 "[keyword function] [def c]() {}") 339 340 TS("typescript_complex_return_type", 341 "[keyword function] [def A]() {", 342 " [keyword return] [keyword this].[property property];", 343 "}", 344 "[keyword function] [def B](): [type Promise][operator <]{ [[ [variable key]: [type string] ]]: [type any] } [operator |] [atom null][operator >] {", 345 " [keyword return] [keyword this].[property property];", 346 "}") 347 348 TS("typescript_complex_type_casting", 349 "[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]; } };") 350 351 TS("typescript_keyof", 352 "[keyword function] [def x][operator <][type T] [keyword extends] [keyword keyof] [type X][operator >]([def a]: [type T]) {", 353 " [keyword return]") 354 355 TS("typescript_new_typeargs", 356 "[keyword let] [def x] [operator =] [keyword new] [variable Map][operator <][type string], [type Date][operator >]([string-2 `foo${][variable bar][string-2 }`])") 357 358 TS("modifiers", 359 "[keyword class] [def Foo] {", 360 " [keyword public] [keyword abstract] [property bar]() {}", 361 " [property constructor]([keyword readonly] [keyword private] [def x]) {}", 362 "}") 363 364 TS("arrow prop", 365 "({[property a]: [def p] [operator =>] [variable-2 p]})") 366 367 var jsonld_mode = CodeMirror.getMode( 368 {indentUnit: 2}, 369 {name: "javascript", jsonld: true} 370 ); 371 function LD(name) { 372 test.mode(name, jsonld_mode, Array.prototype.slice.call(arguments, 1)); 373 } 374 375 LD("json_ld_keywords", 376 '{', 377 ' [meta "@context"]: {', 378 ' [meta "@base"]: [string "http://example.com"],', 379 ' [meta "@vocab"]: [string "http://xmlns.com/foaf/0.1/"],', 380 ' [property "likesFlavor"]: {', 381 ' [meta "@container"]: [meta "@list"]', 382 ' [meta "@reverse"]: [string "@beFavoriteOf"]', 383 ' },', 384 ' [property "nick"]: { [meta "@container"]: [meta "@set"] },', 385 ' [property "nick"]: { [meta "@container"]: [meta "@index"] }', 386 ' },', 387 ' [meta "@graph"]: [[ {', 388 ' [meta "@id"]: [string "http://dbpedia.org/resource/John_Lennon"],', 389 ' [property "name"]: [string "John Lennon"],', 390 ' [property "modified"]: {', 391 ' [meta "@value"]: [string "2010-05-29T14:17:39+02:00"],', 392 ' [meta "@type"]: [string "http://www.w3.org/2001/XMLSchema#dateTime"]', 393 ' }', 394 ' } ]]', 395 '}'); 396 397 LD("json_ld_fake", 398 '{', 399 ' [property "@fake"]: [string "@fake"],', 400 ' [property "@contextual"]: [string "@identifier"],', 401 ' [property "user@domain.com"]: [string "@graphical"],', 402 ' [property "@ID"]: [string "@@ID"]', 403 '}'); 404 })();
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
2005 - 2021 © MyBB.de | Alle Rechte vorbehalten! | Sponsor: netcup | Cross-referenced by PHPXref |