Skip to content

Commit

Permalink
new Foo and type params.
Browse files Browse the repository at this point in the history
  • Loading branch information
thesoftwarephilosopher committed Aug 22, 2024
1 parent adb1d76 commit 80abb57
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions site/token-provider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ export const tokenProvider: monaco.languages.IMonarchLanguage = {
// foo(
[/(#?[a-z_][\w\$]*)(\()/, ['method', 'delimiter']],

// new Foo(
[/(new\s+)([A-Z][\w\$]*)(\()/, ['keyword', 'type.identifier', 'delimiter']],

// Foo(
[/([A-Z][\w\$]*)(\()/, ['function', 'delimiter']],

Expand All @@ -58,6 +61,9 @@ export const tokenProvider: monaco.languages.IMonarchLanguage = {
// regular expression: ensure it is terminated before beginning (otherwise it is an operator)
[/\/(?=([^\\\/]|\\.)+\/([dgimsuy]*)(\s*)(\.|;|,|\)|\]|\}|$))/, { token: 'regexp', bracket: '@open', next: '@regexp' }],

// type params (to avoid parsing them as jsx)
[/</, 'delimiter', '@typeparams'],

// delimiters and operators
[/[()\[\]]/, '@brackets'],
[/[<>](?!@symbols)/, '@brackets'],
Expand Down Expand Up @@ -145,6 +151,11 @@ export const tokenProvider: monaco.languages.IMonarchLanguage = {
[/`/, 'string', '@pop'],
],

typeparams: [
[/>/, 'delimiter', '@pop'],
{ include: 'common' },
],

bracketCounting: [
[/\{/, 'delimiter.bracket', '@bracketCounting'],
[/\}/, 'delimiter.bracket', '@pop'],
Expand Down

0 comments on commit 80abb57

Please sign in to comment.