Example usage for org.eclipse.jdt.core JavaCore COMPILER_PB_UNUSED_TYPE_PARAMETER

List of usage examples for org.eclipse.jdt.core JavaCore COMPILER_PB_UNUSED_TYPE_PARAMETER

Introduction

In this page you can find the example usage for org.eclipse.jdt.core JavaCore COMPILER_PB_UNUSED_TYPE_PARAMETER.

Prototype

String COMPILER_PB_UNUSED_TYPE_PARAMETER

To view the source code for org.eclipse.jdt.core JavaCore COMPILER_PB_UNUSED_TYPE_PARAMETER.

Click Source Link

Document

Compiler option ID: Reporting Unused Type Parameter.

Usage

From source file:org.eclipse.che.jdt.quickfix.LocalCorrectionsQuickFixTest.java

License:Open Source License

@Test
public void testUnusedTypeParameter1() throws Exception {
    Hashtable hashtable = JavaCore.getOptions();
    hashtable.put(JavaCore.COMPILER_PB_UNUSED_TYPE_PARAMETER, JavaCore.ERROR);
    JavaCore.setOptions(hashtable);//  w  w  w. j  av a  2  s .  com

    IPackageFragment pack1 = fSourceFolder.createPackageFragment("test1", false, null);
    StringBuffer buf = new StringBuffer();
    buf.append("package test1;\n");
    buf.append("public interface E<T extends Exception> {\n");
    buf.append("    public void foo(Object str);\n");
    buf.append("}\n");
    ICompilationUnit cu = pack1.createCompilationUnit("E.java", buf.toString(), false, null);

    CompilationUnit astRoot = getASTRoot(cu);
    ArrayList proposals = collectCorrections(cu, astRoot);
    assertNumberOfProposals(proposals, 2);
    assertCorrectLabels(proposals);

    String[] expected = new String[2];

    buf = new StringBuffer();
    buf.append("package test1;\n");
    buf.append("public interface E {\n");
    buf.append("    public void foo(Object str);\n");
    buf.append("}\n");
    expected[0] = buf.toString();

    buf = new StringBuffer();
    buf.append("package test1;\n");
    buf.append("/**\n");
    buf.append(" * @param <T>  \n");
    buf.append(" */\n");
    buf.append("public interface E<T extends Exception> {\n");
    buf.append("    public void foo(Object str);\n");
    buf.append("}\n");
    expected[1] = buf.toString();

    assertExpectedExistInProposals(proposals, expected);
}

From source file:org.eclipse.che.jdt.quickfix.LocalCorrectionsQuickFixTest.java

License:Open Source License

@Test
public void testUnusedTypeParameter2() throws Exception {

    Hashtable hashtable = JavaCore.getOptions();
    hashtable.put(JavaCore.COMPILER_PB_UNUSED_TYPE_PARAMETER, JavaCore.ERROR);
    JavaCore.setOptions(hashtable);//from  w  w w.j  av  a 2s  .com

    IPackageFragment pack1 = fSourceFolder.createPackageFragment("test1", false, null);
    StringBuffer buf = new StringBuffer();
    buf.append("package test1;\n");
    buf.append("    /**\n");
    buf.append("     * @param <X> \n");
    buf.append("     * @see E\n");
    buf.append("     */\n");
    buf.append("public interface E<X, T> {\n");
    buf.append("    public void foo(Object str);\n");
    buf.append("}\n");
    ICompilationUnit cu = pack1.createCompilationUnit("E.java", buf.toString(), false, null);

    CompilationUnit astRoot = getASTRoot(cu);
    ArrayList proposals = collectCorrections(cu, astRoot);
    assertNumberOfProposals(proposals, 2);
    assertCorrectLabels(proposals);

    String[] expected = new String[2];

    buf = new StringBuffer();
    buf.append("package test1;\n");
    buf.append("    /**\n");
    buf.append("     * @param <X> \n");
    buf.append("     * @see E\n");
    buf.append("     */\n");
    buf.append("public interface E<X> {\n");
    buf.append("    public void foo(Object str);\n");
    buf.append("}\n");
    expected[0] = buf.toString();

    buf = new StringBuffer();
    buf.append("package test1;\n");
    buf.append("    /**\n");
    buf.append("     * @param <X> \n");
    buf.append("     * @param <T> \n");
    buf.append("     * @see E\n");
    buf.append("     */\n");
    buf.append("public interface E<X, T> {\n");
    buf.append("    public void foo(Object str);\n");
    buf.append("}\n");
    expected[1] = buf.toString();

    assertExpectedExistInProposals(proposals, expected);
}

From source file:org.eclipse.che.jdt.quickfix.LocalCorrectionsQuickFixTest.java

License:Open Source License

@Test
public void testUnusedTypeParameter3() throws Exception {
    Hashtable hashtable = JavaCore.getOptions();
    hashtable.put(JavaCore.COMPILER_PB_UNUSED_TYPE_PARAMETER, JavaCore.ERROR);
    JavaCore.setOptions(hashtable);/*from  w ww  . j  a  v a 2 s .c  om*/

    IPackageFragment pack1 = fSourceFolder.createPackageFragment("test1", false, null);
    StringBuffer buf = new StringBuffer();
    buf.append("package test1;\n");
    buf.append("public class E {\n");
    buf.append("    public <T> void foo(Object str){}\n");
    buf.append("}\n");
    ICompilationUnit cu = pack1.createCompilationUnit("E.java", buf.toString(), false, null);

    CompilationUnit astRoot = getASTRoot(cu);
    ArrayList proposals = collectCorrections(cu, astRoot);
    assertNumberOfProposals(proposals, 2);
    assertCorrectLabels(proposals);

    String[] expected = new String[2];

    buf = new StringBuffer();
    buf.append("package test1;\n");
    buf.append("public class E {\n");
    buf.append("    public void foo(Object str){}\n");
    buf.append("}\n");
    expected[0] = buf.toString();

    buf = new StringBuffer();
    buf.append("package test1;\n");
    buf.append("public class E {\n");
    buf.append("    /**\n");
    buf.append("     * @param <T>  \n");
    buf.append("     */\n");
    buf.append("    public <T> void foo(Object str){}\n");
    buf.append("}\n");
    expected[1] = buf.toString();

    assertExpectedExistInProposals(proposals, expected);
}