Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,3 +83,11 @@ Layout/AlignHash:

Naming/RescuedExceptionsVariableName:
PreferredName: e

# There's no benefit to this and can make things harder to read.
Style/NumericPredicate:
Enabled: false

# This is not valid on Ruby 2.1
Style/SafeNavigation:
Enabled: false
2 changes: 2 additions & 0 deletions lib/debugserver/debug_protocol.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# Original JSON Schema for the protocol
# https://github.com/Microsoft/vscode-debugadapter-node/blob/master/debugProtocol.json
#
Expand Down
2 changes: 2 additions & 0 deletions lib/lsp/lsp.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

%w[lsp_base lsp_enums lsp_protocol lsp_types lsp_custom].each do |lib|
begin
require "lsp/#{lib}"
Expand Down
2 changes: 2 additions & 0 deletions lib/lsp/lsp_base.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'json'

module LSP
Expand Down
2 changes: 2 additions & 0 deletions lib/lsp/lsp_custom.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# Custom LSP Messages

module LSP
Expand Down
34 changes: 18 additions & 16 deletions lib/lsp/lsp_enums.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# DO NOT MODIFY. This file is built automatically
# LSP Enumerations

Expand All @@ -14,8 +16,8 @@ module DiagnosticSeverity
end

module MarkupKind
PLAINTEXT = 'plaintext'.freeze
MARKDOWN = 'markdown'.freeze
PLAINTEXT = 'plaintext'
MARKDOWN = 'markdown'
end

module CompletionItemKind
Expand Down Expand Up @@ -87,13 +89,13 @@ module SymbolKind
end

module CodeActionKind
QUICKFIX = 'quickfix'.freeze
REFACTOR = 'refactor'.freeze
REFACTOREXTRACT = 'refactor.extract'.freeze
REFACTORINLINE = 'refactor.inline'.freeze
REFACTORREWRITE = 'refactor.rewrite'.freeze
SOURCE = 'source'.freeze
SOURCEORGANIZEIMPORTS = 'source.organizeImports'.freeze
QUICKFIX = 'quickfix'
REFACTOR = 'refactor'
REFACTOREXTRACT = 'refactor.extract'
REFACTORINLINE = 'refactor.inline'
REFACTORREWRITE = 'refactor.rewrite'
SOURCE = 'source'
SOURCEORGANIZEIMPORTS = 'source.organizeImports'
end

module TextDocumentSaveReason
Expand All @@ -103,16 +105,16 @@ module TextDocumentSaveReason
end

module ResourceOperationKind
CREATE = 'create'.freeze
RENAME = 'rename'.freeze
DELETE = 'delete'.freeze
CREATE = 'create'
RENAME = 'rename'
DELETE = 'delete'
end

module FailureHandlingKind
ABORT = 'abort'.freeze
TRANSACTIONAL = 'transactional'.freeze
TEXTONLYTRANSACTIONAL = 'textOnlyTransactional'.freeze
UNDO = 'undo'.freeze
ABORT = 'abort'
TRANSACTIONAL = 'transactional'
TEXTONLYTRANSACTIONAL = 'textOnlyTransactional'
UNDO = 'undo'
end

module TextDocumentSyncKind
Expand Down
2 changes: 2 additions & 0 deletions lib/lsp/lsp_protocol.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# DO NOT MODIFY. This file is built automatically
# LSP Protocol: vscode-languageserver-protocol/lib/protocol.d.ts

Expand Down
2 changes: 2 additions & 0 deletions lib/lsp/lsp_types.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# DO NOT MODIFY. This file is built automatically
# LSP Protocol: vscode-languageserver-types/lib/esm/main.d.ts

Expand Down
2 changes: 2 additions & 0 deletions lib/puppet-debugserver/debug_hook_handlers.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module PuppetDebugServer
module PuppetDebugSession
@hook_handler = nil
Expand Down
2 changes: 2 additions & 0 deletions lib/puppet-debugserver/hooks.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module PuppetDebugServer
# This code was inspired from Puppet-Debugger (https://raw.githubusercontent.com/nwops/puppet-debugger/master/lib/puppet-debugger/hooks.rb) which was borrowed from Pry hooks file

Expand Down
2 changes: 2 additions & 0 deletions lib/puppet-debugserver/json_handler.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'json'

