use of org.eclipse.lsp4j.SignatureHelp in project eclipse.jdt.ls by eclipse.
the class SignatureHelpHandlerTest method testSignatureHelp_javadocOriginal.
// See https://github.com/redhat-developer/vscode-java/issues/1258
@Test
public void testSignatureHelp_javadocOriginal() throws JavaModelException {
IPackageFragment pack1 = sourceFolder.createPackageFragment("test1", false, null);
StringBuilder buf = new StringBuilder();
buf.append("package test1;\n");
buf.append("import java.util.LinkedList;\n");
buf.append("import org.sample.MyList;\n");
buf.append("public class E {\n\n");
buf.append(" void test() {\n");
buf.append(" MyList<String> l = new LinkedList<>();\n");
buf.append(" l.add(\n");
buf.append(" }\n");
buf.append("}\n");
ICompilationUnit cu = pack1.createCompilationUnit("E.java", buf.toString(), false, null);
int[] loc = findCompletionLocation(cu, "l.add(");
SignatureHelp help = getSignatureHelp(cu, loc[0], loc[1]);
assertNotNull(help);
assertEquals(2, help.getSignatures().size());
SignatureInformation signature = help.getSignatures().get(help.getActiveSignature());
assertTrue(signature.getLabel().equals("add(String e) : boolean"));
String documentation = signature.getDocumentation().getLeft();
assertEquals(" Test ", documentation);
}
use of org.eclipse.lsp4j.SignatureHelp in project eclipse.jdt.ls by eclipse.
the class SignatureHelpHandlerTest method testSignatureHelp_multipleMethods.
@Test
public void testSignatureHelp_multipleMethods() throws JavaModelException {
IPackageFragment pack1 = sourceFolder.createPackageFragment("test1", false, null);
StringBuilder buf = new StringBuilder();
buf.append("package test1;\n");
buf.append("public class E {\n");
buf.append(" public int foo(String s) { }\n");
buf.append(" public int foo(int s) { }\n");
buf.append(" public int foo(int s, String s) { }\n");
buf.append(" public int bar(String s) { this.foo(2, ) }\n");
buf.append("}\n");
ICompilationUnit cu = pack1.createCompilationUnit("E.java", buf.toString(), false, null);
SignatureHelp help = getSignatureHelp(cu, 5, 42);
assertNotNull(help);
assertEquals(3, help.getSignatures().size());
assertEquals((Integer) 1, help.getActiveParameter());
assertEquals(help.getSignatures().get(help.getActiveSignature()).getLabel(), "foo(int s, String s) : int");
}
use of org.eclipse.lsp4j.SignatureHelp in project eclipse.jdt.ls by eclipse.
the class SignatureHelpHandlerTest method testSignatureHelpConstructor.
// https://github.com/redhat-developer/vscode-java/issues/2097
@Test
public void testSignatureHelpConstructor() throws JavaModelException {
IJavaProject javaProject = JavaCore.create(project);
IType type = javaProject.findType("test1.SignatureHelp2097");
ICompilationUnit cu = type.getCompilationUnit();
SignatureHelp help = getSignatureHelp(cu, 9, 51);
assertNotNull(help);
assertEquals(1, help.getSignatures().size());
assertTrue(help.getSignatures().get(help.getActiveSignature()).getLabel().equals("SignatureHelp2097(String name)"));
}
use of org.eclipse.lsp4j.SignatureHelp in project eclipse.jdt.ls by eclipse.
the class SignatureHelpHandlerTest method testAssertEquals.
private void testAssertEquals(ICompilationUnit cu, int line, int character) {
SignatureHelp help = getSignatureHelp(cu, line, character);
assertNotNull(help);
assertEquals(12, help.getSignatures().size());
assertNotNull(help.getActiveParameter());
assertTrue(help.getSignatures().get(help.getActiveSignature()).getLabel().equals("assertEquals(long expected, long actual) : void"));
}
use of org.eclipse.lsp4j.SignatureHelp in project eclipse.jdt.ls by eclipse.
the class SignatureHelpHandlerTest method testSignatureHelp_varargs.
@Test
public void testSignatureHelp_varargs() throws JavaModelException {
IPackageFragment pack1 = sourceFolder.createPackageFragment("test1", false, null);
StringBuilder buf = new StringBuilder();
buf.append("package test1;\n");
buf.append("import java.util.Arrays;\n");
buf.append("public class E {\n");
buf.append(" public static void main(String[] args) {\n");
buf.append(" Arrays.asList(1,2,3);\n");
buf.append(" demo(\"1\", \"2\",\"3\" )\n");
buf.append(" }\n");
buf.append(" public static void demo (String s, String... s2) {\n");
buf.append(" }\n");
buf.append("}\n");
ICompilationUnit cu = pack1.createCompilationUnit("E.java", buf.toString(), false, null);
SignatureHelp help = getSignatureHelp(cu, 4, 21);
assertNotNull(help);
assertEquals(1, help.getSignatures().size());
assertTrue(help.getSignatures().get(help.getActiveSignature()).getLabel().startsWith("asList(T... "));
help = getSignatureHelp(cu, 5, 19);
assertNotNull(help);
assertEquals(1, help.getSignatures().size());
assertTrue(help.getSignatures().get(help.getActiveSignature()).getLabel().equals("demo(String s, String... s2) : void"));
}
Aggregations