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

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

Introduction

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

Prototype

String COMPILER_PB_UNUSED_WARNING_TOKEN

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

Click Source Link

Document

Compiler option ID: Reporting Unnecessary @SuppressWarnings.

Usage

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

License:Open Source License

@Test
public void testUnusedSuppressWarnings1() throws Exception {
    Hashtable hashtable = JavaCore.getOptions();
    hashtable.put(JavaCore.COMPILER_PB_UNHANDLED_WARNING_TOKEN, JavaCore.IGNORE);
    hashtable.put(JavaCore.COMPILER_PB_UNUSED_WARNING_TOKEN, JavaCore.WARNING);
    JavaCore.setOptions(hashtable);/*w ww . ja v  a 2  s  . c om*/

    IPackageFragment pack1 = fSourceFolder.createPackageFragment("p", false, null);
    StringBuffer buf = new StringBuffer();
    buf.append("package p;\n");
    buf.append("\n");
    buf.append("@SuppressWarnings(value=\"unused\")\n");
    buf.append("public class E {\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, 1);

    String[] expected = new String[1];
    buf = new StringBuffer();
    buf.append("package p;\n");
    buf.append("\n");
    buf.append("public class E {\n");
    buf.append("\n");
    buf.append("}\n");
    expected[0] = buf.toString();

    assertExpectedExistInProposals(proposals, expected);
}

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

License:Open Source License

@Test
public void testUnusedSuppressWarnings2() throws Exception {
    Hashtable hashtable = JavaCore.getOptions();
    hashtable.put(JavaCore.COMPILER_PB_UNHANDLED_WARNING_TOKEN, JavaCore.IGNORE);
    hashtable.put(JavaCore.COMPILER_PB_UNUSED_WARNING_TOKEN, JavaCore.WARNING);
    JavaCore.setOptions(hashtable);/*from w  ww  .j  a  v  a2 s  .co m*/
    IPackageFragment pack1 = fSourceFolder.createPackageFragment("p", false, null);
    StringBuffer buf = new StringBuffer();
    buf.append("package p;\n");
    buf.append("\n");
    buf.append("@SuppressWarnings(\"unused\")\n");
    buf.append("public class E {\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, 1);

    String[] expected = new String[1];
    buf = new StringBuffer();
    buf.append("package p;\n");
    buf.append("\n");
    buf.append("public class E {\n");
    buf.append("\n");
    buf.append("}\n");
    expected[0] = buf.toString();

    assertExpectedExistInProposals(proposals, expected);
}

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

License:Open Source License

@Test
public void testUnusedSuppressWarnings3() throws Exception {
    Hashtable hashtable = JavaCore.getOptions();
    hashtable.put(JavaCore.COMPILER_PB_UNHANDLED_WARNING_TOKEN, JavaCore.IGNORE);
    hashtable.put(JavaCore.COMPILER_PB_UNUSED_WARNING_TOKEN, JavaCore.WARNING);
    JavaCore.setOptions(hashtable);//from  www .j  a  v a 2  s . co  m
    IPackageFragment pack1 = fSourceFolder.createPackageFragment("p", false, null);
    StringBuffer buf = new StringBuffer();
    buf.append("package p;\n");
    buf.append("\n");
    buf.append("@SuppressWarnings({ \"unused\", \"X\" })\n");
    buf.append("public class E {\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, 1);

    String[] expected = new String[1];
    buf = new StringBuffer();
    buf.append("package p;\n");
    buf.append("\n");
    buf.append("@SuppressWarnings({ \"X\" })\n");
    buf.append("public class E {\n");
    buf.append("\n");
    buf.append("}\n");
    expected[0] = buf.toString();

    assertExpectedExistInProposals(proposals, expected);
}

From source file:org.eclipse.che.jdt.testplugin.TestOptions.java

License:Open Source License

public static Hashtable getDefaultOptions() {
    Hashtable result = org.eclipse.jdt.core.JavaCore.getDefaultOptions();
    result.put(JavaCore.COMPILER_PB_LOCAL_VARIABLE_HIDING, JavaCore.IGNORE);
    result.put(JavaCore.COMPILER_PB_FIELD_HIDING, JavaCore.IGNORE);
    result.put(JavaCore.COMPILER_PB_UNUSED_PRIVATE_MEMBER, JavaCore.IGNORE);
    result.put(JavaCore.COMPILER_PB_UNUSED_LOCAL, JavaCore.IGNORE);
    result.put(JavaCore.COMPILER_PB_RAW_TYPE_REFERENCE, JavaCore.IGNORE);
    result.put(JavaCore.COMPILER_PB_UNUSED_WARNING_TOKEN, JavaCore.IGNORE);
    result.put(JavaCore.COMPILER_PB_DEAD_CODE, JavaCore.IGNORE);
    // should cover all compiler settings
    result.putAll(TestFormatterOptions.getSettings());
    return result;
}