Skip to content

Commit dcd5ebd

Browse files
gselzerclaude
andcommitted
Take completions as one answer in tests
code-lsp's merged completions now come once all servers have answered. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 481b599 commit dcd5ebd

1 file changed

Lines changed: 11 additions & 29 deletions

File tree

‎src/test/java/org/scijava/plugins/scripting/appose/python/ApposePythonCompletionIntegrationTest.java‎

Lines changed: 11 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@
5656
import org.scijava.code.lsp.LanguageServerService;
5757
import org.scijava.code.lsp.Positions;
5858
import org.scijava.code.lsp.ScriptSession;
59-
import org.scijava.code.lsp.UpdatingCompletionList;
6059
import org.scijava.module.ModuleService;
6160
import org.scijava.script.ScriptInfo;
6261
import org.scijava.script.ScriptLanguage;
@@ -257,7 +256,7 @@ private static List<CompletionItem> completeUntil(final String code,
257256
{
258257
final long deadline = System.currentTimeMillis() + BUILD_TIMEOUT;
259258
while (System.currentTimeMillis() < deadline) {
260-
final List<CompletionItem> completions = complete(code, path, true);
259+
final List<CompletionItem> completions = complete(code, path);
261260
if (completions.stream().anyMatch(c -> c.getLabel().equals(expected))) {
262261
return completions;
263262
}
@@ -267,50 +266,33 @@ private static List<CompletionItem> completeUntil(final String code,
267266
return null;
268267
}
269268

270-
/**
271-
* Completes at the end of the code.
272-
*
273-
* @param settled Whether to wait for the slower servers' completions.
274-
*/
269+
/** Completes at the end of the code: all servers' completions. */
275270
private static List<CompletionItem> complete(final String code,
276-
final String path, final boolean settled) throws Exception
271+
final String path) throws Exception
277272
{
278-
CompletionList list = session(path).completion(code, code.length())
279-
.get(1, TimeUnit.MINUTES);
280-
if (settled && list instanceof UpdatingCompletionList) {
281-
final CompletionList better = ((UpdatingCompletionList) list).update()
282-
.get(1, TimeUnit.MINUTES);
283-
if (better != null) list = better;
284-
}
285-
return list.getItems();
273+
return session(path).completion(code, code.length()).get(1,
274+
TimeUnit.MINUTES).getItems();
286275
}
287276

288277
/**
289278
* Prints how long completions take, once warm: for another keystroke of a
290-
* word the server has answered (cached); and for a new word, how long the
291-
* editor waits (barely: it answers at once), and how long until the
292-
* server's completions arrive as an update.
279+
* word the server has answered (cached); and for a new word.
293280
*/
294281
private static void report(final String code, final String path,
295282
final String expected, final String more) throws Exception
296283
{
297284
completeUntil(code, path, expected);
298285
long t0 = System.nanoTime();
299-
final int n = complete(code + more, path, true).size();
286+
final int n = complete(code + more, path).size();
300287
final long cached = System.nanoTime() - t0;
301288
final String other = code.substring(0, code.lastIndexOf('.') + 1) + "s";
302289
final ScriptSession session = session(path);
303290
t0 = System.nanoTime();
304-
final CompletionList first = session.completion(other, other.length())
305-
.get(1, TimeUnit.MINUTES);
306-
final long wait = System.nanoTime() - t0;
307-
final CompletionList update = first instanceof UpdatingCompletionList
308-
? ((UpdatingCompletionList) first).update().get(1, TimeUnit.MINUTES)
309-
: first;
291+
final CompletionList all = session.completion(other, other.length()).get(
292+
1, TimeUnit.MINUTES);
310293
final long arrived = System.nanoTime() - t0;
311294
System.out.println("[completion timing] same word (cached): " + cached /
312-
1000000 + " ms, " + n + " completions; new word: editor waits " + wait /
313-
1000000 + " ms, all servers' " + update.getItems().size() +
314-
" completions after " + arrived / 1000000 + " ms");
295+
1000000 + " ms, " + n + " completions; new word: " + all.getItems()
296+
.size() + " completions after " + arrived / 1000000 + " ms");
315297
}
316298
}

0 commit comments

Comments
 (0)