1
0

java.test.ts 18 KB

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