On Oct 21, 2013, at 12:27 PM, Jeremy Whitlock jcscoobyrs@gmail.com wrote:
- When adding a language specific implementation of a grammar group, like comment.block for JavaScript, should the name of the group be comment.block (expected) or comment.block.js (What's there now)? (I can't tell if I use the name that corresponds with the root group, comment.block, or if I add the language name to the end like comment.block.js.)
All scopes should end with the grammar's suffix, so `comment.block.js` would be correct.
- Is there a way to have certain grammar features enabled based on the existence, or lack of, a certain "enabler" in the file? (For example, JavaScript has a strict mode to mark extra words as keywords due to potential plans for supporting them as keywords in the future. That being said, if you have "use strict;" in your file, certain keywords should be scoped that wouldn't be otherwise *and* variable names with those keywords should be marked as invalid.)
This could be done by including a begin/end rule that never ends. Match the beginning and add a meta.* scope you can target with injections. You could do a branching grammar as well, but it might lead to more duplication.
- Why isn't 'null' treated as a constant like undefined/Infinity/NaN? Right now it's constant.language.null.js but I'd expect it to be constant.language.js.
No reason it needs to be there in that case, we do provide more info in the scope sometimes just to be more specific. Can be useful in some cases to provide special coloring/etc.
One more question about inheritance. I see that the JavaScript grammar has "comment.block.html.js" as a group. While it's invalid, as you can't have XML/HTML comments in JavaScript code even for embedded script content, it does bring up this question:
- Who owns extensions to inherited grammars, the embedding grammar (HTML) or the embedded grammar (JavaScript)? (To answer this, assume that the group above is legit. I'd expect HTML to provide this extension to the JavaScript grammar but what I'm seeing is that the JavaScript grammar has to know it can be embedded by HTML and to provide the HTML extensions.)
Ideally the HTML would provide the necessary rules, this can be done with injections. It wasn't however possible without them which is why you some lingering artifacts still.