Skip to content

Commit

Permalink
Merge pull request #1906 from ahakanbaba/puppetManifest-class-definit…
Browse files Browse the repository at this point in the history
…ion-name-underscore

PuppetManifest:  class, definition and resource names with underscores create expected tags
Close #1902.
  • Loading branch information
masatake authored Oct 7, 2018
2 parents d080788 + b4cdacc commit a39e1de
Show file tree
Hide file tree
Showing 8 changed files with 98 additions and 16 deletions.
2 changes: 2 additions & 0 deletions Units/parser-puppetManifest.r/puppet-classname.d/args.ctags
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
--sort=no
--fields=+KZlne
10 changes: 10 additions & 0 deletions Units/parser-puppetManifest.r/puppet-classname.d/expected.tags
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
t input.pp /^class t {$/;" class line:1 language:PuppetManifest end:3
/tmp/multipleclasst input.pp /^ file { "\/tmp\/multipleclasst": content => "one" }$/;" resource line:2 language:PuppetManifest scope:class:t end:2
one_ input.pp /^class one_ {$/;" class line:5 language:PuppetManifest end:7
/tmp/multipleclassone_ input.pp /^ file { "\/tmp\/multipleclassone_": content => "one" }$/;" resource line:6 language:PuppetManifest scope:class:one_ end:6
on_e input.pp /^class on_e {$/;" class line:9 language:PuppetManifest end:11
/tmp/multipleclasson_e input.pp /^ file { "\/tmp\/multipleclasson_e": content => "one" }$/;" resource line:10 language:PuppetManifest scope:class:on_e end:10
o_ne::tw_o input.pp /^class o_ne::tw_o {$/;" class line:14 language:PuppetManifest end:16
/tmp/multipleclasso_netw_o input.pp /^ file { "\/tmp\/multipleclasso_netw_o": content => "two" }$/;" resource line:15 language:PuppetManifest scope:class:o_ne::tw_o end:15
o_ne::two_ input.pp /^class o_ne::two_ {$/;" class line:18 language:PuppetManifest end:20
/tmp/multipleclasso_netwo_ input.pp /^ file { "\/tmp\/multipleclasso_netwo_": content => "two" }$/;" resource line:19 language:PuppetManifest scope:class:o_ne::two_ end:19
26 changes: 26 additions & 0 deletions Units/parser-puppetManifest.r/puppet-classname.d/input.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
class t {
file { "/tmp/multipleclasst": content => "one" }
}

class one_ {
file { "/tmp/multipleclassone_": content => "one" }
}

class on_e {
file { "/tmp/multipleclasson_e": content => "one" }
}


class o_ne::tw_o {
file { "/tmp/multipleclasso_netw_o": content => "two" }
}

class o_ne::two_ {
file { "/tmp/multipleclasso_netwo_": content => "two" }
}

include t
include one_
include on_e
include o_ne::tw_o
include o_ne::two_
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
--sort=no
--fields=+KZlne
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
t input.pp /^define t {$/;" definition line:2 language:PuppetManifest end:4
/tmp/multipledefinet input.pp /^ file { "\/tmp\/multipledefinet": content => "one" }$/;" resource line:3 language:PuppetManifest scope:definition:t end:3
one_ input.pp /^define one_ {$/;" definition line:6 language:PuppetManifest end:8
/tmp/multipledefineone_ input.pp /^ file { "\/tmp\/multipledefineone_": content => "one" }$/;" resource line:7 language:PuppetManifest scope:definition:one_ end:7
on_e input.pp /^define on_e {$/;" definition line:10 language:PuppetManifest end:12
/tmp/multipledefineon_e input.pp /^ file { "\/tmp\/multipledefineon_e": content => "one" }$/;" resource line:11 language:PuppetManifest scope:definition:on_e end:11
o_ne::tw_o input.pp /^define o_ne::tw_o {$/;" definition line:15 language:PuppetManifest end:17
/tmp/multipledefineo_netw_o input.pp /^ file { "\/tmp\/multipledefineo_netw_o": content => "two" }$/;" resource line:16 language:PuppetManifest scope:definition:o_ne::tw_o end:16
o_ne::two_ input.pp /^define o_ne::two_ {$/;" definition line:19 language:PuppetManifest end:21
/tmp/multipledefineo_netwo_ input.pp /^ file { "\/tmp\/multipledefineo_netwo_": content => "two" }$/;" resource line:20 language:PuppetManifest scope:definition:o_ne::two_ end:20
t input.pp /^t { 't': }$/;" resource line:23 language:PuppetManifest end:23
one_ input.pp /^one_ { 'one_': }$/;" resource line:24 language:PuppetManifest end:24
on_e input.pp /^on_e { 'on_e': }$/;" resource line:25 language:PuppetManifest end:25
o_ne::tw_o input.pp /^o_ne::tw_o { 'o_ne::tw_o': }$/;" resource line:26 language:PuppetManifest end:26
o_ne::two_ input.pp /^o_ne::two_ { 'o_ne::two_': }$/;" resource line:27 language:PuppetManifest end:27
27 changes: 27 additions & 0 deletions Units/parser-puppetManifest.r/puppet-definitionname.d/input.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@

define t {
file { "/tmp/multipledefinet": content => "one" }
}

define one_ {
file { "/tmp/multipledefineone_": content => "one" }
}

define on_e {
file { "/tmp/multipledefineon_e": content => "one" }
}


define o_ne::tw_o {
file { "/tmp/multipledefineo_netw_o": content => "two" }
}

define o_ne::two_ {
file { "/tmp/multipledefineo_netwo_": content => "two" }
}

t { 't': }
one_ { 'one_': }
on_e { 'on_e': }
o_ne::tw_o { 'o_ne::tw_o': }
o_ne::two_ { 'o_ne::two_': }
20 changes: 10 additions & 10 deletions optlib/puppetManifest.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,10 @@ static void initializePuppetManifestParser (const langType language CTAGS_ATTR_U
"^\\$",
"", "", "{tenter=var}", NULL);
addLanguageTagMultiTableRegex (language, "main",
"^@?::[a-zA-Z0-9:]+[ \t\n]*\\{",
"^@?::[a-zA-Z0-9:_]+[ \t\n]*\\{",
"", "", "{tenter=resourceBlock}", NULL);
addLanguageTagMultiTableRegex (language, "main",
"^@?[a-zA-Z][a-zA-Z0-9:]*[ \t\n]*\\{",
"^@?[a-zA-Z][a-zA-Z0-9:_]*[ \t\n]*\\{",
"", "", "{tenter=resourceBlock}", NULL);
addLanguageTagMultiTableRegex (language, "main",
"^class[ \t\n]+",
Expand Down Expand Up @@ -132,10 +132,10 @@ static void initializePuppetManifestParser (const langType language CTAGS_ATTR_U
"^\\#",
"", "", "{tenter=comment_oneline}", NULL);
addLanguageTagMultiTableRegex (language, "blockStart",
"^@?::[a-zA-Z0-9:]+[ \t\n]*\\{",
"^@?::[a-zA-Z0-9:_]+[ \t\n]*\\{",
"", "", "{tenter=resourceBlock}", NULL);
addLanguageTagMultiTableRegex (language, "blockStart",
"^@?[a-zA-Z][a-zA-Z0-9:]*[ \t\n]*\\{",
"^@?[a-zA-Z][a-zA-Z0-9:_]*[ \t\n]*\\{",
"", "", "{tenter=resourceBlock}", NULL);
addLanguageTagMultiTableRegex (language, "blockStart",
"^class[ \t\n]+",
Expand Down Expand Up @@ -195,10 +195,10 @@ static void initializePuppetManifestParser (const langType language CTAGS_ATTR_U
"^<<?\\|",
"", "", "{tenter=skipCollector}", NULL);
addLanguageTagMultiTableRegex (language, "block",
"^@?::[a-zA-Z0-9:]+[ \t\n]*\\{",
"^@?::[a-zA-Z0-9:_]+[ \t\n]*\\{",
"", "", "{tenter=resourceBlock}", NULL);
addLanguageTagMultiTableRegex (language, "block",
"^@?[a-zA-Z][a-zA-Z0-9:]*[ \t\n]*\\{",
"^@?[a-zA-Z][a-zA-Z0-9:_]*[ \t\n]*\\{",
"", "", "{tenter=resourceBlock}", NULL);
addLanguageTagMultiTableRegex (language, "block",
"^class[ \t\n]+",
Expand Down Expand Up @@ -234,10 +234,10 @@ static void initializePuppetManifestParser (const langType language CTAGS_ATTR_U
"^\\#",
"", "", "{tenter=comment_oneline}", NULL);
addLanguageTagMultiTableRegex (language, "classStart",
"^(::[a-zA-Z0-9:]+)",
"^(::[a-z][_a-zA-Z0-9:]*)",
"\\1", "c", "{tenter=blockHead,endWithPop}{scope=push}", NULL);
addLanguageTagMultiTableRegex (language, "classStart",
"^([a-zA-Z][a-zA-Z0-9:]*)",
"^([a-z][_a-zA-Z0-9:]*)",
"\\1", "c", "{tenter=blockHead,endWithPop}{scope=push}", NULL);
addLanguageTagMultiTableRegex (language, "resourceBlock",
"^/\\*",
Expand Down 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
12 changes: 6 additions & 6 deletions optlib/puppetManifest.ctags
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,8 @@
#
# block
#
--_mtable-regex-PuppetManifest=blockStart/@?::[a-zA-Z0-9:]+[ \t\n]*\{//{tenter=resourceBlock}
--_mtable-regex-PuppetManifest=blockStart/@?[a-zA-Z][a-zA-Z0-9:]*[ \t\n]*\{//{tenter=resourceBlock}
--_mtable-regex-PuppetManifest=blockStart/@?::[a-zA-Z0-9:_]+[ \t\n]*\{//{tenter=resourceBlock}
--_mtable-regex-PuppetManifest=blockStart/@?[a-zA-Z][a-zA-Z0-9:_]*[ \t\n]*\{//{tenter=resourceBlock}
--_mtable-regex-PuppetManifest=blockStart/class[ \t\n]+//{tenter=classStart}
--_mtable-regex-PuppetManifest=blockStart/define[ \t\n]+//{tenter=defineStart}
--_mtable-regex-PuppetManifest=blockStart/case[ \t\n]+//{tenter=caseStart}
Expand Down Expand Up @@ -209,8 +209,8 @@
# TODO: inherits:
#
--_mtable-extend-PuppetManifest=classStart+comment
--_mtable-regex-PuppetManifest=classStart/(::[a-zA-Z0-9:]+)/\1/c/{tenter=blockHead,endWithPop}{scope=push}
--_mtable-regex-PuppetManifest=classStart/([a-zA-Z][a-zA-Z0-9:]*)/\1/c/{tenter=blockHead,endWithPop}{scope=push}
--_mtable-regex-PuppetManifest=classStart/(::[a-z][_a-zA-Z0-9:]*)/\1/c/{tenter=blockHead,endWithPop}{scope=push}
--_mtable-regex-PuppetManifest=classStart/([a-z][_a-zA-Z0-9:]*)/\1/c/{tenter=blockHead,endWithPop}{scope=push}

#
# resource
Expand Down 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

0 comments on commit a39e1de

Please sign in to comment.