Fix recognition of regexp class

Fixes #832
This commit is contained in:
Sheetal Nandi 2020-11-05 13:27:34 -08:00
Родитель 7e4ccfde81
Коммит 15b157d42e
5 изменённых файлов: 71 добавлений и 5 удалений

Просмотреть файл

@ -136,7 +136,7 @@ variables:
(:\s*(=>|{{matchingParenthesis}}|(<[^<>]*>)|[^<>(),=])+={{functionOrArrowLookup}})
arrowFunctionEnd: (?==>|\{|(^\s*(export|function|class|interface|let|var|const|import|enum|namespace|module|type|abstract|declare)\s+))
regexpTail: ([gimsuy]+|(?![\/\*])|(?=\/\*))(?!\s*[a-zA-Z0-9_$])
completeRegexp: \/(?![\/*])(?=(?:[^\/\\\[]|\\.|\[([^\]\\]|\\.)+\])+\/{{regexpTail}})
completeRegexp: \/(?![\/*])(?=(?:[^\/\\\[]|\\.|\[([^\]\\]|\\.)*\])+\/{{regexpTail}})
patterns:
- include: '#directives'

Просмотреть файл

@ -4115,7 +4115,7 @@
<key>name</key>
<string>string.regexp.ts</string>
<key>begin</key>
<string>(?&lt;=\))\s*\/(?![\/*])(?=(?:[^\/\\\[]|\\.|\[([^\]\\]|\\.)+\])+\/([gimsuy]+|(?![\/\*])|(?=\/\*))(?!\s*[a-zA-Z0-9_$]))</string>
<string>(?&lt;=\))\s*\/(?![\/*])(?=(?:[^\/\\\[]|\\.|\[([^\]\\]|\\.)*\])+\/([gimsuy]+|(?![\/\*])|(?=\/\*))(?!\s*[a-zA-Z0-9_$]))</string>
<key>beginCaptures</key>
<dict>
<key>0</key>
@ -8076,7 +8076,7 @@
<key>name</key>
<string>string.regexp.ts</string>
<key>begin</key>
<string>((?&lt;![_$[:alnum:])\]]|\+\+|--|}|\*\/)|((?&lt;=^return|[^\._$[:alnum:]]return|^case|[^\._$[:alnum:]]case))\s*)\/(?![\/*])(?=(?:[^\/\\\[]|\\.|\[([^\]\\]|\\.)+\])+\/([gimsuy]+|(?![\/\*])|(?=\/\*))(?!\s*[a-zA-Z0-9_$]))</string>
<string>((?&lt;![_$[:alnum:])\]]|\+\+|--|}|\*\/)|((?&lt;=^return|[^\._$[:alnum:]]return|^case|[^\._$[:alnum:]]case))\s*)\/(?![\/*])(?=(?:[^\/\\\[]|\\.|\[([^\]\\]|\\.)*\])+\/([gimsuy]+|(?![\/\*])|(?=\/\*))(?!\s*[a-zA-Z0-9_$]))</string>
<key>beginCaptures</key>
<dict>
<key>0</key>

Просмотреть файл

@ -4137,7 +4137,7 @@
<key>name</key>
<string>string.regexp.tsx</string>
<key>begin</key>
<string>(?&lt;=\))\s*\/(?![\/*])(?=(?:[^\/\\\[]|\\.|\[([^\]\\]|\\.)+\])+\/([gimsuy]+|(?![\/\*])|(?=\/\*))(?!\s*[a-zA-Z0-9_$]))</string>
<string>(?&lt;=\))\s*\/(?![\/*])(?=(?:[^\/\\\[]|\\.|\[([^\]\\]|\\.)*\])+\/([gimsuy]+|(?![\/\*])|(?=\/\*))(?!\s*[a-zA-Z0-9_$]))</string>
<key>beginCaptures</key>
<dict>
<key>0</key>
@ -8024,7 +8024,7 @@
<key>name</key>
<string>string.regexp.tsx</string>
<key>begin</key>
<string>((?&lt;![_$[:alnum:])\]]|\+\+|--|}|\*\/)|((?&lt;=^return|[^\._$[:alnum:]]return|^case|[^\._$[:alnum:]]case))\s*)\/(?![\/*])(?=(?:[^\/\\\[]|\\.|\[([^\]\\]|\\.)+\])+\/([gimsuy]+|(?![\/\*])|(?=\/\*))(?!\s*[a-zA-Z0-9_$]))</string>
<string>((?&lt;![_$[:alnum:])\]]|\+\+|--|}|\*\/)|((?&lt;=^return|[^\._$[:alnum:]]return|^case|[^\._$[:alnum:]]case))\s*)\/(?![\/*])(?=(?:[^\/\\\[]|\\.|\[([^\]\\]|\\.)*\])+\/([gimsuy]+|(?![\/\*])|(?=\/\*))(?!\s*[a-zA-Z0-9_$]))</string>
<key>beginCaptures</key>
<dict>
<key>0</key>

Просмотреть файл

@ -0,0 +1,64 @@
original file
-----------------------------------
let a = /foo[]bar/;
let b = /foo[^]bar/;
-----------------------------------
Grammar: TypeScript.tmLanguage
-----------------------------------
>let a = /foo[]bar/;
^^^
source.ts meta.var.expr.ts storage.type.ts
^
source.ts meta.var.expr.ts
^
source.ts meta.var.expr.ts meta.var-single-variable.expr.ts meta.definition.variable.ts variable.other.readwrite.ts
^
source.ts meta.var.expr.ts meta.var-single-variable.expr.ts
^
source.ts meta.var.expr.ts keyword.operator.assignment.ts
^
source.ts meta.var.expr.ts
^
source.ts meta.var.expr.ts string.regexp.ts punctuation.definition.string.begin.ts
^^^
source.ts meta.var.expr.ts string.regexp.ts
^
source.ts meta.var.expr.ts string.regexp.ts constant.other.character-class.set.regexp punctuation.definition.character-class.regexp
^
source.ts meta.var.expr.ts string.regexp.ts constant.other.character-class.set.regexp punctuation.definition.character-class.regexp
^^^
source.ts meta.var.expr.ts string.regexp.ts
^
source.ts meta.var.expr.ts string.regexp.ts punctuation.definition.string.end.ts
^
source.ts punctuation.terminator.statement.ts
>let b = /foo[^]bar/;
^^^
source.ts meta.var.expr.ts storage.type.ts
^
source.ts meta.var.expr.ts
^
source.ts meta.var.expr.ts meta.var-single-variable.expr.ts meta.definition.variable.ts variable.other.readwrite.ts
^
source.ts meta.var.expr.ts meta.var-single-variable.expr.ts
^
source.ts meta.var.expr.ts keyword.operator.assignment.ts
^
source.ts meta.var.expr.ts string.regexp.ts
^
source.ts meta.var.expr.ts string.regexp.ts punctuation.definition.string.begin.ts
^^^
source.ts meta.var.expr.ts string.regexp.ts
^
source.ts meta.var.expr.ts string.regexp.ts constant.other.character-class.set.regexp punctuation.definition.character-class.regexp
^
source.ts meta.var.expr.ts string.regexp.ts constant.other.character-class.set.regexp keyword.operator.negation.regexp
^
source.ts meta.var.expr.ts string.regexp.ts constant.other.character-class.set.regexp punctuation.definition.character-class.regexp
^^^
source.ts meta.var.expr.ts string.regexp.ts
^
source.ts meta.var.expr.ts string.regexp.ts punctuation.definition.string.end.ts
^
source.ts punctuation.terminator.statement.ts

2
tests/cases/Issue832.ts Normal file
Просмотреть файл

@ -0,0 +1,2 @@
let a = /foo[]bar/;
let b = /foo[^]bar/;