We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Missing codeActionKind entry prevents RLS init
* OS and language server
macOS 10.14.6, rls 1.35.0 (49efc06 2019-04-06)
* How you installed LSP (Package Control or from git?)
LSP installed from package control today
* Minimal reproduction steps
Install current stable Rust RLS, latest LSP release, enable LSP in Rust project
* Log

    [2019-06-28T16:08:36Z ERROR rls::server] dispatch error: Error { code: InvalidParams, message: "missing field `codeActionKind`", data: None }, message:


      {
      "jsonrpc": "2.0",
      "id": 1,
      "params": {
        "rootPath": "/Users/sth/dev/proj",
        "capabilities": {
          "workspace": {
            "applyEdit": true,
            "executeCommand": {},
            "didChangeConfiguration": {}
          },
          "textDocument": {
            "codeAction": {
              "dynamicRegistration": true,
              "codeActionLiteralSupport": {}
            },
            "documentSymbol": {
              "symbolKind": {
                "valueSet": [
                  1,
                  2,
                  3,
                  4,
                  5,
                  6,
                  7,
                  8,
                  9,
                  10,
                  11,
                  12,
                  13,
                  14,
                  15,
                  16,
                  17,
                  18,
                  19,
                  20,
                  21,
                  22,
                  23,
                  24,
                  25,
                  26
                ]
              }
            },
            "rangeFormatting": {},
            "rename": {},
            "completion": {
              "completionItem": {
                "snippetSupport": true
              },
              "completionItemKind": {
                "valueSet": [
                  1,
                  2,
                  3,
                  4,
                  5,
                  6,
                  7,
                  8,
                  9,
                  10,
                  11,
                  12,
                  13,
                  14,
                  15,
                  16,
                  17,
                  18
                ]
              }
            },
            "signatureHelp": {
              "signatureInformation": {
                "parameterInformation": {
                  "labelOffsetSupport": true
                },
                "documentationFormat": [
                  "markdown",
                  "plaintext"
                ]
              }
            },
            "formatting": {},
            "references": {},
            "synchronization": {
              "didSave": true
            },
            "documentHighlight": {},
            "definition": {},
            "hover": {
              "contentFormat": [
                "markdown",
                "plaintext"
              ]
            }
          }
        },
        "processId": 39815,
        "rootUri": "file:///Users/sth/dev/proj"
      },
      "method": "initialize"}
    


This appears to be related to a missing `codeActionKind` field sent as part of the init, within `codeActionLiteralSupport`.

