Skip to content

Commit 2d666f8

Browse files
committed
prelim changes to clear out errors in all previous files
1 parent 768935e commit 2d666f8

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

client/commands/v2/pysa_server.py

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ def __init__(
5858
pyre_arguments: start.Arguments,
5959
binary_location: str,
6060
server_identifier: str,
61+
file_tracker: dict,
6162
) -> None:
6263
self.input_channel = input_channel
6364
self.output_channel = output_channel
@@ -68,6 +69,7 @@ def __init__(
6869
self.pyre_connection = api_connection.PyreConnection(
6970
Path(self.pyre_arguments.global_root)
7071
)
72+
self.file_tracker = file_tracker
7173

7274
def invalid_model_to_diagnostic(
7375
self,
@@ -103,9 +105,12 @@ def invalid_models_to_diagnostics(
103105
result[Path(model.path)].append(self.invalid_model_to_diagnostic(model))
104106
return result
105107

106-
async def update_errors(self, document_path: Path) -> None:
107-
# Publishing empty diagnostics to clear errors in VSCode
108-
await _publish_diagnostics(self.output_channel, document_path, [])
108+
async def update_errors(self) -> None:
109+
# Publishing empty diagnostics to clear errors in VSCode and reset self.file_tracker
110+
for document_path in self.file_tracker.keys():
111+
await _publish_diagnostics(self.output_channel, Path(document_path), [])
112+
self.file_tracker = {}
113+
# await self.log_and_show_message_to_client(f"All files cleared: {self.file_tracker}")
109114

110115
try:
111116
model_errors = query.get_invalid_taint_models(self.pyre_connection)
@@ -164,16 +169,22 @@ async def process_open_request(
164169
self, parameters: lsp.DidOpenTextDocumentParameters
165170
) -> None:
166171
document_path = parameters.text_document.document_uri().to_file_path()
172+
self.file_tracker[str(document_path)] = True
173+
# await self.log_and_show_message_to_client(f"Tracking Files: {self.file_tracker}")
174+
167175
if document_path is None:
168176
raise json_rpc.InvalidRequestError(
169177
f"Document URI is not a file: {parameters.text_document.uri}"
170178
)
171-
await self.update_errors(document_path)
179+
await self.update_errors()
172180

173181
async def process_close_request(
174182
self, parameters: lsp.DidCloseTextDocumentParameters
175183
) -> None:
176184
document_path = parameters.text_document.document_uri().to_file_path()
185+
# self.file_tracker.pop(str(document_path))
186+
# await self.log_and_show_message_to_client(f"Closed a file. Tracking: {self.file_tracker}")
187+
177188
if document_path is None:
178189
raise json_rpc.InvalidRequestError(
179190
f"Document URI is not a file: {parameters.text_document.uri}"
@@ -192,7 +203,7 @@ async def process_did_save_request(
192203
raise json_rpc.InvalidRequestError(
193204
f"Document URI is not a file: {parameters.text_document.uri}"
194205
)
195-
await self.update_errors(document_path)
206+
await self.update_errors()
196207

197208
async def run(self) -> int:
198209
while True:
@@ -279,6 +290,7 @@ async def run_persistent(
279290
binary_location=binary_location,
280291
server_identifier=server_identifier,
281292
pyre_arguments=pysa_arguments,
293+
file_tracker={},
282294
)
283295
return await server.run()
284296
elif isinstance(initialize_result, InitializationFailure):

0 commit comments

Comments
 (0)