mirror of
https://github.com/atom/atom.git
synced 2026-04-28 03:01:47 -04:00
Add initial support for injection grammars
Build scope selectors and patterns when setting up the grammar for all entries under the grammar's injection object. Include the injection patterns in the scanner when the injection's scope selector matches the current rule stack.
This commit is contained in:
@@ -443,3 +443,27 @@ describe "TokenizedBuffer", ->
|
||||
|
||||
expect(tokens[2].value).toBe '@"'
|
||||
expect(tokens[2].scopes).toEqual ["source.objc++", "meta.function.c", "meta.block.c", "string.quoted.double.objc", "punctuation.definition.string.begin.objc"]
|
||||
|
||||
describe "when the grammar has injections", ->
|
||||
beforeEach ->
|
||||
atom.activatePackage('php.tmbundle', sync: true)
|
||||
editSession = project.buildEditSession('hello.php', autoIndent: false)
|
||||
tokenizedBuffer = editSession.displayBuffer.tokenizedBuffer
|
||||
editSession.setVisible(true)
|
||||
fullyTokenize(tokenizedBuffer)
|
||||
|
||||
afterEach ->
|
||||
editSession.destroy()
|
||||
|
||||
it "correctly includes the injected patterns when tokenizing", ->
|
||||
functionLine = tokenizedBuffer.lineForScreenRow(0)
|
||||
{ tokens } = functionLine
|
||||
|
||||
expect(tokens[0].value).toBe "<?php"
|
||||
expect(tokens[0].scopes).toEqual ["text.html.php", "meta.embedded.line.php", "punctuation.section.embedded.begin.php"]
|
||||
|
||||
expect(tokens[2].value).toBe "function"
|
||||
expect(tokens[2].scopes).toEqual ["text.html.php", "meta.embedded.line.php", "source.php", "meta.function.php", "storage.type.function.php"]
|
||||
|
||||
expect(tokens[4].value).toBe "hello"
|
||||
expect(tokens[4].scopes).toEqual ["text.html.php", "meta.embedded.line.php", "source.php", "meta.function.php", "entity.name.function.php"]
|
||||
|
||||
1
spec/fixtures/hello.php
vendored
Normal file
1
spec/fixtures/hello.php
vendored
Normal file
@@ -0,0 +1 @@
|
||||
<?php function hello() {} ?>
|
||||
Reference in New Issue
Block a user