syntax_test_js_bindings.js (9009B)
1 // SYNTAX TEST "Packages/JavaScript/JavaScript.sublime-syntax" 2 3 4 // Variable declarations 5 6 const x = value; 7 // ^ meta.binding.name variable.other.readwrite 8 9 10 const [ x, y, ...z, ] = value; 11 // ^^^^^^^^^^^^^^^ meta.binding.destructuring.sequence 12 // ^ meta.binding.name variable.other.readwrite 13 // ^ punctuation.separator.comma 14 // ^ meta.binding.name variable.other.readwrite 15 // ^ punctuation.separator.comma 16 // ^^^ keyword.operator.spread 17 // ^ meta.binding.name variable.other.readwrite 18 // ^ punctuation.separator.comma 19 20 const [ x, [a, b], z] = value; 21 // ^^^^^^^^^^^^^^^ meta.binding.destructuring.sequence 22 // ^^^^^^ meta.binding.destructuring.sequence meta.binding.destructuring.sequence 23 // ^ meta.binding.name variable.other.readwrite 24 // ^ meta.binding.name variable.other.readwrite 25 26 const [ x = 42, y = [a, b, c] ] = value; 27 // ^^^^^^^^^^^^^^^^^^^^^^^^^ meta.binding.destructuring.sequence 28 // ^ keyword.operator.assignment 29 // ^^ meta.binding.destructuring.sequence.js meta.number.integer.decimal.js constant.numeric.value.js 30 // ^ keyword.operator.assignment 31 // ^^^^^^^^^ meta.sequence 32 // ^ variable.other.readwrite - meta.binding.name 33 34 const { a, b: c, ...d } = value; 35 // ^^^^^^^^^^^^^^^^^ meta.binding.destructuring.mapping 36 // ^ meta.mapping.key meta.binding.name variable.other.readwrite 37 // ^ punctuation.separator.comma 38 // ^ meta.mapping.key - variable 39 // ^ punctuation.separator.key-value 40 // ^^^ keyword.operator.spread 41 // ^ meta.binding.name variable.other.readwrite 42 43 const { 'a': x, "b": y, [c]: z } = value; 44 // ^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.binding.destructuring.mapping 45 // ^^^ meta.mapping.key string.quoted.single 46 // ^ punctuation.separator.key-value 47 // ^ meta.binding.name variable.other.readwrite 48 // ^^^ meta.mapping.key string.quoted.double 49 // ^ punctuation.separator.key-value 50 // ^ meta.binding.name variable.other.readwrite 51 // ^^^ meta.mapping.key 52 // ^ variable.other.readwrite 53 // ^ punctuation.separator.key-value 54 // ^ meta.binding.name variable.other.readwrite 55 56 const x; 57 // ^ meta.binding.name variable.other.readwrite 58 59 let 60 // <- keyword.declaration 61 w 62 // <- meta.binding.name variable.other.readwrite 63 , 64 // <- punctuation.separator.comma 65 x 66 // <- meta.binding.name variable.other.readwrite 67 y 68 // <- variable.other.readwrite - meta.binding.name 69 , 70 // <- keyword.operator.comma 71 z 72 // <- variable.other.readwrite - meta.binding.name 73 74 // `let` is only reserved in strict mode, and we can't distinguish that yet. 75 76 let let; 77 // ^^^ meta.binding.name variable.other.readwrite 78 79 let 80 let; 81 // <- meta.binding.name variable.other.readwrite 82 83 const 84 const x = 0; 85 // <- keyword.declaration 86 87 // Function parameters 88 89 function f ([ x, y, ...z, ]) {} 90 // ^^^^^^^^^^^^^^^ meta.binding.destructuring.sequence 91 // ^ meta.binding.name variable.parameter.function 92 // ^ punctuation.separator.parameter 93 // ^ meta.binding.name variable.parameter.function 94 // ^ punctuation.separator.parameter 95 // ^^^ keyword.operator.spread 96 // ^ meta.binding.name variable.parameter.function 97 // ^ punctuation.separator.parameter 98 99 function f ([ x, [a, b], z]) {} 100 // ^^^^^^^^^^^^^^^ meta.binding.destructuring.sequence 101 // ^^^^^^ meta.binding.destructuring.sequence meta.binding.destructuring.sequence 102 // ^ meta.binding.name variable.parameter.function 103 // ^ meta.binding.name variable.parameter.function 104 105 function f ([ x = 42, y = [a, b, c] ]) {} 106 // ^^^^^^^^^^^^^^^^^^^^^^^^^ meta.binding.destructuring.sequence 107 // ^ keyword.operator.assignment 108 // ^^ meta.function meta.binding.destructuring.sequence meta.number.integer.decimal constant.numeric.value 109 // ^ keyword.operator.assignment 110 // ^^^^^^^^^ meta.sequence 111 // ^ variable.other.readwrite - meta.binding.name 112 113 function f ({ a, b: c, ...d }) {} 114 // ^^^^^^^^^^^^^^^^^ meta.binding.destructuring.mapping 115 // ^ meta.mapping.key meta.binding.name variable.parameter.function 116 // ^ punctuation.separator.parameter 117 // ^ meta.mapping.key - variable 118 // ^ punctuation.separator.key-value 119 // ^^^ keyword.operator.spread 120 // ^ meta.binding.name variable.parameter.function 121 122 function f ({ 'a': x, "b": y, [c]: z }) = value; 123 // ^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.binding.destructuring.mapping 124 // ^^^ meta.mapping.key string.quoted.single 125 // ^ punctuation.separator.key-value 126 // ^ meta.binding.name variable.parameter.function 127 // ^^^ meta.mapping.key string.quoted.double 128 // ^ punctuation.separator.key-value 129 // ^ meta.binding.name variable.parameter.function 130 // ^^^ meta.mapping.key 131 // ^ variable.other.readwrite 132 // ^ punctuation.separator.key-value 133 // ^ meta.binding.name variable.parameter.function 134 135 function f (a, ...rest) {} 136 // ^ meta.binding.name variable.parameter.function 137 // ^^^ keyword.operator.spread 138 // ^^^^ variable.parameter.function 139 140 function f (new) {} 141 // ^^^^^^^^^^^^^^^^ meta.function 142 // ^^^ invalid.illegal.identifier meta.binding.name variable.parameter.function 143 144 let f = ([ x, y, ...z, ]) => {}; 145 // ^^^^^^^^^^^^^^^^^^^^^^^ meta.function 146 // ^^^^^^^^^^^^^^^ meta.binding.destructuring.sequence 147 // ^ meta.binding.name variable.parameter.function 148 // ^ punctuation.separator.parameter 149 // ^ meta.binding.name variable.parameter.function 150 // ^ punctuation.separator.parameter 151 // ^^^ keyword.operator.spread 152 // ^ meta.binding.name variable.parameter.function 153 // ^ punctuation.separator.parameter 154 155 let f = ([ x, [a, b], z]) => {}; 156 // ^ entity.name.function variable.other.readwrite 157 // ^^^^^^^^^^^^^^^^^^^^^^^ meta.function 158 // ^^^^^^^^^^^^^^^ meta.binding.destructuring.sequence 159 // ^^^^^^ meta.binding.destructuring.sequence meta.binding.destructuring.sequence 160 // ^ meta.binding.name variable.parameter.function 161 // ^ meta.binding.name variable.parameter.function 162 163 let f = ([ x = 42, y = [a, b, c] ]) => {}; 164 // ^ entity.name.function variable.other.readwrite 165 // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function 166 // ^^^^^^^^^^^^^^^^^^^^^^^^^ meta.binding.destructuring.sequence 167 // ^ keyword.operator.assignment 168 // ^^ meta.binding.destructuring.sequence.js meta.number.integer.decimal.js constant.numeric.value.js 169 // ^ keyword.operator.assignment 170 // ^^^^^^^^^ meta.sequence 171 // ^ variable.other.readwrite - meta.binding.name 172 173 let f = ({ a, b: c, ...d }) => {}; 174 // ^ entity.name.function variable.other.readwrite 175 // ^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function 176 // ^^^^^^^^^^^^^^^^^ meta.binding.destructuring.mapping 177 // ^ meta.mapping.key meta.binding.name variable.parameter.function 178 // ^ punctuation.separator.parameter 179 // ^ meta.mapping.key - variable 180 // ^ punctuation.separator.key-value 181 // ^^^ keyword.operator.spread 182 // ^ meta.binding.name variable.parameter.function 183 184 let f = ({ 'a': x, "b": y, [c]: z }) => {}; 185 // ^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.binding.destructuring.mapping 186 // ^^^ meta.mapping.key string.quoted.single 187 // ^ punctuation.separator.key-value 188 // ^ meta.binding.name variable.parameter.function 189 // ^^^ meta.mapping.key string.quoted.double 190 // ^ punctuation.separator.key-value 191 // ^ meta.binding.name variable.parameter.function 192 // ^^^ meta.mapping.key 193 // ^ variable.other.readwrite 194 // ^ punctuation.separator.key-value 195 // ^ meta.binding.name variable.parameter.function 196 197 let f = (a, ...rest) => {}; 198 // ^ entity.name.function variable.other.readwrite 199 // ^^^^^^^^^^^^^^^^^^ meta.function 200 // ^ meta.binding.name variable.parameter.function 201 // ^^^ keyword.operator.spread 202 // ^^^^ meta.binding.name variable.parameter.function 203 204 let f = (new) => {}; 205 // ^^^^^^^^^^^ meta.function 206 // ^^^ invalid.illegal.identifier meta.binding.name variable.parameter.function