Allow _ in jsx attribute names

Fixes #648
This commit is contained in:
Matt Bierner 2018-08-21 10:23:27 +02:00
Родитель e2db601b62
Коммит 4407e8d570
4 изменённых файлов: 121 добавлений и 13 удалений

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

@ -11,7 +11,7 @@ uuid: 805375ec-d614-41f5-8993-5843fe63ea82
variables:
#possiblyMultilineArrowExpressionBeforeEndOfLine: ({{typeParameters}})?\(
possiblyMultilineArrow: ((<\s*$)|([\(]\s*([\{\[]\s*)?$)) # during lookup treat ( followed by line end as arrow
jsxTagOrAtrributeIdentifier: '[_$[:alpha:]][-$[:alnum:].]*'
jsxTagOrAtrributeIdentifier: '[_$[:alpha:]][-_$[:alnum:].]*'
jsxTagNamespace: (?:({{jsxTagOrAtrributeIdentifier}})(?<!\.|-)(:))?
jsxTagName: \s*{{jsxTagNamespace}}((?:[a-z][a-z0-9]*|({{jsxTagOrAtrributeIdentifier}}))(?<!\.|-))
jsxOpeningTagWithoutAttributes: (<){{jsxTagName}}?\s*(>)
@ -164,7 +164,7 @@ repository:
(?x)
\s*
(?:({{jsxTagOrAtrributeIdentifier}})(:))?
([_$[:alpha:]][-$[:alnum:]]*)
([_$[:alpha:]][-_$[:alnum:]]*)
(?=\s|=|/?>|/\*|//)
captures:
'1': {name: entity.other.attribute-name.namespace.tsx}

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

@ -8317,9 +8317,9 @@
<key>jsx-tag-without-attributes-in-expression</key>
<dict>
<key>begin</key>
<string>(?&lt;!\+\+|--)(?&lt;=[({\[,?=&gt;:*]|&amp;&amp;|\|\||\?|^await|[^\._$[:alnum:]]await|^return|[^\._$[:alnum:]]return|^default|[^\._$[:alnum:]]default|^yield|[^\._$[:alnum:]]yield|^)\s*(?=(&lt;)\s*(?:([_$[:alpha:]][-$[:alnum:].]*)(?&lt;!\.|-)(:))?((?:[a-z][a-z0-9]*|([_$[:alpha:]][-$[:alnum:].]*))(?&lt;!\.|-))?\s*(&gt;))</string>
<string>(?&lt;!\+\+|--)(?&lt;=[({\[,?=&gt;:*]|&amp;&amp;|\|\||\?|^await|[^\._$[:alnum:]]await|^return|[^\._$[:alnum:]]return|^default|[^\._$[:alnum:]]default|^yield|[^\._$[:alnum:]]yield|^)\s*(?=(&lt;)\s*(?:([_$[:alpha:]][-_$[:alnum:].]*)(?&lt;!\.|-)(:))?((?:[a-z][a-z0-9]*|([_$[:alpha:]][-_$[:alnum:].]*))(?&lt;!\.|-))?\s*(&gt;))</string>
<key>end</key>
<string>(?!(&lt;)\s*(?:([_$[:alpha:]][-$[:alnum:].]*)(?&lt;!\.|-)(:))?((?:[a-z][a-z0-9]*|([_$[:alpha:]][-$[:alnum:].]*))(?&lt;!\.|-))?\s*(&gt;))</string>
<string>(?!(&lt;)\s*(?:([_$[:alpha:]][-_$[:alnum:].]*)(?&lt;!\.|-)(:))?((?:[a-z][a-z0-9]*|([_$[:alpha:]][-_$[:alnum:].]*))(?&lt;!\.|-))?\s*(&gt;))</string>
<key>patterns</key>
<array>
<dict>
@ -8333,9 +8333,9 @@
<key>name</key>
<string>meta.tag.without-attributes.tsx</string>
<key>begin</key>
<string>(&lt;)\s*(?:([_$[:alpha:]][-$[:alnum:].]*)(?&lt;!\.|-)(:))?((?:[a-z][a-z0-9]*|([_$[:alpha:]][-$[:alnum:].]*))(?&lt;!\.|-))?\s*(&gt;)</string>
<string>(&lt;)\s*(?:([_$[:alpha:]][-_$[:alnum:].]*)(?&lt;!\.|-)(:))?((?:[a-z][a-z0-9]*|([_$[:alpha:]][-_$[:alnum:].]*))(?&lt;!\.|-))?\s*(&gt;)</string>
<key>end</key>
<string>(&lt;/)\s*(?:([_$[:alpha:]][-$[:alnum:].]*)(?&lt;!\.|-)(:))?((?:[a-z][a-z0-9]*|([_$[:alpha:]][-$[:alnum:].]*))(?&lt;!\.|-))?\s*(&gt;)</string>
<string>(&lt;/)\s*(?:([_$[:alpha:]][-_$[:alnum:].]*)(?&lt;!\.|-)(:))?((?:[a-z][a-z0-9]*|([_$[:alpha:]][-_$[:alnum:].]*))(?&lt;!\.|-))?\s*(&gt;)</string>
<key>beginCaptures</key>
<dict>
<key>1</key>
@ -8418,9 +8418,9 @@
<string>(?x)
(?&lt;!\+\+|--)(?&lt;=[({\[,?=&gt;:*]|&amp;&amp;|\|\||\?|^await|[^\._$[:alnum:]]await|^return|[^\._$[:alnum:]]return|^default|[^\._$[:alnum:]]default|^yield|[^\._$[:alnum:]]yield|^)\s*
(?!&lt;\s*[_$[:alpha:]][_$[:alnum:]]*((\s+extends\s+[^=&gt;])|,)) # look ahead is not type parameter of arrow
(?=(&lt;)\s*(?:([_$[:alpha:]][-$[:alnum:].]*)(?&lt;!\.|-)(:))?((?:[a-z][a-z0-9]*|([_$[:alpha:]][-$[:alnum:].]*))(?&lt;!\.|-))(?=((&lt;\s*)|(\s+))(?!\?)|\/?&gt;))</string>
(?=(&lt;)\s*(?:([_$[:alpha:]][-_$[:alnum:].]*)(?&lt;!\.|-)(:))?((?:[a-z][a-z0-9]*|([_$[:alpha:]][-_$[:alnum:].]*))(?&lt;!\.|-))(?=((&lt;\s*)|(\s+))(?!\?)|\/?&gt;))</string>
<key>end</key>
<string>(?!(&lt;)\s*(?:([_$[:alpha:]][-$[:alnum:].]*)(?&lt;!\.|-)(:))?((?:[a-z][a-z0-9]*|([_$[:alpha:]][-$[:alnum:].]*))(?&lt;!\.|-))(?=((&lt;\s*)|(\s+))(?!\?)|\/?&gt;))</string>
<string>(?!(&lt;)\s*(?:([_$[:alpha:]][-_$[:alnum:].]*)(?&lt;!\.|-)(:))?((?:[a-z][a-z0-9]*|([_$[:alpha:]][-_$[:alnum:].]*))(?&lt;!\.|-))(?=((&lt;\s*)|(\s+))(?!\?)|\/?&gt;))</string>
<key>patterns</key>
<array>
<dict>
@ -8434,9 +8434,9 @@
<key>name</key>
<string>meta.tag.tsx</string>
<key>begin</key>
<string>(?=(&lt;)\s*(?:([_$[:alpha:]][-$[:alnum:].]*)(?&lt;!\.|-)(:))?((?:[a-z][a-z0-9]*|([_$[:alpha:]][-$[:alnum:].]*))(?&lt;!\.|-))(?=((&lt;\s*)|(\s+))(?!\?)|\/?&gt;))</string>
<string>(?=(&lt;)\s*(?:([_$[:alpha:]][-_$[:alnum:].]*)(?&lt;!\.|-)(:))?((?:[a-z][a-z0-9]*|([_$[:alpha:]][-_$[:alnum:].]*))(?&lt;!\.|-))(?=((&lt;\s*)|(\s+))(?!\?)|\/?&gt;))</string>
<key>end</key>
<string>(/&gt;)|(?:(&lt;/)\s*(?:([_$[:alpha:]][-$[:alnum:].]*)(?&lt;!\.|-)(:))?((?:[a-z][a-z0-9]*|([_$[:alpha:]][-$[:alnum:].]*))(?&lt;!\.|-))?\s*(&gt;))</string>
<string>(/&gt;)|(?:(&lt;/)\s*(?:([_$[:alpha:]][-_$[:alnum:].]*)(?&lt;!\.|-)(:))?((?:[a-z][a-z0-9]*|([_$[:alpha:]][-_$[:alnum:].]*))(?&lt;!\.|-))?\s*(&gt;))</string>
<key>endCaptures</key>
<dict>
<key>1</key>
@ -8479,7 +8479,7 @@
<array>
<dict>
<key>begin</key>
<string>(&lt;)\s*(?:([_$[:alpha:]][-$[:alnum:].]*)(?&lt;!\.|-)(:))?((?:[a-z][a-z0-9]*|([_$[:alpha:]][-$[:alnum:].]*))(?&lt;!\.|-))(?=((&lt;\s*)|(\s+))(?!\?)|\/?&gt;)</string>
<string>(&lt;)\s*(?:([_$[:alpha:]][-_$[:alnum:].]*)(?&lt;!\.|-)(:))?((?:[a-z][a-z0-9]*|([_$[:alpha:]][-_$[:alnum:].]*))(?&lt;!\.|-))(?=((&lt;\s*)|(\s+))(?!\?)|\/?&gt;)</string>
<key>beginCaptures</key>
<dict>
<key>1</key>
@ -8681,8 +8681,8 @@
<key>match</key>
<string>(?x)
\s*
(?:([_$[:alpha:]][-$[:alnum:].]*)(:))?
([_$[:alpha:]][-$[:alnum:]]*)
(?:([_$[:alpha:]][-_$[:alnum:].]*)(:))?
([_$[:alpha:]][-_$[:alnum:]]*)
(?=\s|=|/?&gt;|/\*|//)</string>
<key>captures</key>
<dict>

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

@ -0,0 +1,103 @@
original file
-----------------------------------
<Test
a=''
b_c='111'
d=''
/>
-----------------------------------
Grammar: TypeScriptReact.tmLanguage
-----------------------------------
><Test
^
source.tsx meta.tag.tsx punctuation.definition.tag.begin.tsx
^^^^
source.tsx meta.tag.tsx entity.name.tag.tsx support.class.component.tsx
> a=''
^^^^
source.tsx meta.tag.tsx meta.tag.attributes.tsx
^
source.tsx meta.tag.tsx meta.tag.attributes.tsx entity.other.attribute-name.tsx
^
source.tsx meta.tag.tsx meta.tag.attributes.tsx keyword.operator.assignment.tsx
^
source.tsx meta.tag.tsx meta.tag.attributes.tsx string.quoted.single.tsx punctuation.definition.string.begin.tsx
^
source.tsx meta.tag.tsx meta.tag.attributes.tsx string.quoted.single.tsx punctuation.definition.string.end.tsx
> b_c='111'
^^^^
source.tsx meta.tag.tsx meta.tag.attributes.tsx
^^^
source.tsx meta.tag.tsx meta.tag.attributes.tsx entity.other.attribute-name.tsx
^
source.tsx meta.tag.tsx meta.tag.attributes.tsx keyword.operator.assignment.tsx
^
source.tsx meta.tag.tsx meta.tag.attributes.tsx string.quoted.single.tsx punctuation.definition.string.begin.tsx
^^^
source.tsx meta.tag.tsx meta.tag.attributes.tsx string.quoted.single.tsx
^
source.tsx meta.tag.tsx meta.tag.attributes.tsx string.quoted.single.tsx punctuation.definition.string.end.tsx
> d=''
^^^^
source.tsx meta.tag.tsx meta.tag.attributes.tsx
^
source.tsx meta.tag.tsx meta.tag.attributes.tsx entity.other.attribute-name.tsx
^
source.tsx meta.tag.tsx meta.tag.attributes.tsx keyword.operator.assignment.tsx
^
source.tsx meta.tag.tsx meta.tag.attributes.tsx string.quoted.single.tsx punctuation.definition.string.begin.tsx
^
source.tsx meta.tag.tsx meta.tag.attributes.tsx string.quoted.single.tsx punctuation.definition.string.end.tsx
>/>
^^
source.tsx meta.tag.tsx punctuation.definition.tag.end.tsx
Grammar: TypeScript.tmLanguage
-----------------------------------
><Test
^
source.ts keyword.operator.relational.ts
^^^^
source.ts variable.other.readwrite.ts
> a=''
^^^^
source.ts
^
source.ts variable.other.readwrite.ts
^
source.ts keyword.operator.assignment.ts
^
source.ts string.quoted.single.ts punctuation.definition.string.begin.ts
^
source.ts string.quoted.single.ts punctuation.definition.string.end.ts
> b_c='111'
^^^^
source.ts
^^^
source.ts variable.other.readwrite.ts
^
source.ts keyword.operator.assignment.ts
^
source.ts string.quoted.single.ts punctuation.definition.string.begin.ts
^^^
source.ts string.quoted.single.ts
^
source.ts string.quoted.single.ts punctuation.definition.string.end.ts
> d=''
^^^^
source.ts
^
source.ts variable.other.readwrite.ts
^
source.ts keyword.operator.assignment.ts
^
source.ts string.quoted.single.ts punctuation.definition.string.begin.ts
^
source.ts string.quoted.single.ts punctuation.definition.string.end.ts
>/>
^
source.ts keyword.operator.arithmetic.ts
^
source.ts keyword.operator.relational.ts

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

@ -0,0 +1,5 @@
<Test
a=''
b_c='111'
d=''
/>