opened
gandm
username_0
Injection grammars work if using `injectionSelector` but not if using `injections`

It appears grammars are only added as injection grammars if they have the injectionSelector property (first example below)  which makes no sense inside a nested set of injections as that property doesn't exist (second example below). Atom adds grammars as Injection grammars [here](https://github.com/atom/first-mate/blob/master/src/grammar-registry.coffee#L82) and are only used as rules if they are marked as such [here](https://github.com/atom/first-mate/blob/9295b5632a2eb5d0716da736aba08ce3f4e3237e/src/rule.coffee#L75)
e.g.
This works
```json
{
  "scopeName": "working.injector",
  "injectionSelector": "L:source.js.embedded.html",
  "patterns": [
    { "include": "source.js.jsx" }
  ]
}
```
This doesn't
```json
{
  "scopeName": "some.injector",
  "injections": {
    "L:source.js.embedded.html": {
      "patterns": [
        { "include": "source.js.jsx" }
      ]
    }
  }
}
```
Injection grammars using the 'injections' property not working.
issue
created
50Wliu
username_1
@username_0 I might need a bit more background.  As far as I know, injection selectors are not meant to be actual grammars that you can select using the Grammar Selector.  They're more for auxiliary highlighting (like language-todo).  Injection grammars are meant to be selected and need to provide the scopes that they inject in themselves (language-php).
comment
created
gandm
username_0
As far as I can see `language-php` doesn't work either. It has an injection [here](https://github.com/atom/first-mate/blob/7195ec726bad720903331092fa9e0ce822b1e82e/spec/fixtures/php.json#L17) that should inject some patterns and eventually the PHP grammar into a scope `L:source.js.embedded.html` as a LEFT rule set. So an html file using `language-html` with  a `<?php` inside a `<script>` and `</script>` which has a scope of `source.js.embedded.html` should highlight as PHP but it doesn't.

I've disabled `language-javascript` to stop it parsing any `source.js` code inside an html file as shown in the image below. PHP isn't highlighted at all which it should be if the above injection of rules was working.
![image](https://user-images.githubusercontent.com/2313237/31610947-f5accbf2-b271-11e7-833e-8e55c5e73ec1.png)
comment
created
50Wliu
username_1
`injections` injects into _itself`, `injectionSelector` injects into other grammars.  So PHP needs to be the active grammar in order for PHP highlighting to work, while TODO doesn't.
comment
created
50Wliu
username_1
What Atom version are you using?
comment
created
gandm
username_0
Atom 1.21.1
comment
closed
gandm
username_0
issue
created
gandm
username_0
Putting a space in front of the `<?php` works. Must be an issue with the inject regex patterns in language-php rather than the injection. 

I'll close this as it appears to work as designed.
comment