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

Fix some sql highlighting #450

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
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
4 changes: 2 additions & 2 deletions grammars/php.cson
Original file line number Diff line number Diff line change
Expand Up @@ -2759,7 +2759,7 @@
'match': '\\\\(?:\\\\(?:\\\\[\\\\\']?|[^\'])|.)'
'name': 'constant.character.escape.php'
'sql-string-double-quoted':
'begin': '"\\s*(?=(SELECT|INSERT|UPDATE|DELETE|CREATE|REPLACE|ALTER|AND|WITH)\\b)'
'begin': '(?i)"(?=\\s*\\(?\\s*(SELECT|INSERT|UPDATE|DELETE|CREATE|REPLACE|ALTER|AND|WITH)\\b)'
'beginCaptures':
'0':
'name': 'punctuation.definition.string.begin.php'
Expand Down Expand Up @@ -2828,7 +2828,7 @@
}
]
'sql-string-single-quoted':
'begin': '\'\\s*(?=(SELECT|INSERT|UPDATE|DELETE|CREATE|REPLACE|ALTER|AND|WITH)\\b)'
'begin': '(?i)\'(?=\\s*\\(?\\s*(SELECT|INSERT|UPDATE|DELETE|CREATE|REPLACE|ALTER|AND|WITH)\\b)'
'beginCaptures':
'0':
'name': 'punctuation.definition.string.begin.php'
Expand Down
18 changes: 18 additions & 0 deletions spec/php-spec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -2948,6 +2948,24 @@ describe 'PHP grammar', ->
expect(tokens[2]).toEqual value: ' something', scopes: ['source.php', scope, 'source.sql.embedded.php']
expect(tokens[3]).toEqual value: delim, scopes: ['source.php', scope, 'punctuation.definition.string.end.php']

{tokens} = grammar.tokenizeLine "#{delim}sEleCT something#{delim}"

# Case insensitive
expect(tokens[0]).toEqual value: delim, scopes: ['source.php', scope, 'punctuation.definition.string.begin.php']
expect(tokens[1]).toEqual value: 'sEleCT', scopes: ['source.php', scope, 'source.sql.embedded.php', 'keyword.other.DML.sql']
expect(tokens[2]).toEqual value: ' something', scopes: ['source.php', scope, 'source.sql.embedded.php']
expect(tokens[3]).toEqual value: delim, scopes: ['source.php', scope, 'punctuation.definition.string.end.php']

{tokens} = grammar.tokenizeLine "#{delim}(select something)#{delim}"

# Surrounded by brackets
expect(tokens[0]).toEqual value: delim, scopes: ['source.php', scope, 'punctuation.definition.string.begin.php']
expect(tokens[1]).toEqual value: '(', scopes: ['source.php', scope, 'source.sql.embedded.php', 'punctuation.definition.section.bracket.round.begin.sql']
expect(tokens[2]).toEqual value: 'select', scopes: ['source.php', scope, 'source.sql.embedded.php', 'keyword.other.DML.sql']
expect(tokens[3]).toEqual value: ' something', scopes: ['source.php', scope, 'source.sql.embedded.php']
expect(tokens[4]).toEqual value: ')', scopes: ['source.php', scope, 'source.sql.embedded.php', 'punctuation.definition.section.bracket.round.end.sql']
expect(tokens[5]).toEqual value: delim, scopes: ['source.php', scope, 'punctuation.definition.string.end.php']

lines = grammar.tokenizeLines """
#{delim}SELECT something
-- uh oh a comment SELECT#{delim}
Expand Down