Skip to content

Commit 81b00ae

Browse files
committed
removed PysaServerHandler, refactored things into PysaServer class
1 parent f86f233 commit 81b00ae

File tree

2 files changed

+4
-16
lines changed

2 files changed

+4
-16
lines changed

client/commands/v2/persistent.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -507,8 +507,6 @@ def type_errors_to_diagnostics(
507507
return result
508508

509509

510-
# ** NEW **
511-
# Convert InvalidModel to Diagnostic object
512510
def invalid_model_to_diagnostic(
513511
invalid_model: query.InvalidModel,
514512
) -> lsp.Diagnostic:
@@ -528,15 +526,14 @@ def invalid_model_to_diagnostic(
528526
)
529527

530528

531-
# ** NEW **
532-
# Convert list of InvalidModels to list of Diagnostics
533529
def invalid_models_to_diagnostics(
534530
invalid_models: Sequence[query.InvalidModel],
535531
) -> Dict[Path, List[lsp.Diagnostic]]:
536532
result: Dict[Path, List[lsp.Diagnostic]] = {}
537533
for model in invalid_models:
538-
result.setdefault(Path(model.path), []).append(invalid_model_to_diagnostic(model))
539-
# LOG.info(f"invalid_models_to_diagnostics(): result = {result}")
534+
result.setdefault(Path(model.path), []).append(
535+
invalid_model_to_diagnostic(model)
536+
)
540537
return result
541538

542539

client/commands/v2/pysa_server.py

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,6 @@
3535

3636
LOG: logging.Logger = logging.getLogger(__name__)
3737

38-
PYSA_HANDLER_OBJ: None
39-
4038

4139
class PysaServer:
4240
# I/O Channels
@@ -103,7 +101,6 @@ async def wait_for_exit(self) -> int:
103101
async def process_open_request(
104102
self, parameters: lsp.DidOpenTextDocumentParameters
105103
) -> None:
106-
# LOG.info("** Inside process_open_request() **")
107104
document_path = parameters.text_document.document_uri().to_file_path()
108105
if document_path is None:
109106
raise json_rpc.InvalidRequestError(
@@ -113,7 +110,6 @@ async def process_open_request(
113110
async def process_close_request(
114111
self, parameters: lsp.DidCloseTextDocumentParameters
115112
) -> None:
116-
# LOG.info("** Inside process_close_request() **")
117113
document_path = parameters.text_document.document_uri().to_file_path()
118114
if document_path is None:
119115
raise json_rpc.InvalidRequestError(
@@ -128,7 +124,6 @@ async def process_close_request(
128124
async def process_did_save_request(
129125
self, parameters: lsp.DidSaveTextDocumentParameters
130126
) -> None:
131-
# LOG.info("** Inside process_did_save_request() **")
132127
document_path = parameters.text_document.document_uri().to_file_path()
133128
if document_path is None:
134129
raise json_rpc.InvalidRequestError(
@@ -150,7 +145,6 @@ async def run(self) -> int:
150145
)
151146
return await self.wait_for_exit()
152147
elif request.method == "textDocument/didOpen":
153-
# LOG.info("** A Document just opened! **")
154148
parameters = request.parameters
155149
if parameters is None:
156150
raise json_rpc.InvalidRequestError(
@@ -162,7 +156,6 @@ async def run(self) -> int:
162156
)
163157
)
164158
elif request.method == "textDocument/didClose":
165-
# LOG.info("** A Document just closed! **")
166159
parameters = request.parameters
167160
if parameters is None:
168161
raise json_rpc.InvalidRequestError(
@@ -174,7 +167,6 @@ async def run(self) -> int:
174167
)
175168
)
176169
elif request.method == "textDocument/didSave":
177-
# LOG.info("** A Document just saved! **")
178170
parameters = request.parameters
179171
if parameters is None:
180172
raise json_rpc.InvalidRequestError(
@@ -192,7 +184,6 @@ async def run(self) -> int:
192184
async def run_persistent(
193185
binary_location: str, server_identifier: str, pysa_arguments: start.Arguments
194186
) -> int:
195-
global PYSA_HANDLER_OBJ
196187
stdin, stdout = await connection.create_async_stdin_stdout()
197188
while True:
198189
initialize_result = await try_initialize(stdin, stdout)
@@ -225,7 +216,7 @@ async def run_persistent(
225216
server_identifier=server_identifier,
226217
pyre_arguments=pysa_arguments,
227218
)
228-
return await server.run()
219+
return await server._run()
229220
elif isinstance(initialize_result, InitializationFailure):
230221
exception = initialize_result.exception
231222
message = (

0 commit comments

Comments
 (0)