Skip to content

Commit 13be370

Browse files
committed
fixed errors highlighted one line below, fixed .pysa files not being tracked by the server
1 parent 817ba2c commit 13be370

File tree

4 files changed

+59
-5
lines changed

4 files changed

+59
-5
lines changed

client/commands/v2/persistent.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,10 +187,14 @@ async def try_initialize(
187187
async def _read_lsp_request(
188188
input_channel: connection.TextReader, output_channel: connection.TextWriter
189189
) -> AsyncIterator[json_rpc.Request]:
190+
LOG.info("** Inside the read lsp function ** ")
190191
try:
192+
LOG.info("** Inside the try and except ** ")
191193
message = await lsp.read_json_rpc(input_channel)
194+
LOG.info(f"** {message} **")
192195
yield message
193196
except json_rpc.JSONRPCException as json_rpc_error:
197+
LOG.info("** Inside the except ** ")
194198
await lsp.write_json_rpc(
195199
output_channel,
196200
json_rpc.ErrorResponse(
@@ -510,9 +514,9 @@ def invalid_model_to_diagnostic(
510514
) -> lsp.Diagnostic:
511515
return lsp.Diagnostic(
512516
range=lsp.Range(
513-
start=lsp.Position(line=invalid_model.line, character=invalid_model.column),
517+
start=lsp.Position(line=invalid_model.line - 1, character=invalid_model.column),
514518
end=lsp.Position(
515-
line=invalid_model.stop_line, character=invalid_model.stop_column
519+
line=invalid_model.stop_line - 1, character=invalid_model.stop_column
516520
),
517521
),
518522
message=invalid_model.full_error_message,

client/commands/v2/pysa_server.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ async def wait_for_exit(self) -> int:
101101
async def process_open_request(
102102
self, parameters: lsp.DidOpenTextDocumentParameters
103103
) -> None:
104-
print("A document was just opened!")
104+
LOG.info("** Inside process_open_request() **")
105105
document_path = parameters.text_document.document_uri().to_file_path()
106106
if document_path is None:
107107
raise json_rpc.InvalidRequestError(
@@ -111,7 +111,7 @@ async def process_open_request(
111111
async def process_close_request(
112112
self, parameters: lsp.DidCloseTextDocumentParameters
113113
) -> None:
114-
print("A document was just closed!")
114+
LOG.info("** Inside process_close_request() **")
115115
document_path = parameters.text_document.document_uri().to_file_path()
116116
if document_path is None:
117117
raise json_rpc.InvalidRequestError(
@@ -126,7 +126,7 @@ async def process_close_request(
126126
async def process_did_save_request(
127127
self, parameters: lsp.DidSaveTextDocumentParameters
128128
) -> None:
129-
print("A document was just saved!")
129+
LOG.info("** Inside process_did_save_request() **")
130130
document_path = parameters.text_document.document_uri().to_file_path()
131131
if document_path is None:
132132
raise json_rpc.InvalidRequestError(
@@ -148,6 +148,7 @@ async def run(self) -> int:
148148
)
149149
return await self.wait_for_exit()
150150
elif request.method == "textDocument/didOpen":
151+
LOG.info("** A Document just opened! **")
151152
parameters = request.parameters
152153
if parameters is None:
153154
raise json_rpc.InvalidRequestError(
@@ -159,6 +160,7 @@ async def run(self) -> int:
159160
)
160161
)
161162
elif request.method == "textDocument/didClose":
163+
LOG.info("** A Document just closed! **")
162164
parameters = request.parameters
163165
if parameters is None:
164166
raise json_rpc.InvalidRequestError(
@@ -170,6 +172,7 @@ async def run(self) -> int:
170172
)
171173
)
172174
elif request.method == "textDocument/didSave":
175+
LOG.info("** A Document just saved! **")
173176
parameters = request.parameters
174177
if parameters is None:
175178
raise json_rpc.InvalidRequestError(
@@ -182,6 +185,8 @@ async def run(self) -> int:
182185
)
183186
elif request.id is not None:
184187
raise lsp.RequestCancelledError("Request not supported yet")
188+
else:
189+
LOG.info("** Hmmm I guess nothing seems to be happening **")
185190

186191

187192
async def run_persistent(
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"source_directories": [
3+
"."
4+
],
5+
"taint_models_path": [
6+
"."
7+
],
8+
"search_path": [
9+
"../../../stubs/"
10+
],
11+
"exclude": [
12+
".*/integration_test/.*"
13+
],
14+
"use_command_v2": true
15+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Copyright (c) Facebook, Inc. and its affiliates.
2+
#
3+
# This source code is licensed under the MIT license found in the
4+
# LICENSE file in the root directory of this source tree.
5+
6+
import subprocess
7+
8+
from django.http import HttpRequest, HttpResponse
9+
10+
def operate_on_twos(request: HttpRequest) -> HttpResponse:
11+
operator = request.POST["operator"]
12+
13+
result = eval(f"2 {operator} 2") # noqa: P204
14+
15+
return result
16+
17+
18+
def operate_on_threes(request: HttpRequest) -> HttpResponse:
19+
operator = request.GET["operator"]
20+
21+
exec(f"result = 3 {operator} 3")
22+
23+
return result # noqa: F82 1
24+
25+
def operate_on_fours(request: HttpRequest) -> HttpResponse:
26+
operator = request.GET["operator"]
27+
28+
result = subprocess.getoutput(f"expr 4 {operator} 4")
29+
30+
return result

0 commit comments

Comments
 (0)