Improve mixin scopes#82
Improve mixin scopes#82winstliu merged 12 commits intoatom:masterfrom dsifford:dsifford-function-params-fix
Conversation
|
FYI I will be gone starting tomorrow until the 16th. So please feel free to create PRs for the other issues you wanted to tackle and I will try to review them after I get back. |
| 'patterns': [ | ||
| { | ||
| 'match': ':' | ||
| 'name': 'punctuation.separator.key-value.less' |
There was a problem hiding this comment.
@50Wliu Should this be punctuation.separator.key-value.css? Or is it incorrectly set here: https://github.com/atom/language-less/pull/82/files#diff-14c55924b6cf1fe75bf40519b9cddaccR317?
There was a problem hiding this comment.
I think this can be kept as .less.
There was a problem hiding this comment.
Should I change the other occurrence then?
There was a problem hiding this comment.
The other one can be kept as .css because that one is the same in CSS, whereas for this one there is no function equivalent in CSS.
It's a bit confusing and is pretty ad-hoc. Hopefully in the future the endings can be standardized.
|
@50Wliu Got all the current tests passing. I'll hold off on going any further for now until I can get confirmation from you that the structure looks acceptable. Enjoy your vacation! |
grammars/less.cson
Outdated
| # http://lesscss.org/features/#mixin-guards-feature-guard-comparison-operators | ||
| 'match': '\\btrue\\b' | ||
| 'name': 'constant.language.boolean.less' | ||
|
|
grammars/less.cson
Outdated
|
|
||
| 'mixins': | ||
| 'name': 'meta.mixin.less' | ||
| 'begin': '(\\.[_a-zA-Z][a-zA-Z0-9_-]*)(?= *\\()' |
There was a problem hiding this comment.
What do you think about giving the . its own punctuation scope? Also, please use \\s* instead of <space>* for extra clarity.
There was a problem hiding this comment.
Re: giving . it's own scope. Good idea. What would that be called?
Re: using \\s* vs *, I agree that's clearer, but the issue is that the space must be horizontal only. Is there a PCRE horizontal whitespace option? IIRC, I think that might be \\h?
Edit: Or is \\s only horizontal? Now I'm confusing myself. 🙈
There was a problem hiding this comment.
You're correct that \\s includes vertical whitespace (like \n and \v), but in practice it doesn't really matter because matches are restricted to single lines only.
I would think that . should be scoped as punctuation.definition.mixin.less.
There was a problem hiding this comment.
I see.. Good to know.
Re: punctuation.definition.mixin.less -- Sounds good to me.
grammars/less.cson
Outdated
| 'beginCaptures': | ||
| '0': | ||
| 'name': 'meta.definition.mixin.less entity.name.mixin.less' | ||
| 'end': '(?<=\\})' |
There was a problem hiding this comment.
{ and } don't need to be escaped.
grammars/less.cson
Outdated
|
|
||
| 'mixin_guards': | ||
| 'name': 'meta.guard.less' | ||
| 'begin': '(?:(when|and|when +not|and +not) *|(,) *)+(\\()' |
grammars/less.cson
Outdated
| 'name': 'punctuation.separator.list.comma.css' | ||
| '3': | ||
| 'name': 'meta.brace.round.css' | ||
| 'end': '(\\))' |
There was a problem hiding this comment.
The outside capture can be removed, since we're only using the 0th capture.
|
Can you please revert the spec structure to how it was originally? |
|
@50Wliu Welcome back! Thanks for looking this over. I'll address these issues soon. Re: crappy looking tests -- that was just temporary until you had time to get your eyes on it because I was being lazy 😝. I'll definitely fix that! |
- still need to fix and add tests
|
@50Wliu Should be ready for review now. Let me know if I missed something. |
spec/less-spec.coffee
Outdated
| expect(tokens[41]).toEqual value: '@', scopes: ['source.css.less', 'meta.mixin.less', 'meta.parameters.less', 'variable.parameter.less', 'punctuation.definition.variable.less'] | ||
| expect(tokens[42]).toEqual value: 'c', scopes: ['source.css.less', 'meta.mixin.less', 'meta.parameters.less', 'variable.parameter.less'] | ||
| expect(tokens[43]).toEqual value: ')', scopes: ['source.css.less', 'meta.mixin.less', 'meta.parameters.less', 'punctuation.definition.parameters.end.bracket.round.less'] | ||
| expect(tokens[44].scopes).not.toContain 'meta.parameters.less' |
There was a problem hiding this comment.
Try to avoid the .not qualifier when writing language tests, because scopes can and do change often. Then if the new meta.parameters.less is added back this test will still pass. While more verbose, it's more useful to write out the exact scope list (i.e. just like tokens[43]).
grammars/less.cson
Outdated
| 'match': '\\btrue\\b' | ||
| 'name': 'constant.language.boolean.less' | ||
| 'variables': | ||
| 'match': '(@|\\-\\-)[\\w-]+(?=\\s*)' |
There was a problem hiding this comment.
This lookahead seems rather useless since it can potentially match nothing.
There was a problem hiding this comment.
Good catch. Not sure what I was thinking there...
grammars/less.cson
Outdated
| 'name': 'variable.parameter.less' | ||
| '1': | ||
| 'name': 'punctuation.definition.variable.less' | ||
| 'end': '(,)(?=\\s*@)' |
There was a problem hiding this comment.
The , doesn't need to have capture parentheses around it because the rest of the match is a lookahead. You can safely target the 0th capture.
There was a problem hiding this comment.
Should be good to go now.
|
@dsifford Sorry to bother you again, but here's another regression I'm seeing: .markdown-preview[data-use-github-style] {
.markdown-body(); // comment this out to fix everything
padding: 30px; // padding is property-value
font-size: 16px; // entity.name.tag.custom
color: #333; // support.type.property-name.media
background-color: #fff; // entity.name.tag.custom
overflow: scroll; // no scope
a {
color: #337ab7;
}
} |
|
Reverted for the time being. |
|
Sorry... this got buried in my notifications. I'll try to look at this this weekend |
|
Yeah no problem! I'm hoping that I'll have time to investigate as well. |
Work In Progress
Description of the Change
See #81
Todo
key-valuefromoperator.assignmentfor colon separating parameter name and default value.meta.mixin.lessscopes in numeric default parameters.Resolves #81