use of org.eclipse.lsp4j.SignatureHelp in project eclipse.jdt.ls by eclipse.
the class SignatureHelpHandlerTest method testSignatureHelp_double.
// https://github.com/eclipse/eclipse.jdt.ls/issues/1980
@Test
public void testSignatureHelp_double() 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 E(String s) {\n");
buf.append(" this.unique(\n");
buf.append(" }\n");
buf.append(" public void unique(double d) {}\n");
buf.append("}\n");
ICompilationUnit cu = pack1.createCompilationUnit("E.java", buf.toString(), false, null);
SignatureHelp help = getSignatureHelp(cu, 3, 20);
assertNotNull(help);
assertEquals(1, help.getSignatures().size());
assertEquals((Integer) 0, help.getActiveParameter());
assertEquals(help.getSignatures().get(help.getActiveSignature()).getLabel(), "unique(double d) : void");
}
use of org.eclipse.lsp4j.SignatureHelp in project eclipse.jdt.ls by eclipse.
the class SignatureHelpHandlerTest method testSignatureHelpMethod.
// https://github.com/redhat-developer/vscode-java/issues/2097
@Test
public void testSignatureHelpMethod() throws Exception {
IJavaProject javaProject = JavaCore.create(project);
IType type = javaProject.findType("test1.SignatureHelp2097");
IType resultType = javaProject.findType("test1.Result", new NullProgressMonitor());
assertNotNull(resultType);
ICompilationUnit cu = type.getCompilationUnit();
SignatureHelp help = getSignatureHelp(cu, 14, 42);
assertNotNull(help);
assertEquals(1, help.getSignatures().size());
assertTrue(help.getSignatures().get(help.getActiveSignature()).getLabel().equals("success(Boolean flag) : Boolean"));
}
use of org.eclipse.lsp4j.SignatureHelp in project eclipse.jdt.ls by eclipse.
the class SignatureHelpHandlerTest method testSignatureHelp_constructorParameters3.
@Test
public void testSignatureHelp_constructorParameters3() throws JavaModelException {
IPackageFragment pack1 = sourceFolder.createPackageFragment("test1", false, null);
StringBuilder buf = new StringBuilder();
buf.append("package test1;\n");
buf.append("import java.text.StringCharacterIterator;\n");
buf.append("public class E {\n");
buf.append(" public void bar() {\n");
buf.append(" new StringCharacterIterator(\"\", 0, , 2);\n");
buf.append(" }\n");
buf.append("}\n");
ICompilationUnit cu = pack1.createCompilationUnit("E.java", buf.toString(), false, null);
SignatureHelp help = getSignatureHelp(cu, 4, 39);
assertNotNull(help);
assertEquals(3, help.getSignatures().size());
// StringCharacterIterator(String arg0, int arg1, int arg2, int arg3)
assertTrue(help.getSignatures().get(help.getActiveSignature()).getLabel().matches("StringCharacterIterator\\(String \\w+, int \\w+, int \\w+, int \\w+\\)"));
}
use of org.eclipse.lsp4j.SignatureHelp in project eclipse.jdt.ls by eclipse.
the class SignatureHelpHandlerTest method testSignatureHelp_constructor.
@Test
public void testSignatureHelp_constructor() 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 void bar() {\n");
buf.append(" new RuntimeException()\n");
buf.append(" }\n");
buf.append("}\n");
ICompilationUnit cu = pack1.createCompilationUnit("E.java", buf.toString(), false, null);
SignatureHelp help = getSignatureHelp(cu, 3, 26);
assertNotNull(help);
assertEquals(4, help.getSignatures().size());
assertEquals(help.getSignatures().get(help.getActiveSignature()).getLabel(), "RuntimeException()");
}
use of org.eclipse.lsp4j.SignatureHelp in project eclipse.jdt.ls by eclipse.
the class SignatureHelpHandlerTest method testSignatureHelp_varargs2.
@Test
public void testSignatureHelp_varargs2() throws JavaModelException {
IJavaProject javaProject = JavaCore.create(project);
IType type = javaProject.findType("test1.Varargs");
ICompilationUnit cu = type.getCompilationUnit();
SignatureHelp help = getSignatureHelp(cu, 4, 16);
assertNotNull(help);
assertEquals(2, help.getSignatures().size());
assertTrue(help.getSignatures().get(help.getActiveSignature()).getLabel().equals("run(Class<?> clazz, String... args) : void"));
}
Aggregations