Skip to content

Tokenize @ and . in decorators #110

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

Merged
merged 2 commits into from
Oct 4, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
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
9 changes: 7 additions & 2 deletions grammars/MagicPython.cson
Original file line number Diff line number Diff line change
Expand Up @@ -1473,7 +1473,7 @@ repository:
begin: '''
(?x)
^\\s*
(@) \\s* (?=[[:alpha:]_]\\w*)
((@)) \\s* (?=[[:alpha:]_]\\w*)

'''
end: '''
Expand All @@ -1487,6 +1487,8 @@ repository:
beginCaptures:
"1":
name: "entity.name.function.decorator.python"
"2":
name: "punctuation.definition.decorator.python"
endCaptures:
"1":
name: "punctuation.definition.arguments.end.python"
Expand All @@ -1512,9 +1514,12 @@ repository:
name: "entity.name.function.decorator.python"
match: '''
(?x)
([[:alpha:]_]\\w*) | \\.
([[:alpha:]_]\\w*) | (\\.)

'''
captures:
"2":
name: "punctuation.separator.period.python"
}
{
include: "#line-continuation"
Expand Down
17 changes: 15 additions & 2 deletions grammars/MagicPython.tmLanguage
Original file line number Diff line number Diff line change
Expand Up @@ -2314,7 +2314,7 @@
<key>begin</key>
<string>(?x)
^\s*
(@) \s* (?=[[:alpha:]_]\w*)
((@)) \s* (?=[[:alpha:]_]\w*)
</string>
<key>end</key>
<string>(?x)
Expand All @@ -2330,6 +2330,11 @@
<key>name</key>
<string>entity.name.function.decorator.python</string>
</dict>
<key>2</key>
<dict>
<key>name</key>
<string>punctuation.definition.decorator.python</string>
</dict>
</dict>
<key>endCaptures</key>
<dict>
Expand Down Expand Up @@ -2373,8 +2378,16 @@
<string>entity.name.function.decorator.python</string>
<key>match</key>
<string>(?x)
([[:alpha:]_]\w*) | \.
([[:alpha:]_]\w*) | (\.)
</string>
<key>captures</key>
<dict>
<key>2</key>
<dict>
<key>name</key>
<string>punctuation.separator.period.python</string>
</dict>
</dict>
</dict>
<dict>
<key>include</key>
Expand Down
7 changes: 5 additions & 2 deletions grammars/src/MagicPython.syntax.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1123,7 +1123,7 @@ repository:
begin: |
(?x)
^\s*
(@) \s* (?=[[:alpha:]_]\w*)
((@)) \s* (?=[[:alpha:]_]\w*)
end: |
(?x)
( \) )
Expand All @@ -1132,6 +1132,7 @@ repository:
| (?=\n|\#)
beginCaptures:
'1': {name: entity.name.function.decorator.python}
'2': {name: punctuation.definition.decorator.python}
endCaptures:
'1': {name: punctuation.definition.arguments.end.python}
'2': {name: invalid.illegal.decorator.python}
Expand All @@ -1147,7 +1148,9 @@ repository:
- name: entity.name.function.decorator.python
match: |
(?x)
([[:alpha:]_]\w*) | \.
([[:alpha:]_]\w*) | (\.)
captures:
'2': {name: punctuation.separator.period.python}
- include: '#line-continuation'
- name: invalid.illegal.decorator.python
match: |
Expand Down
1 change: 1 addition & 0 deletions misc/scopes
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ punctuation.comment.end.regexp
punctuation.definition.arguments.begin.python
punctuation.definition.arguments.end.python
punctuation.definition.comment.python
punctuation.definition.decorator.python
punctuation.definition.dict.begin.python
punctuation.definition.dict.end.python
punctuation.definition.inheritance.begin.python
Expand Down
98 changes: 49 additions & 49 deletions test/atom-spec/python-spec.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion test/classes/class12.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class : meta.class.python, source.python, storage.type.class.python
F : entity.name.type.class.python, meta.class.python, source.python
: : meta.class.python, punctuation.section.class.begin.python, source.python
: meta.function.decorator.python, source.python
@ : entity.name.function.decorator.python, meta.function.decorator.python, source.python
@ : entity.name.function.decorator.python, meta.function.decorator.python, punctuation.definition.decorator.python, source.python
classmethod : meta.function.decorator.python, source.python, support.type.python
: meta.function.python, source.python
def : meta.function.python, source.python, storage.type.function.python
Expand Down
2 changes: 1 addition & 1 deletion test/classes/class2.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class Spam(Foo.Bar, Bar.name={'very': 'odd'}):



@ : entity.name.function.decorator.python, meta.function.decorator.python, source.python
@ : entity.name.function.decorator.python, meta.function.decorator.python, punctuation.definition.decorator.python, source.python
dec : entity.name.function.decorator.python, meta.function.decorator.python, source.python
# : comment.line.number-sign.python, punctuation.definition.comment.python, source.python
Bar.name=... is not legal, but the test is for highlighter not breaking badly : comment.line.number-sign.python, source.python
Expand Down
2 changes: 1 addition & 1 deletion test/docstrings/regr1.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def foo():
# : comment.line.number-sign.python, punctuation.definition.comment.python, source.python
: : comment.line.number-sign.python, source.python
: meta.function.decorator.python, source.python
@ : entity.name.function.decorator.python, meta.function.decorator.python, source.python
@ : entity.name.function.decorator.python, meta.function.decorator.python, punctuation.definition.decorator.python, source.python
asd : entity.name.function.decorator.python, meta.function.decorator.python, source.python
: meta.function.python, source.python
def : meta.function.python, source.python, storage.type.function.python
Expand Down
2 changes: 1 addition & 1 deletion test/functions/async1.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ async def foo():



@ : entity.name.function.decorator.python, meta.function.decorator.python, source.python
@ : entity.name.function.decorator.python, meta.function.decorator.python, punctuation.definition.decorator.python, source.python
foo : entity.name.function.decorator.python, meta.function.decorator.python, source.python
async : meta.function.python, source.python, storage.type.function.async.python
: meta.function.python, source.python
Expand Down
18 changes: 9 additions & 9 deletions test/functions/decorators1.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,25 @@ def decorated(a): pass



@ : entity.name.function.decorator.python, meta.function.decorator.python, source.python
@ : entity.name.function.decorator.python, meta.function.decorator.python, punctuation.definition.decorator.python, source.python
some_decorator : entity.name.function.decorator.python, meta.function.decorator.python, source.python
: meta.function.decorator.python, source.python
# : comment.line.number-sign.python, punctuation.definition.comment.python, source.python
with comment : comment.line.number-sign.python, source.python
@ : entity.name.function.decorator.python, meta.function.decorator.python, source.python
@ : entity.name.function.decorator.python, meta.function.decorator.python, punctuation.definition.decorator.python, source.python
some : entity.name.function.decorator.python, meta.function.decorator.python, source.python
. : entity.name.function.decorator.python, meta.function.decorator.python, source.python
. : entity.name.function.decorator.python, meta.function.decorator.python, punctuation.separator.period.python, source.python
class : keyword.control.flow.python, meta.function.decorator.python, source.python
. : entity.name.function.decorator.python, meta.function.decorator.python, source.python
. : entity.name.function.decorator.python, meta.function.decorator.python, punctuation.separator.period.python, source.python
decorator : entity.name.function.decorator.python, meta.function.decorator.python, source.python
@ : entity.name.function.decorator.python, meta.function.decorator.python, source.python
@ : entity.name.function.decorator.python, meta.function.decorator.python, punctuation.definition.decorator.python, source.python
some_decorator : entity.name.function.decorator.python, meta.function.decorator.python, source.python
( : meta.function.decorator.python, punctuation.definition.arguments.begin.python, source.python
1 : constant.numeric.dec.python, meta.function-call.arguments.python, meta.function.decorator.python, source.python
) : meta.function.decorator.python, punctuation.definition.arguments.end.python, source.python
@ : entity.name.function.decorator.python, meta.function.decorator.python, source.python
@ : entity.name.function.decorator.python, meta.function.decorator.python, punctuation.definition.decorator.python, source.python
some : entity.name.function.decorator.python, meta.function.decorator.python, source.python
. : entity.name.function.decorator.python, meta.function.decorator.python, source.python
. : entity.name.function.decorator.python, meta.function.decorator.python, punctuation.separator.period.python, source.python
decorator : entity.name.function.decorator.python, meta.function.decorator.python, source.python
: meta.function.decorator.python, source.python
( : meta.function.decorator.python, punctuation.definition.arguments.begin.python, source.python
Expand All @@ -35,7 +35,7 @@ class : keyword.control.flow.python, meta.function.decorator.python, sou
: meta.function-call.arguments.python, meta.function.decorator.python, source.python
3 : constant.numeric.dec.python, meta.function-call.arguments.python, meta.function.decorator.python, source.python
) : meta.function.decorator.python, punctuation.definition.arguments.end.python, source.python
@ : entity.name.function.decorator.python, meta.function.decorator.python, source.python
@ : entity.name.function.decorator.python, meta.function.decorator.python, punctuation.definition.decorator.python, source.python
some_decorator : entity.name.function.decorator.python, meta.function.decorator.python, source.python
( : meta.function.decorator.python, punctuation.definition.arguments.begin.python, source.python
a : meta.function-call.arguments.python, meta.function.decorator.python, source.python, variable.parameter.function-call.python
Expand All @@ -58,7 +58,7 @@ class : keyword.control.flow.python, meta.function.decorator.python, sou
** : keyword.operator.unpacking.arguments.python, meta.function-call.arguments.python, meta.function.decorator.python, source.python
kwargs : meta.function-call.arguments.python, meta.function.decorator.python, source.python
) : meta.function.decorator.python, punctuation.definition.arguments.end.python, source.python
@ : entity.name.function.decorator.python, meta.function.decorator.python, source.python
@ : entity.name.function.decorator.python, meta.function.decorator.python, punctuation.definition.decorator.python, source.python
classmethod : meta.function.decorator.python, source.python, support.type.python
def : meta.function.python, source.python, storage.type.function.python
: meta.function.python, source.python
Expand Down
8 changes: 4 additions & 4 deletions test/functions/decorators2.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@ def foo(): pass



@ : entity.name.function.decorator.python, meta.function.decorator.python, source.python
@ : entity.name.function.decorator.python, meta.function.decorator.python, punctuation.definition.decorator.python, source.python
: meta.function.decorator.python, source.python
f : entity.name.function.decorator.python, meta.function.decorator.python, source.python
: meta.function.decorator.python, source.python
. : entity.name.function.decorator.python, meta.function.decorator.python, source.python
. : entity.name.function.decorator.python, meta.function.decorator.python, punctuation.separator.period.python, source.python
: meta.function.decorator.python, source.python
bar : entity.name.function.decorator.python, meta.function.decorator.python, source.python
: meta.function.decorator.python, source.python
. : entity.name.function.decorator.python, meta.function.decorator.python, source.python
. : entity.name.function.decorator.python, meta.function.decorator.python, punctuation.separator.period.python, source.python
: meta.function.decorator.python, source.python
a : entity.name.function.decorator.python, meta.function.decorator.python, source.python
: meta.function.decorator.python, source.python
. : entity.name.function.decorator.python, meta.function.decorator.python, source.python
. : entity.name.function.decorator.python, meta.function.decorator.python, punctuation.separator.period.python, source.python
: meta.function.decorator.python, source.python
b : entity.name.function.decorator.python, meta.function.decorator.python, source.python
def : meta.function.python, source.python, storage.type.function.python
Expand Down
4 changes: 2 additions & 2 deletions test/functions/decorators3.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ def foo(): pass



@ : entity.name.function.decorator.python, meta.function.decorator.python, source.python
@ : entity.name.function.decorator.python, meta.function.decorator.python, punctuation.definition.decorator.python, source.python
: meta.function.decorator.python, source.python
f : entity.name.function.decorator.python, meta.function.decorator.python, source.python
: meta.function.decorator.python, source.python
. : entity.name.function.decorator.python, meta.function.decorator.python, source.python
. : entity.name.function.decorator.python, meta.function.decorator.python, punctuation.separator.period.python, source.python
: meta.function.decorator.python, source.python
bar : entity.name.function.decorator.python, meta.function.decorator.python, source.python
: meta.function.decorator.python, source.python
Expand Down
10 changes: 5 additions & 5 deletions test/functions/decorators4.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ def foo(): pass



@ : entity.name.function.decorator.python, meta.function.decorator.python, source.python
@ : entity.name.function.decorator.python, meta.function.decorator.python, punctuation.definition.decorator.python, source.python
a : entity.name.function.decorator.python, meta.function.decorator.python, source.python
. : entity.name.function.decorator.python, meta.function.decorator.python, source.python
. : entity.name.function.decorator.python, meta.function.decorator.python, punctuation.separator.period.python, source.python
b : entity.name.function.decorator.python, meta.function.decorator.python, source.python
. : entity.name.function.decorator.python, meta.function.decorator.python, source.python
. : entity.name.function.decorator.python, meta.function.decorator.python, punctuation.separator.period.python, source.python
c : entity.name.function.decorator.python, meta.function.decorator.python, source.python
. : entity.name.function.decorator.python, meta.function.decorator.python, source.python
. : entity.name.function.decorator.python, meta.function.decorator.python, punctuation.separator.period.python, source.python
None : keyword.illegal.name.python, meta.function.decorator.python, source.python
. : entity.name.function.decorator.python, meta.function.decorator.python, source.python
. : entity.name.function.decorator.python, meta.function.decorator.python, punctuation.separator.period.python, source.python
z : entity.name.function.decorator.python, meta.function.decorator.python, source.python
def : meta.function.python, source.python, storage.type.function.python
: meta.function.python, source.python
Expand Down
14 changes: 7 additions & 7 deletions test/functions/decorators5.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,24 @@ def foo(): pass



@ : entity.name.function.decorator.python, meta.function.decorator.python, source.python
@ : entity.name.function.decorator.python, meta.function.decorator.python, punctuation.definition.decorator.python, source.python
a : entity.name.function.decorator.python, meta.function.decorator.python, source.python
. : entity.name.function.decorator.python, meta.function.decorator.python, source.python
. : entity.name.function.decorator.python, meta.function.decorator.python, punctuation.separator.period.python, source.python
: meta.function.decorator.python, source.python
\ : meta.function.decorator.python, punctuation.separator.continuation.line.python, source.python
: meta.function.decorator.python, source.python
: meta.function.decorator.python, source.python
b : entity.name.function.decorator.python, meta.function.decorator.python, source.python
: meta.function.decorator.python, source.python
. : entity.name.function.decorator.python, meta.function.decorator.python, source.python
. : entity.name.function.decorator.python, meta.function.decorator.python, punctuation.separator.period.python, source.python
: meta.function.decorator.python, source.python
\ : meta.function.decorator.python, punctuation.separator.continuation.line.python, source.python
: meta.function.decorator.python, source.python
: meta.function.decorator.python, source.python
c : entity.name.function.decorator.python, meta.function.decorator.python, source.python
. : entity.name.function.decorator.python, meta.function.decorator.python, source.python
. : entity.name.function.decorator.python, meta.function.decorator.python, punctuation.separator.period.python, source.python
None : keyword.illegal.name.python, meta.function.decorator.python, source.python
. : entity.name.function.decorator.python, meta.function.decorator.python, source.python
. : entity.name.function.decorator.python, meta.function.decorator.python, punctuation.separator.period.python, source.python
z : entity.name.function.decorator.python, meta.function.decorator.python, source.python
: meta.function.decorator.python, source.python
\ : meta.function.decorator.python, punctuation.separator.continuation.line.python, source.python
Expand All @@ -36,9 +36,9 @@ def foo(): pass
= : keyword.operator.assignment.python, meta.function-call.arguments.python, meta.function.decorator.python, source.python
1 : constant.numeric.dec.python, meta.function-call.arguments.python, meta.function.decorator.python, source.python
) : meta.function.decorator.python, punctuation.definition.arguments.end.python, source.python
@ : entity.name.function.decorator.python, meta.function.decorator.python, source.python
@ : entity.name.function.decorator.python, meta.function.decorator.python, punctuation.definition.decorator.python, source.python
foo : entity.name.function.decorator.python, meta.function.decorator.python, source.python
. : entity.name.function.decorator.python, meta.function.decorator.python, source.python
. : entity.name.function.decorator.python, meta.function.decorator.python, punctuation.separator.period.python, source.python
ok : entity.name.function.decorator.python, meta.function.decorator.python, source.python
def : meta.function.python, source.python, storage.type.function.python
: meta.function.python, source.python
Expand Down
Loading