Search in sources :

Example 1 with ICompletionProposalExtension5

use of org.eclipse.che.jface.text.contentassist.ICompletionProposalExtension5 in project che by eclipse.

the class CompletionJavadocTest method testInheredJavadoc.

@Test
public void testInheredJavadoc() throws Exception {
    IPackageFragment pack1 = fSourceFolder.createPackageFragment("test1", false, null);
    StringBuffer buf = new StringBuffer();
    buf.append("package test1;\n");
    buf.append("public class E {\n");
    buf.append("    /**\n");
    buf.append("     * Test JavaDoc.\n");
    buf.append("     */\n");
    buf.append("    public void foo(int i) {\n");
    buf.append("    }\n");
    buf.append("}\n");
    pack1.createCompilationUnit("E.java", buf.toString(), false, null);
    StringBuffer buf2 = new StringBuffer();
    buf2.append("package test1;\n");
    buf2.append("public class B extends E {\n");
    buf2.append("    @Override\n");
    buf2.append("    public void foo(int i) {\n");
    buf2.append("        foo(10);\n");
    buf2.append("    }\n");
    buf2.append("}\n");
    ICompilationUnit cu2 = pack1.createCompilationUnit("B.java", buf2.toString(), false, null);
    List<ICompletionProposal> proposals = computeProposals(cu2, buf2.indexOf("  foo") + "  foo".length());
    Assertions.assertThat(proposals).hasSize(1);
    ICompletionProposal proposal = proposals.get(0);
    String result;
    if (proposal instanceof ICompletionProposalExtension5) {
        result = ((ICompletionProposalExtension5) proposal).getAdditionalProposalInfo(null).toString();
    } else {
        result = proposal.getAdditionalProposalInfo();
    }
    Assertions.assertThat(result).contains("Test JavaDoc.");
}
Also used : ICompilationUnit(org.eclipse.jdt.core.ICompilationUnit) IPackageFragment(org.eclipse.jdt.core.IPackageFragment) ICompletionProposal(org.eclipse.che.jface.text.contentassist.ICompletionProposal) ICompletionProposalExtension5(org.eclipse.che.jface.text.contentassist.ICompletionProposalExtension5) QuickFixTest(org.eclipse.che.plugin.java.server.jdt.quickfix.QuickFixTest) Test(org.junit.Test)

Example 2 with ICompletionProposalExtension5

use of org.eclipse.che.jface.text.contentassist.ICompletionProposalExtension5 in project che by eclipse.

the class CompletionJavadocTest method testJavadoc.

@Test
public void testJavadoc() throws Exception {
    IPackageFragment pack1 = fSourceFolder.createPackageFragment("test1", false, null);
    StringBuffer buf = new StringBuffer();
    buf.append("package test1;\n");
    buf.append("public class E {\n");
    buf.append("    /**\n");
    buf.append("     * Test JavaDoc.\n");
    buf.append("     */\n");
    buf.append("    public void foo(int i) {\n");
    buf.append("        foo(10);");
    buf.append("    }\n");
    buf.append("}\n");
    ICompilationUnit cu = pack1.createCompilationUnit("E.java", buf.toString(), false, null);
    List<ICompletionProposal> proposals = computeProposals(cu, buf.indexOf("    foo") + "    foo".length());
    Assertions.assertThat(proposals).hasSize(1);
    ICompletionProposal proposal = proposals.get(0);
    String result;
    if (proposal instanceof ICompletionProposalExtension5) {
        result = ((ICompletionProposalExtension5) proposal).getAdditionalProposalInfo(null).toString();
    } else {
        result = proposal.getAdditionalProposalInfo();
    }
    Assertions.assertThat(result).contains("Test JavaDoc.");
}
Also used : ICompilationUnit(org.eclipse.jdt.core.ICompilationUnit) IPackageFragment(org.eclipse.jdt.core.IPackageFragment) ICompletionProposal(org.eclipse.che.jface.text.contentassist.ICompletionProposal) ICompletionProposalExtension5(org.eclipse.che.jface.text.contentassist.ICompletionProposalExtension5) QuickFixTest(org.eclipse.che.plugin.java.server.jdt.quickfix.QuickFixTest) Test(org.junit.Test)

Aggregations

ICompletionProposal (org.eclipse.che.jface.text.contentassist.ICompletionProposal)2 ICompletionProposalExtension5 (org.eclipse.che.jface.text.contentassist.ICompletionProposalExtension5)2 QuickFixTest (org.eclipse.che.plugin.java.server.jdt.quickfix.QuickFixTest)2 ICompilationUnit (org.eclipse.jdt.core.ICompilationUnit)2 IPackageFragment (org.eclipse.jdt.core.IPackageFragment)2 Test (org.junit.Test)2