diff options
author | George Fraser <george@fivetran.com> | 2018-12-27 10:16:32 -0800 |
---|---|---|
committer | George Fraser <george@fivetran.com> | 2018-12-27 10:16:32 -0800 |
commit | b4a923adc396c0a2e69c99fbb5b9c41154b0f023 (patch) | |
tree | 41b0a6110fdb1a504f76abdb15f2fa5b53876d62 /src/test/java | |
parent | 78b75cc116f335c3a342d8069e34c0e500a77236 (diff) | |
download | java-language-server-b4a923adc396c0a2e69c99fbb5b9c41154b0f023.zip |
Resolve codelenses in tests
Diffstat (limited to 'src/test/java')
-rw-r--r-- | src/test/java/org/javacs/CodeLensTest.java | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/src/test/java/org/javacs/CodeLensTest.java b/src/test/java/org/javacs/CodeLensTest.java index ec7bd04..553e3e5 100644 --- a/src/test/java/org/javacs/CodeLensTest.java +++ b/src/test/java/org/javacs/CodeLensTest.java @@ -3,10 +3,10 @@ package org.javacs; import static org.hamcrest.Matchers.*; import static org.junit.Assert.*; +import com.google.gson.Gson; import java.util.ArrayList; import java.util.List; import java.util.Objects; -import java.util.Optional; import java.util.StringJoiner; import java.util.concurrent.ExecutionException; import org.eclipse.lsp4j.CodeLens; @@ -22,7 +22,19 @@ public class CodeLensTest { var uri = FindResource.uri(file); var params = new CodeLensParams(new TextDocumentIdentifier(uri.toString())); try { - return server.getTextDocumentService().codeLens(params).get(); + var lenses = server.getTextDocumentService().codeLens(params).get(); + var resolved = new ArrayList<CodeLens>(); + for (var lens : lenses) { + if (lens.getCommand() == null) { + var gson = new Gson(); + var data = lens.getData(); + var dataJson = gson.toJsonTree(data); + lens.setData(dataJson); + lens = server.getTextDocumentService().resolveCodeLens(lens).get(); + } + resolved.add(lens); + } + return resolved; } catch (InterruptedException | ExecutionException e) { throw new RuntimeException(e); } @@ -33,7 +45,6 @@ public class CodeLensTest { for (var lens : lenses) { var command = new StringJoiner(", "); for (var arg : lens.getCommand().getArguments()) { - if (arg instanceof Optional) arg = ((Optional) arg).orElse(null); command.add(Objects.toString(arg)); } commands.add(command.toString()); |