1717def make_mock_server ():
1818 """Create a mock SlitherServer for testing."""
1919 server = MagicMock ()
20- server .publish_diagnostics = MagicMock ()
20+ server .text_document_publish_diagnostics = MagicMock ()
2121 return server
2222
2323
@@ -85,10 +85,11 @@ def test_publishes_diagnostics_for_detector_results(self):
8585 diagnostics .update ([analysis ], settings )
8686
8787 # Should publish diagnostics
88- server .publish_diagnostics .assert_called ()
89- call_args = server .publish_diagnostics .call_args
90- assert "test.sol" in call_args [0 ][0 ] # URI contains filename
91- assert len (call_args [1 ]["diagnostics" ]) == 1
88+ server .text_document_publish_diagnostics .assert_called ()
89+ call_args = server .text_document_publish_diagnostics .call_args
90+ params = call_args [0 ][0 ] # PublishDiagnosticsParams object
91+ assert "test.sol" in params .uri # URI contains filename
92+ assert len (params .diagnostics ) == 1
9293
9394 def test_filters_hidden_checks (self ):
9495 server = make_mock_server ()
@@ -110,10 +111,8 @@ def test_filters_hidden_checks(self):
110111 diagnostics .update ([analysis ], settings )
111112
112113 # Should not publish any diagnostics (check is hidden)
113- # publish_diagnostics is called but with empty list
114- if server .publish_diagnostics .called :
115- call_args = server .publish_diagnostics .call_args
116- assert len (call_args [1 ]["diagnostics" ]) == 0
114+ # text_document_publish_diagnostics is not called when there are no diagnostics
115+ assert not server .text_document_publish_diagnostics .called
117116
118117 def test_disabled_detectors_produces_no_diagnostics (self ):
119118 server = make_mock_server ()
@@ -132,14 +131,7 @@ def test_disabled_detectors_produces_no_diagnostics(self):
132131 diagnostics .update ([analysis ], settings )
133132
134133 # Should not produce any diagnostics when disabled
135- if server .publish_diagnostics .called :
136- call_args = server .publish_diagnostics .call_args
137- # Either not called or called with empty diagnostics
138- assert (
139- not call_args
140- or "diagnostics" not in call_args [1 ]
141- or len (call_args [1 ].get ("diagnostics" , [])) == 0
142- )
134+ assert not server .text_document_publish_diagnostics .called
143135
144136 def test_skips_results_without_source_mapping (self ):
145137 server = make_mock_server ()
@@ -201,8 +193,9 @@ def test_diagnostic_message_format(self):
201193
202194 diagnostics .update ([analysis ], settings )
203195
204- call_args = server .publish_diagnostics .call_args
205- diag = call_args [1 ]["diagnostics" ][0 ]
196+ call_args = server .text_document_publish_diagnostics .call_args
197+ params = call_args [0 ][0 ] # PublishDiagnosticsParams object
198+ diag = params .diagnostics [0 ]
206199 assert "[MEDIUM]" in diag .message
207200 assert "Low-level call" in diag .message
208201 assert diag .code == "unchecked-lowlevel"
@@ -226,8 +219,9 @@ def test_diagnostic_range_calculation(self):
226219
227220 diagnostics .update ([analysis ], settings )
228221
229- call_args = server .publish_diagnostics .call_args
230- diag = call_args [1 ]["diagnostics" ][0 ]
222+ call_args = server .text_document_publish_diagnostics .call_args
223+ params = call_args [0 ][0 ] # PublishDiagnosticsParams object
224+ diag = params .diagnostics [0 ]
231225
232226 # Range should be 0-indexed
233227 assert diag .range .start .line == 9 # Line 10 -> 9
@@ -259,7 +253,7 @@ def test_multiple_files_get_separate_diagnostics(self):
259253 diagnostics .update ([analysis ], settings )
260254
261255 # Should be called twice (once per file)
262- assert server .publish_diagnostics .call_count == 2
256+ assert server .text_document_publish_diagnostics .call_count == 2
263257
264258 def test_clears_old_diagnostics_on_update (self ):
265259 server = make_mock_server ()
@@ -277,10 +271,10 @@ def test_clears_old_diagnostics_on_update(self):
277271 diagnostics_obj .update ([make_analysis_result ([result ])], settings )
278272
279273 # Reset mock
280- server .publish_diagnostics .reset_mock ()
274+ server .text_document_publish_diagnostics .reset_mock ()
281275
282276 # Second update with no results
283277 diagnostics_obj .update ([make_analysis_result ([])], settings )
284278
285279 # Should clear diagnostics for the file that no longer has issues
286- server .publish_diagnostics .assert_called ()
280+ server .text_document_publish_diagnostics .assert_called ()
0 commit comments