1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
package org.javacs;
import static org.hamcrest.Matchers.*;
import static org.junit.Assert.*;
import java.io.IOException;
import org.javacs.lsp.*;
import org.junit.Test;
public class SignatureHelpTest {
@Test
public void signatureHelp() throws IOException {
var help = doHelp("/org/javacs/example/SignatureHelp.java", 7, 36);
assertThat(help.signatures, hasSize(2));
}
@Test
public void partlyFilledIn() throws IOException {
var help = doHelp("/org/javacs/example/SignatureHelp.java", 8, 39);
assertThat(help.signatures, hasSize(2));
assertThat(help.activeSignature, equalTo(1));
assertThat(help.activeParameter, equalTo(1));
}
@Test
public void constructor() throws IOException {
var help = doHelp("/org/javacs/example/SignatureHelp.java", 9, 27);
assertThat(help.signatures, hasSize(1));
assertThat(help.signatures.get(0).label, startsWith("SignatureHelp"));
}
@Test
public void platformConstructor() throws IOException {
var help = doHelp("/org/javacs/example/SignatureHelp.java", 10, 26);
assertThat(help.signatures, not(empty()));
assertThat(help.signatures.get(0).label, startsWith("ArrayList"));
// TODO
// assertThat(help.signatures.get(0).documentation, not(nullValue()));
}
private static final JavaLanguageServer server = LanguageServerFixture.getJavaLanguageServer();
private SignatureHelp doHelp(String file, int row, int column) throws IOException {
var document = new TextDocumentIdentifier();
document.uri = FindResource.uri(file);
var position = new Position();
position.line = row - 1;
position.character = column - 1;
var p = new TextDocumentPositionParams();
p.textDocument = document;
p.position = position;
return server.signatureHelp(p).get();
}
}
|