@@ -95,9 +95,6 @@ def foo(nnn)
9595 )
9696
9797 expect_request ( "workspace/codeLens/refresh" ) { |json | }
98- expect_notification ( "textDocument/publishDiagnostics" ) do |json |
99- assert_equal ( [ ] , json [ :diagnostics ] )
100- end
10198
10299 notify (
103100 "textDocument/didClose" ,
@@ -120,9 +117,6 @@ def foo(nnn)
120117 )
121118
122119 expect_request ( "workspace/codeLens/refresh" ) { |json | }
123- expect_notification ( "textDocument/publishDiagnostics" ) do |json |
124- assert_equal ( [ ] , json [ :diagnostics ] )
125- end
126120
127121 id = request (
128122 "textDocument/hover" ,
@@ -146,9 +140,6 @@ def foo(nnn)
146140 )
147141
148142 expect_request ( "workspace/codeLens/refresh" ) { |json | }
149- expect_notification ( "textDocument/publishDiagnostics" ) do |json |
150- assert_equal ( [ ] , json [ :diagnostics ] )
151- end
152143
153144 id = request (
154145 "textDocument/hover" ,
@@ -176,17 +167,75 @@ def foo(nnn)
176167
177168 expect_request ( "workspace/codeLens/refresh" ) { |json | }
178169 expect_notification ( "textDocument/publishDiagnostics" ) do |json |
179- assert_equal ( [
180- {
181- message : "wrong number of arguments (2 for 1)" ,
182- range : {
183- start : { line : 4 , character : 0 } ,
184- end : { line : 4 , character : 3 } ,
170+ assert_equal ( {
171+ uri : @folder + "basic.rb" ,
172+ diagnostics : [
173+ {
174+ message : "wrong number of arguments (2 for 1)" ,
175+ range : {
176+ start : { line : 4 , character : 0 } ,
177+ end : { line : 4 , character : 3 } ,
178+ } ,
179+ severity : 1 ,
180+ source : "TypeProf" ,
181+ }
182+ ] ,
183+ } , json )
184+ end
185+ end
186+
187+ def test_diagnostics2
188+ init ( "basic" )
189+
190+ notify (
191+ "textDocument/didOpen" ,
192+ textDocument : { uri : @folder + "basic1.rb" , version : 0 , text : <<-END } ,
193+ def check(nnn)
194+ nnn
195+ end
196+ END
197+ )
198+ expect_request ( "workspace/codeLens/refresh" ) { |json | }
199+
200+ notify (
201+ "textDocument/didOpen" ,
202+ textDocument : { uri : @folder + "basic2.rb" , version : 0 , text : <<-END } ,
203+ check(1, 2)
204+ END
205+ )
206+
207+ expect_request ( "workspace/codeLens/refresh" ) { |json | }
208+ expect_notification ( "textDocument/publishDiagnostics" ) do |json |
209+ assert_equal ( {
210+ uri : @folder + "basic2.rb" ,
211+ diagnostics : [
212+ {
213+ message : "wrong number of arguments (2 for 1)" ,
214+ range : {
215+ start : { line : 0 , character : 0 } ,
216+ end : { line : 0 , character : 5 } ,
217+ } ,
218+ severity : 1 ,
219+ source : "TypeProf" ,
185220 } ,
186- severity : 1 ,
187- source : "TypeProf" ,
221+ ] ,
222+ } , json )
223+ end
224+
225+ notify (
226+ "textDocument/didChange" ,
227+ textDocument : { uri : @folder + "basic1.rb" , version : 1 } ,
228+ contentChanges : [
229+ {
230+ range : { start : { line : 0 , character : 13 } , end : { line : 0 , character : 13 } } ,
231+ text : ", mmm" , # def check(nnn) => def check(nnn, mmm)
188232 }
189- ] , json [ :diagnostics ] )
233+ ]
234+ )
235+
236+ expect_request ( "workspace/codeLens/refresh" ) { |json | }
237+ expect_notification ( "textDocument/publishDiagnostics" ) do |json |
238+ assert_equal ( { uri : @folder + "basic2.rb" , diagnostics : [ ] } , json )
190239 end
191240 end
192241
@@ -215,7 +264,6 @@ def test(x)
215264 )
216265
217266 expect_request ( "workspace/codeLens/refresh" ) { |json | }
218- expect_notification ( "textDocument/publishDiagnostics" ) { |json | }
219267
220268 id = request (
221269 "textDocument/completion" ,
0 commit comments