@@ -460,6 +460,96 @@ describe('brightscript.tmlanguage.json', () => {
460460 ` ) ;
461461 } ) ;
462462
463+ it ( 'interface as param name does not break later tokens' , async ( ) => {
464+ await testGrammar ( `
465+ function test(interface as string)
466+ ' ^^^^^^ storage.type.brs
467+ ' ^^ keyword.control.as.brs
468+ ' ^^^^^^^^^ variable.parameter.brs
469+ ' ^^^^ entity.name.function.brs
470+ '^^^^^^^ keyword.declaration.function.brs
471+ end function
472+ '^^^^^^^^^^^^ keyword.declaration.function.brs
473+ ` ) ;
474+ } ) ;
475+
476+ it ( 'does not match array literal comma as param separator' , async ( ) => {
477+ await testGrammar ( `
478+ function test(items = [1, 2])
479+ ' ^ constant.numeric.brs
480+ ' ^^^^^ entity.name.variable.local.brs
481+ ' ^^^^ entity.name.function.brs
482+ ` ) ;
483+ } ) ;
484+
485+ it ( 'does not match expression comma as param separator' , async ( ) => {
486+ await testGrammar ( `
487+ function test(value = (calc(), 5))
488+ ' ^ constant.numeric.brs
489+ ' ^^^^^ entity.name.variable.local.brs
490+ ` ) ;
491+ } ) ;
492+
493+ it ( 'handles param with newline before as keyword' , async ( ) => {
494+ await testGrammar ( `
495+ function test(param as string)
496+ ' ^^^^^^ storage.type.brs
497+ ' ^^ keyword.control.as.brs
498+ ` ) ;
499+ } ) ;
500+
501+ it ( 'distinguishes param type from type cast in default value' , async ( ) => {
502+ await testGrammar ( `
503+ function test(a as integer, b = val as string)
504+ ' ^^^^^^ storage.type.brs
505+ ' ^^ keyword.control.brs
506+ ' ^ entity.name.variable.local.brs
507+ ` ) ;
508+ } ) ;
509+
510+ it ( 'handles multiple spaces between param and as' , async ( ) => {
511+ await testGrammar ( `
512+ function test(param as string)
513+ ' ^^^^^^ storage.type.brs
514+ ' ^^ keyword.control.as.brs
515+ ' ^^^^^ variable.parameter.brs
516+ ` ) ;
517+ } ) ;
518+
519+ it ( 'handles function call with comma in default param value' , async ( ) => {
520+ await testGrammar ( `
521+ function test(val = call(a, b))
522+ ' ^ entity.name.variable.local.brs
523+ ' ^^^ entity.name.variable.local.brs
524+ ` ) ;
525+ } ) ;
526+
527+ it ( 'handles nested function declaration as default value' , async ( ) => {
528+ await testGrammar ( `
529+ function outer(cb = function(x as integer)
530+ ' ^^^^^^^ storage.type.brs
531+ ' ^^ keyword.control.as.brs
532+ ' ^ variable.parameter.brs
533+ ` ) ;
534+ } ) ;
535+
536+ it ( 'does not match interface field as param' , async ( ) => {
537+ await testGrammar ( `
538+ interface Test
539+ field as string
540+ ' ^^^^^^ storage.type.brs
541+ ' ^^ keyword.control.as.brs
542+ ' ^^^^^ variable.object.property.brs
543+ ` ) ;
544+ } ) ;
545+
546+ it ( 'handles param starting with number (invalid identifier)' , async ( ) => {
547+ await testGrammar ( `
548+ function test(123param as string)
549+ ' ^^^ variable.parameter.brs
550+ ` ) ;
551+ } ) ;
552+
463553 it ( 'colorizes @param without name' , async ( ) => {
464554 await testGrammar ( `
465555 t'@type {boolean}
@@ -767,8 +857,8 @@ describe('brightscript.tmlanguage.json', () => {
767857 ' ^^^^^^ storage.type.brs
768858 ' ^^ keyword.control.brs
769859 ' ^^^^^^^^ storage.type.brs
770- ' ^^ keyword.control.brs
771- ' ^^^^^ entity.name. variable.local .brs
860+ ' ^^ keyword.control.as. brs
861+ ' ^^^^^ variable.parameter .brs
772862 ' ^^^^^ entity.name.function.brs
773863 '^^^ keyword.declaration.function.brs
774864
@@ -875,8 +965,8 @@ describe('brightscript.tmlanguage.json', () => {
875965 await testGrammar ( `
876966 sub nameless(rnd as dynamic)
877967 ' ^^^^^^^ storage.type.brs
878- ' ^^ keyword.control.brs
879- ' ^^^ entity.name. variable.local .brs
968+ ' ^^ keyword.control.as. brs
969+ ' ^^^ variable.parameter .brs
880970 ' ^^^^^^^^ entity.name.function.brs
881971 '^^^ keyword.declaration.function.brs
882972
@@ -969,8 +1059,8 @@ describe('brightscript.tmlanguage.json', () => {
9691059 await testGrammar ( `
9701060 sub rnd(randomVal as Dynamic, rnd as dynamic)
9711061 ' ^^^^^^^ storage.type.brs
972- ' ^^ keyword.control.brs
973- ' ^^^ entity.name. variable.local .brs
1062+ ' ^^ keyword.control.as. brs
1063+ ' ^^^ variable.parameter .brs
9741064 ' ^^^^^^^ storage.type.brs
9751065 ' ^^ keyword.control.brs
9761066 ' ^^^^^^^^^ entity.name.variable.local.brs
@@ -1120,8 +1210,8 @@ describe('brightscript.tmlanguage.json', () => {
11201210 ' ^^^^^^ storage.type.brs
11211211 ' ^^ keyword.control.brs
11221212 ' ^^^^^^^^ storage.type.brs
1123- ' ^^ keyword.control.brs
1124- ' ^^^^^ entity.name. variable.local .brs
1213+ ' ^^ keyword.control.as. brs
1214+ ' ^^^^^ variable.parameter .brs
11251215 ' ^^^^^ entity.name.function.brs
11261216 ' ^^^ keyword.declaration.function.brs
11271217 '^^^^^^ storage.modifier.brs
@@ -1183,8 +1273,8 @@ describe('brightscript.tmlanguage.json', () => {
11831273 ' ^^^^^^ storage.type.brs
11841274 ' ^^ keyword.control.brs
11851275 ' ^^^^^^^^ storage.type.brs
1186- ' ^^ keyword.control.brs
1187- ' ^^^^^ entity.name. variable.local .brs
1276+ ' ^^ keyword.control.as. brs
1277+ ' ^^^^^ variable.parameter .brs
11881278 ' ^^^^^ entity.name.function.brs
11891279 ' ^^^ keyword.declaration.function.brs
11901280 ' ^^^^^^^^ storage.modifier.brs
@@ -1230,8 +1320,8 @@ describe('brightscript.tmlanguage.json', () => {
12301320 ' ^^^^^^ storage.type.brs
12311321 ' ^^ keyword.control.brs
12321322 ' ^^^^^^^^ storage.type.brs
1233- ' ^^ keyword.control.brs
1234- ' ^^^^^ entity.name. variable.local .brs
1323+ ' ^^ keyword.control.as. brs
1324+ ' ^^^^^ variable.parameter .brs
12351325 ' ^^^^^^^^ keyword.declaration.function.brs
12361326 '^^^ entity.name.variable.local.brs
12371327
@@ -1257,8 +1347,8 @@ describe('brightscript.tmlanguage.json', () => {
12571347 ' ^^^^^^ storage.type.brs
12581348 ' ^^ keyword.control.brs
12591349 ' ^^^^^^^^ storage.type.brs
1260- ' ^^ keyword.control.brs
1261- ' ^^^^^ entity.name. variable.local .brs
1350+ ' ^^ keyword.control.as. brs
1351+ ' ^^^^^ variable.parameter .brs
12621352 ' ^^^^^^^^ keyword.declaration.function.brs
12631353
12641354 end function
@@ -1287,7 +1377,7 @@ describe('brightscript.tmlanguage.json', () => {
12871377 } ) ;
12881378
12891379 it ( 'colorizes class_roku_builtin correctly' , async ( ) => {
1290- async function testRokuClass ( className : string ) {
1380+ async function testRokuClass ( className : string ) {
12911381 return testGrammar ( `
12921382 var = createObject("${ className } ")
12931383 ' ${ '^' . repeat ( className . length ) } support.class.brs
@@ -1577,7 +1667,7 @@ describe('brightscript.tmlanguage.json', () => {
15771667 } ) ;
15781668
15791669 it ( 'does NOT colorize class_roku_builtin if exact match is not found' , async ( ) => {
1580- async function testRokuClass ( className : string ) {
1670+ async function testRokuClass ( className : string ) {
15811671 return testGrammar ( `
15821672 var = createObject("${ className } ")
15831673 ' ${ '^' . repeat ( className . length ) } string.quoted.double.brs
0 commit comments