use of org.eclipse.lsp4j.SignatureHelp in project eclipse.jdt.ls by eclipse.
the class SignatureHelpHandlerTest method testSignatureHelp_parameterTypes.
@Test
public void testSignatureHelp_parameterTypes() 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 static void main(String[] args) {\n");
buf.append(" new RuntimeException(new Exception(),)\n");
buf.append(" }\n");
buf.append("}\n");
ICompilationUnit cu = pack1.createCompilationUnit("E.java", buf.toString(), false, null);
SignatureHelp help = getSignatureHelp(cu, 3, 40);
assertNotNull(help);
assertEquals(4, help.getSignatures().size());
assertNull(help.getActiveParameter());
}
use of org.eclipse.lsp4j.SignatureHelp in project eclipse.jdt.ls by eclipse.
the class SignatureHelpHandlerTest method testStringLiteral.
private void testStringLiteral(ICompilationUnit cu, int line, int character) {
SignatureHelp help = getSignatureHelp(cu, line, character);
assertNotNull(help);
// see https://bugs.eclipse.org/bugs/show_bug.cgi?id=575149
// assertEquals(1, help.getSignatures().size());
assertNotNull(help.getActiveParameter());
assertTrue(help.getSignatures().get(help.getActiveSignature()).getLabel().equals("foo(String p, int x) : void"));
}
use of org.eclipse.lsp4j.SignatureHelp in project eclipse.jdt.ls by eclipse.
the class SignatureHelpHandlerTest method testSignatureHelp_parameterObject.
@Test
public void testSignatureHelp_parameterObject() 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 static void main(String[] args) {\n");
buf.append(" Object foo = new Object();\n");
buf.append(" System.err.println(foo);\n");
buf.append(" }\n");
buf.append("}\n");
ICompilationUnit cu = pack1.createCompilationUnit("E.java", buf.toString(), false, null);
SignatureHelp help = getSignatureHelp(cu, 4, 23);
assertNotNull(help);
assertEquals(10, help.getSignatures().size());
assertNotNull(help.getActiveParameter());
assertTrue(help.getSignatures().get(help.getActiveSignature()).getLabel().matches("println\\(Object \\w+\\) : void"));
}
use of org.eclipse.lsp4j.SignatureHelp in project eclipse.jdt.ls by eclipse.
the class SignatureHelpHandlerTest method testSignatureHelp_constructorParameters.
@Test
public void testSignatureHelp_constructorParameters() 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(\"t\", )\n");
buf.append(" }\n");
buf.append("}\n");
ICompilationUnit cu = pack1.createCompilationUnit("E.java", buf.toString(), false, null);
SignatureHelp help = getSignatureHelp(cu, 3, 31);
assertNotNull(help);
assertEquals(4, help.getSignatures().size());
assertTrue(help.getSignatures().get(help.getActiveSignature()).getLabel().matches("RuntimeException\\(String \\w+, Throwable \\w+\\)"));
}
use of org.eclipse.lsp4j.SignatureHelp in project eclipse.jdt.ls by eclipse.
the class SignatureHelpHandlerTest method testSignatureHelp_binary.
@Test
public void testSignatureHelp_binary() 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 bar(String s) { System.out.println( }\n");
buf.append("}\n");
ICompilationUnit cu = pack1.createCompilationUnit("E.java", buf.toString(), false, null);
SignatureHelp help = getSignatureHelp(cu, 2, 50);
assertNotNull(help);
assertTrue(help.getSignatures().size() >= 10);
assertTrue(help.getSignatures().get(help.getActiveSignature()).getLabel().equals("println() : void"));
SignatureHelp help2 = getSignatureHelp(cu, 2, 49);
assertEquals(help.getSignatures().size(), help2.getSignatures().size());
assertEquals(help.getActiveSignature(), help2.getActiveSignature());
}
Aggregations