Skip to content

Commit

Permalink
misc fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
m0mosenpai committed Jul 20, 2021
1 parent 0bb5f98 commit 52f1b40
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions client/commands/v2/pysa_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import asyncio
import logging
from pathlib import Path
from collections import defaultdict
from typing import List, Sequence, Dict

from ... import (
Expand Down Expand Up @@ -64,6 +65,9 @@ def __init__(
self.pyre_arguments = pyre_arguments
self.binary_location = binary_location
self.server_identifier = server_identifier
self.pyre_connection = api_connection.PyreConnection(
Path(self.pyre_arguments.global_root)
)

def invalid_model_to_diagnostic(
self,
Expand All @@ -89,26 +93,22 @@ def invalid_models_to_diagnostics(
self,
invalid_models: Sequence[query.InvalidModel],
) -> Dict[Path, List[lsp.Diagnostic]]:
result: Dict[Path, List[lsp.Diagnostic]] = {}
result: Dict[Path, List[lsp.Diagnostic]] = defaultdict(list)
for model in invalid_models:
if model.path is None:
self.log_and_show_message_to_client(
f"{model.full_error_message}", lsp.MessageType.WARNING
f"{model.full_error_message}", lsp.MessageType.ERROR
)
else:
result.setdefault(Path(model.path), []).append(
self.invalid_model_to_diagnostic(model)
)
result[Path(model.path)].append(self.invalid_model_to_diagnostic(model))
return result

async def update_errors(self, document_path: Path) -> None:
# Publishing empty diagnostics to clear errors in VSCode
await _publish_diagnostics(self.output_channel, document_path, [])
pyre_connection = api_connection.PyreConnection(
Path(self.pyre_arguments.global_root)
)

try:
model_errors = query.get_invalid_taint_models(pyre_connection)
model_errors = query.get_invalid_taint_models(self.pyre_connection)
diagnostics = self.invalid_models_to_diagnostics(model_errors)
await self.show_model_errors_to_client(diagnostics)
except PyreQueryError as e:
Expand Down

0 comments on commit 52f1b40

Please sign in to comment.