Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add highlighting for JSX fragment #535

Merged
merged 3 commits into from
Oct 23, 2017
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 16 additions & 6 deletions TypeScriptReact.YAML-tmLanguage
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,23 @@ repository:
patterns:
- include: '#jsx-tag-without-attributes-in-expression'
- include: '#jsx-tag-in-expression'
- include: '#jsx-tag-invalid'
- include: '#jsx-fragment'

#jsx tags
jsx-fragment:
name: meta.tag.fragment.tsx
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of adding new rule for jsx-fragment,
Update: jsx-tag-without-attributes-in-expression and jsx-tag-without-attributes as:

  #jsx tags
  jsx-tag-without-attributes-in-expression:
    begin: |-
      (?x)
        (?<=[({\[,?=>:*]|&&|\|\||\?|\Wreturn|^return|\Wdefault|^)\s*
        (?=(<)\s*((?:[a-z][a-z0-9]*|([_$a-zA-Z][-$\w.]*))(?<!\.|-))?\s*(>))
    end: (?!\s*(<)\s*((?:[a-z][a-z0-9]*|([_$a-zA-Z][-$\w.]*))(?<!\.|-))?\s*(>))
    patterns:
    - include: '#jsx-tag-without-attributes'

  jsx-tag-without-attributes:
    name: meta.tag.without-attributes.tsx
    begin: (<)\s*((?:[a-z][a-z0-9]*|([_$a-zA-Z][-$\w.]*))(?<!\.|-))?\s*(>)
    end: (</)\s*((?:[a-z][a-z0-9]*|([_$a-zA-Z][-$\w.]*))(?<!\.|-))?\s*(>)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated.

begin: (<)\s*(>)
end: (</)\s*(>)
beginCaptures:
'1': {name: punctuation.definition.tag.begin.tsx}
'2': {name: punctuation.definition.tag.end.tsx}
endCaptures:
'1': {name: punctuation.definition.tag.begin.tsx}
'2': {name: punctuation.definition.tag.end.tsx}
contentName: meta.jsx.children.tsx
patterns:
- include: '#jsx-children'

jsx-tag-without-attributes-in-expression:
begin: |-
(?x)
Expand Down Expand Up @@ -128,16 +142,12 @@ repository:
patterns:
- include: '#jsx-children'

jsx-tag-invalid:
name: invalid.illegal.tag.incomplete.tsx
match: <\s*>

#jsx children
jsx-children:
patterns:
- include: '#jsx-tag-without-attributes'
- include: '#jsx-child-tag'
- include: '#jsx-tag-invalid'
- include: '#jsx-fragment'
- include: '#jsx-evaluated-code'
- include: '#jsx-entities'

Expand Down