powershell.test.ts 20 KB

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