From 86f32392e9b8584bc7afe60d4f9d2fe7df8fc15d Mon Sep 17 00:00:00 2001 From: PanAeon Date: Mon, 27 May 2019 18:48:53 +0100 Subject: [PATCH] fix #5 broken ids with unicode characters. Updated identifiers regexes for val,def,import,parameter-list,package,type. Minor clean up. Added unit test for unicode ids. --- src/typescript/Scala.tmLanguage.ts | 38 ++-- syntaxes/Scala.tmLanguage.json | 2 +- tests/snap/lexical.test.scala.snap | 6 +- tests/snap/scala_spec.test.scala.snap | 11 +- tests/unit/unicode.identifiers.test.scala | 200 ++++++++++++++++++++++ 5 files changed, 233 insertions(+), 24 deletions(-) create mode 100644 tests/unit/unicode.identifiers.test.scala diff --git a/src/typescript/Scala.tmLanguage.ts b/src/typescript/Scala.tmLanguage.ts index 68486b4..43f6d4c 100644 --- a/src/typescript/Scala.tmLanguage.ts +++ b/src/typescript/Scala.tmLanguage.ts @@ -1,14 +1,20 @@ "use strict"; import { TmLanguage } from "./TMLanguageModel"; -const letter = "[_a-zA-Z\\$\\p{Lo}\\p{Lt}\\p{Nl}\\p{Ll}\\p{Lu}]" +const upperLetter = "[A-Z\\p{Lt}\\p{Lu}]" +const lowerLetter = "[_a-z\\$\\p{Lo}\\p{Nl}\\p{Ll}]" +const letter = `[${upperLetter}${lowerLetter}]` const digit = "[0-9]" const letterOrDigit = `${letter}|${digit}` const alphaId = `${letter}+` const simpleInterpolatedVariable = `${letter}(?:${letterOrDigit})*` // see SIP-11 https://docs.scala-lang.org/sips/string-interpolation.html const opchar = `[!#%&*+\\-\\/:<>=?@^|~[\\p{Sm}\\p{So}]]` -const idrest = `${letter}(?:${letterOrDigit})*(?:((?<=_))${opchar}+)?` +const idrest = `${letter}(?:${letterOrDigit})*(?:(?<=_)${opchar}+)?` +const idUpper = `${upperLetter}(?:${letterOrDigit})*(?:(?<=_)${opchar}+)?` +const idLower = `${lowerLetter}(?:${letterOrDigit})*(?:(?<=_)${opchar}+)?` const plainid = `(?:${idrest}|(?:${opchar})+)` +const backQuotedId = "`[^`]+`" + export const scalaTmLanguage: TmLanguage = { fileTypes: [ @@ -41,7 +47,7 @@ export const scalaTmLanguage: TmLanguage = { include: '#comments' }, { - match: '(`[^`]+`|[_$a-zA-Z][_$a-zA-Z0-9]*)', + match: `(${backQuotedId}|${plainid})`, name: 'entity.name.import.scala' }, { @@ -58,7 +64,7 @@ export const scalaTmLanguage: TmLanguage = { }, patterns: [ { - match: '(?x) \\s*\n\t\t\t\t (`[^`]+`|[_$a-zA-Z][_$a-zA-Z0-9]*) \\s*\n\t\t\t\t (=>) \\s*\n\t\t\t\t (`[^`]+`|[_$a-zA-Z][_$a-zA-Z0-9]*) \\s*\n\t\t\t ', + match: `(?x)\\s*(${backQuotedId}|${plainid})\\s*(=>)\\s*(${backQuotedId}|${plainid})\\s*`, captures: { '1': { name: 'entity.name.import.renamed-from.scala' @@ -118,7 +124,7 @@ export const scalaTmLanguage: TmLanguage = { include: '#block-comments' }, { - match: '(?x)\n\t\t\t(?! /\\*)\n\t\t\t(?! \\*/)\n\t\t ' + match: '(?x)(?! /\\*)(?! \\*/)' } ], name: 'comment.block.scala' @@ -201,7 +207,7 @@ export const scalaTmLanguage: TmLanguage = { }, 'special-identifier': { match: '\\b[_$a-zA-Z][_$a-zA-Z0-9]*(?:_[^\\t .,;()\\[\\]{}\'"`\\w])', - comment: '\n\t\t Match special scala style identifiers that can end with and underscore and\n\t\t a a not letter such as blank_?. This way the symbol will not be colored\n\t\t differently.\n\t\t ' + comment: 'Match special scala style identifiers that can end with and underscore and a a not letter such as blank_?. This way the symbol will not be colored differently.' }, strings: { patterns: [ @@ -449,7 +455,7 @@ export const scalaTmLanguage: TmLanguage = { declarations: { patterns: [ { - match: '(?x)\n\t\t\t\t\t\t\\b(def)\\s+\n\t\t\t\t\t\t(`[^`]+`|[_$a-zA-Z][_$a-zA-Z0-9]*(?:_[^\\t .,;()\\[\\]{}\'"`\\w])(?=[(\\t ])|[_$a-zA-Z][_$a-zA-Z0-9]*|[-?~><^+*%:!#|/@\\\\]+)', + match: `(?x)\\b(def)\\s+(${backQuotedId}|${plainid})`, captures: { '1': { name: 'keyword.declaration.scala' @@ -485,7 +491,7 @@ export const scalaTmLanguage: TmLanguage = { } }, { - match: '\\b(type)\\s+(`[^`]+`|[_$a-zA-Z][_$a-zA-Z0-9]*(?:_[^\\s])(?=[\\t ])|[_$a-zA-Z][_$a-zA-Z0-9]*|[-?~><^+*%:!#|/@\\\\]+)', + match: `\\b(type)\\s+(${backQuotedId}|${plainid})`, captures: { '1': { name: 'keyword.declaration.scala' @@ -496,18 +502,19 @@ export const scalaTmLanguage: TmLanguage = { } }, { - match: '\\b(val)\\s+(?:([A-Z][_a-zA-Z0-9]*))\\b', + match: `\\b(val)\\s+(${idUpper})\\b`, captures: { '1': { name: 'keyword.declaration.stable.scala' - }, + } + , '2': { name: 'constant.other.declaration.scala' } } }, { - match: '\\b(?:(val)|(var))\\s+(?:(`[^`]+`|[_$a-zA-Z][_$a-zA-Z0-9]*(?:_[^\\t .,;()\\[\\]{}\'"`\\w])(?=[\\t ])|[_$a-zA-Z][_$a-zA-Z0-9]*|[-?~><^+*%:!#|/@\\\\]+)|(?=\\())', + match: `\\b(?:(val)|(var))\\s+(?:(${backQuotedId}|${plainid})|(?=\\())`, captures: { '1': { name: 'keyword.declaration.stable.scala' @@ -547,7 +554,7 @@ export const scalaTmLanguage: TmLanguage = { include: '#comments' }, { - match: '(`[^`]+`|[_$a-zA-Z][_$a-zA-Z0-9]*)', + match: `(${backQuotedId}|${plainid})`, name: 'entity.name.package.scala' }, { @@ -812,7 +819,7 @@ export const scalaTmLanguage: TmLanguage = { 'parameter-list': { patterns: [ { - match: '(?<=[^\\._$a-zA-Z0-9])(`[^`]+`|[_$a-z][_$a-zA-Z0-9]*(?:_[^\\s])(?=[\\t ])|[_$a-z][_$a-zA-Z0-9]*|[-?~><^+*%:!#|/@\\\\]+)\\s*(:)\\s+', + match: `(?<=[^\\._$a-zA-Z0-9])(${backQuotedId}|${idLower})\\s*(:)\\s+`, captures: { '1': { name: 'variable.parameter.scala' @@ -820,8 +827,7 @@ export const scalaTmLanguage: TmLanguage = { '2': { name: 'meta.colon.scala' } - }, - comment: 'We do not match param names that start with a Capitol letter' + } } ] }, @@ -852,7 +858,7 @@ export const scalaTmLanguage: TmLanguage = { include: '#xml-embedded-content' } ], - comment: 'We do not allow a tag name to start with a - since this would\n\t\t\t\t likely conflict with the <- operator. This is not very common\n\t\t\t\t for tag names anyway. Also code such as -- if (val val3)\n\t\t\t\t will falsly be recognized as an xml tag. The solution is to put a\n\t\t\t\t space on either side of the comparison operator', + comment: 'We do not allow a tag name to start with a - since this would likely conflict with the <- operator. This is not very common for tag names anyway. Also code such as -- if (val val3) will falsly be recognized as an xml tag. The solution is to put a space on either side of the comparison operator', endCaptures: { '1': { name: 'punctuation.definition.tag.xml' diff --git a/syntaxes/Scala.tmLanguage.json b/syntaxes/Scala.tmLanguage.json index 487f411..db1c0a8 100644 --- a/syntaxes/Scala.tmLanguage.json +++ b/syntaxes/Scala.tmLanguage.json @@ -1 +1 @@ -{"fileTypes":["scala"],"firstLineMatch":"^#!/.*\\b\\w*scala\\b","foldingStartMarker":"/\\*\\*|\\{\\s*$","foldingStopMarker":"\\*\\*/|^\\s*\\}","keyEquivalent":"^~S","repository":{"empty-parentheses":{"match":"(\\(\\))","captures":{"1":{"name":"meta.bracket.scala"}},"name":"meta.parentheses.scala"},"imports":{"end":"(?<=[\\n;])","begin":"\\b(import)\\s+","beginCaptures":{"1":{"name":"keyword.other.import.scala"}},"patterns":[{"include":"#comments"},{"match":"(`[^`]+`|[_$a-zA-Z][_$a-zA-Z0-9]*)","name":"entity.name.import.scala"},{"match":"\\.","name":"punctuation.definition.import"},{"end":"}","begin":"{","beginCaptures":{"0":{"name":"meta.bracket.scala"}},"patterns":[{"match":"(?x) \\s*\n\t\t\t\t (`[^`]+`|[_$a-zA-Z][_$a-zA-Z0-9]*) \\s*\n\t\t\t\t (=>) \\s*\n\t\t\t\t (`[^`]+`|[_$a-zA-Z][_$a-zA-Z0-9]*) \\s*\n\t\t\t ","captures":{"1":{"name":"entity.name.import.renamed-from.scala"},"2":{"name":"keyword.other.arrow.scala"},"3":{"name":"entity.name.import.renamed-to.scala"}}},{"match":"([^\\s.,}]+)","name":"entity.name.import.scala"}],"endCaptures":{"0":{"name":"meta.bracket.scala"}},"name":"meta.import.selector.scala"}],"name":"meta.import.scala"},"constants":{"patterns":[{"match":"\\b(false|null|true|Nil|None)\\b","name":"constant.language.scala"},{"match":"\\b((0(x|X)[0-9a-fA-F]*)|(([0-9]+\\.[0-9]+)|(\\.[0-9]+))((e|E)(\\+|-)?[0-9]+)?|[0-9]+)([LlFfDd]|UL|ul)?\\b","name":"constant.numeric.scala"},{"match":"\\b(this|super|self)\\b","name":"variable.language.scala"},{"match":"\\b(Unit|Boolean|Byte|Char|Short|Int|Float|Long|Double)\\b","name":"storage.type.primitive.scala"},{"match":"\\b(String|Symbol)\\b","name":"storage.type.scala"}]},"block-comments":{"end":"\\*/","begin":"/\\*","patterns":[{"include":"#block-comments"},{"match":"(?x)\n\t\t\t(?! /\\*)\n\t\t\t(?! \\*/)\n\t\t "}],"name":"comment.block.scala"},"script-header":{"match":"^#!(.*)$","captures":{"1":{"name":"string.unquoted.shebang.scala"}},"name":"comment.block.shebang.scala"},"code":{"patterns":[{"include":"#script-header"},{"include":"#storage-modifiers"},{"include":"#declarations"},{"include":"#inheritance"},{"include":"#imports"},{"include":"#comments"},{"include":"#strings"},{"include":"#initialization"},{"include":"#xml-literal"},{"include":"#keywords"},{"include":"#constants"},{"include":"#scala-symbol"},{"include":"#scala-quoted"},{"include":"#special-identifier"},{"include":"#char-literal"},{"include":"#empty-parentheses"},{"include":"#parameter-list"},{"include":"#qualifiedClassName"},{"include":"#meta-brackets"},{"include":"#meta-bounds"},{"include":"#meta-colons"}]},"special-identifier":{"match":"\\b[_$a-zA-Z][_$a-zA-Z0-9]*(?:_[^\\t .,;()\\[\\]{}'\"`\\w])","comment":"\n\t\t Match special scala style identifiers that can end with and underscore and\n\t\t a a not letter such as blank_?. This way the symbol will not be colored\n\t\t differently.\n\t\t "},"strings":{"patterns":[{"end":"\"\"\"(?!\")","begin":"\"\"\"","beginCaptures":{"0":{"name":"punctuation.definition.string.begin.scala"}},"patterns":[{"match":"\\\\\\\\|\\\\u[0-9A-Fa-f]{4}","name":"constant.character.escape.scala"}],"endCaptures":{"0":{"name":"punctuation.definition.string.end.scala"}},"name":"string.quoted.triple.scala"},{"begin":"\\b([_a-zA-Z\\$\\p{Lo}\\p{Lt}\\p{Nl}\\p{Ll}\\p{Lu}]+)(\"\"\")","end":"\"\"\"(?!\")","beginCaptures":{"1":{"name":"keyword.interpolation.scala"},"2":{"name":"string.quoted.triple.interpolated.scala punctuation.definition.string.begin.scala"}},"patterns":[{"include":"#string-interpolation"},{"match":"\\\\\\\\|\\\\u[0-9A-Fa-f]{4}","name":"constant.character.escape.scala"},{"match":".","name":"string.quoted.triple.interpolated.scala"}],"endCaptures":{"0":{"name":"string.quoted.triple.interpolated.scala punctuation.definition.string.end.scala"}}},{"end":"\"","begin":"\"","beginCaptures":{"0":{"name":"punctuation.definition.string.begin.scala"}},"patterns":[{"match":"\\\\(?:[btnfr\\\\\"']|[0-7]{1,3}|u[0-9A-Fa-f]{4})","name":"constant.character.escape.scala"},{"match":"\\\\.","name":"invalid.illegal.unrecognized-string-escape.scala"}],"endCaptures":{"0":{"name":"punctuation.definition.string.end.scala"}},"name":"string.quoted.double.scala"},{"begin":"\\b([_a-zA-Z\\$\\p{Lo}\\p{Lt}\\p{Nl}\\p{Ll}\\p{Lu}]+)(\")","end":"\"","beginCaptures":{"1":{"name":"keyword.interpolation.scala"},"2":{"name":"string.quoted.double.interpolated.scala punctuation.definition.string.begin.scala"}},"patterns":[{"include":"#string-interpolation"},{"match":"\\\\(?:[btnfr\\\\\"']|[0-7]{1,3}|u[0-9A-Fa-f]{4})","name":"constant.character.escape.scala"},{"match":"\\\\.","name":"invalid.illegal.unrecognized-string-escape.scala"},{"match":".","name":"string.quoted.double.interpolated.scala"}],"endCaptures":{"0":{"name":"string.quoted.double.interpolated.scala punctuation.definition.string.end.scala"}}}]},"string-interpolation":{"patterns":[{"name":"constant.character.escape.interpolation.scala","match":"\\$\\$"},{"match":"(\\$)([_a-zA-Z\\$\\p{Lo}\\p{Lt}\\p{Nl}\\p{Ll}\\p{Lu}](?:[_a-zA-Z\\$\\p{Lo}\\p{Lt}\\p{Nl}\\p{Ll}\\p{Lu}]|[0-9])*)","captures":{"1":{"name":"punctuation.definition.template-expression.begin.scala"}}},{"name":"punctuation.definition.template-expression.scala","begin":"\\$\\{","beginCaptures":{"0":{"name":"punctuation.definition.template-expression.begin.scala"}},"end":"\\}","endCaptures":{"0":{"name":"punctuation.definition.template-expression.end.scala"}},"patterns":[{"include":"#code"}]}]},"xml-entity":{"match":"(&)([:a-zA-Z_][:a-zA-Z0-9_.-]*|#[0-9]+|#x[0-9a-fA-F]+)(;)","captures":{"1":{"name":"punctuation.definition.constant.xml"},"3":{"name":"punctuation.definition.constant.xml"}},"name":"constant.character.entity.xml"},"xml-singlequotedString":{"end":"'","begin":"'","beginCaptures":{"0":{"name":"punctuation.definition.string.begin.xml"}},"patterns":[{"include":"#xml-entity"}],"endCaptures":{"0":{"name":"punctuation.definition.string.end.xml"}},"name":"string.quoted.single.xml"},"meta-colons":{"patterns":[{"match":"(?=|<>|<|>)","name":"keyword.operator.comparison.scala"},{"match":"(\\-|\\+|\\*|/(?![/*])|%|~)","name":"keyword.operator.arithmetic.scala"},{"match":"(!|&&|\\|\\|)","name":"keyword.operator.logical.scala"},{"match":"(<-|←|->|→|=>|⇒|\\?|\\:+|@|\\|)+","name":"keyword.operator.scala"}]},"scala-quoted":{"match":"'\\{'|'\\('|'\\['|'\\{|'\\(|'\\[","name":"constant.other.quoted.scala"},"xml-doublequotedString":{"end":"\"","begin":"\"","beginCaptures":{"0":{"name":"punctuation.definition.string.begin.xml"}},"patterns":[{"include":"#xml-entity"}],"endCaptures":{"0":{"name":"punctuation.definition.string.end.xml"}},"name":"string.quoted.double.xml"},"declarations":{"patterns":[{"match":"(?x)\n\t\t\t\t\t\t\\b(def)\\s+\n\t\t\t\t\t\t(`[^`]+`|[_$a-zA-Z][_$a-zA-Z0-9]*(?:_[^\\t .,;()\\[\\]{}'\"`\\w])(?=[(\\t ])|[_$a-zA-Z][_$a-zA-Z0-9]*|[-?~><^+*%:!#|/@\\\\]+)","captures":{"1":{"name":"keyword.declaration.scala"},"2":{"name":"entity.name.function.declaration"}}},{"match":"\\b(trait)\\s+([^\\s\\{\\(\\[]+)","captures":{"1":{"name":"keyword.declaration.scala"},"2":{"name":"entity.name.class.declaration"}}},{"match":"\\b(?:(case)\\s+)?(class|object)\\s+([^\\s\\{\\(\\[]+)","captures":{"1":{"name":"keyword.declaration.scala"},"2":{"name":"keyword.declaration.scala"},"3":{"name":"entity.name.class.declaration"}}},{"match":"\\b(type)\\s+(`[^`]+`|[_$a-zA-Z][_$a-zA-Z0-9]*(?:_[^\\s])(?=[\\t ])|[_$a-zA-Z][_$a-zA-Z0-9]*|[-?~><^+*%:!#|/@\\\\]+)","captures":{"1":{"name":"keyword.declaration.scala"},"2":{"name":"entity.name.type.declaration"}}},{"match":"\\b(val)\\s+(?:([A-Z][_a-zA-Z0-9]*))\\b","captures":{"1":{"name":"keyword.declaration.stable.scala"},"2":{"name":"constant.other.declaration.scala"}}},{"match":"\\b(?:(val)|(var))\\s+(?:(`[^`]+`|[_$a-zA-Z][_$a-zA-Z0-9]*(?:_[^\\t .,;()\\[\\]{}'\"`\\w])(?=[\\t ])|[_$a-zA-Z][_$a-zA-Z0-9]*|[-?~><^+*%:!#|/@\\\\]+)|(?=\\())","captures":{"1":{"name":"keyword.declaration.stable.scala"},"2":{"name":"keyword.declaration.volatile.scala"},"3":{"name":"variable.other.declaration.scala"}}},{"match":"\\b(package)\\s+(object)\\s+([^\\s\\{\\(\\[]+)","captures":{"1":{"name":"keyword.other.scoping.scala"},"2":{"name":"keyword.declaration.scala"},"3":{"name":"entity.name.class.declaration"}}},{"end":"(?<=[\\n;])","begin":"\\b(package)\\s+","beginCaptures":{"1":{"name":"keyword.other.import.scala"}},"patterns":[{"include":"#comments"},{"match":"(`[^`]+`|[_$a-zA-Z][_$a-zA-Z0-9]*)","name":"entity.name.package.scala"},{"match":"\\.","name":"punctuation.definition.package"}],"name":"meta.package.scala"}]},"char-literal":{"end":"'","begin":"'","beginCaptures":{"0":{"name":"punctuation.definition.character.begin.scala"}},"patterns":[{"match":"\\\\(?:[btnfr\\\\\"']|[0-7]{1,3}|u[0-9A-Fa-f]{4})","name":"constant.character.escape.scala"},{"match":"\\\\.","name":"invalid.illegal.unrecognized-character-escape.scala"},{"match":"[^']{2,}","name":"invalid.illegal.character-literal-too-long"},{"match":"(?'(?:[_a-zA-Z\\$\\p{Lo}\\p{Lt}\\p{Nl}\\p{Ll}\\p{Lu}](?:[_a-zA-Z\\$\\p{Lo}\\p{Lt}\\p{Nl}\\p{Ll}\\p{Lu}]|[0-9])*(?:((?<=_))[!#%&*+\\-\\/:<>=?@^|~[\\p{Sm}\\p{So}]]+)?|(?:[!#%&*+\\-\\/:<>=?@^|~[\\p{Sm}\\p{So}]])+))(?!')","name":"constant.other.symbol.scala"},"meta-brackets":{"patterns":[{"match":"\\{","comment":"The punctuation.section.*.begin is needed for return snippet in source bundle","name":"punctuation.section.block.begin.scala"},{"match":"\\}","comment":"The punctuation.section.*.end is needed for return snippet in source bundle","name":"punctuation.section.block.end.scala"},{"match":"{|}|\\(|\\)|\\[|\\]","name":"meta.bracket.scala"}],"comment":"For themes: Brackets look nice when colored."},"qualifiedClassName":{"match":"(\\b([A-Z][\\w]*))","captures":{"1":{"name":"entity.name.class"}}},"storage-modifiers":{"patterns":[{"match":"\\b(private\\[\\S+\\]|protected\\[\\S+\\]|private|protected)\\b","name":"storage.modifier.access"},{"match":"\\b(synchronized|@volatile|abstract|final|lazy|sealed|implicit|override|@transient|@native)\\b","name":"storage.modifier.other"}]},"meta-bounds":{"match":"<%|=:=|<:<|<%<|>:|<:","comment":"For themes: Matching view bounds","name":"meta.bounds.scala"},"comments":{"patterns":[{"match":"/\\*\\*/","captures":{"0":{"name":"punctuation.definition.comment.scala"}},"name":"comment.block.empty.scala"},{"end":"\\*/","begin":"^\\s*(/\\*\\*)(?!/)","beginCaptures":{"1":{"name":"punctuation.definition.comment.scala"}},"patterns":[{"match":"(@param)\\s+(\\S+)","captures":{"1":{"name":"keyword.other.documentation.scaladoc.scala"},"2":{"name":"variable.parameter.scala"}}},{"match":"(@(?:tparam|throws))\\s+(\\S+)","captures":{"1":{"name":"keyword.other.documentation.scaladoc.scala"},"2":{"name":"entity.name.class"}}},{"match":"@(return|see|note|example|usecase|author|version|since|todo|deprecated|migration|define|inheritdoc)\\b","name":"keyword.other.documentation.scaladoc.scala"},{"match":"(\\[\\[)([^\\]]+)(\\]\\])","captures":{"1":{"name":"punctuation.definition.documentation.link.scala"},"2":{"name":"entity.other.documentation.link.scala"},"3":{"name":"punctuation.definition.documentation.link.scala"}}}],"endCaptures":{"0":{"name":"punctuation.definition.comment.scala"}},"name":"comment.block.documentation.scala"},{"end":"\\*/","begin":"/\\*","captures":{"0":{"name":"punctuation.definition.comment.scala"}},"name":"comment.block.scala"},{"end":"(?!\\G)","begin":"(^[ \\t]+)?(?=//)","beginCaptures":{"1":{"name":"punctuation.whitespace.comment.leading.scala"}},"patterns":[{"end":"\\n","begin":"//","beginCaptures":{"0":{"name":"punctuation.definition.comment.scala"}},"name":"comment.line.double-slash.scala"}]}]},"xml-embedded-content":{"patterns":[{"end":"}","begin":"{","patterns":[{"include":"#code"}],"captures":{"0":{"name":"meta.bracket.scala"}},"name":"meta.source.embedded.scala"},{"match":" (?:([-_a-zA-Z0-9]+)((:)))?([_a-zA-Z-]+)=","captures":{"1":{"name":"entity.other.attribute-name.namespace.xml"},"2":{"name":"entity.other.attribute-name.xml"},"3":{"name":"punctuation.separator.namespace.xml"},"4":{"name":"entity.other.attribute-name.localname.xml"}}},{"include":"#xml-doublequotedString"},{"include":"#xml-singlequotedString"}]},"inheritance":{"patterns":[{"match":"(extends|with)\\s+([^\\s\\{\\(\\[\\]]+)","captures":{"1":{"name":"keyword.declaration.scala"},"2":{"name":"entity.other.inherited-class.scala"}}}]},"parameter-list":{"patterns":[{"match":"(?<=[^\\._$a-zA-Z0-9])(`[^`]+`|[_$a-z][_$a-zA-Z0-9]*(?:_[^\\s])(?=[\\t ])|[_$a-z][_$a-zA-Z0-9]*|[-?~><^+*%:!#|/@\\\\]+)\\s*(:)\\s+","captures":{"1":{"name":"variable.parameter.scala"},"2":{"name":"meta.colon.scala"}},"comment":"We do not match param names that start with a Capitol letter"}]},"xml-literal":{"patterns":[{"end":"(>(<))/(?:([-_a-zA-Z0-9]+)((:)))?([-_a-zA-Z0-9:]*[_a-zA-Z0-9])(>)","begin":"(<)((?:([_a-zA-Z0-9][_a-zA-Z0-9]*)((:)))?([_a-zA-Z0-9][-_a-zA-Z0-9:]*))(?=(\\s[^>]*)?>)","beginCaptures":{"1":{"name":"punctuation.definition.tag.xml"},"3":{"name":"entity.name.tag.namespace.xml"},"4":{"name":"entity.name.tag.xml"},"5":{"name":"punctuation.separator.namespace.xml"},"6":{"name":"entity.name.tag.localname.xml"}},"patterns":[{"include":"#xml-embedded-content"}],"comment":"We do not allow a tag name to start with a - since this would\n\t\t\t\t likely conflict with the <- operator. This is not very common\n\t\t\t\t for tag names anyway. Also code such as -- if (val val3)\n\t\t\t\t will falsly be recognized as an xml tag. The solution is to put a\n\t\t\t\t space on either side of the comparison operator","endCaptures":{"1":{"name":"punctuation.definition.tag.xml"},"2":{"name":"meta.scope.between-tag-pair.xml"},"3":{"name":"entity.name.tag.namespace.xml"},"4":{"name":"entity.name.tag.xml"},"5":{"name":"punctuation.separator.namespace.xml"},"6":{"name":"entity.name.tag.localname.xml"},"7":{"name":"punctuation.definition.tag.xml"}},"name":"meta.tag.no-content.xml"},{"end":"(/?>)","begin":"(]*?>)","patterns":[{"include":"#xml-embedded-content"}],"captures":{"1":{"name":"punctuation.definition.tag.xml"},"2":{"name":"entity.name.tag.namespace.xml"},"3":{"name":"entity.name.tag.xml"},"4":{"name":"punctuation.separator.namespace.xml"},"5":{"name":"entity.name.tag.localname.xml"}},"name":"meta.tag.xml"},{"include":"#xml-entity"}]}},"uuid":"158C0929-299A-40C8-8D89-316BE0C446E8","$schema":"https://raw.githubusercontent.com/Septh/tmlanguage/master/tmLanguage.schema.json","patterns":[{"include":"#code"}],"name":"Scala","scopeName":"source.scala"} +{"fileTypes":["scala"],"firstLineMatch":"^#!/.*\\b\\w*scala\\b","foldingStartMarker":"/\\*\\*|\\{\\s*$","foldingStopMarker":"\\*\\*/|^\\s*\\}","keyEquivalent":"^~S","repository":{"empty-parentheses":{"match":"(\\(\\))","captures":{"1":{"name":"meta.bracket.scala"}},"name":"meta.parentheses.scala"},"imports":{"end":"(?<=[\\n;])","begin":"\\b(import)\\s+","beginCaptures":{"1":{"name":"keyword.other.import.scala"}},"patterns":[{"include":"#comments"},{"match":"(`[^`]+`|(?:[[A-Z\\p{Lt}\\p{Lu}][_a-z\\$\\p{Lo}\\p{Nl}\\p{Ll}]](?:[[A-Z\\p{Lt}\\p{Lu}][_a-z\\$\\p{Lo}\\p{Nl}\\p{Ll}]]|[0-9])*(?:(?<=_)[!#%&*+\\-\\/:<>=?@^|~[\\p{Sm}\\p{So}]]+)?|(?:[!#%&*+\\-\\/:<>=?@^|~[\\p{Sm}\\p{So}]])+))","name":"entity.name.import.scala"},{"match":"\\.","name":"punctuation.definition.import"},{"end":"}","begin":"{","beginCaptures":{"0":{"name":"meta.bracket.scala"}},"patterns":[{"match":"(?x)\\s*(`[^`]+`|(?:[[A-Z\\p{Lt}\\p{Lu}][_a-z\\$\\p{Lo}\\p{Nl}\\p{Ll}]](?:[[A-Z\\p{Lt}\\p{Lu}][_a-z\\$\\p{Lo}\\p{Nl}\\p{Ll}]]|[0-9])*(?:(?<=_)[!#%&*+\\-\\/:<>=?@^|~[\\p{Sm}\\p{So}]]+)?|(?:[!#%&*+\\-\\/:<>=?@^|~[\\p{Sm}\\p{So}]])+))\\s*(=>)\\s*(`[^`]+`|(?:[[A-Z\\p{Lt}\\p{Lu}][_a-z\\$\\p{Lo}\\p{Nl}\\p{Ll}]](?:[[A-Z\\p{Lt}\\p{Lu}][_a-z\\$\\p{Lo}\\p{Nl}\\p{Ll}]]|[0-9])*(?:(?<=_)[!#%&*+\\-\\/:<>=?@^|~[\\p{Sm}\\p{So}]]+)?|(?:[!#%&*+\\-\\/:<>=?@^|~[\\p{Sm}\\p{So}]])+))\\s*","captures":{"1":{"name":"entity.name.import.renamed-from.scala"},"2":{"name":"keyword.other.arrow.scala"},"3":{"name":"entity.name.import.renamed-to.scala"}}},{"match":"([^\\s.,}]+)","name":"entity.name.import.scala"}],"endCaptures":{"0":{"name":"meta.bracket.scala"}},"name":"meta.import.selector.scala"}],"name":"meta.import.scala"},"constants":{"patterns":[{"match":"\\b(false|null|true|Nil|None)\\b","name":"constant.language.scala"},{"match":"\\b((0(x|X)[0-9a-fA-F]*)|(([0-9]+\\.[0-9]+)|(\\.[0-9]+))((e|E)(\\+|-)?[0-9]+)?|[0-9]+)([LlFfDd]|UL|ul)?\\b","name":"constant.numeric.scala"},{"match":"\\b(this|super|self)\\b","name":"variable.language.scala"},{"match":"\\b(Unit|Boolean|Byte|Char|Short|Int|Float|Long|Double)\\b","name":"storage.type.primitive.scala"},{"match":"\\b(String|Symbol)\\b","name":"storage.type.scala"}]},"block-comments":{"end":"\\*/","begin":"/\\*","patterns":[{"include":"#block-comments"},{"match":"(?x)(?! /\\*)(?! \\*/)"}],"name":"comment.block.scala"},"script-header":{"match":"^#!(.*)$","captures":{"1":{"name":"string.unquoted.shebang.scala"}},"name":"comment.block.shebang.scala"},"code":{"patterns":[{"include":"#script-header"},{"include":"#storage-modifiers"},{"include":"#declarations"},{"include":"#inheritance"},{"include":"#imports"},{"include":"#comments"},{"include":"#strings"},{"include":"#initialization"},{"include":"#xml-literal"},{"include":"#keywords"},{"include":"#constants"},{"include":"#scala-symbol"},{"include":"#scala-quoted"},{"include":"#special-identifier"},{"include":"#char-literal"},{"include":"#empty-parentheses"},{"include":"#parameter-list"},{"include":"#qualifiedClassName"},{"include":"#meta-brackets"},{"include":"#meta-bounds"},{"include":"#meta-colons"}]},"special-identifier":{"match":"\\b[_$a-zA-Z][_$a-zA-Z0-9]*(?:_[^\\t .,;()\\[\\]{}'\"`\\w])","comment":"Match special scala style identifiers that can end with and underscore and a a not letter such as blank_?. This way the symbol will not be colored differently."},"strings":{"patterns":[{"end":"\"\"\"(?!\")","begin":"\"\"\"","beginCaptures":{"0":{"name":"punctuation.definition.string.begin.scala"}},"patterns":[{"match":"\\\\\\\\|\\\\u[0-9A-Fa-f]{4}","name":"constant.character.escape.scala"}],"endCaptures":{"0":{"name":"punctuation.definition.string.end.scala"}},"name":"string.quoted.triple.scala"},{"begin":"\\b([[A-Z\\p{Lt}\\p{Lu}][_a-z\\$\\p{Lo}\\p{Nl}\\p{Ll}]]+)(\"\"\")","end":"\"\"\"(?!\")","beginCaptures":{"1":{"name":"keyword.interpolation.scala"},"2":{"name":"string.quoted.triple.interpolated.scala punctuation.definition.string.begin.scala"}},"patterns":[{"include":"#string-interpolation"},{"match":"\\\\\\\\|\\\\u[0-9A-Fa-f]{4}","name":"constant.character.escape.scala"},{"match":".","name":"string.quoted.triple.interpolated.scala"}],"endCaptures":{"0":{"name":"string.quoted.triple.interpolated.scala punctuation.definition.string.end.scala"}}},{"end":"\"","begin":"\"","beginCaptures":{"0":{"name":"punctuation.definition.string.begin.scala"}},"patterns":[{"match":"\\\\(?:[btnfr\\\\\"']|[0-7]{1,3}|u[0-9A-Fa-f]{4})","name":"constant.character.escape.scala"},{"match":"\\\\.","name":"invalid.illegal.unrecognized-string-escape.scala"}],"endCaptures":{"0":{"name":"punctuation.definition.string.end.scala"}},"name":"string.quoted.double.scala"},{"begin":"\\b([[A-Z\\p{Lt}\\p{Lu}][_a-z\\$\\p{Lo}\\p{Nl}\\p{Ll}]]+)(\")","end":"\"","beginCaptures":{"1":{"name":"keyword.interpolation.scala"},"2":{"name":"string.quoted.double.interpolated.scala punctuation.definition.string.begin.scala"}},"patterns":[{"include":"#string-interpolation"},{"match":"\\\\(?:[btnfr\\\\\"']|[0-7]{1,3}|u[0-9A-Fa-f]{4})","name":"constant.character.escape.scala"},{"match":"\\\\.","name":"invalid.illegal.unrecognized-string-escape.scala"},{"match":".","name":"string.quoted.double.interpolated.scala"}],"endCaptures":{"0":{"name":"string.quoted.double.interpolated.scala punctuation.definition.string.end.scala"}}}]},"string-interpolation":{"patterns":[{"name":"constant.character.escape.interpolation.scala","match":"\\$\\$"},{"match":"(\\$)([[A-Z\\p{Lt}\\p{Lu}][_a-z\\$\\p{Lo}\\p{Nl}\\p{Ll}]](?:[[A-Z\\p{Lt}\\p{Lu}][_a-z\\$\\p{Lo}\\p{Nl}\\p{Ll}]]|[0-9])*)","captures":{"1":{"name":"punctuation.definition.template-expression.begin.scala"}}},{"name":"punctuation.definition.template-expression.scala","begin":"\\$\\{","beginCaptures":{"0":{"name":"punctuation.definition.template-expression.begin.scala"}},"end":"\\}","endCaptures":{"0":{"name":"punctuation.definition.template-expression.end.scala"}},"patterns":[{"include":"#code"}]}]},"xml-entity":{"match":"(&)([:a-zA-Z_][:a-zA-Z0-9_.-]*|#[0-9]+|#x[0-9a-fA-F]+)(;)","captures":{"1":{"name":"punctuation.definition.constant.xml"},"3":{"name":"punctuation.definition.constant.xml"}},"name":"constant.character.entity.xml"},"xml-singlequotedString":{"end":"'","begin":"'","beginCaptures":{"0":{"name":"punctuation.definition.string.begin.xml"}},"patterns":[{"include":"#xml-entity"}],"endCaptures":{"0":{"name":"punctuation.definition.string.end.xml"}},"name":"string.quoted.single.xml"},"meta-colons":{"patterns":[{"match":"(?=|<>|<|>)","name":"keyword.operator.comparison.scala"},{"match":"(\\-|\\+|\\*|/(?![/*])|%|~)","name":"keyword.operator.arithmetic.scala"},{"match":"(!|&&|\\|\\|)","name":"keyword.operator.logical.scala"},{"match":"(<-|←|->|→|=>|⇒|\\?|\\:+|@|\\|)+","name":"keyword.operator.scala"}]},"scala-quoted":{"match":"'\\{'|'\\('|'\\['|'\\{|'\\(|'\\[","name":"constant.other.quoted.scala"},"xml-doublequotedString":{"end":"\"","begin":"\"","beginCaptures":{"0":{"name":"punctuation.definition.string.begin.xml"}},"patterns":[{"include":"#xml-entity"}],"endCaptures":{"0":{"name":"punctuation.definition.string.end.xml"}},"name":"string.quoted.double.xml"},"declarations":{"patterns":[{"match":"(?x)\\b(def)\\s+(`[^`]+`|(?:[[A-Z\\p{Lt}\\p{Lu}][_a-z\\$\\p{Lo}\\p{Nl}\\p{Ll}]](?:[[A-Z\\p{Lt}\\p{Lu}][_a-z\\$\\p{Lo}\\p{Nl}\\p{Ll}]]|[0-9])*(?:(?<=_)[!#%&*+\\-\\/:<>=?@^|~[\\p{Sm}\\p{So}]]+)?|(?:[!#%&*+\\-\\/:<>=?@^|~[\\p{Sm}\\p{So}]])+))","captures":{"1":{"name":"keyword.declaration.scala"},"2":{"name":"entity.name.function.declaration"}}},{"match":"\\b(trait)\\s+([^\\s\\{\\(\\[]+)","captures":{"1":{"name":"keyword.declaration.scala"},"2":{"name":"entity.name.class.declaration"}}},{"match":"\\b(?:(case)\\s+)?(class|object)\\s+([^\\s\\{\\(\\[]+)","captures":{"1":{"name":"keyword.declaration.scala"},"2":{"name":"keyword.declaration.scala"},"3":{"name":"entity.name.class.declaration"}}},{"match":"\\b(type)\\s+(`[^`]+`|(?:[[A-Z\\p{Lt}\\p{Lu}][_a-z\\$\\p{Lo}\\p{Nl}\\p{Ll}]](?:[[A-Z\\p{Lt}\\p{Lu}][_a-z\\$\\p{Lo}\\p{Nl}\\p{Ll}]]|[0-9])*(?:(?<=_)[!#%&*+\\-\\/:<>=?@^|~[\\p{Sm}\\p{So}]]+)?|(?:[!#%&*+\\-\\/:<>=?@^|~[\\p{Sm}\\p{So}]])+))","captures":{"1":{"name":"keyword.declaration.scala"},"2":{"name":"entity.name.type.declaration"}}},{"match":"\\b(val)\\s+([A-Z\\p{Lt}\\p{Lu}](?:[[A-Z\\p{Lt}\\p{Lu}][_a-z\\$\\p{Lo}\\p{Nl}\\p{Ll}]]|[0-9])*(?:(?<=_)[!#%&*+\\-\\/:<>=?@^|~[\\p{Sm}\\p{So}]]+)?)\\b","captures":{"1":{"name":"keyword.declaration.stable.scala"},"2":{"name":"constant.other.declaration.scala"}}},{"match":"\\b(?:(val)|(var))\\s+(?:(`[^`]+`|(?:[[A-Z\\p{Lt}\\p{Lu}][_a-z\\$\\p{Lo}\\p{Nl}\\p{Ll}]](?:[[A-Z\\p{Lt}\\p{Lu}][_a-z\\$\\p{Lo}\\p{Nl}\\p{Ll}]]|[0-9])*(?:(?<=_)[!#%&*+\\-\\/:<>=?@^|~[\\p{Sm}\\p{So}]]+)?|(?:[!#%&*+\\-\\/:<>=?@^|~[\\p{Sm}\\p{So}]])+))|(?=\\())","captures":{"1":{"name":"keyword.declaration.stable.scala"},"2":{"name":"keyword.declaration.volatile.scala"},"3":{"name":"variable.other.declaration.scala"}}},{"match":"\\b(package)\\s+(object)\\s+([^\\s\\{\\(\\[]+)","captures":{"1":{"name":"keyword.other.scoping.scala"},"2":{"name":"keyword.declaration.scala"},"3":{"name":"entity.name.class.declaration"}}},{"end":"(?<=[\\n;])","begin":"\\b(package)\\s+","beginCaptures":{"1":{"name":"keyword.other.import.scala"}},"patterns":[{"include":"#comments"},{"match":"(`[^`]+`|(?:[[A-Z\\p{Lt}\\p{Lu}][_a-z\\$\\p{Lo}\\p{Nl}\\p{Ll}]](?:[[A-Z\\p{Lt}\\p{Lu}][_a-z\\$\\p{Lo}\\p{Nl}\\p{Ll}]]|[0-9])*(?:(?<=_)[!#%&*+\\-\\/:<>=?@^|~[\\p{Sm}\\p{So}]]+)?|(?:[!#%&*+\\-\\/:<>=?@^|~[\\p{Sm}\\p{So}]])+))","name":"entity.name.package.scala"},{"match":"\\.","name":"punctuation.definition.package"}],"name":"meta.package.scala"}]},"char-literal":{"end":"'","begin":"'","beginCaptures":{"0":{"name":"punctuation.definition.character.begin.scala"}},"patterns":[{"match":"\\\\(?:[btnfr\\\\\"']|[0-7]{1,3}|u[0-9A-Fa-f]{4})","name":"constant.character.escape.scala"},{"match":"\\\\.","name":"invalid.illegal.unrecognized-character-escape.scala"},{"match":"[^']{2,}","name":"invalid.illegal.character-literal-too-long"},{"match":"(?'(?:[[A-Z\\p{Lt}\\p{Lu}][_a-z\\$\\p{Lo}\\p{Nl}\\p{Ll}]](?:[[A-Z\\p{Lt}\\p{Lu}][_a-z\\$\\p{Lo}\\p{Nl}\\p{Ll}]]|[0-9])*(?:(?<=_)[!#%&*+\\-\\/:<>=?@^|~[\\p{Sm}\\p{So}]]+)?|(?:[!#%&*+\\-\\/:<>=?@^|~[\\p{Sm}\\p{So}]])+))(?!')","name":"constant.other.symbol.scala"},"meta-brackets":{"patterns":[{"match":"\\{","comment":"The punctuation.section.*.begin is needed for return snippet in source bundle","name":"punctuation.section.block.begin.scala"},{"match":"\\}","comment":"The punctuation.section.*.end is needed for return snippet in source bundle","name":"punctuation.section.block.end.scala"},{"match":"{|}|\\(|\\)|\\[|\\]","name":"meta.bracket.scala"}],"comment":"For themes: Brackets look nice when colored."},"qualifiedClassName":{"match":"(\\b([A-Z][\\w]*))","captures":{"1":{"name":"entity.name.class"}}},"storage-modifiers":{"patterns":[{"match":"\\b(private\\[\\S+\\]|protected\\[\\S+\\]|private|protected)\\b","name":"storage.modifier.access"},{"match":"\\b(synchronized|@volatile|abstract|final|lazy|sealed|implicit|override|@transient|@native)\\b","name":"storage.modifier.other"}]},"meta-bounds":{"match":"<%|=:=|<:<|<%<|>:|<:","comment":"For themes: Matching view bounds","name":"meta.bounds.scala"},"comments":{"patterns":[{"match":"/\\*\\*/","captures":{"0":{"name":"punctuation.definition.comment.scala"}},"name":"comment.block.empty.scala"},{"end":"\\*/","begin":"^\\s*(/\\*\\*)(?!/)","beginCaptures":{"1":{"name":"punctuation.definition.comment.scala"}},"patterns":[{"match":"(@param)\\s+(\\S+)","captures":{"1":{"name":"keyword.other.documentation.scaladoc.scala"},"2":{"name":"variable.parameter.scala"}}},{"match":"(@(?:tparam|throws))\\s+(\\S+)","captures":{"1":{"name":"keyword.other.documentation.scaladoc.scala"},"2":{"name":"entity.name.class"}}},{"match":"@(return|see|note|example|usecase|author|version|since|todo|deprecated|migration|define|inheritdoc)\\b","name":"keyword.other.documentation.scaladoc.scala"},{"match":"(\\[\\[)([^\\]]+)(\\]\\])","captures":{"1":{"name":"punctuation.definition.documentation.link.scala"},"2":{"name":"entity.other.documentation.link.scala"},"3":{"name":"punctuation.definition.documentation.link.scala"}}}],"endCaptures":{"0":{"name":"punctuation.definition.comment.scala"}},"name":"comment.block.documentation.scala"},{"end":"\\*/","begin":"/\\*","captures":{"0":{"name":"punctuation.definition.comment.scala"}},"name":"comment.block.scala"},{"end":"(?!\\G)","begin":"(^[ \\t]+)?(?=//)","beginCaptures":{"1":{"name":"punctuation.whitespace.comment.leading.scala"}},"patterns":[{"end":"\\n","begin":"//","beginCaptures":{"0":{"name":"punctuation.definition.comment.scala"}},"name":"comment.line.double-slash.scala"}]}]},"xml-embedded-content":{"patterns":[{"end":"}","begin":"{","patterns":[{"include":"#code"}],"captures":{"0":{"name":"meta.bracket.scala"}},"name":"meta.source.embedded.scala"},{"match":" (?:([-_a-zA-Z0-9]+)((:)))?([_a-zA-Z-]+)=","captures":{"1":{"name":"entity.other.attribute-name.namespace.xml"},"2":{"name":"entity.other.attribute-name.xml"},"3":{"name":"punctuation.separator.namespace.xml"},"4":{"name":"entity.other.attribute-name.localname.xml"}}},{"include":"#xml-doublequotedString"},{"include":"#xml-singlequotedString"}]},"inheritance":{"patterns":[{"match":"(extends|with)\\s+([^\\s\\{\\(\\[\\]]+)","captures":{"1":{"name":"keyword.declaration.scala"},"2":{"name":"entity.other.inherited-class.scala"}}}]},"parameter-list":{"patterns":[{"match":"(?<=[^\\._$a-zA-Z0-9])(`[^`]+`|[_a-z\\$\\p{Lo}\\p{Nl}\\p{Ll}](?:[[A-Z\\p{Lt}\\p{Lu}][_a-z\\$\\p{Lo}\\p{Nl}\\p{Ll}]]|[0-9])*(?:(?<=_)[!#%&*+\\-\\/:<>=?@^|~[\\p{Sm}\\p{So}]]+)?)\\s*(:)\\s+","captures":{"1":{"name":"variable.parameter.scala"},"2":{"name":"meta.colon.scala"}}}]},"xml-literal":{"patterns":[{"end":"(>(<))/(?:([-_a-zA-Z0-9]+)((:)))?([-_a-zA-Z0-9:]*[_a-zA-Z0-9])(>)","begin":"(<)((?:([_a-zA-Z0-9][_a-zA-Z0-9]*)((:)))?([_a-zA-Z0-9][-_a-zA-Z0-9:]*))(?=(\\s[^>]*)?>)","beginCaptures":{"1":{"name":"punctuation.definition.tag.xml"},"3":{"name":"entity.name.tag.namespace.xml"},"4":{"name":"entity.name.tag.xml"},"5":{"name":"punctuation.separator.namespace.xml"},"6":{"name":"entity.name.tag.localname.xml"}},"patterns":[{"include":"#xml-embedded-content"}],"comment":"We do not allow a tag name to start with a - since this would likely conflict with the <- operator. This is not very common for tag names anyway. Also code such as -- if (val val3) will falsly be recognized as an xml tag. The solution is to put a space on either side of the comparison operator","endCaptures":{"1":{"name":"punctuation.definition.tag.xml"},"2":{"name":"meta.scope.between-tag-pair.xml"},"3":{"name":"entity.name.tag.namespace.xml"},"4":{"name":"entity.name.tag.xml"},"5":{"name":"punctuation.separator.namespace.xml"},"6":{"name":"entity.name.tag.localname.xml"},"7":{"name":"punctuation.definition.tag.xml"}},"name":"meta.tag.no-content.xml"},{"end":"(/?>)","begin":"(]*?>)","patterns":[{"include":"#xml-embedded-content"}],"captures":{"1":{"name":"punctuation.definition.tag.xml"},"2":{"name":"entity.name.tag.namespace.xml"},"3":{"name":"entity.name.tag.xml"},"4":{"name":"punctuation.separator.namespace.xml"},"5":{"name":"entity.name.tag.localname.xml"}},"name":"meta.tag.xml"},{"include":"#xml-entity"}]}},"uuid":"158C0929-299A-40C8-8D89-316BE0C446E8","$schema":"https://raw.githubusercontent.com/Septh/tmlanguage/master/tmLanguage.schema.json","patterns":[{"include":"#code"}],"name":"Scala","scopeName":"source.scala"} diff --git a/tests/snap/lexical.test.scala.snap b/tests/snap/lexical.test.scala.snap index 1b156b6..0733526 100644 --- a/tests/snap/lexical.test.scala.snap +++ b/tests/snap/lexical.test.scala.snap @@ -74,7 +74,11 @@ # ^ source.scala constant.numeric.scala # ^^^^^^^^ source.scala > val αρετη = 3 -#^^^^^^^^^^^^ source.scala +#^^ source.scala +# ^^^ source.scala keyword.declaration.stable.scala +# ^ source.scala +# ^^^^^ source.scala variable.other.declaration.scala +# ^ source.scala # ^ source.scala keyword.operator.comparison.scala # ^ source.scala # ^ source.scala constant.numeric.scala diff --git a/tests/snap/scala_spec.test.scala.snap b/tests/snap/scala_spec.test.scala.snap index 42fbd9d..e8fadd4 100644 --- a/tests/snap/scala_spec.test.scala.snap +++ b/tests/snap/scala_spec.test.scala.snap @@ -184,8 +184,9 @@ # ^ source.scala meta.colon.scala # ^ source.scala # ^^^^^^ source.scala storage.type.scala -# ^^^^^^^ source.scala -# ^ source.scala keyword.operator.scala +# ^^ source.scala +# ^^^^^ source.scala variable.parameter.scala +# ^ source.scala meta.colon.scala # ^ source.scala # ^^^^^^^ source.scala storage.type.primitive.scala # ^ source.scala meta.bracket.scala @@ -1321,8 +1322,7 @@ #^^^^ source.scala # ^^^ source.scala keyword.declaration.scala # ^ source.scala -# ^ source.scala entity.name.function.declaration -# ^ source.scala keyword.operator.comparison.scala +# ^^ source.scala entity.name.function.declaration # ^ source.scala meta.bracket.scala # ^^^^ source.scala variable.parameter.scala # ^ source.scala meta.colon.scala @@ -1370,8 +1370,7 @@ #^^^^ source.scala # ^^^ source.scala keyword.declaration.scala # ^ source.scala -# ^ source.scala entity.name.function.declaration -# ^ source.scala keyword.operator.comparison.scala +# ^^ source.scala entity.name.function.declaration # ^ source.scala meta.bracket.scala # ^^^^ source.scala variable.parameter.scala # ^ source.scala meta.colon.scala diff --git a/tests/unit/unicode.identifiers.test.scala b/tests/unit/unicode.identifiers.test.scala new file mode 100644 index 0000000..8afaf50 --- /dev/null +++ b/tests/unit/unicode.identifiers.test.scala @@ -0,0 +1,200 @@ +// SYNTAX TEST "source.scala" + +class Φδφκξ(x : Int, δφξκξ: Int, val y: Int, val φξ: Int) { +// <----- keyword.declaration.scala +// ^^^^^ entity.name.class.declaration +// ^ meta.bracket.scala +// ^ variable.parameter.scala +// ^ meta.colon.scala +// ^^^ storage.type.primitive.scala +// ^^^^^ variable.parameter.scala +// ^ meta.colon.scala +// ^^^ storage.type.primitive.scala +// ^^^ keyword.declaration.stable.scala +// ^ variable.other.declaration.scala +// ^ keyword.operator.scala +// ^^^ storage.type.primitive.scala +// ^^^ keyword.declaration.stable.scala +// ^^ variable.other.declaration.scala +// ^ keyword.operator.scala +// ^^^ storage.type.primitive.scala +// ^ meta.bracket.scala +// ^ punctuation.section.block.begin.scala + def δφξ() = 3 +//^^^ keyword.declaration.scala +// ^^^ entity.name.function.declaration +// ^^ meta.parentheses.scala meta.bracket.scala +// ^ keyword.operator.comparison.scala + val δφξ = 4 +//^^^ keyword.declaration.stable.scala +// ^^^ variable.other.declaration.scala +// ^ keyword.operator.comparison.scala + var δφξ = 5 +//^^^ keyword.declaration.volatile.scala +// ^^^ variable.other.declaration.scala +// ^ keyword.operator.comparison.scala + def δφξ(δφξκξ: Int) = () +//^^^ keyword.declaration.scala +// ^^^ entity.name.function.declaration +// ^ meta.bracket.scala +// ^^^^^ variable.parameter.scala +// ^ meta.colon.scala +// ^^^ storage.type.primitive.scala +// ^ meta.bracket.scala +// ^ keyword.operator.comparison.scala +// ^^ meta.parentheses.scala meta.bracket.scala + def foo(fj: Int) = () +//^^^ keyword.declaration.scala +// ^^^ entity.name.function.declaration +// ^ meta.bracket.scala +// ^^ variable.parameter.scala +// ^ meta.colon.scala +// ^^^ storage.type.primitive.scala +// ^ meta.bracket.scala +// ^ keyword.operator.comparison.scala +// ^^ meta.parentheses.scala meta.bracket.scala + + val Constant = 3 +//^^^ keyword.declaration.stable.scala +// ^^^^^^^^ constant.other.declaration.scala +// ^ keyword.operator.comparison.scala + val Константа = 4 +//^^^ keyword.declaration.stable.scala +// ^^^^^^^^^ constant.other.declaration.scala +// ^ keyword.operator.comparison.scala + +} + + +trait * { } +// <----- keyword.declaration.scala +// ^ entity.name.class.declaration +// ^ punctuation.section.block.begin.scala +// ^ punctuation.section.block.end.scala +class * { } +// <----- keyword.declaration.scala +// ^ entity.name.class.declaration +// ^ punctuation.section.block.begin.scala +// ^ punctuation.section.block.end.scala +case class **(x: Int) {} +// <---- keyword.declaration.scala +// ^^^^^ keyword.declaration.scala +// ^^ entity.name.class.declaration +// ^ meta.bracket.scala +// ^ variable.parameter.scala +// ^ meta.colon.scala +// ^^^ storage.type.primitive.scala +// ^ meta.bracket.scala + +trait f_*[A,x] { +// <----- keyword.declaration.scala +// ^^^ entity.name.class.declaration +// ^ meta.bracket.scala +// ^ entity.name.class +// ^ meta.bracket.scala +// ^ punctuation.section.block.begin.scala + + type * = Int +//^^^^ keyword.declaration.scala +// ^ entity.name.type.declaration +// ^ keyword.operator.comparison.scala +// ^^^ storage.type.primitive.scala + type x_* = Int +//^^^^ keyword.declaration.scala +// ^^^ entity.name.type.declaration +// ^ keyword.operator.comparison.scala +// ^^^ storage.type.primitive.scala + } + + +import scala.colection.Seq +// <------ meta.import.scala keyword.other.import.scala +// ^ meta.import.scala +// ^^^^^ meta.import.scala entity.name.import.scala +// ^ meta.import.scala punctuation.definition.import +// ^^^^^^^^^ meta.import.scala entity.name.import.scala +// ^ meta.import.scala punctuation.definition.import +// ^^^ meta.import.scala entity.name.import.scala +import users._ // import everything from the users package +// <------ meta.import.scala keyword.other.import.scala +// ^ meta.import.scala +// ^^^^^ meta.import.scala entity.name.import.scala +// ^ meta.import.scala punctuation.definition.import +// ^ meta.import.scala entity.name.import.scala + + +import users.User // import the class User +// <------ meta.import.scala keyword.other.import.scala +// ^ meta.import.scala +// ^^^^^ meta.import.scala entity.name.import.scala +// ^ meta.import.scala punctuation.definition.import +// ^^^^ meta.import.scala entity.name.import.scala +// ^^ comment.line.double-slash.scala punctuation.definition.comment.scala +// ^^^^^^^^^^^^^^^^^^^^^^ comment.line.double-slash.scala +import users.{User, UserPreferences} // Only imports selected members +// <------ meta.import.scala keyword.other.import.scala +// ^ meta.import.scala +// ^^^^^ meta.import.scala entity.name.import.scala +// ^ meta.import.scala punctuation.definition.import +// ^ meta.import.scala meta.import.selector.scala meta.bracket.scala +// ^^^^ meta.import.scala meta.import.selector.scala entity.name.import.scala +// ^^ meta.import.scala meta.import.selector.scala +// ^^^^^^^^^^^^^^^ meta.import.scala meta.import.selector.scala entity.name.import.scala +// ^ meta.import.scala meta.import.selector.scala meta.bracket.scala + + + +import users.{UserPreferences => UPrefs} // import and rename for convenience +// <------ meta.import.scala keyword.other.import.scala +// ^ meta.import.scala +// ^^^^^ meta.import.scala entity.name.import.scala +// ^ meta.import.scala punctuation.definition.import +// ^ meta.import.scala meta.import.selector.scala meta.bracket.scala +// ^^^^^^^^^^^^^^^ meta.import.scala meta.import.selector.scala entity.name.import.renamed-from.scala +// ^ meta.import.scala meta.import.selector.scala +// ^^ meta.import.scala meta.import.selector.scala keyword.other.arrow.scala +// ^ meta.import.scala meta.import.selector.scala +// ^^^^^^ meta.import.scala meta.import.selector.scala entity.name.import.renamed-to.scala +// ^ meta.import.scala meta.import.selector.scala meta.bracket.scala + + + + +import δκφξ._ +// <------ meta.import.scala keyword.other.import.scala +// ^ meta.import.scala +// ^^^^ meta.import.scala entity.name.import.scala +// ^ meta.import.scala punctuation.definition.import +// ^ meta.import.scala entity.name.import.scala +import φξξ0ξ.δκφξ +// <------ meta.import.scala keyword.other.import.scala +// ^ meta.import.scala +// ^^^^^ meta.import.scala entity.name.import.scala +// ^ meta.import.scala punctuation.definition.import +// ^^^^ meta.import.scala entity.name.import.scala +import φξ_+.{+,-, id} +// <------ meta.import.scala keyword.other.import.scala +// ^ meta.import.scala +// ^^^^ meta.import.scala entity.name.import.scala +// ^ meta.import.scala punctuation.definition.import +// ^ meta.import.scala meta.import.selector.scala meta.bracket.scala +// ^ meta.import.scala meta.import.selector.scala entity.name.import.scala +// ^ meta.import.scala meta.import.selector.scala +// ^ meta.import.scala meta.import.selector.scala entity.name.import.scala +// ^^ meta.import.scala meta.import.selector.scala +// ^^ meta.import.scala meta.import.selector.scala entity.name.import.scala +// ^ meta.import.scala meta.import.selector.scala meta.bracket.scala +import δφξ_+.{δφξ => φξ} +// <------ meta.import.scala keyword.other.import.scala +// ^ meta.import.scala +// ^^^^^ meta.import.scala entity.name.import.scala +// ^ meta.import.scala punctuation.definition.import +// ^ meta.import.scala meta.import.selector.scala meta.bracket.scala +// ^^^ source.scala meta.import.scala meta.import.selector.scala entity.name.import.renamed-from.scala +// ^ meta.import.scala meta.import.selector.scala +// ^^ meta.import.selector.scala keyword.other.arrow.scala +// ^ meta.import.scala meta.import.selector.scala +// ^^ meta.import.scala meta.import.selector.scala entity.name.import.renamed-to.scala +// ^ meta.import.scala meta.import.selector.scala meta.bracket.scala + +