powershell.test.ts 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737
  1. /*---------------------------------------------------------------------------------------------
  2. * Copyright (c) Microsoft Corporation. All rights reserved.
  3. * Licensed under the MIT License. See License.txt in the project root for license information.
  4. *--------------------------------------------------------------------------------------------*/
  5. 'use strict';
  6. import {testTokenization} from './testRunner';
  7. testTokenization('powershell', [
  8. // Comments - single line
  9. [{
  10. line: '#',
  11. tokens: [
  12. { startIndex: 0, type: 'comment.ps1' }
  13. ]}],
  14. [{
  15. line: ' # a comment',
  16. tokens: [
  17. { startIndex: 0, type: '' },
  18. { startIndex: 4, type: 'comment.ps1' }
  19. ]}],
  20. [{
  21. line: '# a comment',
  22. tokens: [
  23. { startIndex: 0, type: 'comment.ps1' }
  24. ]}],
  25. [{
  26. line: '#sticky comment',
  27. tokens: [
  28. { startIndex: 0, type: 'comment.ps1' }
  29. ]}],
  30. [{
  31. line: '##still a comment',
  32. tokens: [
  33. { startIndex: 0, type: 'comment.ps1' }
  34. ]}],
  35. [{
  36. line: '1 / 2 /# comment',
  37. tokens: [
  38. { startIndex: 0, type: 'number.ps1' },
  39. { startIndex: 1, type: '' },
  40. { startIndex: 2, type: 'delimiter.ps1' },
  41. { startIndex: 3, type: '' },
  42. { startIndex: 4, type: 'number.ps1' },
  43. { startIndex: 5, type: '' },
  44. { startIndex: 6, type: 'delimiter.ps1' },
  45. { startIndex: 7, type: 'comment.ps1' }
  46. ]}],
  47. [{
  48. line: '$x = 1 # my comment # is a nice one',
  49. tokens: [
  50. { startIndex: 0, type: 'variable.ps1' },
  51. { startIndex: 2, type: '' },
  52. { startIndex: 3, type: 'delimiter.ps1' },
  53. { startIndex: 4, type: '' },
  54. { startIndex: 5, type: 'number.ps1' },
  55. { startIndex: 6, type: '' },
  56. { startIndex: 7, type: 'comment.ps1' }
  57. ]}],
  58. // Comments - range comment, single line
  59. [{
  60. line: '<# a simple comment #>',
  61. tokens: [
  62. { startIndex: 0, type: 'comment.ps1' }
  63. ]}],
  64. [{
  65. line: '$x = <# a simple comment #> 1',
  66. tokens: [
  67. { startIndex: 0, type: 'variable.ps1' },
  68. { startIndex: 2, type: '' },
  69. { startIndex: 3, type: 'delimiter.ps1' },
  70. { startIndex: 4, type: '' },
  71. { startIndex: 5, type: 'comment.ps1' },
  72. { startIndex: 27, type: '' },
  73. { startIndex: 28, type: 'number.ps1' }
  74. ]}],
  75. [{
  76. line: '$yy = <# comment #> 14',
  77. tokens: [
  78. { startIndex: 0, type: 'variable.ps1' },
  79. { startIndex: 3, type: '' },
  80. { startIndex: 4, type: 'delimiter.ps1' },
  81. { startIndex: 5, type: '' },
  82. { startIndex: 6, type: 'comment.ps1' },
  83. { startIndex: 19, type: '' },
  84. { startIndex: 20, type: 'number.ps1' }
  85. ]}],
  86. [{
  87. line: '$x = <##>7',
  88. tokens: [
  89. { startIndex: 0, type: 'variable.ps1' },
  90. { startIndex: 2, type: '' },
  91. { startIndex: 3, type: 'delimiter.ps1' },
  92. { startIndex: 4, type: '' },
  93. { startIndex: 5, type: 'comment.ps1' },
  94. { startIndex: 9, type: 'number.ps1' }
  95. ]}],
  96. [{
  97. line: '$x = <#<85',
  98. tokens: [
  99. { startIndex: 0, type: 'variable.ps1' },
  100. { startIndex: 2, type: '' },
  101. { startIndex: 3, type: 'delimiter.ps1' },
  102. { startIndex: 4, type: '' },
  103. { startIndex: 5, type: 'comment.ps1' }
  104. ]}],
  105. // Comments - range comment, multiple lines
  106. [{
  107. line: '<# start of multiline comment',
  108. tokens: [
  109. { startIndex: 0, type: 'comment.ps1' }
  110. ]}, {
  111. line: 'a comment between',
  112. tokens: [
  113. { startIndex: 0, type: 'comment.ps1' }
  114. ]}, {
  115. line: 'end of multiline comment#>',
  116. tokens: [
  117. { startIndex: 0, type: 'comment.ps1' }
  118. ]}],
  119. [{
  120. line: '$x = <# start a comment',
  121. tokens: [
  122. { startIndex: 0, type: 'variable.ps1' },
  123. { startIndex: 2, type: '' },
  124. { startIndex: 3, type: 'delimiter.ps1' },
  125. { startIndex: 4, type: '' },
  126. { startIndex: 5, type: 'comment.ps1' }
  127. ]}, {
  128. line: ' a ',
  129. tokens: [
  130. { startIndex: 0, type: 'comment.ps1' }
  131. ]}, {
  132. line: 'and end it #> 2',
  133. tokens: [
  134. { startIndex: 0, type: 'comment.ps1' },
  135. { startIndex: 13, type: '' },
  136. { startIndex: 14, type: 'number.ps1' }
  137. ]}],
  138. // Keywords
  139. [{
  140. line: 'foreach($i in $b) {if (7) continue}',
  141. tokens: [
  142. { startIndex: 0, type: 'keyword.foreach.ps1' },
  143. { startIndex: 7, type: 'delimiter.parenthesis.ps1' },
  144. { startIndex: 8, type: 'variable.ps1' },
  145. { startIndex: 10, type: '' },
  146. { startIndex: 11, type: 'keyword.in.ps1' },
  147. { startIndex: 13, type: '' },
  148. { startIndex: 14, type: 'variable.ps1' },
  149. { startIndex: 16, type: 'delimiter.parenthesis.ps1' },
  150. { startIndex: 17, type: '' },
  151. { startIndex: 18, type: 'delimiter.curly.ps1' },
  152. { startIndex: 19, type: 'keyword.if.ps1' },
  153. { startIndex: 21, type: '' },
  154. { startIndex: 22, type: 'delimiter.parenthesis.ps1' },
  155. { startIndex: 23, type: 'number.ps1' },
  156. { startIndex: 24, type: 'delimiter.parenthesis.ps1' },
  157. { startIndex: 25, type: '' },
  158. { startIndex: 26, type: 'keyword.continue.ps1' },
  159. { startIndex: 34, type: 'delimiter.curly.ps1' }
  160. ]}],
  161. // Redirect operand
  162. [{
  163. line: '$i > output1.txt',
  164. tokens: [
  165. { startIndex: 0, type: 'variable.ps1' },
  166. { startIndex: 2, type: '' },
  167. { startIndex: 3, type: 'delimiter.ps1' },
  168. { startIndex: 4, type: '' },
  169. { startIndex: 12, type: 'delimiter.ps1' },
  170. { startIndex: 13, type: '' }
  171. ]}],
  172. // Numbers
  173. [{
  174. line: '0',
  175. tokens: [
  176. { startIndex: 0, type: 'number.ps1' }
  177. ]}],
  178. [{
  179. line: '0.10',
  180. tokens: [
  181. { startIndex: 0, type: 'number.float.ps1' }
  182. ]}],
  183. [{
  184. line: '0X123',
  185. tokens: [
  186. { startIndex: 0, type: 'number.hex.ps1' }
  187. ]}],
  188. [{
  189. line: '0x123',
  190. tokens: [
  191. { startIndex: 0, type: 'number.hex.ps1' }
  192. ]}],
  193. [{
  194. line: '23.5e3',
  195. tokens: [
  196. { startIndex: 0, type: 'number.float.ps1' }
  197. ]}],
  198. [{
  199. line: '23.5e-3',
  200. tokens: [
  201. { startIndex: 0, type: 'number.float.ps1' }
  202. ]}],
  203. [{
  204. line: '23.5E3',
  205. tokens: [
  206. { startIndex: 0, type: 'number.float.ps1' }
  207. ]}],
  208. [{
  209. line: '23.5E-3',
  210. tokens: [
  211. { startIndex: 0, type: 'number.float.ps1' }
  212. ]}],
  213. [{
  214. line: '23.5',
  215. tokens: [
  216. { startIndex: 0, type: 'number.float.ps1' }
  217. ]}],
  218. [{
  219. line: '0+0',
  220. tokens: [
  221. { startIndex: 0, type: 'number.ps1' },
  222. { startIndex: 1, type: 'delimiter.ps1' },
  223. { startIndex: 2, type: 'number.ps1' }
  224. ]}],
  225. [{
  226. line: '100+10',
  227. tokens: [
  228. { startIndex: 0, type: 'number.ps1' },
  229. { startIndex: 3, type: 'delimiter.ps1' },
  230. { startIndex: 4, type: 'number.ps1' }
  231. ]}],
  232. [{
  233. line: '10 + 0',
  234. tokens: [
  235. { startIndex: 0, type: 'number.ps1' },
  236. { startIndex: 2, type: '' },
  237. { startIndex: 3, type: 'delimiter.ps1' },
  238. { startIndex: 4, type: '' },
  239. { startIndex: 5, type: 'number.ps1' }
  240. ]}],
  241. // Strings
  242. [{
  243. line: '$s = "I am a String"',
  244. tokens: [
  245. { startIndex: 0, type: 'variable.ps1' },
  246. { startIndex: 2, type: '' },
  247. { startIndex: 3, type: 'delimiter.ps1' },
  248. { startIndex: 4, type: '' },
  249. { startIndex: 5, type: 'string.ps1' }
  250. ]}],
  251. [{
  252. line: '\'I am also a ( String\'',
  253. tokens: [
  254. { startIndex: 0, type: 'string.ps1' }
  255. ]}],
  256. [{
  257. line: '$s = "concatenated" + " String"',
  258. tokens: [
  259. { startIndex: 0, type: 'variable.ps1' },
  260. { startIndex: 2, type: '' },
  261. { startIndex: 3, type: 'delimiter.ps1' },
  262. { startIndex: 4, type: '' },
  263. { startIndex: 5, type: 'string.ps1' },
  264. { startIndex: 19, type: '' },
  265. { startIndex: 20, type: 'delimiter.ps1' },
  266. { startIndex: 21, type: '' },
  267. { startIndex: 22, type: 'string.ps1' }
  268. ]}],
  269. [{
  270. line: '"escaping `"quotes`" is cool"',
  271. tokens: [
  272. { startIndex: 0, type: 'string.ps1' },
  273. { startIndex: 10, type: 'string.escape.ps1' },
  274. { startIndex: 12, type: 'string.ps1' },
  275. { startIndex: 18, type: 'string.escape.ps1' },
  276. { startIndex: 20, type: 'string.ps1' }
  277. ]}],
  278. [{
  279. line: '\'`\'end of the string',
  280. tokens: [
  281. { startIndex: 0, type: 'string.ps1' },
  282. { startIndex: 1, type: 'string.escape.ps1' },
  283. { startIndex: 3, type: 'string.ps1' }
  284. ]}],
  285. [{
  286. line: '@"I am an expandable String"@',
  287. tokens: [
  288. { startIndex: 0, type: 'string.ps1' }
  289. ]}],
  290. [{
  291. line: '@\'I am also an expandable String\'@',
  292. tokens: [
  293. { startIndex: 0, type: 'string.ps1' }
  294. ]}],
  295. [{
  296. line: '$s = @\'I am also an expandable String\'@',
  297. tokens: [
  298. { startIndex: 0, type: 'variable.ps1' },
  299. { startIndex: 2, type: '' },
  300. { startIndex: 3, type: 'delimiter.ps1' },
  301. { startIndex: 4, type: '' },
  302. { startIndex: 5, type: 'string.ps1' }
  303. ]}],
  304. [{
  305. line: '$s = @\'I am also an expandable String\'@+7',
  306. tokens: [
  307. { startIndex: 0, type: 'variable.ps1' },
  308. { startIndex: 2, type: '' },
  309. { startIndex: 3, type: 'delimiter.ps1' },
  310. { startIndex: 4, type: '' },
  311. { startIndex: 5, type: 'string.ps1' }
  312. ]}],
  313. [{
  314. line: '@\'I am a multiline string,',
  315. tokens: [
  316. { startIndex: 0, type: 'string.ps1' }
  317. ]}, {
  318. line: 'and this is the middle line,',
  319. tokens: [
  320. { startIndex: 0, type: 'string.ps1' }
  321. ]}, {
  322. line: 'and this is NOT the end of the string\'@foreach $i',
  323. tokens: [
  324. { startIndex: 0, type: 'string.ps1' }
  325. ]}, {
  326. line: '\'@',
  327. tokens: [
  328. { startIndex: 0, type: 'string.ps1' }
  329. ]}, {
  330. line: '${script:foo}',
  331. tokens: [
  332. { startIndex: 0, type: 'variable.ps1' }
  333. ]}, {
  334. line: 'foreach $i',
  335. tokens: [
  336. { startIndex: 0, type: 'keyword.foreach.ps1' },
  337. { startIndex: 7, type: '' },
  338. { startIndex: 8, type: 'variable.ps1' }
  339. ]}],
  340. // Generated from sample
  341. [{
  342. line: '$SelectedObjectNames=@();',
  343. tokens: [
  344. { startIndex: 0, type: 'variable.ps1' },
  345. { startIndex: 20, type: 'delimiter.ps1' },
  346. { startIndex: 21, type: '' },
  347. { startIndex: 22, type: 'delimiter.parenthesis.ps1' },
  348. { startIndex: 24, type: 'delimiter.ps1' }
  349. ]}, {
  350. line: '$XenCenterNodeSelected = 0;',
  351. tokens: [
  352. { startIndex: 0, type: 'variable.ps1' },
  353. { startIndex: 22, type: '' },
  354. { startIndex: 23, type: 'delimiter.ps1' },
  355. { startIndex: 24, type: '' },
  356. { startIndex: 25, type: 'number.ps1' },
  357. { startIndex: 26, type: 'delimiter.ps1' }
  358. ]}, {
  359. line: '#the object info array contains hashmaps, each of which represent a parameter set and describe a target in the XenCenter resource list',
  360. tokens: [
  361. { startIndex: 0, type: 'comment.ps1' }
  362. ]}, {
  363. line: 'foreach($parameterSet in $ObjInfoArray)',
  364. tokens: [
  365. { startIndex: 0, type: 'keyword.foreach.ps1' },
  366. { startIndex: 7, type: 'delimiter.parenthesis.ps1' },
  367. { startIndex: 8, type: 'variable.ps1' },
  368. { startIndex: 21, type: '' },
  369. { startIndex: 22, type: 'keyword.in.ps1' },
  370. { startIndex: 24, type: '' },
  371. { startIndex: 25, type: 'variable.ps1' },
  372. { startIndex: 38, type: 'delimiter.parenthesis.ps1' }
  373. ]}, {
  374. line: '{',
  375. tokens: [
  376. { startIndex: 0, type: 'delimiter.curly.ps1' }
  377. ]}, {
  378. line: ' if ($parameterSet["class"] -eq "blank")',
  379. tokens: [
  380. { startIndex: 0, type: '' },
  381. { startIndex: 1, type: 'keyword.if.ps1' },
  382. { startIndex: 3, type: '' },
  383. { startIndex: 4, type: 'delimiter.parenthesis.ps1' },
  384. { startIndex: 5, type: 'variable.ps1' },
  385. { startIndex: 18, type: 'delimiter.square.ps1' },
  386. { startIndex: 19, type: 'string.ps1' },
  387. { startIndex: 26, type: 'delimiter.square.ps1' },
  388. { startIndex: 27, type: '' },
  389. { startIndex: 28, type: 'delimiter.ps1' },
  390. { startIndex: 29, type: '' },
  391. { startIndex: 32, type: 'string.ps1' },
  392. { startIndex: 39, type: 'delimiter.parenthesis.ps1' }
  393. ]}, {
  394. line: ' {',
  395. tokens: [
  396. { startIndex: 0, type: '' },
  397. { startIndex: 1, type: 'delimiter.curly.ps1' }
  398. ]}, {
  399. line: ' #When the XenCenter node is selected a parameter set is created for each of your connected servers with the class and objUuid keys marked as blank',
  400. tokens: [
  401. { startIndex: 0, type: '' },
  402. { startIndex: 2, type: 'comment.ps1' }
  403. ]}, {
  404. line: ' if ($XenCenterNodeSelected)',
  405. tokens: [
  406. { startIndex: 0, type: '' },
  407. { startIndex: 2, type: 'keyword.if.ps1' },
  408. { startIndex: 4, type: '' },
  409. { startIndex: 5, type: 'delimiter.parenthesis.ps1' },
  410. { startIndex: 6, type: 'variable.ps1' },
  411. { startIndex: 28, type: 'delimiter.parenthesis.ps1' }
  412. ]}, {
  413. line: ' {',
  414. tokens: [
  415. { startIndex: 0, type: '' },
  416. { startIndex: 2, type: 'delimiter.curly.ps1' }
  417. ]}, {
  418. line: ' continue',
  419. tokens: [
  420. { startIndex: 0, type: '' },
  421. { startIndex: 3, type: 'keyword.continue.ps1' }
  422. ]}, {
  423. line: ' }',
  424. tokens: [
  425. { startIndex: 0, type: '' },
  426. { startIndex: 2, type: 'delimiter.curly.ps1' }
  427. ]}, {
  428. line: ' $XenCenterNodeSelected = 1;',
  429. tokens: [
  430. { startIndex: 0, type: '' },
  431. { startIndex: 2, type: 'variable.ps1' },
  432. { startIndex: 24, type: '' },
  433. { startIndex: 25, type: 'delimiter.ps1' },
  434. { startIndex: 26, type: '' },
  435. { startIndex: 27, type: 'number.ps1' },
  436. { startIndex: 28, type: 'delimiter.ps1' }
  437. ]}, {
  438. line: ' $SelectedObjectNames += "XenCenter"',
  439. tokens: [
  440. { startIndex: 0, type: '' },
  441. { startIndex: 2, type: 'variable.ps1' },
  442. { startIndex: 22, type: '' },
  443. { startIndex: 23, type: 'delimiter.ps1' },
  444. { startIndex: 25, type: '' },
  445. { startIndex: 26, type: 'string.ps1' }
  446. ]}, {
  447. line: ' }',
  448. tokens: [
  449. { startIndex: 0, type: '' },
  450. { startIndex: 1, type: 'delimiter.curly.ps1' }
  451. ]}, {
  452. line: ' elseif ($parameterSet["sessionRef"] -eq "null")',
  453. tokens: [
  454. { startIndex: 0, type: '' },
  455. { startIndex: 1, type: 'keyword.elseif.ps1' },
  456. { startIndex: 7, type: '' },
  457. { startIndex: 8, type: 'delimiter.parenthesis.ps1' },
  458. { startIndex: 9, type: 'variable.ps1' },
  459. { startIndex: 22, type: 'delimiter.square.ps1' },
  460. { startIndex: 23, type: 'string.ps1' },
  461. { startIndex: 35, type: 'delimiter.square.ps1' },
  462. { startIndex: 36, type: '' },
  463. { startIndex: 37, type: 'delimiter.ps1' },
  464. { startIndex: 38, type: '' },
  465. { startIndex: 41, type: 'string.ps1' },
  466. { startIndex: 47, type: 'delimiter.parenthesis.ps1' }
  467. ]}, {
  468. line: ' {',
  469. tokens: [
  470. { startIndex: 0, type: '' },
  471. { startIndex: 1, type: 'delimiter.curly.ps1' }
  472. ]}, {
  473. line: ' #When a disconnected server is selected there is no session information, we get null for everything except class',
  474. tokens: [
  475. { startIndex: 0, type: '' },
  476. { startIndex: 2, type: 'comment.ps1' }
  477. ]}, {
  478. line: ' }',
  479. tokens: [
  480. { startIndex: 0, type: '' },
  481. { startIndex: 1, type: 'delimiter.curly.ps1' }
  482. ]}, {
  483. line: ' $SelectedObjectNames += "a disconnected server"',
  484. tokens: [
  485. { startIndex: 0, type: '' },
  486. { startIndex: 2, type: 'variable.ps1' },
  487. { startIndex: 22, type: '' },
  488. { startIndex: 23, type: 'delimiter.ps1' },
  489. { startIndex: 25, type: '' },
  490. { startIndex: 26, type: 'string.ps1' }
  491. ]}, {
  492. line: ' else',
  493. tokens: [
  494. { startIndex: 0, type: '' },
  495. { startIndex: 1, type: 'keyword.else.ps1' }
  496. ]}, {
  497. line: ' {',
  498. tokens: [
  499. { startIndex: 0, type: '' },
  500. { startIndex: 1, type: 'delimiter.curly.ps1' }
  501. ]}, {
  502. line: ' Connect-XenServer -url $parameterSet["url"] -opaqueref $parameterSet["sessionRef"]',
  503. tokens: [
  504. { startIndex: 0, type: '' },
  505. { startIndex: 20, type: 'delimiter.ps1' },
  506. { startIndex: 21, type: '' },
  507. { startIndex: 25, type: 'variable.ps1' },
  508. { startIndex: 38, type: 'delimiter.square.ps1' },
  509. { startIndex: 39, type: 'string.ps1' },
  510. { startIndex: 44, type: 'delimiter.square.ps1' },
  511. { startIndex: 45, type: '' },
  512. { startIndex: 46, type: 'delimiter.ps1' },
  513. { startIndex: 47, type: '' },
  514. { startIndex: 57, type: 'variable.ps1' },
  515. { startIndex: 70, type: 'delimiter.square.ps1' },
  516. { startIndex: 71, type: 'string.ps1' },
  517. { startIndex: 83, type: 'delimiter.square.ps1' }
  518. ]}, {
  519. line: ' #Use $class to determine which server objects to get',
  520. tokens: [
  521. { startIndex: 0, type: '' },
  522. { startIndex: 2, type: 'comment.ps1' }
  523. ]}, {
  524. line: ' #-properties allows us to filter the results to just include the selected object',
  525. tokens: [
  526. { startIndex: 0, type: '' },
  527. { startIndex: 2, type: 'comment.ps1' }
  528. ]}, {
  529. line: ' $exp = "Get-XenServer:{0} -properties @{{uuid=\'{1}\'}}" -f $parameterSet["class"], $parameterSet["objUuid"]',
  530. tokens: [
  531. { startIndex: 0, type: '' },
  532. { startIndex: 2, type: 'variable.ps1' },
  533. { startIndex: 6, type: '' },
  534. { startIndex: 7, type: 'delimiter.ps1' },
  535. { startIndex: 8, type: '' },
  536. { startIndex: 9, type: 'string.ps1' },
  537. { startIndex: 56, type: '' },
  538. { startIndex: 57, type: 'delimiter.ps1' },
  539. { startIndex: 58, type: '' },
  540. { startIndex: 60, type: 'variable.ps1' },
  541. { startIndex: 73, type: 'delimiter.square.ps1' },
  542. { startIndex: 74, type: 'string.ps1' },
  543. { startIndex: 81, type: 'delimiter.square.ps1' },
  544. { startIndex: 82, type: 'delimiter.ps1' },
  545. { startIndex: 83, type: '' },
  546. { startIndex: 84, type: 'variable.ps1' },
  547. { startIndex: 97, type: 'delimiter.square.ps1' },
  548. { startIndex: 98, type: 'string.ps1' },
  549. { startIndex: 107, type: 'delimiter.square.ps1' }
  550. ]}, {
  551. line: ' $obj = Invoke-Expression $exp',
  552. tokens: [
  553. { startIndex: 0, type: '' },
  554. { startIndex: 2, type: 'variable.ps1' },
  555. { startIndex: 6, type: '' },
  556. { startIndex: 7, type: 'delimiter.ps1' },
  557. { startIndex: 8, type: '' },
  558. { startIndex: 27, type: 'variable.ps1' }
  559. ]}, {
  560. line: ' $SelectedObjectNames += $obj.name_label;',
  561. tokens: [
  562. { startIndex: 0, type: '' },
  563. { startIndex: 2, type: 'variable.ps1' },
  564. { startIndex: 22, type: '' },
  565. { startIndex: 23, type: 'delimiter.ps1' },
  566. { startIndex: 25, type: '' },
  567. { startIndex: 26, type: 'variable.ps1' },
  568. { startIndex: 30, type: 'delimiter.ps1' },
  569. { startIndex: 31, type: '' },
  570. { startIndex: 41, type: 'delimiter.ps1' }
  571. ]}, {
  572. line: ' } ',
  573. tokens: [
  574. { startIndex: 0, type: '' },
  575. { startIndex: 1, type: 'delimiter.curly.ps1' },
  576. { startIndex: 2, type: '' }
  577. ]}, {
  578. line: '}',
  579. tokens: [
  580. { startIndex: 0, type: 'delimiter.curly.ps1' }
  581. ]}, {
  582. line: '',
  583. tokens: [
  584. ]}, {
  585. line: '$test = "in string var$test"',
  586. tokens: [
  587. { startIndex: 0, type: 'variable.ps1' },
  588. { startIndex: 5, type: '' },
  589. { startIndex: 6, type: 'delimiter.ps1' },
  590. { startIndex: 7, type: '' },
  591. { startIndex: 8, type: 'string.ps1' },
  592. { startIndex: 22, type: 'variable.ps1' },
  593. { startIndex: 27, type: 'string.ps1' }
  594. ]}, {
  595. line: '$another = \'not a $var\'',
  596. tokens: [
  597. { startIndex: 0, type: 'variable.ps1' },
  598. { startIndex: 8, type: '' },
  599. { startIndex: 9, type: 'delimiter.ps1' },
  600. { startIndex: 10, type: '' },
  601. { startIndex: 11, type: 'string.ps1' }
  602. ]}, {
  603. line: '$third = "a $var and not `$var string"',
  604. tokens: [
  605. { startIndex: 0, type: 'variable.ps1' },
  606. { startIndex: 6, type: '' },
  607. { startIndex: 7, type: 'delimiter.ps1' },
  608. { startIndex: 8, type: '' },
  609. { startIndex: 9, type: 'string.ps1' },
  610. { startIndex: 12, type: 'variable.ps1' },
  611. { startIndex: 16, type: 'string.ps1' },
  612. { startIndex: 25, type: 'string.escape.ps1' },
  613. { startIndex: 27, type: 'string.ps1' }
  614. ]}, {
  615. line: '',
  616. tokens: [
  617. ]}, {
  618. line: ':aLabel',
  619. tokens: [
  620. { startIndex: 0, type: 'metatag.ps1' }
  621. ]}, {
  622. line: '',
  623. tokens: [
  624. ]}, {
  625. line: '<#',
  626. tokens: [
  627. { startIndex: 0, type: 'comment.ps1' }
  628. ]}, {
  629. line: '.SYNOPSIS',
  630. tokens: [
  631. { startIndex: 0, type: 'comment.keyword.synopsis.ps1' }
  632. ]}, {
  633. line: ' some text',
  634. tokens: [
  635. { startIndex: 0, type: 'comment.ps1' }
  636. ]}, {
  637. line: ' ',
  638. tokens: [
  639. { startIndex: 0, type: 'comment.ps1' }
  640. ]}, {
  641. line: '.LINK',
  642. tokens: [
  643. { startIndex: 0, type: 'comment.keyword.link.ps1' }
  644. ]}, {
  645. line: ' some more text',
  646. tokens: [
  647. { startIndex: 0, type: 'comment.ps1' }
  648. ]}, {
  649. line: '#>',
  650. tokens: [
  651. { startIndex: 0, type: 'comment.ps1' }
  652. ]}, {
  653. line: '',
  654. tokens: [
  655. ]}, {
  656. line: '',
  657. tokens: [
  658. ]}, {
  659. line: '$hereString = @"',
  660. tokens: [
  661. { startIndex: 0, type: 'variable.ps1' },
  662. { startIndex: 11, type: '' },
  663. { startIndex: 12, type: 'delimiter.ps1' },
  664. { startIndex: 13, type: '' },
  665. { startIndex: 14, type: 'string.ps1' }
  666. ]}, {
  667. line: ' a string',
  668. tokens: [
  669. { startIndex: 0, type: 'string.ps1' }
  670. ]}, {
  671. line: ' still "@ a string $withVar',
  672. tokens: [
  673. { startIndex: 0, type: 'string.ps1' },
  674. { startIndex: 20, type: 'variable.ps1' }
  675. ]}, {
  676. line: ' still a string `$noVar',
  677. tokens: [
  678. { startIndex: 0, type: 'string.ps1' },
  679. { startIndex: 17, type: 'string.escape.ps1' },
  680. { startIndex: 19, type: 'string.ps1' }
  681. ]}, {
  682. line: '',
  683. tokens: [
  684. ]}, {
  685. line: '"@ still a string',
  686. tokens: [
  687. { startIndex: 0, type: 'string.ps1' },
  688. { startIndex: 2, type: '' }
  689. ]}]
  690. ]);