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

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

Introduction

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

Prototype

String COMPILER_PB_SYNTHETIC_ACCESS_EMULATION

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

Click Source Link

Document

Compiler option ID: Reporting Synthetic Access Emulation.

Usage

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

License:Open Source License

@Test
public void testNeedToEmulateMethodAccess() throws Exception {
    Hashtable hashtable = JavaCore.getOptions();
    hashtable.put(JavaCore.COMPILER_PB_SYNTHETIC_ACCESS_EMULATION, JavaCore.ERROR);
    JavaCore.setOptions(hashtable);/*from   w ww  .  j a  va  2s  .  c  o m*/

    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 void x() {\n");
    buf.append("        Runnable r= new Runnable() {\n");
    buf.append("            public void run() {\n");
    buf.append("                foo();\n");
    buf.append("            }\n");
    buf.append("        };\n");
    buf.append("    }\n");
    buf.append("    private void foo() {\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);
    assertNumberOfProposals(proposals, 1);
    assertCorrectLabels(proposals);

    CUCorrectionProposal proposal = (CUCorrectionProposal) proposals.get(0);
    String preview = getPreviewContent(proposal);

    buf = new StringBuffer();
    buf.append("package test1;\n");
    buf.append("public class E {\n");
    buf.append("    public void x() {\n");
    buf.append("        Runnable r= new Runnable() {\n");
    buf.append("            public void run() {\n");
    buf.append("                foo();\n");
    buf.append("            }\n");
    buf.append("        };\n");
    buf.append("    }\n");
    buf.append("    void foo() {\n");
    buf.append("    }\n");
    buf.append("}\n");
    assertEqualString(preview, buf.toString());
}

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

License:Open Source License

@Test
public void testNeedToEmulateConstructorAccess() throws Exception {
    Hashtable hashtable = JavaCore.getOptions();
    hashtable.put(JavaCore.COMPILER_PB_SYNTHETIC_ACCESS_EMULATION, JavaCore.ERROR);
    JavaCore.setOptions(hashtable);/*from w w  w.ja v  a  2s .  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 void x() {\n");
    buf.append("        Runnable r= new Runnable() {\n");
    buf.append("            public void run() {\n");
    buf.append("               E e= new E();\n");
    buf.append("            }\n");
    buf.append("        };\n");
    buf.append("    }\n");
    buf.append("    private 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);
    assertNumberOfProposals(proposals, 1);
    assertCorrectLabels(proposals);

    CUCorrectionProposal proposal = (CUCorrectionProposal) proposals.get(0);
    String preview = getPreviewContent(proposal);

    buf = new StringBuffer();
    buf.append("package test1;\n");
    buf.append("public class E {\n");
    buf.append("    public void x() {\n");
    buf.append("        Runnable r= new Runnable() {\n");
    buf.append("            public void run() {\n");
    buf.append("               E e= new E();\n");
    buf.append("            }\n");
    buf.append("        };\n");
    buf.append("    }\n");
    buf.append("    E() {\n");
    buf.append("    }\n");
    buf.append("}\n");
    assertEqualString(preview, buf.toString());
}

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

License:Open Source License

@Test
public void testNeedToEmulateFieldRead() throws Exception {
    Hashtable hashtable = JavaCore.getOptions();
    hashtable.put(JavaCore.COMPILER_PB_SYNTHETIC_ACCESS_EMULATION, JavaCore.ERROR);
    JavaCore.setOptions(hashtable);//from   w w  w .  jav  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 void x() {\n");
    buf.append("        Runnable r= new Runnable() {\n");
    buf.append("            public void run() {\n");
    buf.append("               int x= fCount;\n");
    buf.append("            }\n");
    buf.append("        };\n");
    buf.append("    }\n");
    buf.append("    private int fCount; {\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);
    assertNumberOfProposals(proposals, 1);
    assertCorrectLabels(proposals);

    CUCorrectionProposal proposal = (CUCorrectionProposal) proposals.get(0);
    String preview = getPreviewContent(proposal);

    buf = new StringBuffer();
    buf.append("package test1;\n");
    buf.append("public class E {\n");
    buf.append("    public void x() {\n");
    buf.append("        Runnable r= new Runnable() {\n");
    buf.append("            public void run() {\n");
    buf.append("               int x= fCount;\n");
    buf.append("            }\n");
    buf.append("        };\n");
    buf.append("    }\n");
    buf.append("    int fCount; {\n");
    buf.append("    }\n");
    buf.append("}\n");
    assertEqualString(preview, buf.toString());
}

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

License:Open Source License

@Test
public void testNeedToEmulateFieldReadInGeneric() throws Exception {
    Hashtable hashtable = JavaCore.getOptions();
    hashtable.put(JavaCore.COMPILER_PB_SYNTHETIC_ACCESS_EMULATION, JavaCore.ERROR);
    JavaCore.setOptions(hashtable);/*from   w w w.  j  a  va2 s  .  c  o m*/

    IPackageFragment pack1 = fSourceFolder.createPackageFragment("test1", false, null);
    StringBuffer buf = new StringBuffer();
    buf.append("package test1;\n");
    buf.append("public class E<T> {\n");
    buf.append("    public void x() {\n");
    buf.append("        Runnable r= new Runnable() {\n");
    buf.append("            public void run() {\n");
    buf.append("               T x= fCount;\n");
    buf.append("            }\n");
    buf.append("        };\n");
    buf.append("    }\n");
    buf.append("    private T fCount; {\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);
    assertNumberOfProposals(proposals, 1);
    assertCorrectLabels(proposals);

    CUCorrectionProposal proposal = (CUCorrectionProposal) proposals.get(0);
    String preview = getPreviewContent(proposal);

    buf = new StringBuffer();
    buf.append("package test1;\n");
    buf.append("public class E<T> {\n");
    buf.append("    public void x() {\n");
    buf.append("        Runnable r= new Runnable() {\n");
    buf.append("            public void run() {\n");
    buf.append("               T x= fCount;\n");
    buf.append("            }\n");
    buf.append("        };\n");
    buf.append("    }\n");
    buf.append("    T fCount; {\n");
    buf.append("    }\n");
    buf.append("}\n");
    assertEqualString(preview, buf.toString());
}

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

License:Open Source License

@Test
public void testNeedToEmulateFieldWrite() throws Exception {
    Hashtable hashtable = JavaCore.getOptions();
    hashtable.put(JavaCore.COMPILER_PB_SYNTHETIC_ACCESS_EMULATION, JavaCore.ERROR);
    JavaCore.setOptions(hashtable);/*from  w  w  w  . j av a 2s. c o m*/

    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 void x() {\n");
    buf.append("        Runnable r= new Runnable() {\n");
    buf.append("            public void run() {\n");
    buf.append("               fCount= 2;\n");
    buf.append("            }\n");
    buf.append("        };\n");
    buf.append("    }\n");
    buf.append("    private int fCount; {\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);
    assertNumberOfProposals(proposals, 1);
    assertCorrectLabels(proposals);

    CUCorrectionProposal proposal = (CUCorrectionProposal) proposals.get(0);
    String preview = getPreviewContent(proposal);

    buf = new StringBuffer();
    buf.append("package test1;\n");
    buf.append("public class E {\n");
    buf.append("    public void x() {\n");
    buf.append("        Runnable r= new Runnable() {\n");
    buf.append("            public void run() {\n");
    buf.append("               fCount= 2;\n");
    buf.append("            }\n");
    buf.append("        };\n");
    buf.append("    }\n");
    buf.append("    int fCount; {\n");
    buf.append("    }\n");
    buf.append("}\n");
    assertEqualString(preview, buf.toString());
}

From source file:processing.plugin.core.builder.SketchProject.java

License:Open Source License

/**
 * Sets the Java options to ignore all of the warnings because the Processing build chain
 * doesn't acknowledge or deal with compiler warnings.
 * <p>/*from   ww w.  j av a  2  s  . co m*/
 * Unlike the batch compiler, the JavaCore has no direct way of passing something simple,
 * like -nowarn, so each preference that could set a warning is explicitly set to ignore.
 * If there is a way to simplify this, please file a bug and suggest a fix!
 */
public void ignoreWarnings() {
    Hashtable options = JavaCore.getOptions();
    options.put(JavaCore.COMPILER_PB_ANNOTATION_SUPER_INTERFACE, JavaCore.IGNORE);
    options.put(JavaCore.COMPILER_PB_AUTOBOXING, JavaCore.IGNORE);
    options.put(JavaCore.COMPILER_PB_CHAR_ARRAY_IN_STRING_CONCATENATION, JavaCore.IGNORE);
    options.put(JavaCore.COMPILER_PB_DEPRECATION, JavaCore.IGNORE);
    options.put(JavaCore.COMPILER_PB_DISCOURAGED_REFERENCE, JavaCore.IGNORE);
    options.put(JavaCore.COMPILER_PB_EMPTY_STATEMENT, JavaCore.IGNORE);
    options.put(JavaCore.COMPILER_PB_ENUM_IDENTIFIER, JavaCore.IGNORE);
    options.put(JavaCore.COMPILER_PB_FALLTHROUGH_CASE, JavaCore.IGNORE);
    options.put(JavaCore.COMPILER_PB_FIELD_HIDING, JavaCore.IGNORE);
    options.put(JavaCore.COMPILER_PB_FINAL_PARAMETER_BOUND, JavaCore.IGNORE);
    options.put(JavaCore.COMPILER_PB_FINALLY_BLOCK_NOT_COMPLETING, JavaCore.IGNORE);
    options.put(JavaCore.COMPILER_PB_FORBIDDEN_REFERENCE, JavaCore.IGNORE);
    options.put(JavaCore.COMPILER_PB_HIDDEN_CATCH_BLOCK, JavaCore.IGNORE);
    options.put(JavaCore.COMPILER_PB_INCOMPATIBLE_NON_INHERITED_INTERFACE_METHOD, JavaCore.IGNORE);
    options.put(JavaCore.COMPILER_PB_INCOMPLETE_ENUM_SWITCH, JavaCore.IGNORE);
    options.put(JavaCore.COMPILER_PB_INDIRECT_STATIC_ACCESS, JavaCore.IGNORE);
    options.put(JavaCore.COMPILER_PB_INVALID_JAVADOC, JavaCore.IGNORE);
    options.put(JavaCore.COMPILER_PB_INVALID_JAVADOC_TAGS, JavaCore.IGNORE);
    options.put(JavaCore.COMPILER_PB_INVALID_JAVADOC_TAGS__DEPRECATED_REF, JavaCore.IGNORE);
    options.put(JavaCore.COMPILER_PB_LOCAL_VARIABLE_HIDING, JavaCore.IGNORE);
    options.put(JavaCore.COMPILER_PB_METHOD_WITH_CONSTRUCTOR_NAME, JavaCore.IGNORE);
    options.put(JavaCore.COMPILER_PB_MISSING_DEPRECATED_ANNOTATION, JavaCore.IGNORE);
    options.put(JavaCore.COMPILER_PB_MISSING_JAVADOC_COMMENTS, JavaCore.IGNORE);
    options.put(JavaCore.COMPILER_PB_MISSING_JAVADOC_TAGS, JavaCore.IGNORE);
    options.put(JavaCore.COMPILER_PB_MISSING_JAVADOC_TAGS_VISIBILITY, JavaCore.IGNORE);
    options.put(JavaCore.COMPILER_PB_MISSING_OVERRIDE_ANNOTATION, JavaCore.IGNORE);
    options.put(JavaCore.COMPILER_PB_MISSING_SERIAL_VERSION, JavaCore.IGNORE);
    options.put(JavaCore.COMPILER_PB_NO_EFFECT_ASSIGNMENT, JavaCore.IGNORE);
    options.put(JavaCore.COMPILER_PB_NON_NLS_STRING_LITERAL, JavaCore.IGNORE);
    options.put(JavaCore.COMPILER_PB_NULL_REFERENCE, JavaCore.IGNORE);
    options.put(JavaCore.COMPILER_PB_POTENTIAL_NULL_REFERENCE, JavaCore.IGNORE);
    options.put(JavaCore.COMPILER_PB_REDUNDANT_NULL_CHECK, JavaCore.IGNORE);
    options.put(JavaCore.COMPILER_PB_OVERRIDING_PACKAGE_DEFAULT_METHOD, JavaCore.IGNORE);
    options.put(JavaCore.COMPILER_PB_PARAMETER_ASSIGNMENT, JavaCore.IGNORE);
    options.put(JavaCore.COMPILER_PB_POSSIBLE_ACCIDENTAL_BOOLEAN_ASSIGNMENT, JavaCore.IGNORE);
    options.put(JavaCore.COMPILER_PB_RAW_TYPE_REFERENCE, JavaCore.IGNORE);
    options.put(JavaCore.COMPILER_PB_SPECIAL_PARAMETER_HIDING_FIELD, JavaCore.IGNORE);
    options.put(JavaCore.COMPILER_PB_STATIC_ACCESS_RECEIVER, JavaCore.IGNORE);
    options.put(JavaCore.COMPILER_PB_SUPPRESS_WARNINGS, JavaCore.IGNORE);
    options.put(JavaCore.COMPILER_PB_SYNTHETIC_ACCESS_EMULATION, JavaCore.IGNORE);
    options.put(JavaCore.COMPILER_PB_TYPE_PARAMETER_HIDING, JavaCore.IGNORE);
    options.put(JavaCore.COMPILER_PB_UNCHECKED_TYPE_OPERATION, JavaCore.IGNORE);
    options.put(JavaCore.COMPILER_PB_UNDOCUMENTED_EMPTY_BLOCK, JavaCore.IGNORE);
    options.put(JavaCore.COMPILER_PB_UNHANDLED_WARNING_TOKEN, JavaCore.IGNORE);
    options.put(JavaCore.COMPILER_PB_UNNECESSARY_ELSE, JavaCore.IGNORE);
    options.put(JavaCore.COMPILER_PB_UNNECESSARY_TYPE_CHECK, JavaCore.IGNORE);
    options.put(JavaCore.COMPILER_PB_UNQUALIFIED_FIELD_ACCESS, JavaCore.IGNORE);
    options.put(JavaCore.COMPILER_PB_UNUSED_DECLARED_THROWN_EXCEPTION, JavaCore.IGNORE);
    options.put(JavaCore.COMPILER_PB_UNUSED_LABEL, JavaCore.IGNORE);
    options.put(JavaCore.COMPILER_PB_UNUSED_DECLARED_THROWN_EXCEPTION_WHEN_OVERRIDING, JavaCore.IGNORE);
    options.put(JavaCore.COMPILER_PB_UNUSED_IMPORT, JavaCore.IGNORE);
    options.put(JavaCore.COMPILER_PB_UNUSED_LOCAL, JavaCore.IGNORE);
    options.put(JavaCore.COMPILER_PB_UNUSED_PARAMETER, JavaCore.IGNORE);
    options.put(JavaCore.COMPILER_PB_UNUSED_PARAMETER_WHEN_IMPLEMENTING_ABSTRACT, JavaCore.IGNORE);
    options.put(JavaCore.COMPILER_PB_UNUSED_PARAMETER_WHEN_OVERRIDING_CONCRETE, JavaCore.IGNORE);
    options.put(JavaCore.COMPILER_PB_UNUSED_PARAMETER_INCLUDE_DOC_COMMENT_REFERENCE, JavaCore.IGNORE);
    options.put(JavaCore.COMPILER_PB_UNUSED_PRIVATE_MEMBER, JavaCore.IGNORE);
    options.put(JavaCore.COMPILER_PB_VARARGS_ARGUMENT_NEED_CAST, JavaCore.IGNORE);
    // its finally over! yeah!

    JavaCore.setOptions(options);
}