@@ -55,7 +55,14 @@ def self.complete(content, line_num, char_num, options = {})
5555 # properities and parameters.
5656
5757 # Try Types first
58- item_object = PuppetLanguageServer ::PuppetHelper . get_type ( item . type_name . value )
58+ if item . type_name . value == 'class'
59+ item_object = PuppetLanguageServer ::PuppetHelper . get_type ( item . bodies [ 0 ] . title . value )
60+ item_value = item . bodies [ 0 ] . title . value
61+ else
62+ item_object = PuppetLanguageServer ::PuppetHelper . get_type ( item . type_name . value )
63+ item_value = item . type_name . value
64+ end
65+
5966 unless item_object . nil?
6067 # Add Parameters
6168 item_object . attributes . select { |_name , data | data [ :type ] == :param } . each_key do |name |
@@ -66,7 +73,7 @@ def self.complete(content, line_num, char_num, options = {})
6673 'data' => {
6774 'type' => 'resource_parameter' ,
6875 'param' => name . to_s ,
69- 'resource_type' => item . type_name . value
76+ 'resource_type' => item_value
7077 }
7178 )
7279 end
@@ -79,15 +86,15 @@ def self.complete(content, line_num, char_num, options = {})
7986 'data' => {
8087 'type' => 'resource_property' ,
8188 'prop' => name . to_s ,
82- 'resource_type' => item . type_name . value
89+ 'resource_type' => item_value
8390 }
8491 )
8592 end
8693 # TODO: What about meta parameters?
8794 end
8895 if item_object . nil?
8996 # Try Classes/Defined Types
90- item_object = PuppetLanguageServer ::PuppetHelper . get_class ( item . type_name . value )
97+ item_object = PuppetLanguageServer ::PuppetHelper . get_class ( item_value )
9198 unless item_object . nil?
9299 # Add Parameters
93100 item_object . parameters . each_key do |name |
@@ -98,7 +105,7 @@ def self.complete(content, line_num, char_num, options = {})
98105 'data' => {
99106 'type' => 'resource_class_parameter' ,
100107 'param' => name . to_s ,
101- 'resource_type' => item . type_name . value
108+ 'resource_type' => item_value
102109 }
103110 )
104111 end
0 commit comments