From a467bb07747b6bdbabfabdee200395d7525dcd33 Mon Sep 17 00:00:00 2001 From: "alan.invents" Date: Fri, 21 Feb 2020 20:33:04 -0500 Subject: [PATCH 1/5] Create scala.ts --- src/scala/scala.ts | 229 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 229 insertions(+) create mode 100644 src/scala/scala.ts diff --git a/src/scala/scala.ts b/src/scala/scala.ts new file mode 100644 index 00000000..dfb52e5d --- /dev/null +++ b/src/scala/scala.ts @@ -0,0 +1,229 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ + +'use strict'; + +import IRichLanguageConfiguration = monaco.languages.LanguageConfiguration; +import ILanguage = monaco.languages.IMonarchLanguage; + +export const conf: IRichLanguageConfiguration = { + tokenPostfix: '.scala', + + keywords: [ + 'asInstanceOf', + 'catch', 'class', 'classOf', + 'def', 'do', + 'else', 'extends', + 'finally', 'for', 'foreach', 'forSome', + 'if', 'import', 'isInstanceOf', + 'match', + 'new', + 'object', + 'package', + 'return', + 'throw', 'trait', 'try', 'type', + 'until', + 'val', 'var', + 'while', 'with', + 'yield' + ], + + constants: [ + 'true', 'false', 'null', + 'this', 'super' + ], + + modifiers: [ + 'abstract', 'final', 'implicit', 'lazy', 'override', + 'private', 'protected', 'sealed' + ], + + name: /[a-z_$][\w$]*/, + + // we include these common regular expressions + symbols: /[=>))/, ['@brackets', 'white', 'variable']], + [/@name/, {cases: { + '@keywords': 'keyword', + '@modifiers': 'tag.id.pug', + '@constants': 'constant', + '@default': 'identifier' + }}], + [/[A-Z]\w*/, 'type.identifier'], + + // whitespace + {include: '@whitespace'}, + + // @ annotations. + [/@[a-zA-Z_$][\w$]*(?:\.[a-zA-Z_$][\w$]*)*/, 'annotation'], + + // delimiters and operators + [/[{}()]/, '@brackets'], + [/[\[\]]/, 'operator.scss'], + [/[=-]>|<-|>:|<:|<%/, 'keyword'], + [/@symbols/, 'operator'], + + // delimiter: after number because of .\d floats + [/[;,.]/, 'delimiter'], + + // characters + [/'[^\\']'/, 'string'], + [/(')(@escapes)(')/, ['string', 'string.escape', 'string']], + [/'/, 'string.invalid'] + ], + + comment: [ + [/[^\/*]+/, 'comment'], + [/\/\*/, 'comment', '@push'], // nested comment + ["\\*/", 'comment', '@pop'], + [/[\/*]/, 'comment'] + ], + + case: [ + [/\b_\*/, 'key'], + [/\b(_|true|false|null|this|super)\b/, 'keyword'], + [/\bif\b|=>/, 'keyword', '@pop'], + [/`@name`/, 'identifier'], + [/@name/, 'variable'], + [/:::?|\||@(?![a-z_$])/, 'keyword'], + {include: '@root'} + ], + + vardef: [ + [/\b_\*/, 'key'], + [/\b(_|true|false|null|this|super)\b/, 'keyword'], + [/@name/, 'variable'], + [/:::?|\||@(?![a-z_$])/, 'keyword'], + [/[=:]/, 'operator', '@pop'], + [/$/, 'white', '@pop'], + {include: '@root'} + ], + + string: [ + [/[^\\"\n\r]+/, 'string'], + [/@escapes/, 'string.escape'], + [/\\./, 'string.escape.invalid'], + [/"/, {token: 'string.quote', bracket: '@close', next: '@pop'}], + ], + + stringt: [ + [/[^\\"\n\r]+/, 'string'], + [/@escapes/, 'string.escape'], + [/\\./, 'string.escape.invalid'], + [/"""/, {token: 'string.quote', bracket: '@close', next: '@pop'}], + [/"/, 'string'] + ], + + fstring: [ + [/@escapes/, 'string.escape'], + [/"/, {token: 'string.quote', bracket: '@close', next: '@pop'}], + [/\$\$/, 'string'], + [/(\$)([a-z_]\w*)/, ['operator', 'identifier']], + [/\$\{/, 'operator', '@interp'], + [/%%/, 'string'], + [/(%)([\-#+ 0,(])(\d+|\.\d+|\d+\.\d+)(@fstring_conv)/, ['metatag', 'tag.id.pug', 'number', 'metatag']], + [/(%)(\d+|\.\d+|\d+\.\d+)(@fstring_conv)/, ['metatag', 'number', 'metatag']], + [/(%)([\-#+ 0,(])(@fstring_conv)/, ['metatag', 'tag.id.pug', 'metatag']], + [/(%)(@fstring_conv)/, ['metatag', 'metatag']], + [/./, 'string'] + ], + + fstringt: [ + [/@escapes/, 'string.escape'], + [/"""/, {token: 'string.quote', bracket: '@close', next: '@pop'}], + [/\$\$/, 'string'], + [/(\$)([a-z_]\w*)/, ['operator', 'identifier']], + [/\$\{/, 'operator', '@interp'], + [/%%/, 'string'], + [/(%)([\-#+ 0,(])(\d+|\.\d+|\d+\.\d+)(@fstring_conv)/, ['metatag', 'tag.id.pug', 'number', 'metatag']], + [/(%)(\d+|\.\d+|\d+\.\d+)(@fstring_conv)/, ['metatag', 'number', 'metatag']], + [/(%)([\-#+ 0,(])(@fstring_conv)/, ['metatag', 'tag.id.pug', 'metatag']], + [/(%)(@fstring_conv)/, ['metatag', 'metatag']], + [/./, 'string'] + ], + + sstring: [ + [/@escapes/, 'string.escape'], + [/"/, {token: 'string.quote', bracket: '@close', next: '@pop'}], + [/\$\$/, 'string'], + [/(\$)([a-z_]\w*)/, ['operator', 'identifier']], + [/\$\{/, 'operator', '@interp'], + [/./, 'string'] + ], + + sstringt: [ + [/@escapes/, 'string.escape'], + [/"""/, {token: 'string.quote', bracket: '@close', next: '@pop'}], + [/\$\$/, 'string'], + [/(\$)([a-z_]\w*)/, ['operator', 'identifier']], + [/\$\{/, 'operator', '@interp'], + [/./, 'string'] + ], + + interp: [ + [/\{/, 'operator', '@push'], + [/\}/, 'operator', '@pop'], + {include: '@root'} + ], + + rawstring: [ + [/[^"]/, 'string'], + [/"/, {token: 'string.quote', bracket: '@close', next: '@pop'}] + ], + + rawstringt: [ + [/[^"]/, 'string'], + [/"""/, {token: 'string.quote', bracket: '@close', next: '@pop'}], + [/"/, 'string'] + ], + + whitespace: [ + [/[ \t\r\n]+/, 'white'], + [/\/\*/, 'comment', '@comment'], + [/\/\/.*$/, 'comment'], + ], + }, +}; From b2a10419ce0b902c51545678bc34860edd29c972 Mon Sep 17 00:00:00 2001 From: "alan.invents" Date: Wed, 1 Jul 2020 18:52:31 -0400 Subject: [PATCH 2/5] Finish implementing Scala --- src/scala/scala.contribution.ts | 15 +++ src/scala/scala.test.ts | 38 +++++++ src/scala/scala.ts | 176 ++++++++++++++++++++++++-------- 3 files changed, 187 insertions(+), 42 deletions(-) create mode 100644 src/scala/scala.contribution.ts create mode 100644 src/scala/scala.test.ts diff --git a/src/scala/scala.contribution.ts b/src/scala/scala.contribution.ts new file mode 100644 index 00000000..84bd2178 --- /dev/null +++ b/src/scala/scala.contribution.ts @@ -0,0 +1,15 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ +'use strict'; + +import { registerLanguage } from '../_.contribution'; + +registerLanguage({ + id: 'scala', + extensions: ['.scala', '.sbt', '.sc'], + aliases: ['Scala', 'scala', 'SBT', 'Sbt', 'sbt', 'Dotty', 'dotty'], + mimetypes: ['text/x-scala', 'text/x-sbt', 'text/x-dotty'], + loader: () => import('./scala') +}); diff --git a/src/scala/scala.test.ts b/src/scala/scala.test.ts new file mode 100644 index 00000000..2f93a17d --- /dev/null +++ b/src/scala/scala.test.ts @@ -0,0 +1,38 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ + +'use strict'; + +import { testTokenization } from '../test/testRunner'; + +testTokenization('scala', [ + [{ + line: '//', + tokens: [ + {startIndex: 0, type: 'comment.scala'} + ] + }], + + [{ + line: ' // a comment', + tokens: [ + {startIndex: 0, type: 'white.scala'}, + {startIndex: 4, type: 'comment.scala'} + ] + }], + + [{ + line: 'var a = 1', + tokens: [ + {startIndex: 0, type: 'keyword.scala'}, + {startIndex: 3, type: 'white.scala'}, + {startIndex: 4, type: 'variable.scala'}, + {startIndex: 5, type: 'white.scala'}, + {startIndex: 6, type: 'operator.scala'}, + {startIndex: 7, type: 'white.scala'}, + {startIndex: 8, type: 'number.scala'} + ] + }] +]); diff --git a/src/scala/scala.ts b/src/scala/scala.ts index dfb52e5d..03b87972 100644 --- a/src/scala/scala.ts +++ b/src/scala/scala.ts @@ -9,8 +9,48 @@ import IRichLanguageConfiguration = monaco.languages.LanguageConfiguration; import ILanguage = monaco.languages.IMonarchLanguage; export const conf: IRichLanguageConfiguration = { + /* + * `...` is allowed as an identifier. + * $ is allowed in identifiers. + * unary_ is allowed as an identifier. + * _= is allowed as an identifier. + */ + wordPattern: /(unary_[@~!#%^&*()\-=+\\|:<>\/?]+)|([a-zA-Z_$][\w$]*?_=)|(`[^`]+`)|([a-zA-Z_$][\w$]*)/g, + comments: { + lineComment: '//', + blockComment: ['/*', '*/'], + }, + brackets: [ + ['{', '}'], + ['[', ']'], + ['(', ')'], + ], + autoClosingPairs: [ + { open: '{', close: '}' }, + { open: '[', close: ']' }, + { open: '(', close: ')' }, + { open: '"', close: '"' }, + { open: '\'', close: '\'' }, + ], + surroundingPairs: [ + { open: '{', close: '}' }, + { open: '[', close: ']' }, + { open: '(', close: ')' }, + { open: '"', close: '"' }, + { open: '\'', close: '\'' }, + ], + folding: { + markers: { + start: new RegExp("^\\s*//\\s*(?:(?:#?region\\b)|(?:))") + } + } +}; + +export const language = { tokenPostfix: '.scala', + // We can't easily add everything from Dotty, but we can at least add some of its keywords keywords: [ 'asInstanceOf', 'catch', 'class', 'classOf', @@ -18,7 +58,7 @@ export const conf: IRichLanguageConfiguration = { 'else', 'extends', 'finally', 'for', 'foreach', 'forSome', 'if', 'import', 'isInstanceOf', - 'match', + 'macro', 'match', 'new', 'object', 'package', @@ -27,7 +67,16 @@ export const conf: IRichLanguageConfiguration = { 'until', 'val', 'var', 'while', 'with', - 'yield' + 'yield', + + // Dotty-specific: + 'given', 'enum', 'then' + ], + + // Dotty-specific: + softKeywords: [ + 'as', 'export', 'extension', 'end', + 'derives', 'on' ], constants: [ @@ -40,10 +89,16 @@ export const conf: IRichLanguageConfiguration = { 'private', 'protected', 'sealed' ], - name: /[a-z_$][\w$]*/, + // Dotty-specific: + softModifiers: [ + 'inline', 'opaque', 'open', 'transparent', 'using' + ], + + name: /(?:[a-z_$][\w$]*|`[^`]+`)/, + type: /(?:[A-Z][\w$]*)/, // we include these common regular expressions - symbols: /[=>))/, ['@brackets', 'white', 'variable']], + [/\b(def[ \t]+)((?:unary_)?@symbols|@name(?:_=)|@name)/, ['keyword', 'keyword.flow']], + [/@name(?=[ \t]*:(?!:))/, 'variable'], + [/(\.)(@name|@symbols)/, ['operator', {token: 'keyword.flow', next: '@allowMethod'}]], + [/([{(])(\s*)(@name(?=\s*=>))/, ['@brackets', 'white', 'variable']], [/@name/, {cases: { '@keywords': 'keyword', + '@softKeywords': 'keyword', '@modifiers': 'tag.id.pug', - '@constants': 'constant', - '@default': 'identifier' + '@softModifiers': 'tag.id.pug', + '@constants': {token: 'constant', next: '@allowMethod'}, + '@default': {token: 'identifier', next: '@allowMethod'} }}], - [/[A-Z]\w*/, 'type.identifier'], + [/@type/, 'type', '@allowMethod'], // whitespace {include: '@whitespace'}, - + // @ annotations. [/@[a-zA-Z_$][\w$]*(?:\.[a-zA-Z_$][\w$]*)*/, 'annotation'], // delimiters and operators - [/[{}()]/, '@brackets'], - [/[\[\]]/, 'operator.scss'], - [/[=-]>|<-|>:|<:|<%/, 'keyword'], + [/[{(]/, '@brackets'], + [/[})]/, '@brackets', '@allowMethod'], + [/\[/, 'operator.scss'], + [/](?!\s*(?:va[rl]|def|type)\b)/, 'operator.scss', '@allowMethod'], + [/]/, 'operator.scss'], + [/([=-]>|<-|>:|<:|:>|<%)(?=[\s\w()[\]{},\."'`])/, 'keyword'], [/@symbols/, 'operator'], // delimiter: after number because of .\d floats - [/[;,.]/, 'delimiter'], + [/[;,\.]/, 'delimiter'], + + // symbols + [/'[a-zA-Z$][\w$]*(?!')/, 'attribute.name'], // characters - [/'[^\\']'/, 'string'], - [/(')(@escapes)(')/, ['string', 'string.escape', 'string']], + [/'[^\\']'/, 'string', '@allowMethod'], + [/(')(@escapes)(')/, ['string', 'string.escape', {token: 'string', next: '@allowMethod'}]], [/'/, 'string.invalid'] ], + import: [ + [/;/, 'delimiter', '@pop'], + [/^|$/, '', '@pop'], + [/[ \t]+/, 'white'], + [/[\n\r]+/, 'white', '@pop'], + [/\/\*/, 'comment', '@comment'], + [/@name|@type/, 'type'], + [/[(){}]/, '@brackets'], + [/[[\]]/, 'operator.scss'], + [/[\.,]/, 'delimiter'], + ], + + allowMethod: [ + [/^|$/, '', '@pop'], + [/[ \t]+/, 'white'], + [/[\n\r]+/, 'white', '@pop'], + [/\/\*/, 'comment', '@comment'], + [/(?==>[\s\w([{])/, 'keyword', '@pop'], + [/(@name|@symbols)(?=[ \t]*[[({"'`]|[ \t]+(?:[+-]?\.?\d|\w))/, { + cases: { + '@keywords': {token: 'keyword', next: '@pop'}, + '->|<-|>:|<:|<%': {token: 'keyword', next: '@pop'}, + '@default': {token: 'keyword.flow', next: '@pop'} + } + }], + ["", "", "@pop"] + ], + comment: [ [/[^\/*]+/, 'comment'], [/\/\*/, 'comment', '@push'], // nested comment - ["\\*/", 'comment', '@pop'], + [/\*\//, 'comment', '@pop'], [/[\/*]/, 'comment'] ], case: [ [/\b_\*/, 'key'], - [/\b(_|true|false|null|this|super)\b/, 'keyword'], + [/\b(_|true|false|null|this|super)\b/, 'keyword', '@allowMethod'], [/\bif\b|=>/, 'keyword', '@pop'], - [/`@name`/, 'identifier'], - [/@name/, 'variable'], + [/`[^`]+`/, 'identifier', '@allowMethod'], + [/@name/, 'variable', '@allowMethod'], [/:::?|\||@(?![a-z_$])/, 'keyword'], {include: '@root'} ], @@ -137,7 +225,7 @@ export const conf: IRichLanguageConfiguration = { [/\b(_|true|false|null|this|super)\b/, 'keyword'], [/@name/, 'variable'], [/:::?|\||@(?![a-z_$])/, 'keyword'], - [/[=:]/, 'operator', '@pop'], + [/=|:(?!:)/, 'operator', '@pop'], [/$/, 'white', '@pop'], {include: '@root'} ], @@ -146,20 +234,21 @@ export const conf: IRichLanguageConfiguration = { [/[^\\"\n\r]+/, 'string'], [/@escapes/, 'string.escape'], [/\\./, 'string.escape.invalid'], - [/"/, {token: 'string.quote', bracket: '@close', next: '@pop'}], + [/"/, {token: 'string.quote', bracket: '@close', switchTo: '@allowMethod'}], ], stringt: [ [/[^\\"\n\r]+/, 'string'], [/@escapes/, 'string.escape'], [/\\./, 'string.escape.invalid'], - [/"""/, {token: 'string.quote', bracket: '@close', next: '@pop'}], + [/"(?=""")/, 'string'], + [/"""/, {token: 'string.quote', bracket: '@close', switchTo: '@allowMethod'}], [/"/, 'string'] ], fstring: [ [/@escapes/, 'string.escape'], - [/"/, {token: 'string.quote', bracket: '@close', next: '@pop'}], + [/"/, {token: 'string.quote', bracket: '@close', switchTo: '@allowMethod'}], [/\$\$/, 'string'], [/(\$)([a-z_]\w*)/, ['operator', 'identifier']], [/\$\{/, 'operator', '@interp'], @@ -173,7 +262,8 @@ export const conf: IRichLanguageConfiguration = { fstringt: [ [/@escapes/, 'string.escape'], - [/"""/, {token: 'string.quote', bracket: '@close', next: '@pop'}], + [/"(?=""")/, 'string'], + [/"""/, {token: 'string.quote', bracket: '@close', switchTo: '@allowMethod'}], [/\$\$/, 'string'], [/(\$)([a-z_]\w*)/, ['operator', 'identifier']], [/\$\{/, 'operator', '@interp'], @@ -187,7 +277,7 @@ export const conf: IRichLanguageConfiguration = { sstring: [ [/@escapes/, 'string.escape'], - [/"/, {token: 'string.quote', bracket: '@close', next: '@pop'}], + [/"/, {token: 'string.quote', bracket: '@close', switchTo: '@allowMethod'}], [/\$\$/, 'string'], [/(\$)([a-z_]\w*)/, ['operator', 'identifier']], [/\$\{/, 'operator', '@interp'], @@ -196,7 +286,8 @@ export const conf: IRichLanguageConfiguration = { sstringt: [ [/@escapes/, 'string.escape'], - [/"""/, {token: 'string.quote', bracket: '@close', next: '@pop'}], + [/"(?=""")/, 'string'], + [/"""/, {token: 'string.quote', bracket: '@close', switchTo: '@allowMethod'}], [/\$\$/, 'string'], [/(\$)([a-z_]\w*)/, ['operator', 'identifier']], [/\$\{/, 'operator', '@interp'], @@ -204,19 +295,20 @@ export const conf: IRichLanguageConfiguration = { ], interp: [ - [/\{/, 'operator', '@push'], - [/\}/, 'operator', '@pop'], + [/{/, 'operator', '@push'], + [/}/, 'operator', '@pop'], {include: '@root'} ], rawstring: [ [/[^"]/, 'string'], - [/"/, {token: 'string.quote', bracket: '@close', next: '@pop'}] + [/"/, {token: 'string.quote', bracket: '@close', switchTo: '@allowMethod'}] ], rawstringt: [ [/[^"]/, 'string'], - [/"""/, {token: 'string.quote', bracket: '@close', next: '@pop'}], + [/"(?=""")/, 'string'], + [/"""/, {token: 'string.quote', bracket: '@close', switchTo: '@allowMethod'}], [/"/, 'string'] ], From b2e616bc5f93d7162e5cb0fddcc4647c0314a2e6 Mon Sep 17 00:00:00 2001 From: "alan.invents" Date: Wed, 1 Jul 2020 19:15:38 -0400 Subject: [PATCH 3/5] Edit monaco.contribution.ts... --- src/monaco.contribution.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/monaco.contribution.ts b/src/monaco.contribution.ts index 345fdd05..77065787 100644 --- a/src/monaco.contribution.ts +++ b/src/monaco.contribution.ts @@ -51,6 +51,7 @@ import './restructuredtext/restructuredtext.contribution'; import './ruby/ruby.contribution'; import './rust/rust.contribution'; import './sb/sb.contribution'; +import './scala/scala.contribution'; import './scheme/scheme.contribution'; import './scss/scss.contribution'; import './shell/shell.contribution'; From 87864636a3a82600410c8aedb6762ca97b38e98b Mon Sep 17 00:00:00 2001 From: Alex Dima Date: Thu, 27 Aug 2020 13:03:41 +0200 Subject: [PATCH 4/5] Rematch in default case --- src/scala/scala.test.ts | 32 +++++++++----------------------- src/scala/scala.ts | 2 +- 2 files changed, 10 insertions(+), 24 deletions(-) diff --git a/src/scala/scala.test.ts b/src/scala/scala.test.ts index a1063dfe..df03d3fa 100644 --- a/src/scala/scala.test.ts +++ b/src/scala/scala.test.ts @@ -8,20 +8,6 @@ import { testTokenization } from '../test/testRunner'; testTokenization('scala', [ - [{ - line: '//', - tokens: [ - {startIndex: 0, type: 'comment.scala'} - ] - }], - - [{ - line: ' // a comment', - tokens: [ - {startIndex: 0, type: 'white.scala'}, - {startIndex: 4, type: 'comment.scala'} - ] - }], [{ line: 'var a = 1', @@ -80,7 +66,7 @@ testTokenization('scala', [ { startIndex: 0, type: 'operator.scala' }, { startIndex: 1, type: 'identifier.scala' }, { startIndex: 7, type: 'white.scala' }, - { startIndex: 8, type: 'keyword.flow.scala' }, + { startIndex: 8, type: 'identifier.scala' }, { startIndex: 9, type: 'white.scala' }, { startIndex: 10, type: 'identifier.scala' } ] @@ -91,7 +77,7 @@ testTokenization('scala', [ tokens: [ { startIndex: 0, type: 'number.scala' }, { startIndex: 1, type: 'white.scala' }, - { startIndex: 2, type: 'keyword.flow.scala' }, // TODO + { startIndex: 2, type: 'operator.scala' }, { startIndex: 3, type: 'white.scala' }, { startIndex: 4, type: 'number.scala' }, { startIndex: 5, type: 'delimiter.scala' }, @@ -110,7 +96,7 @@ testTokenization('scala', [ { startIndex: 6, type: 'white.scala' }, { startIndex: 7, type: 'type.scala' }, { startIndex: 10, type: 'white.scala' }, - { startIndex: 11, type: 'keyword.flow.scala' }, // TODO + { startIndex: 11, type: 'operator.scala' }, { startIndex: 12, type: 'white.scala' }, { startIndex: 13, type: 'number.scala' }, { startIndex: 14, type: 'delimiter.scala' }, @@ -282,11 +268,11 @@ testTokenization('scala', [ { startIndex: 52, type: 'type.scala' }, { startIndex: 58, type: 'operator.square.scala' }, { startIndex: 59, type: 'delimiter.parenthesis.scala' }, - { startIndex: 60, type: 'keyword.flow.scala' }, // TODO + { startIndex: 60, type: 'operator.scala' }, { startIndex: 61, type: 'white.scala' }, { startIndex: 62, type: 'type.scala' }, { startIndex: 66, type: 'white.scala' }, - { startIndex: 67, type: 'keyword.flow.scala' }, // TODO + { startIndex: 67, type: 'operator.scala' }, { startIndex: 68, type: 'white.scala' }, { startIndex: 69, type: 'delimiter.curly.scala' }, { startIndex: 71, type: 'white.scala' }, @@ -568,7 +554,7 @@ testTokenization('scala', [ tokens: [ { startIndex: 0, type: 'number.scala' }, { startIndex: 1, type: 'white.scala' }, - { startIndex: 2, type: 'keyword.flow.scala' }, // TODO + { startIndex: 2, type: 'operator.scala' }, { startIndex: 3, type: 'white.scala' }, { startIndex: 4, type: 'number.scala' } ] @@ -585,7 +571,7 @@ testTokenization('scala', [ { startIndex: 6, type: 'white.scala' }, { startIndex: 7, type: 'type.scala' }, { startIndex: 13, type: 'white.scala' }, - { startIndex: 14, type: 'keyword.flow.scala' }, // TODO + { startIndex: 14, type: 'operator.scala' }, { startIndex: 15, type: 'white.scala' }, { startIndex: 16, type: 'string.quote.scala' }, { startIndex: 17, type: 'string.scala' }, @@ -604,13 +590,13 @@ testTokenization('scala', [ { startIndex: 6, type: 'white.scala' }, { startIndex: 7, type: 'type.scala' }, { startIndex: 13, type: 'white.scala' }, - { startIndex: 14, type: 'keyword.flow.scala' }, // TODO + { startIndex: 14, type: 'operator.scala' }, { startIndex: 15, type: 'white.scala' }, { startIndex: 16, type: 'string.quote.scala' }, { startIndex: 17, type: 'string.scala' }, { startIndex: 29, type: 'string.quote.scala' }, { startIndex: 30, type: 'white.scala' }, - { startIndex: 31, type: 'keyword.flow.scala' }, // TODO + { startIndex: 31, type: 'operator.scala' }, { startIndex: 32, type: 'white.scala' }, { startIndex: 33, type: 'string.quote.scala' }, { startIndex: 34, type: 'string.scala' }, diff --git a/src/scala/scala.ts b/src/scala/scala.ts index 6b1efcdb..0b016d0f 100644 --- a/src/scala/scala.ts +++ b/src/scala/scala.ts @@ -201,7 +201,7 @@ export const language = { cases: { '@keywords': {token: 'keyword', next: '@pop'}, '->|<-|>:|<:|<%': {token: 'keyword', next: '@pop'}, - '@default': {token: 'keyword.flow', next: '@pop'} + '@default': {token: '@rematch', next: '@pop'} } }], ["", "", "@pop"] From 776384e14eb0a94be7e90c1aa4e2cde438de9fd7 Mon Sep 17 00:00:00 2001 From: Alex Dima Date: Thu, 27 Aug 2020 13:08:12 +0200 Subject: [PATCH 5/5] Remove a few left over TODOs --- src/scala/scala.test.ts | 6 +++--- src/scala/scala.ts | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/scala/scala.test.ts b/src/scala/scala.test.ts index df03d3fa..59b7f1c2 100644 --- a/src/scala/scala.test.ts +++ b/src/scala/scala.test.ts @@ -468,7 +468,7 @@ testTokenization('scala', [ line: '3_.1415F', tokens: [ { startIndex: 0, type: 'number.scala' }, - { startIndex: 1, type: 'keyword.scala' }, // TODO + { startIndex: 1, type: 'keyword.scala' }, { startIndex: 2, type: 'delimiter.scala' }, { startIndex: 3, type: 'number.float.scala' } ] @@ -479,7 +479,7 @@ testTokenization('scala', [ tokens: [ { startIndex: 0, type: 'number.scala' }, { startIndex: 1, type: 'operator.scala' }, - { startIndex: 2, type: 'keyword.flow.scala' } // TODO + { startIndex: 2, type: 'identifier.scala' } ] }], @@ -495,7 +495,7 @@ testTokenization('scala', [ line: '52_', tokens: [ { startIndex: 0, type: 'number.scala' }, - { startIndex: 2, type: 'keyword.scala' } // TODO + { startIndex: 2, type: 'keyword.scala' } ] }], diff --git a/src/scala/scala.ts b/src/scala/scala.ts index 0b016d0f..2094b3a5 100644 --- a/src/scala/scala.ts +++ b/src/scala/scala.ts @@ -140,7 +140,7 @@ export const language = { [/\bva[lr]\b/, 'keyword', '@vardef'], [/\b(def)([ \t]+)((?:unary_)?@symbols|@name(?:_=)|@name)/, ['keyword', 'white', 'identifier']], [/@name(?=[ \t]*:(?!:))/, 'variable'], - [/(\.)(@name|@symbols)/, ['operator', {token: 'keyword.flow', next: '@allowMethod'}]], + [/(\.)(@name|@symbols)/, ['operator', {token: '@rematch', next: '@allowMethod'}]], [/([{(])(\s*)(@name(?=\s*=>))/, ['@brackets', 'white', 'variable']], [/@name/, {cases: { '@keywords': 'keyword',