# Full debug protocol
Expand Down
2 changes: 2 additions & 0 deletions lib/puppet-debugserver/message_router.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module PuppetDebugServer
class MessageRouter
attr_accessor :json_handler
Expand Down
2 changes: 2 additions & 0 deletions lib/puppet-debugserver/puppet_debug_breakpoints.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module PuppetDebugServer
module PuppetDebugSession
@session_function_breakpoints = []
Expand Down
2 changes: 2 additions & 0 deletions lib/puppet-debugserver/puppet_debug_session.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module PuppetDebugServer
module PuppetDebugSession
@connection = nil
Expand Down
2 changes: 2 additions & 0 deletions lib/puppet-debugserver/puppet_monkey_patches.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# Monkey patch the Apply application (puppet apply) so that we route the exit
# statement into the debugger first and then exit the puppet thread
require 'puppet/application/apply'
Expand Down
2 changes: 2 additions & 0 deletions lib/puppet-editor-services/logging.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module PuppetEditorServices
def self.log_message(severity, message)
return if @logger.nil?
Expand Down
2 changes: 2 additions & 0 deletions lib/puppet-editor-services/simple_base.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module PuppetEditorServices
class SimpleServerConnectionBase
# Override this method
Expand Down
2 changes: 2 additions & 0 deletions lib/puppet-editor-services/simple_stdio_server.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module PuppetEditorServices
class SimpleSTDIOServerConnection < SimpleServerConnectionBase
attr_accessor :simple_stdio_server
Expand Down
2 changes: 2 additions & 0 deletions lib/puppet-editor-services/simple_tcp_server.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'socket'

# Based on code from
Expand Down
4 changes: 3 additions & 1 deletion lib/puppet-editor-services/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# frozen_string_literal: true

module PuppetEditorServices
PUPPETEDITORSERVICESVERSION = '0.19.0'.freeze unless defined? PUPPETEDITORSERVICESVERSION
PUPPETEDITORSERVICESVERSION = '0.19.0' unless defined? PUPPETEDITORSERVICESVERSION

# @api public
#
Expand Down
8 changes: 5 additions & 3 deletions lib/puppet-languageserver-sidecar/cache/base.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
# frozen_string_literal: true

module PuppetLanguageServerSidecar
module Cache
CLASSES_SECTION = 'classes'.freeze
FUNCTIONS_SECTION = 'functions'.freeze
TYPES_SECTION = 'types'.freeze
CLASSES_SECTION = 'classes'
FUNCTIONS_SECTION = 'functions'
TYPES_SECTION = 'types'

class Base
attr_reader :cache_options
Expand Down
2 changes: 2 additions & 0 deletions lib/puppet-languageserver-sidecar/cache/filesystem.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module PuppetLanguageServerSidecar
module Cache
class FileSystem < Base
Expand Down
2 changes: 2 additions & 0 deletions lib/puppet-languageserver-sidecar/cache/null.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module PuppetLanguageServerSidecar
module Cache
class Null < Base
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module Puppet::Environments # rubocop:disable Style/ClassAndModuleChildren
class Directories
# Monkey patch the environment loader. When it attempts to load the special sidecar
Expand Down
4 changes: 3 additions & 1 deletion lib/puppet-languageserver-sidecar/puppet_helper.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
# frozen_string_literal: true

require 'puppet/indirector/face'

module PuppetLanguageServerSidecar
module PuppetHelper
SIDECAR_PUPPET_ENVIRONMENT = 'sidecarenvironment'.freeze
SIDECAR_PUPPET_ENVIRONMENT = 'sidecarenvironment'

def self.path_has_child?(path, child)
# Doesn't matter what the child is, if the path is nil it's true.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# Inject the workspace libdir on the fly
require 'puppet/util/autoload'
module Puppet
Expand Down
2 changes: 2 additions & 0 deletions lib/puppet-languageserver-sidecar/puppet_monkey_patches.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# Monkey Patch 3.x functions so where know where they were loaded from
require 'puppet/parser/functions'
module Puppet
Expand Down
2 changes: 2 additions & 0 deletions lib/puppet-languageserver-sidecar/puppet_parser_helper.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module PuppetLanguageServerSidecar
module PuppetParserHelper
def self.compile_node_graph(content)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'puppet-languageserver/sidecar_protocol'

module PuppetLanguageServerSidecar
Expand Down
2 changes: 2 additions & 0 deletions lib/puppet-languageserver-sidecar/workspace.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module PuppetLanguageServerSidecar
module Workspace
@root_path = nil
Expand Down
2 changes: 2 additions & 0 deletions lib/puppet-languageserver/crash_dump.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module PuppetLanguageServer
module CrashDump
def self.default_crash_file
Expand Down
2 changes: 2 additions & 0 deletions lib/puppet-languageserver/document_store.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module PuppetLanguageServer
module DocumentStore
@documents = {}
Expand Down
2 changes: 2 additions & 0 deletions lib/puppet-languageserver/epp/validation_provider.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module PuppetLanguageServer
module Epp
module ValidationProvider
Expand Down
2 changes: 2 additions & 0 deletions lib/puppet-languageserver/facter_helper.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module PuppetLanguageServer
module FacterHelper
@ops_lock = Mutex.new
Expand Down
42 changes: 22 additions & 20 deletions lib/puppet-languageserver/json_rpc_handler.rb
Original file line number Diff line number Diff line change
@@ -1,41 +1,43 @@
# frozen_string_literal: true

