Skip to content

Commit

Permalink
PuppetManifest: allow to use a underscore char and a hyphen char in a…
Browse files Browse the repository at this point in the history
… name

Close universal-ctags#1901.

I refereed https://puppet.com/docs/puppet/6.0/lang_data_string.html#bare-words for fixing this.
I also add a hyphen char to the list of acceptable chars.
  • Loading branch information
masatake committed Oct 4, 2018
1 parent d080788 commit 9171923
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 4 deletions.
4 changes: 4 additions & 0 deletions Units/parser-puppetManifest.r/fix-1901.d/expected.tags
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/tmp/12 input.pp /^ file { "\/tmp\/12": ensure => $ensure }$/;" r definition:one_one::two
/tmp/34 input.pp /^ file { "\/tmp\/34": ensure => $ensure }$/;" r definition:three::four_four
one_one::two input.pp /^define one_one::two($ensure) {$/;" d
three::four_four input.pp /^define three::four_four($ensure) {$/;" d
8 changes: 8 additions & 0 deletions Units/parser-puppetManifest.r/fix-1901.d/input.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
define one_one::two($ensure) {
file { "/tmp/12": ensure => $ensure }
}

define three::four_four($ensure) {
file { "/tmp/34": ensure => $ensure }
}

4 changes: 2 additions & 2 deletions optlib/puppetManifest.c
Original file line number Diff line number Diff line change
Expand Up @@ -366,10 +366,10 @@ static void initializePuppetManifestParser (const langType language CTAGS_ATTR_U
"^\\#",
"", "", "{tenter=comment_oneline}", NULL);
addLanguageTagMultiTableRegex (language, "defineStart",
"^([a-zA-Z:][a-zA-Z0-9:]*)[ \n\t]*\\(",
"^([a-z:][-_a-zA-Z0-9:]*)[ \n\t]*\\(",
"\\1", "d", "{tenter=skipArgs,blockHeadPopAtLast}{scope=push}", NULL);
addLanguageTagMultiTableRegex (language, "defineStart",
"^([a-zA-Z:][a-zA-Z0-9:]*)[ \n\t]*\\{",
"^([a-z:][-_a-zA-Z0-9:]*)[ \n\t]*\\{",
"\\1", "d", "{tenter=block,endWithPop}{scope=push}", NULL);
addLanguageTagMultiTableRegex (language, "caseStart",
"^/\\*",
Expand Down
4 changes: 2 additions & 2 deletions optlib/puppetManifest.ctags
Original file line number Diff line number Diff line change
Expand Up @@ -277,8 +277,8 @@
# define
#
--_mtable-extend-PuppetManifest=defineStart+comment
--_mtable-regex-PuppetManifest=defineStart/([a-zA-Z:][a-zA-Z0-9:]*)[ \n\t]*\(/\1/d/{tenter=skipArgs,blockHeadPopAtLast}{scope=push}
--_mtable-regex-PuppetManifest=defineStart/([a-zA-Z:][a-zA-Z0-9:]*)[ \n\t]*\{/\1/d/{tenter=block,endWithPop}{scope=push}
--_mtable-regex-PuppetManifest=defineStart/([a-z:][-_a-zA-Z0-9:]*)[ \n\t]*\(/\1/d/{tenter=skipArgs,blockHeadPopAtLast}{scope=push}
--_mtable-regex-PuppetManifest=defineStart/([a-z:][-_a-zA-Z0-9:]*)[ \n\t]*\{/\1/d/{tenter=block,endWithPop}{scope=push}

#
# case
Expand Down

1 comment on commit 9171923

@ahakanbaba
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure hyphen is allowed in names of defined resources .
Lookint at the docs specific to the Class and defined resource type names hyphen is not mentioned there.
The regular expression to match is

\A([a-z][a-z0-9_]*)?(::[a-z][a-z0-9_]*)*\Z

The same change needs to apply to classStart too here. Underscore is also allowed for them.

Please sign in to comment.