Skip to content

Commit

Permalink
{WIP} (puppetlabsGH-269) Workspace Symbol Provider
Browse files Browse the repository at this point in the history
Output DataTypes
Ignore Facts
Fix comments
  • Loading branch information
glennsarti committed Jul 15, 2020
1 parent 580712f commit df52780
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
18 changes: 16 additions & 2 deletions lib/puppet-languageserver/manifest/document_symbol_provider.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def self.workspace_symbols(query, object_cache)
'kind' => LSP::SymbolKind::METHOD,
'location' => {
'uri' => PuppetLanguageServer::UriHelper.build_file_uri(item.source),
# Don't have char pos for functions so just pick extreme values
# Don't have char pos for types so just pick extreme values
'range' => LSP.create_range(item.line, 0, item.line, 1024)
}
)
Expand All @@ -38,11 +38,25 @@ def self.workspace_symbols(query, object_cache)
'kind' => LSP::SymbolKind::CLASS,
'location' => {
'uri' => PuppetLanguageServer::UriHelper.build_file_uri(item.source),
# Don't have char pos for functions so just pick extreme values
# Don't have char pos for classes so just pick extreme values
'range' => LSP.create_range(item.line, 0, item.line, 1024)
}
)

when PuppetLanguageServer::Sidecar::Protocol::PuppetDataType
result << LSP::SymbolInformation.new(
'name' => key_string,
'kind' => LSP::SymbolKind::NAMESPACE,
'location' => {
'uri' => PuppetLanguageServer::UriHelper.build_file_uri(item.source),
# Don't have char pos for data types so just pick extreme values
'range' => LSP.create_range(item.line, 0, item.line, 1024)
}
)

when PuppetLanguageServer::Sidecar::Protocol::Fact
# Do nothing

else
PuppetLanguageServer.log_message(:warn, "[Manifest::DocumentSymbolProvider] Unknown object type #{item.class}")
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@
expect(result[1]).to be_symbol_information('func1', LSP::SymbolKind::FUNCTION)
expect(result[2]).to be_symbol_information('type1', LSP::SymbolKind::METHOD)

# Facts and Datatypes
expect(1).to eq(2)

all_cache_names = []
cache.all_objects { |key, _| all_cache_names << key.to_s }
expect(result.count).to eq(all_cache_names.count)
Expand Down

0 comments on commit df52780

Please sign in to comment.