require 'json'

module PuppetLanguageServer
CODE_INVALID_JSON = -32700
MSG_INVALID_JSON = 'invalid JSON'.freeze
MSG_INVALID_JSON = 'invalid JSON'

CODE_INVALID_REQUEST = -32600
MSG_INVALID_REQ_JSONRPC = "invalid request: doesn't include \"jsonrpc\": \"2.0\"".freeze
MSG_INVALID_REQ_ID = 'invalid request: wrong id'.freeze
MSG_INVALID_REQ_METHOD = 'invalid request: wrong method'.freeze
MSG_INVALID_REQ_PARAMS = 'invalid request: wrong params'.freeze
MSG_INVALID_REQ_JSONRPC = "invalid request: doesn't include \"jsonrpc\": \"2.0\""
MSG_INVALID_REQ_ID = 'invalid request: wrong id'
MSG_INVALID_REQ_METHOD = 'invalid request: wrong method'
MSG_INVALID_REQ_PARAMS = 'invalid request: wrong params'

CODE_METHOD_NOT_FOUND = -32601
MSG_METHOD_NOT_FOUND = 'method not found'.freeze
MSG_METHOD_NOT_FOUND = 'method not found'

CODE_INVALID_PARAMS = -32602
MSG_INVALID_PARAMS = 'invalid parameter(s)'.freeze
MSG_INVALID_PARAMS = 'invalid parameter(s)'

CODE_INTERNAL_ERROR = -32603
MSG_INTERNAL_ERROR = 'internal error'.freeze
MSG_INTERNAL_ERROR = 'internal error'

PARSING_ERROR_RESPONSE = '{"jsonrpc":"2.0","id":null,"error":{' \
"\"code\":#{CODE_INVALID_JSON}," \
"\"message\":\"#{MSG_INVALID_JSON}\"}}".freeze
"\"message\":\"#{MSG_INVALID_JSON}\"}}"

BATCH_NOT_SUPPORTED_RESPONSE = '{"jsonrpc":"2.0","id":null,"error":{' \
'"code":-32099,' \
'"message":"batch mode not implemented"}}'.freeze

KEY_JSONRPC = 'jsonrpc'.freeze
VALUE_VERSION = '2.0'.freeze
KEY_ID = 'id'.freeze
KEY_METHOD = 'method'.freeze
KEY_PARAMS = 'params'.freeze
KEY_RESULT = 'result'.freeze
KEY_ERROR = 'error'.freeze
KEY_CODE = 'code'.freeze
KEY_MESSAGE = 'message'.freeze
'"message":"batch mode not implemented"}}'

KEY_JSONRPC = 'jsonrpc'
VALUE_VERSION = '2.0'
KEY_ID = 'id'
KEY_METHOD = 'method'
KEY_PARAMS = 'params'
KEY_RESULT = 'result'
KEY_ERROR = 'error'
KEY_CODE = 'code'
KEY_MESSAGE = 'message'

class JSONRPCHandler < PuppetEditorServices::SimpleServerConnectionHandler
attr_accessor :message_router
Expand Down
2 changes: 2 additions & 0 deletions lib/puppet-languageserver/manifest/completion_provider.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module PuppetLanguageServer
module Manifest
module CompletionProvider
Expand Down
2 changes: 2 additions & 0 deletions lib/puppet-languageserver/manifest/definition_provider.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module PuppetLanguageServer
module Manifest
module DefinitionProvider
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module PuppetLanguageServer
module Manifest
module DocumentSymbolProvider
Expand Down
2 changes: 2 additions & 0 deletions lib/puppet-languageserver/manifest/hover_provider.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module PuppetLanguageServer
module Manifest
module HoverProvider
Expand Down
2 changes: 2 additions & 0 deletions lib/puppet-languageserver/manifest/validation_provider.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'puppet-lint'
module PuppetLanguageServer
module Manifest
Expand Down
2 changes: 2 additions & 0 deletions lib/puppet-languageserver/message_router.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module PuppetLanguageServer
class MessageRouter
attr_reader :server_options
Expand Down
2 changes: 2 additions & 0 deletions lib/puppet-languageserver/providers.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

%w[
epp/validation_provider
manifest/completion_provider
Expand Down
2 changes: 2 additions & 0 deletions lib/puppet-languageserver/puppet_helper.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'pathname'
require 'tempfile'

Expand Down
Loading