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

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

Introduction

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

Prototype

String COMPILER_PB_DEPRECATION_WHEN_OVERRIDING_DEPRECATED_METHOD

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

Click Source Link

Document

Compiler option ID: Reporting Deprecation When Overriding Deprecated Method.

Usage

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

License:Open Source License

@Test
public void testMethodOverrideDeprecated1() throws Exception {
    Hashtable options = JavaCore.getOptions();
    options.put(JavaCore.COMPILER_PB_DEPRECATION_WHEN_OVERRIDING_DEPRECATED_METHOD, JavaCore.ENABLED);
    JavaCore.setOptions(options);/*  ww w . j av  a2 s.  c o  m*/

    IPackageFragment pack1 = fSourceFolder.createPackageFragment("pack", false, null);
    StringBuffer buf = new StringBuffer();
    buf.append("package pack;\n");
    buf.append("public class E {\n");
    buf.append("    @Deprecated\n");
    buf.append("    public void foo() {\n");
    buf.append("    }\n");
    buf.append("}    \n");
    buf.append("\n");
    buf.append("class F extends E {\n");
    buf.append("    public void foo() {\n");
    buf.append("    }\n");
    buf.append("}\n");
    buf.append("\n");
    ICompilationUnit cu = pack1.createCompilationUnit("E.java", buf.toString(), false, null);

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

    assertCorrectLabels(proposals);
    assertNumberOfProposals(proposals, 2);

    String[] expected = new String[2];
    buf = new StringBuffer();
    buf.append("package pack;\n");
    buf.append("public class E {\n");
    buf.append("    @Deprecated\n");
    buf.append("    public void foo() {\n");
    buf.append("    }\n");
    buf.append("}    \n");
    buf.append("\n");
    buf.append("class F extends E {\n");
    buf.append("    @Deprecated\n");
    buf.append("    public void foo() {\n");
    buf.append("    }\n");
    buf.append("}\n");
    buf.append("\n");
    expected[0] = buf.toString();

    buf = new StringBuffer();
    buf.append("package pack;\n");
    buf.append("public class E {\n");
    buf.append("    @Deprecated\n");
    buf.append("    public void foo() {\n");
    buf.append("    }\n");
    buf.append("}    \n");
    buf.append("\n");
    buf.append("class F extends E {\n");
    buf.append("    @SuppressWarnings(\"deprecation\")\n");
    buf.append("    public void foo() {\n");
    buf.append("    }\n");
    buf.append("}\n");
    buf.append("\n");
    expected[1] = buf.toString();

    assertExpectedExistInProposals(proposals, expected);
}

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

License:Open Source License

@Test
public void testMethodOverrideDeprecated2() throws Exception {
    Hashtable options = JavaCore.getOptions();
    options.put(JavaCore.COMPILER_PB_DEPRECATION_WHEN_OVERRIDING_DEPRECATED_METHOD, JavaCore.ENABLED);
    JavaCore.setOptions(options);//from   w  w w  . j a  v a2 s . com

    IPackageFragment pack1 = fSourceFolder.createPackageFragment("pack", false, null);
    StringBuffer buf = new StringBuffer();
    buf.append("package pack;\n");
    buf.append("public class E {\n");
    buf.append("    @Deprecated\n");
    buf.append("    public void foo() {\n");
    buf.append("    }\n");
    buf.append("}    \n");
    buf.append("\n");
    buf.append("class F extends E {\n");
    buf.append("    /**\n");
    buf.append("     */\n");
    buf.append("    public void foo() {\n");
    buf.append("    }\n");
    buf.append("}\n");
    buf.append("\n");
    ICompilationUnit cu = pack1.createCompilationUnit("E.java", buf.toString(), false, null);

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

    assertCorrectLabels(proposals);
    assertNumberOfProposals(proposals, 2);

    String[] expected = new String[2];
    buf = new StringBuffer();
    buf.append("package pack;\n");
    buf.append("public class E {\n");
    buf.append("    @Deprecated\n");
    buf.append("    public void foo() {\n");
    buf.append("    }\n");
    buf.append("}    \n");
    buf.append("\n");
    buf.append("class F extends E {\n");
    buf.append("    /**\n");
    buf.append("     * @deprecated\n");
    buf.append("     */\n");
    buf.append("    @Deprecated\n");
    buf.append("    public void foo() {\n");
    buf.append("    }\n");
    buf.append("}\n");
    buf.append("\n");
    expected[0] = buf.toString();

    buf = new StringBuffer();
    buf.append("package pack;\n");
    buf.append("public class E {\n");
    buf.append("    @Deprecated\n");
    buf.append("    public void foo() {\n");
    buf.append("    }\n");
    buf.append("}    \n");
    buf.append("\n");
    buf.append("class F extends E {\n");
    buf.append("    /**\n");
    buf.append("     */\n");
    buf.append("    @SuppressWarnings(\"deprecation\")\n");
    buf.append("    public void foo() {\n");
    buf.append("    }\n");
    buf.append("}\n");
    buf.append("\n");
    expected[1] = buf.toString();

    assertExpectedExistInProposals(proposals, expected);
}