Some restructuring in react grammar
This commit is contained in:
Родитель
aef7be5c6d
Коммит
cd961ac97a
|
@ -16,6 +16,7 @@ variables:
|
|||
jsxClosingTag: (</){{jsxTagName}}?\s*(>)
|
||||
jsxTagStart: (<){{jsxTagName}}(?=(?:\s*{{typeArguments}})?\s+(?!\?)|\/?>)
|
||||
jsxTagStartLookahead: (?={{jsxTagStart}})
|
||||
jsxLookBehindInExpression: (?<=[({\[,?=>:*]|&&|\|\||\?|{{lookBehindReturn}}|{{lookBehindDefault}}|^)\s*
|
||||
|
||||
repository:
|
||||
# Additions:
|
||||
|
@ -40,11 +41,8 @@ repository:
|
|||
|
||||
#jsx tags
|
||||
jsx-tag-without-attributes-in-expression:
|
||||
begin: |-
|
||||
(?x)
|
||||
(?<=[({\[,?=>:*]|&&|\|\||\?|{{lookBehindReturn}}|{{lookBehindDefault}}|^)\s*
|
||||
(?={{jsxOpeningTagWithoutAttributes}})
|
||||
end: (?!\s*{{jsxOpeningTagWithoutAttributes}})
|
||||
begin: '{{jsxLookBehindInExpression}}(?={{jsxOpeningTagWithoutAttributes}})'
|
||||
end: (?!{{jsxOpeningTagWithoutAttributes}})
|
||||
patterns:
|
||||
- include: '#jsx-tag-without-attributes'
|
||||
|
||||
|
@ -74,28 +72,18 @@ repository:
|
|||
# We need to differentiate between the relational '<' operator and the beginning of a tag using the surrounding context.
|
||||
begin: |-
|
||||
(?x)
|
||||
(?<=[({\[,?=>:*]|&&|\|\||\?|{{lookBehindReturn}}|{{lookBehindDefault}}|^)\s*
|
||||
{{jsxLookBehindInExpression}}
|
||||
(?!<\s*[_$[:alpha:]][_$[:alnum:]]*((\s+extends\s+[^=>])|,)) # look ahead is not type parameter of arrow
|
||||
{{jsxTagStartLookahead}}
|
||||
end: (/>)|(?:{{jsxClosingTag}})
|
||||
endCaptures:
|
||||
'0': { name: meta.tag.tsx }
|
||||
'1': { name: punctuation.definition.tag.end.tsx }
|
||||
'2': { name: punctuation.definition.tag.begin.tsx }
|
||||
'3': { name: entity.name.tag.namespace.tsx }
|
||||
'4': { name: punctuation.separator.namespace.tsx }
|
||||
'5': { name: entity.name.tag.tsx }
|
||||
'6': { name: support.class.component.tsx }
|
||||
'7': { name: punctuation.definition.tag.end.tsx }
|
||||
end: (?!{{jsxTagStart}})
|
||||
patterns:
|
||||
- include: '#jsx-tag'
|
||||
|
||||
jsx-child-tag:
|
||||
# Because this would be included from the jsx-children, this doesnt need to inspect surrounding context
|
||||
jsx-tag:
|
||||
name: meta.tag.tsx
|
||||
begin: '{{jsxTagStartLookahead}}'
|
||||
end: (/>)|(?:{{jsxClosingTag}})
|
||||
endCaptures:
|
||||
'0': { name: meta.tag.tsx }
|
||||
'1': { name: punctuation.definition.tag.end.tsx }
|
||||
'2': { name: punctuation.definition.tag.begin.tsx }
|
||||
'3': { name: entity.name.tag.namespace.tsx }
|
||||
|
@ -104,13 +92,6 @@ repository:
|
|||
'6': { name: support.class.component.tsx }
|
||||
'7': { name: punctuation.definition.tag.end.tsx }
|
||||
patterns:
|
||||
- include: '#jsx-tag'
|
||||
|
||||
jsx-tag:
|
||||
name: meta.tag.tsx
|
||||
begin: '{{jsxTagStartLookahead}}'
|
||||
end: (?=(/>)|(?:{{jsxClosingTag}}))
|
||||
patterns:
|
||||
- begin: '{{jsxTagStart}}'
|
||||
beginCaptures:
|
||||
'1': { name: punctuation.definition.tag.begin.tsx }
|
||||
|
@ -137,7 +118,8 @@ repository:
|
|||
jsx-children:
|
||||
patterns:
|
||||
- include: '#jsx-tag-without-attributes'
|
||||
- include: '#jsx-child-tag'
|
||||
# Because this would be included from the jsx-children, this doesnt need to inspect surrounding context
|
||||
- include: '#jsx-tag'
|
||||
- include: '#jsx-evaluated-code'
|
||||
- include: '#jsx-entities'
|
||||
|
||||
|
|
|
@ -6926,11 +6926,9 @@
|
|||
<key>jsx-tag-without-attributes-in-expression</key>
|
||||
<dict>
|
||||
<key>begin</key>
|
||||
<string>(?x)
|
||||
(?<=[({\[,?=>:*]|&&|\|\||\?|^return|[^\._$[:alnum:]]return|^default|[^\._$[:alnum:]]default|^)\s*
|
||||
(?=(<)\s*(?:([_$a-zA-Z][-$\w.]*)(?<!\.|-)(:))?((?:[a-z][a-z0-9]*|([_$a-zA-Z][-$\w.]*))(?<!\.|-))?\s*(>))</string>
|
||||
<string>(?<=[({\[,?=>:*]|&&|\|\||\?|^return|[^\._$[:alnum:]]return|^default|[^\._$[:alnum:]]default|^)\s*(?=(<)\s*(?:([_$a-zA-Z][-$\w.]*)(?<!\.|-)(:))?((?:[a-z][a-z0-9]*|([_$a-zA-Z][-$\w.]*))(?<!\.|-))?\s*(>))</string>
|
||||
<key>end</key>
|
||||
<string>(?!\s*(<)\s*(?:([_$a-zA-Z][-$\w.]*)(?<!\.|-)(:))?((?:[a-z][a-z0-9]*|([_$a-zA-Z][-$\w.]*))(?<!\.|-))?\s*(>))</string>
|
||||
<string>(?!(<)\s*(?:([_$a-zA-Z][-$\w.]*)(?<!\.|-)(:))?((?:[a-z][a-z0-9]*|([_$a-zA-Z][-$\w.]*))(?<!\.|-))?\s*(>))</string>
|
||||
<key>patterns</key>
|
||||
<array>
|
||||
<dict>
|
||||
|
@ -7031,107 +7029,7 @@
|
|||
(?!<\s*[_$[:alpha:]][_$[:alnum:]]*((\s+extends\s+[^=>])|,)) # look ahead is not type parameter of arrow
|
||||
(?=(<)\s*(?:([_$a-zA-Z][-$\w.]*)(?<!\.|-)(:))?((?:[a-z][a-z0-9]*|([_$a-zA-Z][-$\w.]*))(?<!\.|-))(?=(?:\s*<\s*(([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))|(\'[^\']*\')|(\"[^\"]*\")|(\`[^\`]*\`))([^<>\(]|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(?<==)\>|\<\s*(([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))|(\'[^\']*\')|(\"[^\"]*\")|(\`[^\`]*\`))([^<>\(]|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(?<==)\>)*(?!=)\>)*(?!=)>)?\s+(?!\?)|\/?>))</string>
|
||||
<key>end</key>
|
||||
<string>(/>)|(?:(</)\s*(?:([_$a-zA-Z][-$\w.]*)(?<!\.|-)(:))?((?:[a-z][a-z0-9]*|([_$a-zA-Z][-$\w.]*))(?<!\.|-))?\s*(>))</string>
|
||||
<key>endCaptures</key>
|
||||
<dict>
|
||||
<key>0</key>
|
||||
<dict>
|
||||
<key>name</key>
|
||||
<string>meta.tag.tsx</string>
|
||||
</dict>
|
||||
<key>1</key>
|
||||
<dict>
|
||||
<key>name</key>
|
||||
<string>punctuation.definition.tag.end.tsx</string>
|
||||
</dict>
|
||||
<key>2</key>
|
||||
<dict>
|
||||
<key>name</key>
|
||||
<string>punctuation.definition.tag.begin.tsx</string>
|
||||
</dict>
|
||||
<key>3</key>
|
||||
<dict>
|
||||
<key>name</key>
|
||||
<string>entity.name.tag.namespace.tsx</string>
|
||||
</dict>
|
||||
<key>4</key>
|
||||
<dict>
|
||||
<key>name</key>
|
||||
<string>punctuation.separator.namespace.tsx</string>
|
||||
</dict>
|
||||
<key>5</key>
|
||||
<dict>
|
||||
<key>name</key>
|
||||
<string>entity.name.tag.tsx</string>
|
||||
</dict>
|
||||
<key>6</key>
|
||||
<dict>
|
||||
<key>name</key>
|
||||
<string>support.class.component.tsx</string>
|
||||
</dict>
|
||||
<key>7</key>
|
||||
<dict>
|
||||
<key>name</key>
|
||||
<string>punctuation.definition.tag.end.tsx</string>
|
||||
</dict>
|
||||
</dict>
|
||||
<key>patterns</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>include</key>
|
||||
<string>#jsx-tag</string>
|
||||
</dict>
|
||||
</array>
|
||||
</dict>
|
||||
<key>jsx-child-tag</key>
|
||||
<dict>
|
||||
<key>begin</key>
|
||||
<string>(?=(<)\s*(?:([_$a-zA-Z][-$\w.]*)(?<!\.|-)(:))?((?:[a-z][a-z0-9]*|([_$a-zA-Z][-$\w.]*))(?<!\.|-))(?=(?:\s*<\s*(([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))|(\'[^\']*\')|(\"[^\"]*\")|(\`[^\`]*\`))([^<>\(]|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(?<==)\>|\<\s*(([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))|(\'[^\']*\')|(\"[^\"]*\")|(\`[^\`]*\`))([^<>\(]|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(?<==)\>)*(?!=)\>)*(?!=)>)?\s+(?!\?)|\/?>))</string>
|
||||
<key>end</key>
|
||||
<string>(/>)|(?:(</)\s*(?:([_$a-zA-Z][-$\w.]*)(?<!\.|-)(:))?((?:[a-z][a-z0-9]*|([_$a-zA-Z][-$\w.]*))(?<!\.|-))?\s*(>))</string>
|
||||
<key>endCaptures</key>
|
||||
<dict>
|
||||
<key>0</key>
|
||||
<dict>
|
||||
<key>name</key>
|
||||
<string>meta.tag.tsx</string>
|
||||
</dict>
|
||||
<key>1</key>
|
||||
<dict>
|
||||
<key>name</key>
|
||||
<string>punctuation.definition.tag.end.tsx</string>
|
||||
</dict>
|
||||
<key>2</key>
|
||||
<dict>
|
||||
<key>name</key>
|
||||
<string>punctuation.definition.tag.begin.tsx</string>
|
||||
</dict>
|
||||
<key>3</key>
|
||||
<dict>
|
||||
<key>name</key>
|
||||
<string>entity.name.tag.namespace.tsx</string>
|
||||
</dict>
|
||||
<key>4</key>
|
||||
<dict>
|
||||
<key>name</key>
|
||||
<string>punctuation.separator.namespace.tsx</string>
|
||||
</dict>
|
||||
<key>5</key>
|
||||
<dict>
|
||||
<key>name</key>
|
||||
<string>entity.name.tag.tsx</string>
|
||||
</dict>
|
||||
<key>6</key>
|
||||
<dict>
|
||||
<key>name</key>
|
||||
<string>support.class.component.tsx</string>
|
||||
</dict>
|
||||
<key>7</key>
|
||||
<dict>
|
||||
<key>name</key>
|
||||
<string>punctuation.definition.tag.end.tsx</string>
|
||||
</dict>
|
||||
</dict>
|
||||
<string>(?!(<)\s*(?:([_$a-zA-Z][-$\w.]*)(?<!\.|-)(:))?((?:[a-z][a-z0-9]*|([_$a-zA-Z][-$\w.]*))(?<!\.|-))(?=(?:\s*<\s*(([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))|(\'[^\']*\')|(\"[^\"]*\")|(\`[^\`]*\`))([^<>\(]|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(?<==)\>|\<\s*(([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))|(\'[^\']*\')|(\"[^\"]*\")|(\`[^\`]*\`))([^<>\(]|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(?<==)\>)*(?!=)\>)*(?!=)>)?\s+(?!\?)|\/?>))</string>
|
||||
<key>patterns</key>
|
||||
<array>
|
||||
<dict>
|
||||
|
@ -7147,7 +7045,45 @@
|
|||
<key>begin</key>
|
||||
<string>(?=(<)\s*(?:([_$a-zA-Z][-$\w.]*)(?<!\.|-)(:))?((?:[a-z][a-z0-9]*|([_$a-zA-Z][-$\w.]*))(?<!\.|-))(?=(?:\s*<\s*(([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))|(\'[^\']*\')|(\"[^\"]*\")|(\`[^\`]*\`))([^<>\(]|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(?<==)\>|\<\s*(([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))|(\'[^\']*\')|(\"[^\"]*\")|(\`[^\`]*\`))([^<>\(]|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(?<==)\>)*(?!=)\>)*(?!=)>)?\s+(?!\?)|\/?>))</string>
|
||||
<key>end</key>
|
||||
<string>(?=(/>)|(?:(</)\s*(?:([_$a-zA-Z][-$\w.]*)(?<!\.|-)(:))?((?:[a-z][a-z0-9]*|([_$a-zA-Z][-$\w.]*))(?<!\.|-))?\s*(>)))</string>
|
||||
<string>(/>)|(?:(</)\s*(?:([_$a-zA-Z][-$\w.]*)(?<!\.|-)(:))?((?:[a-z][a-z0-9]*|([_$a-zA-Z][-$\w.]*))(?<!\.|-))?\s*(>))</string>
|
||||
<key>endCaptures</key>
|
||||
<dict>
|
||||
<key>1</key>
|
||||
<dict>
|
||||
<key>name</key>
|
||||
<string>punctuation.definition.tag.end.tsx</string>
|
||||
</dict>
|
||||
<key>2</key>
|
||||
<dict>
|
||||
<key>name</key>
|
||||
<string>punctuation.definition.tag.begin.tsx</string>
|
||||
</dict>
|
||||
<key>3</key>
|
||||
<dict>
|
||||
<key>name</key>
|
||||
<string>entity.name.tag.namespace.tsx</string>
|
||||
</dict>
|
||||
<key>4</key>
|
||||
<dict>
|
||||
<key>name</key>
|
||||
<string>punctuation.separator.namespace.tsx</string>
|
||||
</dict>
|
||||
<key>5</key>
|
||||
<dict>
|
||||
<key>name</key>
|
||||
<string>entity.name.tag.tsx</string>
|
||||
</dict>
|
||||
<key>6</key>
|
||||
<dict>
|
||||
<key>name</key>
|
||||
<string>support.class.component.tsx</string>
|
||||
</dict>
|
||||
<key>7</key>
|
||||
<dict>
|
||||
<key>name</key>
|
||||
<string>punctuation.definition.tag.end.tsx</string>
|
||||
</dict>
|
||||
</dict>
|
||||
<key>patterns</key>
|
||||
<array>
|
||||
<dict>
|
||||
|
@ -7240,7 +7176,7 @@
|
|||
</dict>
|
||||
<dict>
|
||||
<key>include</key>
|
||||
<string>#jsx-child-tag</string>
|
||||
<string>#jsx-tag</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>include</key>
|
||||
|
|
Загрузка…
Ссылка в новой задаче