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

Commit 663b158

Browse files
fix: update tree-sitter-embedded-php b/c end tags within strings shouldn't count
1 parent b177937 commit 663b158

3 files changed

Lines changed: 29 additions & 7 deletions

File tree

package-lock.json

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"url": "https://github.com/atom/language-php/issues"
1818
},
1919
"dependencies": {
20-
"tree-sitter-embedded-php": "0.0.1",
20+
"tree-sitter-embedded-php": "0.0.3",
2121
"tree-sitter-php-abc": "^0.17.0",
2222
"tree-sitter-phpdoc": "0.0.4"
2323
},

spec/tree-sitter-spec.js

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4131,8 +4131,8 @@ describe("Tree-sitter PHP grammar", () => {
41314131
])
41324132
})
41334133

4134-
fit('scopes double quoted strings', () => {
4135-
editor.setPhpText('"just a string"')
4134+
it('scopes double quoted strings', () => {
4135+
editor.setPhpText('"just a string";')
41364136

41374137
expect(editor).toHaveScopesAtPosition([1, 0], '"', ["source.php", "string.quoted.double.php",
41384138
// FIXME following scopes differ from TM
@@ -4145,9 +4145,31 @@ describe("Tree-sitter PHP grammar", () => {
41454145
])
41464146
})
41474147

4148+
it('handles strings containing php tags (regression)', () => {
4149+
// this regression was in the embedded-php parser, not this grammar
4150+
4151+
editor.setPhpText('"just a string ?>" . $foo;')
4152+
4153+
expect(editor).toHaveScopesAtPosition([1, 0], '"', ["source.php", "string.quoted.double.php",
4154+
// FIXME following scopes differ from TM
4155+
// "punctuation.definition.string.begin.php"
4156+
])
4157+
expect(editor).toHaveScopesAtPosition([1, 1], 'just', ["source.php", "string.quoted.double.php"])
4158+
expect(editor).toHaveScopesAtPosition([1, 15], '?>', ["source.php", "string.quoted.double.php",
4159+
// FIXME following scopes differ from TM
4160+
// "punctuation.definition.string.end.php"
4161+
])
4162+
expect(editor).toHaveScopesAtPosition([1, 17], '"', ["source.php", "string.quoted.double.php",
4163+
// FIXME following scopes differ from TM
4164+
// "punctuation.definition.string.end.php"
4165+
])
4166+
expect(editor).toHaveScopesAtPosition([1, 19], '.', ["source.php", "keyword.operator.string.php"])
4167+
expect(editor).toHaveScopesAtPosition([1, 21], '$', ['source.php', 'variable.other.php', 'punctuation.definition.variable.php'])
4168+
})
4169+
41484170
describe('string escape sequences', () => {
41494171
it( 'tokenizes escaped octal sequences', () => {
4150-
editor.setContent('"test \\007 test";')
4172+
editor.setPhpText('"test \\007 test";')
41514173

41524174
expect(editor).toHaveScopesAtPosition([1, 0], '"', ['source.php', 'string.quoted.double.php',
41534175
// FIXME following scopes differ from TM

0 commit comments

Comments
 (0)