Skip to content
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.

update constant.character.escape.php #134

Merged
merged 4 commits into from
Jun 27, 2016
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
20 changes: 7 additions & 13 deletions grammars/php.cson
Original file line number Diff line number Diff line change
Expand Up @@ -1503,6 +1503,9 @@
'name': 'punctuation.definition.string.end.php'
'name': 'string.regexp.single-quoted.php'
'patterns': [
{
'include': '#single_quote_regex_escape'
}
{
'captures':
'1':
Expand All @@ -1519,25 +1522,16 @@
'name': 'punctuation.definition.character-class.php'
'end': '\\]'
'name': 'string.regexp.character-class.php'
Copy link
Contributor

Choose a reason for hiding this comment

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

So are you saying that this isn't needed, or that it isn't working properly?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I commented out the redundant sections after I placed the single_quote_regex_escape content into the patterns array as its own item, rather than being a referenced sub-item. I wasn't sure whether I should completely remove the comments or not prior to review and finalization. The code works, just the scoping was off. Does that explain it better?

'patterns': [
{
'include': '#single_quote_regex_escape'
}
]
}
{
'match': '[$^+*]'
'name': 'keyword.operator.regexp.php'
}
{
'include': '#single_quote_regex_escape'
}
]
'repository':
'single_quote_regex_escape':
'comment': 'Support both PHP string and regex escaping'
'match': '(?x) \\\\ (?: \\\\ (?: \\\\ [\\\\\']? | [^\'] ) | . )'
'name': 'constant.character.escape.php'
'single_quote_regex_escape':
'comment': 'Support both PHP string and regex escaping'
'match': '(?x) \\\\ (?: \\\\ (?: \\\\ [\\\\\']? | [^\'] ) | . )'
'name': 'constant.character.escape.php'
'sql-string-double-quoted':
'begin': '"\\s*(?=(SELECT|INSERT|UPDATE|DELETE|CREATE|REPLACE|ALTER)\\b)'
'beginCaptures':
Expand Down
7 changes: 7 additions & 0 deletions spec/php-spec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,13 @@ describe 'PHP grammar', ->
expect(tokens[1][4]).toEqual value: '/\'', scopes: ['text.html.php', 'meta.embedded.block.php', 'source.php', 'string.regexp.single-quoted.php', 'punctuation.definition.string.end.php']
expect(tokens[1][5]).toEqual value: ';', scopes: ['text.html.php', 'meta.embedded.block.php', 'source.php', 'punctuation.terminator.expression.php']

it 'should tokenize single quoted string regex with escaped bracket', ->
tokens = grammar.tokenizeLines "<?php\n'/\\[/'"

expect(tokens[1][0]).toEqual value: '\'/', scopes: ['text.html.php', 'meta.embedded.block.php', 'source.php', 'string.regexp.single-quoted.php', 'punctuation.definition.string.begin.php']
expect(tokens[1][1]).toEqual value: '\\[', scopes: ['text.html.php', 'meta.embedded.block.php', 'source.php', 'string.regexp.single-quoted.php', 'constant.character.escape.php']
expect(tokens[1][2]).toEqual value: '/\'', scopes: ['text.html.php', 'meta.embedded.block.php', 'source.php', 'string.regexp.single-quoted.php', 'punctuation.definition.string.end.php']

it 'should tokenize opening scope of a closure correctly', ->
tokens = grammar.tokenizeLines "<?php\n$a = function() {};"

Expand Down