Skip to content

Commit

Permalink
hardcoded path value for testing publishing diagnostics
Browse files Browse the repository at this point in the history
  • Loading branch information
m0mosenpai committed May 4, 2021
1 parent 8f48337 commit d85d819
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions client/commands/v2/pysa_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,24 +106,26 @@ async def log_and_show_message_to_client(
def update_model_errors(self, model_errors: Sequence[query.InvalidModel]) -> None:
LOG.info(
(
"Refereshing errors received from Pysa server. "
"Refreshing errors received from Pysa server. "
+ f"Total number of errors is {len(model_errors)}."
)
)
self.server_state.diagnostics = invalid_models_to_diagnostics(model_errors)
LOG.info(f"update_model_errors(): server_state.diagnostics = {self.server_state.diagnostics}")

# ** NEW **
# Show invalid model errors from Pysa to the client
async def show_model_errors_to_client(self) -> None:
LOG.info(f"server_state.opened_documents = {self.server_state.opened_documents}")
for path in self.server_state.opened_documents:
await _publish_diagnostics(self.client_output_channel, path, [])
diagnostics = self.server_state.diagnostics.get(path, None)
LOG.info(f"show_model_errors_to_client(): diagnostics = {diagnostics}")
if diagnostics is not None:
await _publish_diagnostics(
self.client_output_channel, path, diagnostics
)
# for path in self.server_state.opened_documents:
path = "/home/momo/Documents/Programs/pyre-check/documentation/pysa_tutorial/exercise2/sources_sinks.pysa"
await _publish_diagnostics(self.client_output_channel, path, [])
diagnostics = self.server_state.diagnostics.get(path, None)
LOG.info(f"show_model_errors_to_client(): diagnostics = {diagnostics}")
if diagnostics is not None:
await _publish_diagnostics(
self.client_output_channel, path, diagnostics
)

@connection.asynccontextmanager
async def _read_server_response(
Expand Down Expand Up @@ -370,6 +372,7 @@ async def _try_restart_pyre_server(self) -> None:
async def process_open_request(
self, parameters: lsp.DidOpenTextDocumentParameters
) -> None:
print("A document was just opened!")
document_path = parameters.text_document.document_uri().to_file_path()
if document_path is None:
raise json_rpc.InvalidRequestError(
Expand All @@ -392,6 +395,7 @@ async def process_open_request(
async def process_close_request(
self, parameters: lsp.DidCloseTextDocumentParameters
) -> None:
print("A document was just closed!")
document_path = parameters.text_document.document_uri().to_file_path()
if document_path is None:
raise json_rpc.InvalidRequestError(
Expand All @@ -410,6 +414,7 @@ async def process_close_request(
async def process_did_save_request(
self, parameters: lsp.DidSaveTextDocumentParameters
) -> None:
print("A document was just saved!")
document_path = parameters.text_document.document_uri().to_file_path()
if document_path is None:
raise json_rpc.InvalidRequestError(
Expand Down

0 comments on commit d85d819

Please sign in to comment.