From 3e5266a2a437060be319c3373f4945341806d436 Mon Sep 17 00:00:00 2001 From: Christopher Dwyer-Perkins Date: Thu, 14 Nov 2024 09:24:25 -0400 Subject: [PATCH 1/5] Added AppManager AppMemoryMonitor AppMemoryMonitorEvent coloring --- syntaxes/brightscript.tmLanguage.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/syntaxes/brightscript.tmLanguage.json b/syntaxes/brightscript.tmLanguage.json index cc429074..2c63db55 100644 --- a/syntaxes/brightscript.tmLanguage.json +++ b/syntaxes/brightscript.tmLanguage.json @@ -981,7 +981,7 @@ "name": "support.function.component.brs" }, "class_roku_builtin": { - "match": "(?i:\\bro(R(ss(Parser|Article)|e(sourceManager|ctangle|ad(File|WriteFile)|gistry(Section)?))|G(pio(Button|ControlPort)|lobal)|XML(Element|List)|MessagePort|AppInfo|Array|AssociativeArray|AudioGuide|AudioMetadata|AudioPlayer|AudioResource|Bitmap|Boolean|ByteArray|CaptionRenderer|ChannelStore|CodeRegistrationScreen|Compositor|DataGramSocket|DateTime|DeviceInfo|Double|IntrinsicDouble|EVPCipher|EVPDigest|FileSystem|Float|Font|FontMetrics|FontRegistry|Function|GridScreen|HdmiStatus|HMAC|HttpAgent|ImageCanvas|ImageMetadata|Input|Int|Invalid|KeyboardScreen|List|ListScreen|Localization|LongInteger|MessageDialog|MessagePort|Microphone|OneLineDialog|ParagraphScreen|Path|PinEntryDialog|PosterScreen|ProgramGuide|Regex|Region|Registry|RegistrySection|RSA|Screen|SearchHistory|SearchScreen|SlideShow|SocketAddress|SpringboardScreen|Sprite|StreamSocket|String|SystemLog|TextScreen|TextToSpeech|TextureManager|TextureRequest|Timespan|Tuner|UrlTransfer|VideoPlayer|VideoScreen|XMLElement|XMLList|SGScreen|SGNode|SGNodeEvent|SGScreenEvent|AudioPlayerEvent|CaptionRendererEvent|CECStatusEvent|ChannelStoreEvent|CodeRegistrationScreenEvent|DeviceInfoEvent|FileSystemEvent|GridScreenEvent|HdmiHotPlugEvent|HdmiStatusEvent|ImageCanvasEvent|InputEvent|KeyboardScreenEvent|ListScreenEvent|MessageDialogEvent|MicrophoneEvent|OneLineDialogEvent|ParagraphScreenEvent|PinEntryDialogEvent|PosterScreenEvent|SearchScreenEvent|SlideShowEvent|SocketEvent|SpringboardScreenEvent|SystemLogEvent|TextScreenEvent|TextToSpeechEvent|TextureRequestEvent|TunerEvent|UniversalControlEvent|UrlEvent|VideoPlayerEvent|VideoScreenEvent|B(yteArray|oolean|r(Sub|ightPackage))|S(ystemTime|t(orageInfo|ring( )?)|erialPort( )?)|NetworkConfiguration|C(ontrol(Down( )?|Up|Port)|ecInterface|lockWidget|reateFile)|T(imer|ouchScreen( )?|ext(Field|Widget))|I(RRemote( )?|n(t|valid)|mage(Player|Widget))|D(eviceInfo( )?|at(eTime|agram(Receiver|Sender)))|Url(Transfer|Event)|Video(Mode|Input|Player|Event)|Keyboard(Press( )?| )?|Quadravox(Button( )?|SNS5( )?)|Float|List|A(ssociativeArray|udio(Player|Event)|ppendFile|rray))\\b)", + "match": "(?i:\\bro(R(ss(Parser|Article)|e(sourceManager|ctangle|ad(File|WriteFile)|gistry(Section)?))|G(pio(Button|ControlPort)|lobal)|XML(Element|List)|MessagePort|AppInfo|AppManager|AppMemoryMonitor|AppMemoryMonitorEvent|Array|AssociativeArray|AudioGuide|AudioMetadata|AudioPlayer|AudioResource|Bitmap|Boolean|ByteArray|CaptionRenderer|ChannelStore|CodeRegistrationScreen|Compositor|DataGramSocket|DateTime|DeviceInfo|Double|IntrinsicDouble|EVPCipher|EVPDigest|FileSystem|Float|Font|FontMetrics|FontRegistry|Function|GridScreen|HdmiStatus|HMAC|HttpAgent|ImageCanvas|ImageMetadata|Input|Int|Invalid|KeyboardScreen|List|ListScreen|Localization|LongInteger|MessageDialog|MessagePort|Microphone|OneLineDialog|ParagraphScreen|Path|PinEntryDialog|PosterScreen|ProgramGuide|Regex|Region|Registry|RegistrySection|RSA|Screen|SearchHistory|SearchScreen|SlideShow|SocketAddress|SpringboardScreen|Sprite|StreamSocket|String|SystemLog|TextScreen|TextToSpeech|TextureManager|TextureRequest|Timespan|Tuner|UrlTransfer|VideoPlayer|VideoScreen|XMLElement|XMLList|SGScreen|SGNode|SGNodeEvent|SGScreenEvent|AudioPlayerEvent|CaptionRendererEvent|CECStatusEvent|ChannelStoreEvent|CodeRegistrationScreenEvent|DeviceInfoEvent|FileSystemEvent|GridScreenEvent|HdmiHotPlugEvent|HdmiStatusEvent|ImageCanvasEvent|InputEvent|KeyboardScreenEvent|ListScreenEvent|MessageDialogEvent|MicrophoneEvent|OneLineDialogEvent|ParagraphScreenEvent|PinEntryDialogEvent|PosterScreenEvent|SearchScreenEvent|SlideShowEvent|SocketEvent|SpringboardScreenEvent|SystemLogEvent|TextScreenEvent|TextToSpeechEvent|TextureRequestEvent|TunerEvent|UniversalControlEvent|UrlEvent|VideoPlayerEvent|VideoScreenEvent|B(yteArray|oolean|r(Sub|ightPackage))|S(ystemTime|t(orageInfo|ring( )?)|erialPort( )?)|NetworkConfiguration|C(ontrol(Down( )?|Up|Port)|ecInterface|lockWidget|reateFile)|T(imer|ouchScreen( )?|ext(Field|Widget))|I(RRemote( )?|n(t|valid)|mage(Player|Widget))|D(eviceInfo( )?|at(eTime|agram(Receiver|Sender)))|Url(Transfer|Event)|Video(Mode|Input|Player|Event)|Keyboard(Press( )?| )?|Quadravox(Button( )?|SNS5( )?)|Float|List|A(ssociativeArray|udio(Player|Event)|ppendFile|rray))\\b)", "name": "support.class.brs" }, "region_comment": { From 38e2bdfa8521a7886efa4cef96e1b5eaf3f709bc Mon Sep 17 00:00:00 2001 From: Christopher Dwyer-Perkins Date: Thu, 14 Nov 2024 10:23:37 -0400 Subject: [PATCH 2/5] Potental fix for numeric literal colorization --- src/grammar/brightscript.tmLanguage.spec.ts | 67 +++++++++++++++++++++ syntaxes/brightscript.tmLanguage.json | 14 ++++- 2 files changed, 79 insertions(+), 2 deletions(-) diff --git a/src/grammar/brightscript.tmLanguage.spec.ts b/src/grammar/brightscript.tmLanguage.spec.ts index 99a369be..a9507d66 100644 --- a/src/grammar/brightscript.tmLanguage.spec.ts +++ b/src/grammar/brightscript.tmLanguage.spec.ts @@ -6,6 +6,73 @@ import { standardizePath as s } from 'brighterscript'; const brightscriptTmlanguagePath = s`${__dirname}/../../syntaxes/brightscript.tmLanguage.json`; describe('brightscript.tmlanguage.json', () => { + it('colors numerics correctly', async () => { + await testGrammar(` + var = 1 + ' ^ constant.numeric.brs + '^^^ entity.name.variable.local.brs + `); + + await testGrammar(` + var = 1.1 + ' ^ constant.numeric.brs + ' ^ constant.numeric.brs + '^^^ entity.name.variable.local.brs + `); + + await testGrammar(` + var = .1 + ' ^ constant.numeric.brs + '^^^ entity.name.variable.local.brs + `); + + await testGrammar(` + var = 0x2 + ' ^^^ constant.numeric.brs + '^^^ entity.name.variable.local.brs + `); + + await testGrammar(` + var = 1.8e+308 + ' ^^^^^^^^ constant.numeric.brs + '^^^ entity.name.variable.local.brs + `); + + await testGrammar(` + var = 0x2 + ' ^^^ constant.numeric.brs + '^^^ entity.name.variable.local.brs + `); + + await testGrammar(` + var = 0% + ' ^ source.brs + ' ^ constant.numeric.brs + '^^^ entity.name.variable.local.brs + `); + + await testGrammar(` + var = 0! + ' ^ source.brs + ' ^ constant.numeric.brs + '^^^ entity.name.variable.local.brs + `); + + await testGrammar(` + var = 0# + ' ^ source.brs + ' ^ constant.numeric.brs + '^^^ entity.name.variable.local.brs + `); + + await testGrammar(` + var = 0& + ' ^ source.brs + ' ^ constant.numeric.brs + '^^^ entity.name.variable.local.brs + `); + }); + it('colors m, m.top, m.global, and super correctly', async () => { await testGrammar(` super.doSomething() diff --git a/syntaxes/brightscript.tmLanguage.json b/syntaxes/brightscript.tmLanguage.json index 2c63db55..e7ac5009 100644 --- a/syntaxes/brightscript.tmLanguage.json +++ b/syntaxes/brightscript.tmLanguage.json @@ -82,6 +82,9 @@ { "include": "#function_call" }, + { + "include": "#numeric_literal" + }, { "include": "#object_properties" }, @@ -581,8 +584,7 @@ ] }, { - "match": "\\b((0(x|X)[0-9a-fA-F]*)|(([0-9]+\\.?[0-9]*)|(\\.[0-9]+))((e|E)(\\+|-)?[0-9]+)?)(L|l|UL|ul|u|U|F|f)?\\b", - "name": "constant.numeric.brs" + "include": "#numeric_literal" }, { "patterns": [ @@ -606,6 +608,14 @@ } ] }, + "numeric_literal": { + "patterns": [ + { + "match": "\\b((0(x|X)[0-9a-fA-F]*)|(([0-9]+\\.?[0-9]*)|(\\.[0-9]+))((e|E)(\\+|-)?[0-9]+)?)(L|l|UL|ul|u|U|F|f)?\\b", + "name": "constant.numeric.brs" + } + ] + }, "comment": { "patterns": [ { From 5bf7d8ac88b683bc1906708a6aec981979994ac6 Mon Sep 17 00:00:00 2001 From: Christopher Dwyer-Perkins Date: Thu, 14 Nov 2024 11:09:39 -0400 Subject: [PATCH 3/5] Better unit tests --- src/grammar/brightscript.tmLanguage.spec.ts | 96 +++++++++++++++++++++ 1 file changed, 96 insertions(+) diff --git a/src/grammar/brightscript.tmLanguage.spec.ts b/src/grammar/brightscript.tmLanguage.spec.ts index 99a369be..186901f2 100644 --- a/src/grammar/brightscript.tmLanguage.spec.ts +++ b/src/grammar/brightscript.tmLanguage.spec.ts @@ -486,8 +486,104 @@ describe('brightscript.tmlanguage.json', () => { end class `); }); + + it('colorizes class_roku_builtin correctly', async () => { + async function testRokuClass (className: string) { + return testGrammar(` + var = createObject("${className}") + ' ${'^'.repeat(className.length)} support.class.brs + ' ^^^^^^^^^^^^ entity.name.function.brs + '^^^ entity.name.variable.local.brs + `); + } + + await testRokuClass('roAppInfo'); + await testRokuClass('roAppManager'); + await testRokuClass('roAppMemoryMonitor'); + await testRokuClass('roAppMemoryMonitorEvent'); + await testRokuClass('roArray'); + await testRokuClass('roAssociativeArray'); + await testRokuClass('roAudioGuide'); + await testRokuClass('roAudioMetadata'); + await testRokuClass('roAudioPlayer'); + await testRokuClass('roAudioPlayerEvent'); + await testRokuClass('roAudioResource'); + await testRokuClass('roBitmap'); + await testRokuClass('roBoolean'); + await testRokuClass('roByteArray'); + await testRokuClass('roCECStatus'); + await testRokuClass('roCECStatusEvent'); + await testRokuClass('roChannelStore'); + await testRokuClass('roChannelStoreEvent'); + await testRokuClass('roCompositor'); + await testRokuClass('roDataGramSocket'); + await testRokuClass('roDateTime'); + await testRokuClass('roDeviceCrypto'); + await testRokuClass('roDeviceInfo'); + await testRokuClass('roDeviceInfoEvent'); + await testRokuClass('roDouble'); + await testRokuClass('roDsa'); + await testRokuClass('roEVPCipher'); + await testRokuClass('roEVPDigest'); + await testRokuClass('roFileSystem'); + await testRokuClass('roFileSystemEvent'); + await testRokuClass('roFloat'); + await testRokuClass('roFont'); + await testRokuClass('roFontRegistry'); + await testRokuClass('roFunction'); + await testRokuClass('roHdmiStatus'); + await testRokuClass('roHdmiStatusEvent'); + await testRokuClass('roHMAC'); + await testRokuClass('roHttpAgent'); + await testRokuClass('roImageMetaData'); + await testRokuClass('roInput'); + await testRokuClass('roInputEvent'); + await testRokuClass('roInt'); + await testRokuClass('roInvalid'); + await testRokuClass('roList'); + await testRokuClass('roLocalization'); + await testRokuClass('roLongInteger'); + await testRokuClass('roMessagePort'); + await testRokuClass('roMicrophone'); + await testRokuClass('roMicrophoneEvent'); + await testRokuClass('roPath'); + await testRokuClass('roProgramGuide'); + await testRokuClass('roRegex'); + await testRokuClass('roRegion'); + await testRokuClass('roRegistry'); + await testRokuClass('roRegistrySection'); + await testRokuClass('roRemoteInfo'); + await testRokuClass('roRSA'); + await testRokuClass('roScreen'); + await testRokuClass('roSGNode'); + await testRokuClass('roSGNodeEvent'); + await testRokuClass('roSGScreen'); + await testRokuClass('roSGScreenEvent'); + await testRokuClass('roSocketAddress'); + await testRokuClass('roSocketEvent'); + await testRokuClass('roSprite'); + await testRokuClass('roStreamSocket'); + await testRokuClass('roString'); + await testRokuClass('roSystemlog'); + await testRokuClass('roSystemLogEvent'); + await testRokuClass('roTextToSpeech'); + await testRokuClass('roTextToSpeechEvent'); + await testRokuClass('roTextureManager'); + await testRokuClass('roTextureRequest'); + await testRokuClass('roTextureRequestEvent'); + await testRokuClass('roTimespan'); + await testRokuClass('roUniversalControlEvent'); + await testRokuClass('roUrlEvent'); + await testRokuClass('roUrlTransfer'); + await testRokuClass('roVideoPlayer'); + await testRokuClass('roVideoPlayerEvent'); + await testRokuClass('roXMLElement'); + await testRokuClass('roXMLList'); + + }); }); + const registries = new Cache(); async function testGrammar(testCaseText: string) { testCaseText = `' SYNTAX TEST "source.brs" +AllowMiddleLineAssertions` + testCaseText; From 6cdf152bceced252aacc4d1daf7dbc34b9f579ba Mon Sep 17 00:00:00 2001 From: Christopher Dwyer-Perkins Date: Thu, 14 Nov 2024 11:10:45 -0400 Subject: [PATCH 4/5] Added missing built ins for roCECStatus, roDeviceCrypto, roDsa, and roRemoteInfo --- syntaxes/brightscript.tmLanguage.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/syntaxes/brightscript.tmLanguage.json b/syntaxes/brightscript.tmLanguage.json index 2c63db55..88c02d7a 100644 --- a/syntaxes/brightscript.tmLanguage.json +++ b/syntaxes/brightscript.tmLanguage.json @@ -981,7 +981,7 @@ "name": "support.function.component.brs" }, "class_roku_builtin": { - "match": "(?i:\\bro(R(ss(Parser|Article)|e(sourceManager|ctangle|ad(File|WriteFile)|gistry(Section)?))|G(pio(Button|ControlPort)|lobal)|XML(Element|List)|MessagePort|AppInfo|AppManager|AppMemoryMonitor|AppMemoryMonitorEvent|Array|AssociativeArray|AudioGuide|AudioMetadata|AudioPlayer|AudioResource|Bitmap|Boolean|ByteArray|CaptionRenderer|ChannelStore|CodeRegistrationScreen|Compositor|DataGramSocket|DateTime|DeviceInfo|Double|IntrinsicDouble|EVPCipher|EVPDigest|FileSystem|Float|Font|FontMetrics|FontRegistry|Function|GridScreen|HdmiStatus|HMAC|HttpAgent|ImageCanvas|ImageMetadata|Input|Int|Invalid|KeyboardScreen|List|ListScreen|Localization|LongInteger|MessageDialog|MessagePort|Microphone|OneLineDialog|ParagraphScreen|Path|PinEntryDialog|PosterScreen|ProgramGuide|Regex|Region|Registry|RegistrySection|RSA|Screen|SearchHistory|SearchScreen|SlideShow|SocketAddress|SpringboardScreen|Sprite|StreamSocket|String|SystemLog|TextScreen|TextToSpeech|TextureManager|TextureRequest|Timespan|Tuner|UrlTransfer|VideoPlayer|VideoScreen|XMLElement|XMLList|SGScreen|SGNode|SGNodeEvent|SGScreenEvent|AudioPlayerEvent|CaptionRendererEvent|CECStatusEvent|ChannelStoreEvent|CodeRegistrationScreenEvent|DeviceInfoEvent|FileSystemEvent|GridScreenEvent|HdmiHotPlugEvent|HdmiStatusEvent|ImageCanvasEvent|InputEvent|KeyboardScreenEvent|ListScreenEvent|MessageDialogEvent|MicrophoneEvent|OneLineDialogEvent|ParagraphScreenEvent|PinEntryDialogEvent|PosterScreenEvent|SearchScreenEvent|SlideShowEvent|SocketEvent|SpringboardScreenEvent|SystemLogEvent|TextScreenEvent|TextToSpeechEvent|TextureRequestEvent|TunerEvent|UniversalControlEvent|UrlEvent|VideoPlayerEvent|VideoScreenEvent|B(yteArray|oolean|r(Sub|ightPackage))|S(ystemTime|t(orageInfo|ring( )?)|erialPort( )?)|NetworkConfiguration|C(ontrol(Down( )?|Up|Port)|ecInterface|lockWidget|reateFile)|T(imer|ouchScreen( )?|ext(Field|Widget))|I(RRemote( )?|n(t|valid)|mage(Player|Widget))|D(eviceInfo( )?|at(eTime|agram(Receiver|Sender)))|Url(Transfer|Event)|Video(Mode|Input|Player|Event)|Keyboard(Press( )?| )?|Quadravox(Button( )?|SNS5( )?)|Float|List|A(ssociativeArray|udio(Player|Event)|ppendFile|rray))\\b)", + "match": "(?i:\\bro(R(ss(Parser|Article)|e(sourceManager|ctangle|ad(File|WriteFile)|gistry(Section)?))|G(pio(Button|ControlPort)|lobal)|XML(Element|List)|MessagePort|AppInfo|AppManager|AppMemoryMonitor|AppMemoryMonitorEvent|Array|AssociativeArray|AudioGuide|AudioMetadata|AudioPlayer|AudioResource|Bitmap|Boolean|ByteArray|CaptionRenderer|CECStatus|ChannelStore|CodeRegistrationScreen|Compositor|DataGramSocket|DateTime|DeviceInfo|DeviceCrypto|Double|Dsa|IntrinsicDouble|EVPCipher|EVPDigest|FileSystem|Float|Font|FontMetrics|FontRegistry|Function|GridScreen|HdmiStatus|HMAC|HttpAgent|ImageCanvas|ImageMetadata|Input|Int|Invalid|KeyboardScreen|List|ListScreen|Localization|LongInteger|MessageDialog|MessagePort|Microphone|OneLineDialog|ParagraphScreen|Path|PinEntryDialog|PosterScreen|ProgramGuide|Regex|Region|Registry|RegistrySection|RemoteInfo|RSA|Screen|SearchHistory|SearchScreen|SlideShow|SocketAddress|SpringboardScreen|Sprite|StreamSocket|String|SystemLog|TextScreen|TextToSpeech|TextureManager|TextureRequest|Timespan|Tuner|UrlTransfer|VideoPlayer|VideoScreen|XMLElement|XMLList|SGScreen|SGNode|SGNodeEvent|SGScreenEvent|AudioPlayerEvent|CaptionRendererEvent|CECStatusEvent|ChannelStoreEvent|CodeRegistrationScreenEvent|DeviceInfoEvent|FileSystemEvent|GridScreenEvent|HdmiHotPlugEvent|HdmiStatusEvent|ImageCanvasEvent|InputEvent|KeyboardScreenEvent|ListScreenEvent|MessageDialogEvent|MicrophoneEvent|OneLineDialogEvent|ParagraphScreenEvent|PinEntryDialogEvent|PosterScreenEvent|SearchScreenEvent|SlideShowEvent|SocketEvent|SpringboardScreenEvent|SystemLogEvent|TextScreenEvent|TextToSpeechEvent|TextureRequestEvent|TunerEvent|UniversalControlEvent|UrlEvent|VideoPlayerEvent|VideoScreenEvent|B(yteArray|oolean|r(Sub|ightPackage))|S(ystemTime|t(orageInfo|ring( )?)|erialPort( )?)|NetworkConfiguration|C(ontrol(Down( )?|Up|Port)|ecInterface|lockWidget|reateFile)|T(imer|ouchScreen( )?|ext(Field|Widget))|I(RRemote( )?|n(t|valid)|mage(Player|Widget))|D(eviceInfo( )?|at(eTime|agram(Receiver|Sender)))|Url(Transfer|Event)|Video(Mode|Input|Player|Event)|Keyboard(Press( )?| )?|Quadravox(Button( )?|SNS5( )?)|Float|List|A(ssociativeArray|udio(Player|Event)|ppendFile|rray))\\b)", "name": "support.class.brs" }, "region_comment": { From eb9cb42ee86e845c702815d8feb5f93a311e31fc Mon Sep 17 00:00:00 2001 From: Christopher Dwyer-Perkins Date: Thu, 14 Nov 2024 11:12:27 -0400 Subject: [PATCH 5/5] Update src/grammar/brightscript.tmLanguage.spec.ts --- src/grammar/brightscript.tmLanguage.spec.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/grammar/brightscript.tmLanguage.spec.ts b/src/grammar/brightscript.tmLanguage.spec.ts index 186901f2..8d8fc925 100644 --- a/src/grammar/brightscript.tmLanguage.spec.ts +++ b/src/grammar/brightscript.tmLanguage.spec.ts @@ -583,7 +583,6 @@ describe('brightscript.tmlanguage.json', () => { }); }); - const registries = new Cache(); async function testGrammar(testCaseText: string) { testCaseText = `' SYNTAX TEST "source.brs" +AllowMiddleLineAssertions` + testCaseText;