Per the spec and some other extant implementations, an init message containing a complete `codeKindAction` entry might look like:


    {
      "jsonrpc": "2.0",
      "id": 1,
      "params": {
        "rootPath": "/Users/sth/dev/proj",
        "capabilities": {
          "workspace": {
            "applyEdit": true,
            "executeCommand": {},
            "didChangeConfiguration": {}
          },
          "textDocument": {
            "codeAction": {
              "dynamicRegistration": true,
              "codeActionLiteralSupport": {
                "codeActionKind": {
                  "valueSet": [
                    "",
                    "quickfix",
                    "refactor",
                    "refactor.extract",
                    "refactor.inline",
                    "refactor.rewrite",
                    "source",
                    "source.organizeImports"
                  ]
                }
              }
            },
            "documentSymbol": {
              "symbolKind": {
                "valueSet": [
                  1,
                  2,
                  3,
                  4,
                  5,
                  6,
                  7,
                  8,
                  9,
                  10,
                  11,
                  12,
                  13,
                  14,
                  15,
                  16,
                  17,
                  18,
                  19,
                  20,
                  21,
                  22,
                  23,
                  24,
                  25,
                  26
                ]
              }
            },
            "rangeFormatting": {},
            "rename": {},
            "completion": {
              "completionItem": {
                "snippetSupport": true
              },
              "completionItemKind": {
                "valueSet": [
                  1,
                  2,
                  3,
                  4,
                  5,
                  6,
                  7,
                  8,
                  9,
                  10,
                  11,
                  12,
                  13,
                  14,
                  15,
                  16,
                  17,
                  18
                ]
              }
            },
            "signatureHelp": {
              "signatureInformation": {
                "parameterInformation": {
                  "labelOffsetSupport": true
                },
                "documentationFormat": [
                  "markdown",
                  "plaintext"
                ]
              }
            },
            "formatting": {},
            "references": {},
            "synchronization": {
              "didSave": true
            },
            "documentHighlight": {},
            "definition": {},
            "hover": {
              "contentFormat": [
                "markdown",
                "plaintext"
              ]
            }
          }
        },
        "processId": 39815,
        "rootUri": "file:///Users/sth/dev/proj"
      },
      "method": "initialize"
     }

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `plugin/core/sessions.py`
Content:
```
1 from .types import ClientConfig, ClientStates, Settings
2 from .protocol import Request
3 from .transports import start_tcp_transport
4 from .rpc import Client, attach_stdio_client
5 from .process import start_server
6 from .url import filename_to_uri
7 from .logging import debug
8 import os
9 from .protocol import CompletionItemKind, SymbolKind
10 try:
11     from typing import Callable, Dict, Any, Optional
12     assert Callable and Dict and Any and Optional
13 except ImportError:
14     pass
15 
16 
17 def create_session(config: ClientConfig, project_path: str, env: dict, settings: Settings,
18                    on_created=None, on_ended: 'Optional[Callable[[str], None]]' = None,
19                    bootstrap_client=None) -> 'Optional[Session]':
20     session = None
21     if config.binary_args:
22 
23         process = start_server(config.binary_args, project_path, env, settings.log_stderr)
24         if process:
25             if config.tcp_port:
26                 transport = start_tcp_transport(config.tcp_port, config.tcp_host)
27                 if transport:
28                     session = Session(config, project_path, Client(transport, settings), on_created, on_ended)
29                 else:
30                     # try to terminate the process
31                     try:
32                         process.terminate()
33                     except Exception:
34                         pass
35             else:
36                 client = attach_stdio_client(process, settings)
37                 session = Session(config, project_path, client, on_created, on_ended)
38     else:
39         if config.tcp_port:
40             transport = start_tcp_transport(config.tcp_port)
41 
42             session = Session(config, project_path, Client(transport, settings),
43                               on_created, on_ended)
44         elif bootstrap_client:
45             session = Session(config, project_path, bootstrap_client,
46                               on_created, on_ended)
47         else:
48             debug("No way to start session")
49 
50     return session
51 
52 
53 def get_initialize_params(project_path: str, config: ClientConfig):
54     initializeParams = {
55         "processId": os.getpid(),
56         "rootUri": filename_to_uri(project_path),
57         "rootPath": project_path,
58         "capabilities": {
59             "textDocument": {
60                 "synchronization": {
61                     "didSave": True
62                 },
63                 "hover": {
64                     "contentFormat": ["markdown", "plaintext"]
65                 },
66                 "completion": {
67                     "completionItem": {
68                         "snippetSupport": True
69                     },
70                     "completionItemKind": {
71                         "valueSet": [
72                             CompletionItemKind.Text,
73                             CompletionItemKind.Method,
74                             CompletionItemKind.Function,
75                             CompletionItemKind.Constructor,
76                             CompletionItemKind.Field,
77                             CompletionItemKind.Variable,
78                             CompletionItemKind.Class,
79                             CompletionItemKind.Interface,
80                             CompletionItemKind.Module,
81                             CompletionItemKind.Property,
82                             CompletionItemKind.Unit,
83                             CompletionItemKind.Value,
84                             CompletionItemKind.Enum,
85                             CompletionItemKind.Keyword,
86                             CompletionItemKind.Snippet,
87                             CompletionItemKind.Color,
88                             CompletionItemKind.File,
89                             CompletionItemKind.Reference
90                         ]
91                     }
92                 },
93                 "signatureHelp": {
94                     "signatureInformation": {
95                         "documentationFormat": ["markdown", "plaintext"],
96                         "parameterInformation": {
97                             "labelOffsetSupport": True
98                         }
99                     }
100                 },
101                 "references": {},
102                 "documentHighlight": {},
103                 "documentSymbol": {
104                     "symbolKind": {
105                         "valueSet": [
106                             SymbolKind.File,
107                             SymbolKind.Module,
108                             SymbolKind.Namespace,
109                             SymbolKind.Package,
110                             SymbolKind.Class,
111                             SymbolKind.Method,
112                             SymbolKind.Property,
113                             SymbolKind.Field,
114                             SymbolKind.Constructor,
115                             SymbolKind.Enum,
116                             SymbolKind.Interface,
117                             SymbolKind.Function,
118                             SymbolKind.Variable,
119                             SymbolKind.Constant,
120                             SymbolKind.String,
121                             SymbolKind.Number,
122                             SymbolKind.Boolean,
123                             SymbolKind.Array,
124                             SymbolKind.Object,
125                             SymbolKind.Key,
126                             SymbolKind.Null,
127                             SymbolKind.EnumMember,
128                             SymbolKind.Struct,
129                             SymbolKind.Event,
130                             SymbolKind.Operator,
131                             SymbolKind.TypeParameter
132                         ]
133                     }
134                 },
135                 "formatting": {},
136                 "rangeFormatting": {},
137                 "definition": {},
138                 "codeAction": {
139                     "codeActionLiteralSupport": {}
140                 },
141                 "rename": {}
142             },
143             "workspace": {
144                 "applyEdit": True,
145                 "didChangeConfiguration": {},
146                 "executeCommand": {},
147             }
148         }
149     }
150     if config.init_options:
151         initializeParams['initializationOptions'] = config.init_options
152 
153     return initializeParams
154 
155 
156 class Session(object):
157     def __init__(self, config: ClientConfig, project_path, client: Client,
158                  on_created=None, on_ended: 'Optional[Callable[[str], None]]' = None) -> None:
159         self.config = config
160         self.project_path = project_path
161         self.state = ClientStates.STARTING
162         self._on_created = on_created
163         self._on_ended = on_ended
164         self.capabilities = dict()  # type: Dict[str, Any]
165         self.client = client
166         self.initialize()
167 
168     def has_capability(self, capability):
169         return capability in self.capabilities and self.capabilities[capability] is not False
170 
171     def get_capability(self, capability):
172         return self.capabilities.get(capability)
173 
174     def initialize(self):
175         params = get_initialize_params(self.project_path, self.config)
176         self.client.send_request(
177             Request.initialize(params),
178             lambda result: self._handle_initialize_result(result))
179 
180     def _handle_initialize_result(self, result):
181         self.state = ClientStates.READY
182         self.capabilities = result.get('capabilities', dict())
183         if self._on_created:
184             self._on_created(self)
185 
186     def end(self):
187         self.state = ClientStates.STOPPING
188         self.client.send_request(
189             Request.shutdown(),
190             lambda result: self._handle_shutdown_result(),
191             lambda: self._handle_shutdown_result())
192 
193     def _handle_shutdown_result(self):
194         self.client.exit()
195         self.client = None
196         self.capabilities = dict()
197         if self._on_ended:
198             self._on_ended(self.config.name)
199
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/plugin/core/sessions.py b/plugin/core/sessions.py
--- a/plugin/core/sessions.py
+++ b/plugin/core/sessions.py
@@ -136,7 +136,11 @@
                 "rangeFormatting": {},
                 "definition": {},
                 "codeAction": {
-                    "codeActionLiteralSupport": {}
+                    "codeActionLiteralSupport": {
+                        "codeActionKind": {
+                            "valueSet": []
+                        }
+                    }
                 },
                 "rename": {}
             },

{"golden_diff": "diff --git a/plugin/core/sessions.py b/plugin/core/sessions.py\n--- a/plugin/core/sessions.py\n+++ b/plugin/core/sessions.py\n@@ -136,7 +136,11 @@\n                 \"rangeFormatting\": {},\n                 \"definition\": {},\n                 \"codeAction\": {\n-                    \"codeActionLiteralSupport\": {}\n+                    \"codeActionLiteralSupport\": {\n+                        \"codeActionKind\": {\n+                            \"valueSet\": []\n+                        }\n+                    }\n                 },\n                 \"rename\": {}\n             },\n", "issue": "Missing codeActionKind entry prevents RLS init\n* OS and language server\r\nmacOS 10.14.6, rls 1.35.0 (49efc06 2019-04-06)\r\n* How you installed LSP (Package Control or from git?)\r\nLSP installed from package control today\r\n* Minimal reproduction steps\r\nInstall current stable Rust RLS, latest LSP release, enable LSP in Rust project\r\n* Log\r\n\r\n    [2019-06-28T16:08:36Z ERROR rls::server] dispatch error: Error { code: InvalidParams, message: \"missing field `codeActionKind`\", data: None }, message:\r\n\r\n\r\n      {\r\n      \"jsonrpc\": \"2.0\",\r\n      \"id\": 1,\r\n      \"params\": {\r\n        \"rootPath\": \"/Users/sth/dev/proj\",\r\n        \"capabilities\": {\r\n          \"workspace\": {\r\n            \"applyEdit\": true,\r\n            \"executeCommand\": {},\r\n            \"didChangeConfiguration\": {}\r\n          },\r\n          \"textDocument\": {\r\n            \"codeAction\": {\r\n              \"dynamicRegistration\": true,\r\n              \"codeActionLiteralSupport\": {}\r\n            },\r\n            \"documentSymbol\": {\r\n              \"symbolKind\": {\r\n                \"valueSet\": [\r\n                  1,\r\n                  2,\r\n                  3,\r\n                  4,\r\n                  5,\r\n                  6,\r\n                  7,\r\n                  8,\r\n                  9,\r\n                  10,\r\n                  11,\r\n                  12,\r\n                  13,\r\n                  14,\r\n                  15,\r\n                  16,\r\n                  17,\r\n                  18,\r\n                  19,\r\n                  20,\r\n                  21,\r\n                  22,\r\n                  23,\r\n                  24,\r\n                  25,\r\n                  26\r\n                ]\r\n              }\r\n            },\r\n            \"rangeFormatting\": {},\r\n            \"rename\": {},\r\n            \"completion\": {\r\n              \"completionItem\": {\r\n                \"snippetSupport\": true\r\n              },\r\n              \"completionItemKind\": {\r\n                \"valueSet\": [\r\n                  1,\r\n                  2,\r\n                  3,\r\n                  4,\r\n                  5,\r\n                  6,\r\n                  7,\r\n                  8,\r\n                  9,\r\n                  10,\r\n                  11,\r\n                  12,\r\n                  13,\r\n                  14,\r\n                  15,\r\n                  16,\r\n                  17,\r\n                  18\r\n                ]\r\n              }\r\n            },\r\n            \"signatureHelp\": {\r\n              \"signatureInformation\": {\r\n                \"parameterInformation\": {\r\n                  \"labelOffsetSupport\": true\r\n                },\r\n                \"documentationFormat\": [\r\n                  \"markdown\",\r\n                  \"plaintext\"\r\n                ]\r\n              }\r\n            },\r\n            \"formatting\": {},\r\n            \"references\": {},\r\n            \"synchronization\": {\r\n              \"didSave\": true\r\n            },\r\n            \"documentHighlight\": {},\r\n            \"definition\": {},\r\n            \"hover\": {\r\n              \"contentFormat\": [\r\n                \"markdown\",\r\n                \"plaintext\"\r\n              ]\r\n            }\r\n          }\r\n        },\r\n        \"processId\": 39815,\r\n        \"rootUri\": \"file:///Users/sth/dev/proj\"\r\n      },\r\n      \"method\": \"initialize\"}\r\n    \r\n\r\n\r\nThis appears to be related to a missing `codeActionKind` field sent as part of the init, within `codeActionLiteralSupport`.\r\n\r\nPer the spec and some other extant implementations, an init message containing a complete `codeKindAction` entry might look like:\r\n\r\n\r\n    {\r\n      \"jsonrpc\": \"2.0\",\r\n      \"id\": 1,\r\n      \"params\": {\r\n        \"rootPath\": \"/Users/sth/dev/proj\",\r\n        \"capabilities\": {\r\n          \"workspace\": {\r\n            \"applyEdit\": true,\r\n            \"executeCommand\": {},\r\n            \"didChangeConfiguration\": {}\r\n          },\r\n          \"textDocument\": {\r\n            \"codeAction\": {\r\n              \"dynamicRegistration\": true,\r\n              \"codeActionLiteralSupport\": {\r\n                \"codeActionKind\": {\r\n                  \"valueSet\": [\r\n                    \"\",\r\n                    \"quickfix\",\r\n                    \"refactor\",\r\n                    \"refactor.extract\",\r\n                    \"refactor.inline\",\r\n                    \"refactor.rewrite\",\r\n                    \"source\",\r\n                    \"source.organizeImports\"\r\n                  ]\r\n                }\r\n              }\r\n            },\r\n            \"documentSymbol\": {\r\n              \"symbolKind\": {\r\n                \"valueSet\": [\r\n                  1,\r\n                  2,\r\n                  3,\r\n                  4,\r\n                  5,\r\n                  6,\r\n                  7,\r\n                  8,\r\n                  9,\r\n                  10,\r\n                  11,\r\n                  12,\r\n                  13,\r\n                  14,\r\n                  15,\r\n                  16,\r\n                  17,\r\n                  18,\r\n                  19,\r\n                  20,\r\n                  21,\r\n                  22,\r\n                  23,\r\n                  24,\r\n                  25,\r\n                  26\r\n                ]\r\n              }\r\n            },\r\n            \"rangeFormatting\": {},\r\n            \"rename\": {},\r\n            \"completion\": {\r\n              \"completionItem\": {\r\n                \"snippetSupport\": true\r\n              },\r\n              \"completionItemKind\": {\r\n                \"valueSet\": [\r\n                  1,\r\n                  2,\r\n                  3,\r\n                  4,\r\n                  5,\r\n                  6,\r\n                  7,\r\n                  8,\r\n                  9,\r\n                  10,\r\n                  11,\r\n                  12,\r\n                  13,\r\n                  14,\r\n                  15,\r\n                  16,\r\n                  17,\r\n                  18\r\n                ]\r\n              }\r\n            },\r\n            \"signatureHelp\": {\r\n              \"signatureInformation\": {\r\n                \"parameterInformation\": {\r\n                  \"labelOffsetSupport\": true\r\n                },\r\n                \"documentationFormat\": [\r\n                  \"markdown\",\r\n                  \"plaintext\"\r\n                ]\r\n              }\r\n            },\r\n            \"formatting\": {},\r\n            \"references\": {},\r\n            \"synchronization\": {\r\n              \"didSave\": true\r\n            },\r\n            \"documentHighlight\": {},\r\n            \"definition\": {},\r\n            \"hover\": {\r\n              \"contentFormat\": [\r\n                \"markdown\",\r\n                \"plaintext\"\r\n              ]\r\n            }\r\n          }\r\n        },\r\n        \"processId\": 39815,\r\n        \"rootUri\": \"file:///Users/sth/dev/proj\"\r\n      },\r\n      \"method\": \"initialize\"\r\n     }\n", "before_files": [{"content": "from .types import ClientConfig, ClientStates, Settings\nfrom .protocol import Request\nfrom .transports import start_tcp_transport\nfrom .rpc import Client, attach_stdio_client\nfrom .process import start_server\nfrom .url import filename_to_uri\nfrom .logging import debug\nimport os\nfrom .protocol import CompletionItemKind, SymbolKind\ntry:\n    from typing import Callable, Dict, Any, Optional\n    assert Callable and Dict and Any and Optional\nexcept ImportError:\n    pass\n\n\ndef create_session(config: ClientConfig, project_path: str, env: dict, settings: Settings,\n                   on_created=None, on_ended: 'Optional[Callable[[str], None]]' = None,\n                   bootstrap_client=None) -> 'Optional[Session]':\n    session = None\n    if config.binary_args:\n\n        process = start_server(config.binary_args, project_path, env, settings.log_stderr)\n        if process:\n            if config.tcp_port:\n                transport = start_tcp_transport(config.tcp_port, config.tcp_host)\n                if transport:\n                    session = Session(config, project_path, Client(transport, settings), on_created, on_ended)\n                else:\n                    # try to terminate the process\n                    try:\n                        process.terminate()\n                    except Exception:\n                        pass\n            else:\n                client = attach_stdio_client(process, settings)\n                session = Session(config, project_path, client, on_created, on_ended)\n    else:\n        if config.tcp_port:\n            transport = start_tcp_transport(config.tcp_port)\n\n            session = Session(config, project_path, Client(transport, settings),\n                              on_created, on_ended)\n        elif bootstrap_client:\n            session = Session(config, project_path, bootstrap_client,\n                              on_created, on_ended)\n        else:\n            debug(\"No way to start session\")\n\n    return session\n\n\ndef get_initialize_params(project_path: str, config: ClientConfig):\n    initializeParams = {\n        \"processId\": os.getpid(),\n        \"rootUri\": filename_to_uri(project_path),\n        \"rootPath\": project_path,\n        \"capabilities\": {\n            \"textDocument\": {\n                \"synchronization\": {\n                    \"didSave\": True\n                },\n                \"hover\": {\n                    \"contentFormat\": [\"markdown\", \"plaintext\"]\n                },\n                \"completion\": {\n                    \"completionItem\": {\n                        \"snippetSupport\": True\n                    },\n                    \"completionItemKind\": {\n                        \"valueSet\": [\n                            CompletionItemKind.Text,\n                            CompletionItemKind.Method,\n                            CompletionItemKind.Function,\n                            CompletionItemKind.Constructor,\n                            CompletionItemKind.Field,\n                            CompletionItemKind.Variable,\n                            CompletionItemKind.Class,\n                            CompletionItemKind.Interface,\n                            CompletionItemKind.Module,\n                            CompletionItemKind.Property,\n                            CompletionItemKind.Unit,\n                            CompletionItemKind.Value,\n                            CompletionItemKind.Enum,\n                            CompletionItemKind.Keyword,\n                            CompletionItemKind.Snippet,\n                            CompletionItemKind.Color,\n                            CompletionItemKind.File,\n                            CompletionItemKind.Reference\n                        ]\n                    }\n                },\n                \"signatureHelp\": {\n                    \"signatureInformation\": {\n                        \"documentationFormat\": [\"markdown\", \"plaintext\"],\n                        \"parameterInformation\": {\n                            \"labelOffsetSupport\": True\n                        }\n                    }\n                },\n                \"references\": {},\n                \"documentHighlight\": {},\n                \"documentSymbol\": {\n                    \"symbolKind\": {\n                        \"valueSet\": [\n                            SymbolKind.File,\n                            SymbolKind.Module,\n                            SymbolKind.Namespace,\n                            SymbolKind.Package,\n                            SymbolKind.Class,\n                            SymbolKind.Method,\n                            SymbolKind.Property,\n                            SymbolKind.Field,\n                            SymbolKind.Constructor,\n                            SymbolKind.Enum,\n                            SymbolKind.Interface,\n                            SymbolKind.Function,\n                            SymbolKind.Variable,\n                            SymbolKind.Constant,\n                            SymbolKind.String,\n                            SymbolKind.Number,\n                            SymbolKind.Boolean,\n                            SymbolKind.Array,\n                            SymbolKind.Object,\n                            SymbolKind.Key,\n                            SymbolKind.Null,\n                            SymbolKind.EnumMember,\n                            SymbolKind.Struct,\n                            SymbolKind.Event,\n                            SymbolKind.Operator,\n                            SymbolKind.TypeParameter\n                        ]\n                    }\n                },\n                \"formatting\": {},\n                \"rangeFormatting\": {},\n                \"definition\": {},\n                \"codeAction\": {\n                    \"codeActionLiteralSupport\": {}\n                },\n                \"rename\": {}\n            },\n            \"workspace\": {\n                \"applyEdit\": True,\n                \"didChangeConfiguration\": {},\n                \"executeCommand\": {},\n            }\n        }\n    }\n    if config.init_options:\n        initializeParams['initializationOptions'] = config.init_options\n\n    return initializeParams\n\n\nclass Session(object):\n    def __init__(self, config: ClientConfig, project_path, client: Client,\n                 on_created=None, on_ended: 'Optional[Callable[[str], None]]' = None) -> None:\n        self.config = config\n        self.project_path = project_path\n        self.state = ClientStates.STARTING\n        self._on_created = on_created\n        self._on_ended = on_ended\n        self.capabilities = dict()  # type: Dict[str, Any]\n        self.client = client\n        self.initialize()\n\n    def has_capability(self, capability):\n        return capability in self.capabilities and self.capabilities[capability] is not False\n\n    def get_capability(self, capability):\n        return self.capabilities.get(capability)\n\n    def initialize(self):\n        params = get_initialize_params(self.project_path, self.config)\n        self.client.send_request(\n            Request.initialize(params),\n            lambda result: self._handle_initialize_result(result))\n\n    def _handle_initialize_result(self, result):\n        self.state = ClientStates.READY\n        self.capabilities = result.get('capabilities', dict())\n        if self._on_created:\n            self._on_created(self)\n\n    def end(self):\n        self.state = ClientStates.STOPPING\n        self.client.send_request(\n            Request.shutdown(),\n            lambda result: self._handle_shutdown_result(),\n            lambda: self._handle_shutdown_result())\n\n    def _handle_shutdown_result(self):\n        self.client.exit()\n        self.client = None\n        self.capabilities = dict()\n        if self._on_ended:\n            self._on_ended(self.config.name)\n", "path": "plugin/core/sessions.py"}], "after_files": [{"content": "from .types import ClientConfig, ClientStates, Settings\nfrom .protocol import Request\nfrom .transports import start_tcp_transport\nfrom .rpc import Client, attach_stdio_client\nfrom .process import start_server\nfrom .url import filename_to_uri\nfrom .logging import debug\nimport os\nfrom .protocol import CompletionItemKind, SymbolKind\ntry:\n    from typing import Callable, Dict, Any, Optional\n    assert Callable and Dict and Any and Optional\nexcept ImportError:\n    pass\n\n\ndef create_session(config: ClientConfig, project_path: str, env: dict, settings: Settings,\n                   on_created=None, on_ended: 'Optional[Callable[[str], None]]' = None,\n                   bootstrap_client=None) -> 'Optional[Session]':\n    session = None\n    if config.binary_args:\n\n        process = start_server(config.binary_args, project_path, env, settings.log_stderr)\n        if process:\n            if config.tcp_port:\n                transport = start_tcp_transport(config.tcp_port, config.tcp_host)\n                if transport:\n                    session = Session(config, project_path, Client(transport, settings), on_created, on_ended)\n                else:\n                    # try to terminate the process\n                    try:\n                        process.terminate()\n                    except Exception:\n                        pass\n            else:\n                client = attach_stdio_client(process, settings)\n                session = Session(config, project_path, client, on_created, on_ended)\n    else:\n        if config.tcp_port:\n            transport = start_tcp_transport(config.tcp_port)\n\n            session = Session(config, project_path, Client(transport, settings),\n                              on_created, on_ended)\n        elif bootstrap_client:\n            session = Session(config, project_path, bootstrap_client,\n                              on_created, on_ended)\n        else:\n            debug(\"No way to start session\")\n\n    return session\n\n\ndef get_initialize_params(project_path: str, config: ClientConfig):\n    initializeParams = {\n        \"processId\": os.getpid(),\n        \"rootUri\": filename_to_uri(project_path),\n        \"rootPath\": project_path,\n        \"capabilities\": {\n            \"textDocument\": {\n                \"synchronization\": {\n                    \"didSave\": True\n                },\n                \"hover\": {\n                    \"contentFormat\": [\"markdown\", \"plaintext\"]\n                },\n                \"completion\": {\n                    \"completionItem\": {\n                        \"snippetSupport\": True\n                    },\n                    \"completionItemKind\": {\n                        \"valueSet\": [\n                            CompletionItemKind.Text,\n                            CompletionItemKind.Method,\n                            CompletionItemKind.Function,\n                            CompletionItemKind.Constructor,\n                            CompletionItemKind.Field,\n                            CompletionItemKind.Variable,\n                            CompletionItemKind.Class,\n                            CompletionItemKind.Interface,\n                            CompletionItemKind.Module,\n                            CompletionItemKind.Property,\n                            CompletionItemKind.Unit,\n                            CompletionItemKind.Value,\n                            CompletionItemKind.Enum,\n                            CompletionItemKind.Keyword,\n                            CompletionItemKind.Snippet,\n                            CompletionItemKind.Color,\n                            CompletionItemKind.File,\n                            CompletionItemKind.Reference\n                        ]\n                    }\n                },\n                \"signatureHelp\": {\n                    \"signatureInformation\": {\n                        \"documentationFormat\": [\"markdown\", \"plaintext\"],\n                        \"parameterInformation\": {\n                            \"labelOffsetSupport\": True\n                        }\n                    }\n                },\n                \"references\": {},\n                \"documentHighlight\": {},\n                \"documentSymbol\": {\n                    \"symbolKind\": {\n                        \"valueSet\": [\n                            SymbolKind.File,\n                            SymbolKind.Module,\n                            SymbolKind.Namespace,\n                            SymbolKind.Package,\n                            SymbolKind.Class,\n                            SymbolKind.Method,\n                            SymbolKind.Property,\n                            SymbolKind.Field,\n                            SymbolKind.Constructor,\n                            SymbolKind.Enum,\n                            SymbolKind.Interface,\n                            SymbolKind.Function,\n                            SymbolKind.Variable,\n                            SymbolKind.Constant,\n                            SymbolKind.String,\n                            SymbolKind.Number,\n                            SymbolKind.Boolean,\n                            SymbolKind.Array,\n                            SymbolKind.Object,\n                            SymbolKind.Key,\n                            SymbolKind.Null,\n                            SymbolKind.EnumMember,\n                            SymbolKind.Struct,\n                            SymbolKind.Event,\n                            SymbolKind.Operator,\n                            SymbolKind.TypeParameter\n                        ]\n                    }\n                },\n                \"formatting\": {},\n                \"rangeFormatting\": {},\n                \"definition\": {},\n                \"codeAction\": {\n                    \"codeActionLiteralSupport\": {\n                        \"codeActionKind\": {\n                            \"valueSet\": []\n                        }\n                    }\n                },\n                \"rename\": {}\n            },\n            \"workspace\": {\n                \"applyEdit\": True,\n                \"didChangeConfiguration\": {},\n                \"executeCommand\": {},\n            }\n        }\n    }\n    if config.init_options:\n        initializeParams['initializationOptions'] = config.init_options\n\n    return initializeParams\n\n\nclass Session(object):\n    def __init__(self, config: ClientConfig, project_path, client: Client,\n                 on_created=None, on_ended: 'Optional[Callable[[str], None]]' = None) -> None:\n        self.config = config\n        self.project_path = project_path\n        self.state = ClientStates.STARTING\n        self._on_created = on_created\n        self._on_ended = on_ended\n        self.capabilities = dict()  # type: Dict[str, Any]\n        self.client = client\n        self.initialize()\n\n    def has_capability(self, capability):\n        return capability in self.capabilities and self.capabilities[capability] is not False\n\n    def get_capability(self, capability):\n        return self.capabilities.get(capability)\n\n    def initialize(self):\n        params = get_initialize_params(self.project_path, self.config)\n        self.client.send_request(\n            Request.initialize(params),\n            lambda result: self._handle_initialize_result(result))\n\n    def _handle_initialize_result(self, result):\n        self.state = ClientStates.READY\n        self.capabilities = result.get('capabilities', dict())\n        if self._on_created:\n            self._on_created(self)\n\n    def end(self):\n        self.state = ClientStates.STOPPING\n        self.client.send_request(\n            Request.shutdown(),\n            lambda result: self._handle_shutdown_result(),\n            lambda: self._handle_shutdown_result())\n\n    def _handle_shutdown_result(self):\n        self.client.exit()\n        self.client = None\n        self.capabilities = dict()\n        if self._on_ended:\n            self._on_ended(self.config.name)\n", "path": "plugin/core/sessions.py"}]}