|
38 | 38 |
|
39 | 39 | (ert-deftest lsp--parser-read--multibyte ()
|
40 | 40 | (let* ((p (make-lsp--parser :workspace lsp--test-workspace))
|
41 |
| - (message-in "Content-Length: 3\r\n\r\n\xe2\x80\x99") |
| 41 | + (message-in "Content-Length: 3\r\n\r\n\xe2\x80\x99") |
42 | 42 | (messages (lsp--parser-read p message-in)))
|
43 | 43 | (should (equal messages '("’")))))
|
44 | 44 |
|
45 | 45 | (ert-deftest lsp--parser-read--multibyte-nospace ()
|
46 | 46 | (let* ((p (make-lsp--parser :workspace lsp--test-workspace))
|
47 |
| - (message-in "Content-Length:3\r\n\r\n\xe2\x80\x99") |
| 47 | + (message-in "Content-Length:3\r\n\r\n\xe2\x80\x99") |
48 | 48 | (messages (lsp--parser-read p message-in)))
|
49 | 49 | (should (equal messages '("’")))))
|
50 | 50 |
|
51 | 51 | (ert-deftest lsp--parser-read--multibyte-received ()
|
52 | 52 | (let* ((p (make-lsp--parser :workspace lsp--test-workspace))
|
53 |
| - (message-in "Content-Length: 1152\r\n\r\n{\"jsonrpc\":\"2.0\",\"method\":\"sts/highlight\",\"params\":{\"doc\":{\"version\":0,\"uri\":\"file:///home/kyoncho/Public/Desktop/hellow/hello-world/src/main/java/com/example/helloworld/HelloWorldController.java\"},\"codeLenses\":[{\"range\":{\"start\":{\"line\":9,\"character\":0},\"end\":{\"line\":9,\"character\":11}},\"command\":{\"title\":\"← SampleBean\",\"command\":\"sts.showHoverAtPosition\",\"arguments\":[{\"line\":9,\"character\":0}]},\"data\":\"← SampleBean\"},{\"range\":{\"start\":{\"line\":14,\"character\":4},\"end\":{\"line\":14,\"character\":14}},\"command\":{\"title\":\"← SampleBean\",\"command\":\"sts.showHoverAtPosition\",\"arguments\":[{\"line\":14,\"character\":4}]},\"data\":\"← SampleBean\"},{\"range\":{\"start\":{\"line\":17,\"character\":4},\"end\":{\"line\":17,\"character\":31}},\"command\":{\"title\":\"http://127.0.0.1:8080/hello-world\",\"command\":\"sts.open.url\",\"arguments\":[\"http://127.0.0.1:8080/hello-world\"]},\"data\":\"http://127.0.0.1:8080/hello-world\"},{\"range\":{\"start\":{\"line\":25,\"character\":4},\"end\":{\"line\":25,\"character\":32}},\"command\":{\"title\":\"http://127.0.0.1:8080/hello-world2\",\"command\":\"sts.open.url\",\"arguments\":[\"http://127.0.0.1:8080/hello-world2\"]},\"data\":\"http://127.0.0.1:8080/hello-world2\"}]}}") |
| 53 | + (message-in "Content-Length: 1152\r\n\r\n{\"jsonrpc\":\"2.0\",\"method\":\"sts/highlight\",\"params\":{\"doc\":{\"version\":0,\"uri\":\"file:///home/kyoncho/Public/Desktop/hellow/hello-world/src/main/java/com/example/helloworld/HelloWorldController.java\"},\"codeLenses\":[{\"range\":{\"start\":{\"line\":9,\"character\":0},\"end\":{\"line\":9,\"character\":11}},\"command\":{\"title\":\"← SampleBean\",\"command\":\"sts.showHoverAtPosition\",\"arguments\":[{\"line\":9,\"character\":0}]},\"data\":\"← SampleBean\"},{\"range\":{\"start\":{\"line\":14,\"character\":4},\"end\":{\"line\":14,\"character\":14}},\"command\":{\"title\":\"← SampleBean\",\"command\":\"sts.showHoverAtPosition\",\"arguments\":[{\"line\":14,\"character\":4}]},\"data\":\"← SampleBean\"},{\"range\":{\"start\":{\"line\":17,\"character\":4},\"end\":{\"line\":17,\"character\":31}},\"command\":{\"title\":\"http://127.0.0.1:8080/hello-world\",\"command\":\"sts.open.url\",\"arguments\":[\"http://127.0.0.1:8080/hello-world\"]},\"data\":\"http://127.0.0.1:8080/hello-world\"},{\"range\":{\"start\":{\"line\":25,\"character\":4},\"end\":{\"line\":25,\"character\":32}},\"command\":{\"title\":\"http://127.0.0.1:8080/hello-world2\",\"command\":\"sts.open.url\",\"arguments\":[\"http://127.0.0.1:8080/hello-world2\"]},\"data\":\"http://127.0.0.1:8080/hello-world2\"}]}}") |
54 | 54 | (messages (lsp--parser-read p message-in)))
|
55 | 55 | (should (equal messages '("{\"jsonrpc\":\"2.0\",\"method\":\"sts/highlight\",\"params\":{\"doc\":{\"version\":0,\"uri\":\"file:///home/kyoncho/Public/Desktop/hellow/hello-world/src/main/java/com/example/helloworld/HelloWorldController.java\"},\"codeLenses\":[{\"range\":{\"start\":{\"line\":9,\"character\":0},\"end\":{\"line\":9,\"character\":11}},\"command\":{\"title\":\"← SampleBean\",\"command\":\"sts.showHoverAtPosition\",\"arguments\":[{\"line\":9,\"character\":0}]},\"data\":\"← SampleBean\"},{\"range\":{\"start\":{\"line\":14,\"character\":4},\"end\":{\"line\":14,\"character\":14}},\"command\":{\"title\":\"← SampleBean\",\"command\":\"sts.showHoverAtPosition\",\"arguments\":[{\"line\":14,\"character\":4}]},\"data\":\"← SampleBean\"},{\"range\":{\"start\":{\"line\":17,\"character\":4},\"end\":{\"line\":17,\"character\":31}},\"command\":{\"title\":\"http://127.0.0.1:8080/hello-world\",\"command\":\"sts.open.url\",\"arguments\":[\"http://127.0.0.1:8080/hello-world\"]},\"data\":\"http://127.0.0.1:8080/hello-world\"},{\"range\":{\"start\":{\"line\":25,\"character\":4},\"end\":{\"line\":25,\"character\":32}},\"command\":{\"title\":\"http://127.0.0.1:8080/hello-world2\",\"command\":\"sts.open.url\",\"arguments\":[\"http://127.0.0.1:8080/hello-world2\"]},\"data\":\"http://127.0.0.1:8080/hello-world2\"}]}}")))))
|
56 | 56 |
|
57 | 57 | (ert-deftest lsp--parser-read--multiple-chunks ()
|
58 | 58 | (let* ((p (make-lsp--parser :workspace lsp--test-workspace)))
|
59 |
| - (should (equal (lsp--parser-read p "Content-Length: 14\r\n\r\n{") nil)) |
60 |
| - (should (equal (lsp--parser-read p "\"somedata\":1") nil)) |
61 |
| - (should (equal (lsp--parser-read p "}Content-Length: 14\r\n\r\n{") |
62 |
| - '("{\"somedata\":1}"))) |
63 |
| - (should (equal (lsp--parser-read p "\"somedata\":2}") |
64 |
| - '("{\"somedata\":2}"))))) |
| 59 | + (should (equal (lsp--parser-read p "Content-Length: 14\r\n\r\n{") nil)) |
| 60 | + (should (equal (lsp--parser-read p "\"somedata\":1") nil)) |
| 61 | + (should (equal (lsp--parser-read p "}Content-Length: 14\r\n\r\n{") |
| 62 | + '("{\"somedata\":1}"))) |
| 63 | + (should (equal (lsp--parser-read p "\"somedata\":2}") |
| 64 | + '("{\"somedata\":2}"))))) |
65 | 65 |
|
66 | 66 | (ert-deftest lsp--parser-read--multiple-multibyte-chunks ()
|
67 | 67 | (let* ((p (make-lsp--parser :workspace lsp--test-workspace)))
|
68 |
| - (should (equal (lsp--parser-read p "Content-Length: 18\r") nil)) |
69 |
| - (should (equal (lsp--parser-read p "\n\r\n{\"somedata\":\"\xe2\x80") nil)) |
70 |
| - (should (equal (lsp--parser-read p "\x99\"}Content-Length: 14\r\n\r\n{") |
71 |
| - '("{\"somedata\":\"’\"}"))) |
72 |
| - (should (equal (lsp--parser-read p "\"somedata\":2}") |
73 |
| - '("{\"somedata\":2}"))))) |
| 68 | + (should (equal (lsp--parser-read p "Content-Length: 18\r") nil)) |
| 69 | + (should (equal (lsp--parser-read p "\n\r\n{\"somedata\":\"\xe2\x80") nil)) |
| 70 | + (should (equal (lsp--parser-read p "\x99\"}Content-Length: 14\r\n\r\n{") |
| 71 | + '("{\"somedata\":\"’\"}"))) |
| 72 | + (should (equal (lsp--parser-read p "\"somedata\":2}") |
| 73 | + '("{\"somedata\":2}"))))) |
| 74 | + |
| 75 | +(ert-deftest lsp--non-related-content-on-stdout () |
| 76 | + (let* ((p (make-lsp--parser :workspace lsp--test-workspace))) |
| 77 | + (let* ((p (make-lsp--parser :workspace lsp--test-workspace))) |
| 78 | + (should (equal (lsp--parser-read p "ConentOnStdoutContent-Length: 14\r\n\r\n{\"somedata\":1}") |
| 79 | + '("{\"somedata\":1}")))))) |
74 | 80 |
|
75 | 81 | (ert-deftest lsp--parser-read--ignored-messages ()
|
76 | 82 | (lsp--on-notification
|
|
0 commit comments