-
Notifications
You must be signed in to change notification settings - Fork 31
Allows variables starting with underscores #34
Allows variables starting with underscores #34
Conversation
| expect(tokens[2]).toEqual value: '$foo', scopes: ['source.puppet', 'meta.definition.resource.puppet', 'entity.name.section.puppet'] | ||
|
|
||
| it "tokenizes variable starting with underscore", -> | ||
| {tokens} = grammar.tokenizeLine('$foo') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You seem to have forgotten an underscore here... 😉
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whoops...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed and added a test for regular variables too! 👍
3454c29 to
b4e93ed
Compare
spec/puppet-spec.coffee
Outdated
| expect(tokens[0]).toEqual value: 'package', scopes: ['source.puppet', 'meta.definition.resource.puppet', 'storage.type.puppet'] | ||
| expect(tokens[2]).toEqual value: '$foo', scopes: ['source.puppet', 'meta.definition.resource.puppet', 'entity.name.section.puppet'] | ||
|
|
||
| it "tokenizes variablee", -> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it "tokenizes regular variables", ->
8c4fcaa to
51143b8
Compare
| {tokens} = grammar.tokenizeLine('$foo') | ||
| expect(tokens[0]).toEqual value: '$', scopes: ['source.puppet', 'variable.other.readwrite.global.puppet', 'punctuation.definition.variable.puppet'] | ||
| expect(tokens[1]).toEqual value: 'foo', scopes: ['source.puppet', 'variable.other.readwrite.global.puppet'] | ||
| {tokens} = grammar.tokenizeLine('$_foo') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tiny little nit: can there be a newline between lines 54 and 55?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed 👍
51143b8 to
e51e8a7
Compare
|
One more question: Does Puppet allow variables such as |
|
@50Wliu Yep, that's valid $_woo__='hello'
notice($_woo__)
Notice: Scope(Class[main]): hello |
grammars/puppet.cson
Outdated
| '1': | ||
| 'name': 'punctuation.definition.variable.puppet' | ||
| 'match': '(\\$)([a-zA-Zx7f-xff\\$]|::)([a-zA-Z0-9_x7f-xff\\$]|::)*\\b' | ||
| 'match': '(\\$)([a-zA-Zx7f-xff\\$_]|::)([a-zA-Z0-9_x7f-xff\\$]|::)*\\b' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The latter capture should also include _ then
e51e8a7 to
457522d
Compare
|
Can variables not start with uppercase letters? |
|
In Puppet 4, the official regex as given by the parser: In older puppet its possible but linters will complain, |
457522d to
880801c
Compare
|
Wow, that's pretty awesome how it gives you the regex right in the error message. Just waiting on Travis now... ⌚ 😴 |
…core Allows variables starting with underscores
No description provided.