Example usage for org.eclipse.jdt.internal.compiler.impl CompilerOptions OPTION_ReportUnusedImport

List of usage examples for org.eclipse.jdt.internal.compiler.impl CompilerOptions OPTION_ReportUnusedImport

Introduction

In this page you can find the example usage for org.eclipse.jdt.internal.compiler.impl CompilerOptions OPTION_ReportUnusedImport.

Prototype

String OPTION_ReportUnusedImport

To view the source code for org.eclipse.jdt.internal.compiler.impl CompilerOptions OPTION_ReportUnusedImport.

Click Source Link

Usage

From source file:com.tsc9526.monalisa.plugin.eclipse.jdt.JDTCompiler.java

License:Open Source License

public CompilerOptions getCompilerOptions() {
    Map<String, String> settings = new HashMap<String, String>();
    settings.put(CompilerOptions.OPTION_ReportMissingSerialVersion, CompilerOptions.IGNORE);
    settings.put(CompilerOptions.OPTION_LineNumberAttribute, CompilerOptions.GENERATE);
    settings.put(CompilerOptions.OPTION_SourceFileAttribute, CompilerOptions.GENERATE);
    settings.put(CompilerOptions.OPTION_ReportDeprecation, CompilerOptions.IGNORE);
    settings.put(CompilerOptions.OPTION_ReportUnusedImport, CompilerOptions.IGNORE);
    settings.put(CompilerOptions.OPTION_Encoding, "UTF-8");
    settings.put(CompilerOptions.OPTION_LocalVariableAttribute, CompilerOptions.GENERATE);
    String javaVersion = CompilerOptions.VERSION_1_6;

    if (System.getProperty("java.version").startsWith("1.5")) {
        javaVersion = CompilerOptions.VERSION_1_5;
    } else if (System.getProperty("java.version").startsWith("1.7")) {
        javaVersion = CompilerOptions.VERSION_1_7;
    } else if (System.getProperty("java.version").startsWith("1.8")) {
        javaVersion = CompilerOptions.VERSION_1_8;
    }//from w ww.  j ava 2 s .  c o m

    settings.put(CompilerOptions.OPTION_Source, javaVersion);
    settings.put(CompilerOptions.OPTION_TargetPlatform, javaVersion);
    settings.put(CompilerOptions.OPTION_PreserveUnusedLocal, CompilerOptions.PRESERVE);
    settings.put(CompilerOptions.OPTION_Compliance, javaVersion);
    return new CompilerOptions(settings);
}

From source file:dacapo.eclipse.EclipseBuildTests.java

License:Open Source License

protected static Hashtable warningOptions(int kind) {
    // Values/*ww w.j a v  a 2  s.  c o  m*/
    Hashtable optionsMap = null;
    switch (kind) {
    case 0:
        optionsMap = JavaCore.getDefaultOptions();
        break;
    default:
        optionsMap = new Hashtable(350);
        break;
    }
    if (kind == 0) {
        // Default set since 3.1
        optionsMap.put(CompilerOptions.OPTION_ReportUnusedImport, CompilerOptions.IGNORE);
    } else {
        boolean all = kind == 1;
        String generate = all ? CompilerOptions.GENERATE : CompilerOptions.DO_NOT_GENERATE;
        String warning = all ? CompilerOptions.WARNING : CompilerOptions.IGNORE;
        String enabled = all ? CompilerOptions.ENABLED : CompilerOptions.DISABLED;
        String preserve = all ? CompilerOptions.OPTIMIZE_OUT : CompilerOptions.PRESERVE;

        // Set options values
        optionsMap.put(CompilerOptions.OPTION_LocalVariableAttribute, generate);
        optionsMap.put(CompilerOptions.OPTION_LineNumberAttribute, generate);
        optionsMap.put(CompilerOptions.OPTION_SourceFileAttribute, generate);
        optionsMap.put(CompilerOptions.OPTION_PreserveUnusedLocal, preserve);
        optionsMap.put(CompilerOptions.OPTION_DocCommentSupport, enabled);
        optionsMap.put(CompilerOptions.OPTION_ReportMethodWithConstructorName, warning);
        optionsMap.put(CompilerOptions.OPTION_ReportOverridingPackageDefaultMethod, warning);
        optionsMap.put(CompilerOptions.OPTION_ReportDeprecation, warning);
        optionsMap.put(CompilerOptions.OPTION_ReportDeprecationInDeprecatedCode, enabled);
        optionsMap.put(CompilerOptions.OPTION_ReportDeprecationWhenOverridingDeprecatedMethod, enabled);
        optionsMap.put(CompilerOptions.OPTION_ReportHiddenCatchBlock, warning);
        optionsMap.put(CompilerOptions.OPTION_ReportUnusedLocal, warning);
        optionsMap.put(CompilerOptions.OPTION_ReportUnusedParameter, warning);
        optionsMap.put(CompilerOptions.OPTION_ReportUnusedImport, warning);
        optionsMap.put(CompilerOptions.OPTION_ReportSyntheticAccessEmulation, warning);
        optionsMap.put(CompilerOptions.OPTION_ReportNoEffectAssignment, warning);
        optionsMap.put(CompilerOptions.OPTION_ReportNonExternalizedStringLiteral, warning);
        optionsMap.put(CompilerOptions.OPTION_ReportNoImplicitStringConversion, warning);
        optionsMap.put(CompilerOptions.OPTION_ReportNonStaticAccessToStatic, warning);
        optionsMap.put(CompilerOptions.OPTION_ReportIndirectStaticAccess, warning);
        optionsMap.put(CompilerOptions.OPTION_ReportIncompatibleNonInheritedInterfaceMethod, warning);
        optionsMap.put(CompilerOptions.OPTION_ReportUnusedPrivateMember, warning);
        optionsMap.put(CompilerOptions.OPTION_ReportLocalVariableHiding, warning);
        optionsMap.put(CompilerOptions.OPTION_ReportFieldHiding, warning);
        optionsMap.put(CompilerOptions.OPTION_ReportPossibleAccidentalBooleanAssignment, warning);
        optionsMap.put(CompilerOptions.OPTION_ReportEmptyStatement, warning);
        optionsMap.put(CompilerOptions.OPTION_ReportAssertIdentifier, warning);
        optionsMap.put(CompilerOptions.OPTION_ReportUndocumentedEmptyBlock, warning);
        optionsMap.put(CompilerOptions.OPTION_ReportUnnecessaryTypeCheck, warning);
        optionsMap.put(CompilerOptions.OPTION_ReportUnnecessaryElse, warning);
        optionsMap.put(CompilerOptions.OPTION_ReportInvalidJavadoc, warning);
        optionsMap.put(CompilerOptions.OPTION_ReportInvalidJavadocTags, enabled);
        optionsMap.put(CompilerOptions.OPTION_ReportMissingJavadocTags, warning);
        optionsMap.put(CompilerOptions.OPTION_ReportMissingJavadocComments, warning);
        optionsMap.put(CompilerOptions.OPTION_ReportFinallyBlockNotCompletingNormally, warning);
        optionsMap.put(CompilerOptions.OPTION_ReportUnusedDeclaredThrownException, warning);
        optionsMap.put(CompilerOptions.OPTION_ReportUnqualifiedFieldAccess, warning);
        optionsMap.put(CompilerOptions.OPTION_TaskTags, all ? JavaCore.DEFAULT_TASK_TAGS : "");
        optionsMap.put(CompilerOptions.OPTION_TaskPriorities, all ? JavaCore.DEFAULT_TASK_PRIORITIES : "");
        optionsMap.put(CompilerOptions.OPTION_TaskCaseSensitive, enabled);
        optionsMap.put(CompilerOptions.OPTION_ReportUnusedParameterWhenImplementingAbstract, enabled);
        optionsMap.put(CompilerOptions.OPTION_ReportUnusedParameterWhenOverridingConcrete, enabled);
        optionsMap.put(CompilerOptions.OPTION_ReportSpecialParameterHidingField, enabled);
        optionsMap.put(CompilerOptions.OPTION_InlineJsr, enabled);
    }

    // Ignore 3.1 options
    optionsMap.put(CompilerOptions.OPTION_ReportMissingSerialVersion, CompilerOptions.IGNORE);
    optionsMap.put(CompilerOptions.OPTION_ReportEnumIdentifier, CompilerOptions.IGNORE);

    // Return created options map
    return optionsMap;
}

From source file:lombok.RunTestsViaEcj.java

License:Open Source License

protected CompilerOptions ecjCompilerOptions() {
    CompilerOptions options = new CompilerOptions();
    options.complianceLevel = Eclipse.getLatestEcjCompilerVersionConstant();
    options.sourceLevel = Eclipse.getLatestEcjCompilerVersionConstant();
    options.targetJDK = Eclipse.getLatestEcjCompilerVersionConstant();
    options.docCommentSupport = false;/*from   www . j a va 2s  .  c o m*/
    options.parseLiteralExpressionsAsConstants = true;
    options.inlineJsrBytecode = true;
    options.reportUnusedDeclaredThrownExceptionExemptExceptionAndThrowable = false;
    options.reportUnusedDeclaredThrownExceptionIncludeDocCommentReference = false;
    options.reportUnusedDeclaredThrownExceptionWhenOverriding = false;
    options.reportUnusedParameterIncludeDocCommentReference = false;
    options.reportUnusedParameterWhenImplementingAbstract = false;
    options.reportUnusedParameterWhenOverridingConcrete = false;
    options.reportDeadCodeInTrivialIfStatement = false;
    options.generateClassFiles = false;
    Map<String, String> warnings = new HashMap<String, String>();
    warnings.put(CompilerOptions.OPTION_ReportUnusedLocal, "ignore");
    warnings.put(CompilerOptions.OPTION_ReportUnusedLabel, "ignore");
    warnings.put(CompilerOptions.OPTION_ReportUnusedImport, "ignore");
    warnings.put(CompilerOptions.OPTION_ReportUnusedPrivateMember, "ignore");
    warnings.put(CompilerOptions.OPTION_Source, "1." + Eclipse.getEcjCompilerVersion());
    options.set(warnings);
    return options;
}

From source file:org.apache.cocoon.components.language.programming.java.EclipseJavaCompiler.java

License:Apache License

public boolean compile() throws IOException {
    final String targetClassName = makeClassName(sourceFile);
    final ClassLoader classLoader = ClassUtils.getClassLoader();
    String[] fileNames = new String[] { sourceFile };
    String[] classNames = new String[] { targetClassName };
    class CompilationUnit implements ICompilationUnit {

        String className;/* w ww.  ja v a 2s  .  c om*/
        String sourceFile;

        CompilationUnit(String sourceFile, String className) {
            this.className = className;
            this.sourceFile = sourceFile;
        }

        public char[] getFileName() {
            return className.toCharArray();
        }

        public char[] getContents() {
            char[] result = null;
            FileReader fr = null;
            try {
                fr = new FileReader(sourceFile);
                Reader reader = new BufferedReader(fr);
                if (reader != null) {
                    char[] chars = new char[8192];
                    StringBuffer buf = new StringBuffer();
                    int count;
                    while ((count = reader.read(chars, 0, chars.length)) > 0) {
                        buf.append(chars, 0, count);
                    }
                    result = new char[buf.length()];
                    buf.getChars(0, result.length, result, 0);
                }
            } catch (IOException e) {
                handleError(className, -1, -1, e.getMessage());
            }
            return result;
        }

        public char[] getMainTypeName() {
            int dot = className.lastIndexOf('.');
            if (dot > 0) {
                return className.substring(dot + 1).toCharArray();
            }
            return className.toCharArray();
        }

        public char[][] getPackageName() {
            StringTokenizer izer = new StringTokenizer(className, ".");
            char[][] result = new char[izer.countTokens() - 1][];
            for (int i = 0; i < result.length; i++) {
                String tok = izer.nextToken();
                result[i] = tok.toCharArray();
            }
            return result;
        }
    }

    final INameEnvironment env = new INameEnvironment() {

        public NameEnvironmentAnswer findType(char[][] compoundTypeName) {
            StringBuffer result = new StringBuffer();
            for (int i = 0; i < compoundTypeName.length; i++) {
                if (i > 0) {
                    result.append(".");
                }
                result.append(compoundTypeName[i]);
            }
            return findType(result.toString());
        }

        public NameEnvironmentAnswer findType(char[] typeName, char[][] packageName) {
            StringBuffer result = new StringBuffer();
            for (int i = 0; i < packageName.length; i++) {
                if (i > 0) {
                    result.append(".");
                }
                result.append(packageName[i]);
            }
            result.append(".");
            result.append(typeName);
            return findType(result.toString());
        }

        private NameEnvironmentAnswer findType(String className) {

            try {
                if (className.equals(targetClassName)) {
                    ICompilationUnit compilationUnit = new CompilationUnit(sourceFile, className);
                    return new NameEnvironmentAnswer(compilationUnit);
                }
                String resourceName = className.replace('.', '/') + ".class";
                InputStream is = classLoader.getResourceAsStream(resourceName);
                if (is != null) {
                    byte[] classBytes;
                    byte[] buf = new byte[8192];
                    ByteArrayOutputStream baos = new ByteArrayOutputStream(buf.length);
                    int count;
                    while ((count = is.read(buf, 0, buf.length)) > 0) {
                        baos.write(buf, 0, count);
                    }
                    baos.flush();
                    classBytes = baos.toByteArray();
                    char[] fileName = className.toCharArray();
                    ClassFileReader classFileReader = new ClassFileReader(classBytes, fileName, true);
                    return new NameEnvironmentAnswer(classFileReader);
                }
            } catch (IOException exc) {
                handleError(className, -1, -1, exc.getMessage());
            } catch (org.eclipse.jdt.internal.compiler.classfmt.ClassFormatException exc) {
                handleError(className, -1, -1, exc.getMessage());
            }
            return null;
        }

        private boolean isPackage(String result) {
            if (result.equals(targetClassName)) {
                return false;
            }
            String resourceName = result.replace('.', '/') + ".class";
            InputStream is = classLoader.getResourceAsStream(resourceName);
            return is == null;
        }

        public boolean isPackage(char[][] parentPackageName, char[] packageName) {
            StringBuffer result = new StringBuffer();
            if (parentPackageName != null) {
                for (int i = 0; i < parentPackageName.length; i++) {
                    if (i > 0) {
                        result.append(".");
                    }
                    result.append(parentPackageName[i]);
                }
            }
            String str = new String(packageName);
            if (Character.isUpperCase(str.charAt(0)) && !isPackage(result.toString())) {
                return false;
            }
            result.append(".");
            result.append(str);
            return isPackage(result.toString());
        }

        public void cleanup() {
            // EMPTY
        }
    };
    final IErrorHandlingPolicy policy = DefaultErrorHandlingPolicies.proceedWithAllProblems();
    final Map settings = new HashMap(9);
    settings.put(CompilerOptions.OPTION_LineNumberAttribute, CompilerOptions.GENERATE);
    settings.put(CompilerOptions.OPTION_SourceFileAttribute, CompilerOptions.GENERATE);
    settings.put(CompilerOptions.OPTION_ReportDeprecation, CompilerOptions.IGNORE);
    settings.put(CompilerOptions.OPTION_ReportUnusedImport, CompilerOptions.IGNORE);
    if (sourceEncoding != null) {
        settings.put(CompilerOptions.OPTION_Encoding, sourceEncoding);
    }
    if (debug) {
        settings.put(CompilerOptions.OPTION_LocalVariableAttribute, CompilerOptions.GENERATE);
    }
    // Set the sourceCodeVersion
    switch (this.compilerComplianceLevel) {
    case 150:
        settings.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5);
        settings.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5);
        break;
    case 140:
        settings.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_4);
        break;
    default:
        settings.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_3);
    }
    // Set the target platform
    switch (SystemUtils.JAVA_VERSION_INT) {
    case 150:
        settings.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5);
        break;
    case 140:
        settings.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_4);
        break;
    default:
        settings.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_3);
    }
    final IProblemFactory problemFactory = new DefaultProblemFactory(Locale.getDefault());

    final ICompilerRequestor requestor = new ICompilerRequestor() {
        public void acceptResult(CompilationResult result) {
            try {
                if (result.hasErrors()) {
                    IProblem[] errors = result.getErrors();
                    for (int i = 0; i < errors.length; i++) {
                        IProblem error = errors[i];
                        String name = new String(errors[i].getOriginatingFileName());
                        handleError(name, error.getSourceLineNumber(), -1, error.getMessage());
                    }
                } else {
                    ClassFile[] classFiles = result.getClassFiles();
                    for (int i = 0; i < classFiles.length; i++) {
                        ClassFile classFile = classFiles[i];
                        char[][] compoundName = classFile.getCompoundName();
                        StringBuffer className = new StringBuffer();
                        for (int j = 0; j < compoundName.length; j++) {
                            if (j > 0) {
                                className.append(".");
                            }
                            className.append(compoundName[j]);
                        }
                        byte[] bytes = classFile.getBytes();
                        String outFile = destDir + "/" + className.toString().replace('.', '/') + ".class";
                        FileOutputStream fout = new FileOutputStream(outFile);
                        BufferedOutputStream bos = new BufferedOutputStream(fout);
                        bos.write(bytes);
                        bos.close();
                    }
                }
            } catch (IOException exc) {
                exc.printStackTrace();
            }
        }
    };
    ICompilationUnit[] compilationUnits = new ICompilationUnit[classNames.length];
    for (int i = 0; i < compilationUnits.length; i++) {
        String className = classNames[i];
        compilationUnits[i] = new CompilationUnit(fileNames[i], className);
    }
    Compiler compiler = new Compiler(env, policy, settings, requestor, problemFactory);
    compiler.compile(compilationUnits);
    return errors.size() == 0;
}

From source file:org.apache.commons.jci.compilers.EclipseJavaCompilerSettings.java

License:Apache License

public EclipseJavaCompilerSettings() {
    defaultEclipseSettings.put(CompilerOptions.OPTION_LineNumberAttribute, CompilerOptions.GENERATE);
    defaultEclipseSettings.put(CompilerOptions.OPTION_SourceFileAttribute, CompilerOptions.GENERATE);
    defaultEclipseSettings.put(CompilerOptions.OPTION_ReportUnusedImport, CompilerOptions.IGNORE);
    defaultEclipseSettings.put(CompilerOptions.OPTION_LocalVariableAttribute, CompilerOptions.GENERATE);
}

From source file:org.apache.sling.scripting.java.jdt.EclipseJavaCompiler.java

License:Apache License

private CompilerOptions getCompilerOptions() {
    CompilerOptions options = new CompilerOptions();
    final Map<String, String> settings = new HashMap<String, String>();
    settings.put(CompilerOptions.OPTION_LineNumberAttribute, CompilerOptions.GENERATE);
    settings.put(CompilerOptions.OPTION_SourceFileAttribute, CompilerOptions.GENERATE);
    settings.put(CompilerOptions.OPTION_ReportDeprecation, CompilerOptions.IGNORE);
    settings.put(CompilerOptions.OPTION_ReportUnusedImport, CompilerOptions.IGNORE);
    settings.put(CompilerOptions.OPTION_Encoding, this.compilerOptions.getJavaEncoding());
    if (this.compilerOptions.getClassDebugInfo()) {
        settings.put(CompilerOptions.OPTION_LocalVariableAttribute, CompilerOptions.GENERATE);
    }//from  w  w  w.  j ava 2  s  .  c om
    if (this.compilerOptions.getCompilerSourceVM().equals("1.6")) {
        settings.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_6);
    } else {
        settings.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5);
    }
    if (this.compilerOptions.getCompilerTargetVM().equals("1.6")) {
        settings.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_6);
        settings.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_6);
    } else {
        settings.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5);
        settings.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5);
    }

    options.set(settings);
    return options;
}

From source file:org.eclipse.objectteams.otdt.tests.otjld.calloutbinding.CalloutParameterBinding_LiftingAndLowering.java

License:Open Source License

public void test3241_importUsedInParammap1() {
    Map customOptions = getCompilerOptions();
    customOptions.put(CompilerOptions.OPTION_ReportUnusedParameter, CompilerOptions.WARNING);
    customOptions.put(CompilerOptions.OPTION_ReportUnusedPrivateMember, CompilerOptions.WARNING);
    customOptions.put(CompilerOptions.OPTION_ReportUnusedDeclaredThrownException, CompilerOptions.WARNING);
    customOptions.put(CompilerOptions.OPTION_ReportUnusedTypeArgumentsForMethodInvocation,
            CompilerOptions.WARNING);/*from  w ww . j av a2s.  co m*/
    customOptions.put(CompilerOptions.OPTION_ReportUnusedLabel, CompilerOptions.WARNING);
    customOptions.put(CompilerOptions.OPTION_ReportUnusedImport, CompilerOptions.WARNING);
    customOptions.put(CompilerOptions.OPTION_ReportUnusedLocal, CompilerOptions.WARNING);

    runConformTest(new String[] { "T3241iuip1Main.java",
            "\n" + "public class T3241iuip1Main {\n" + "    public static void main(String[] args) {\n"
                    + "        new Team3241iuip1().test();\n" + "    }\n" + "}\n" + "    \n",
            "p1/T3241iuip1_1.java",
            "\n" + "package p1;\n" + "public class T3241iuip1_1 {\n"
                    + "    public static String getO() { return \"O\"; }\n" + "}\n" + "    \n",
            "p1/T3241iuip1_2.java",
            "\n" + "package p1;\n" + "public class T3241iuip1_2 {\n"
                    + "    public String getK() { return \"K\"; }\n" + "}\n" + "    \n",
            "Team3241iuip1.java",
            "\n" + "import p1.T3241iuip1_1;\n" + "import base p1.T3241iuip1_2;\n"
                    + "public team class Team3241iuip1 {\n" + "    protected class R playedBy T3241iuip1_2 {\n"
                    + "        protected R() { base(); }\n" + "        String getOK () -> String getK()\n"
                    + "            with { result <- T3241iuip1_1.getO()+result }\n" + "    }\n"
                    + "    void test() {\n" + "        System.out.print(new R().getOK());\n" + "    }\n" + "}\n"
                    + "    \n" },
            "OK", null/*classLibraries*/, true/*shouldFlushOutputDirectory*/, null/*vmArguments*/,
            customOptions, null/*no custom requestor*/);
}

From source file:org.eclipse.objectteams.otdt.tests.otjld.regression.ReportedBugs.java

License:Open Source License

public void testB11_sh67() {
    Map customOptions = getCompilerOptions();
    customOptions.put(CompilerOptions.OPTION_ReportUnusedParameter, CompilerOptions.WARNING);
    customOptions.put(CompilerOptions.OPTION_ReportUnusedPrivateMember, CompilerOptions.WARNING);
    customOptions.put(CompilerOptions.OPTION_ReportUnusedDeclaredThrownException, CompilerOptions.WARNING);
    customOptions.put(CompilerOptions.OPTION_ReportUnusedTypeArgumentsForMethodInvocation,
            CompilerOptions.WARNING);//  w ww. j  a v  a  2s . c o  m
    customOptions.put(CompilerOptions.OPTION_ReportUnusedLabel, CompilerOptions.WARNING);
    customOptions.put(CompilerOptions.OPTION_ReportUnusedImport, CompilerOptions.WARNING);
    customOptions.put(CompilerOptions.OPTION_ReportUnusedLocal, CompilerOptions.WARNING);
    runTestExpectingWarnings(new String[] { "TB11sh67.java", "\n" + "public class TB11sh67 {\n"
            + "    @SuppressWarnings(\"unused\")\n" + "    private int secret;\n" + "}\n" + "    \n",
            "TeamB11sh67.java",
            "\n" + "@SuppressWarnings({\"unused\",\"basecall\"})\n" + "public team class TeamB11sh67 {\n"
                    + "    void bar(int unused) {}\n" + "    protected class R playedBy TB11sh67 {\n"
                    + "        int getSecret() -> get int secret; // <- decapsulation warning was masked by above @SuppressWarnings\n"
                    + "        callin void noBaseCall() {\n" + "        }\n" + "    }\n" + "}\n" + "    \n" },
            "----------\n" + "1. WARNING in TeamB11sh67.java (at line 6)\n"
                    + "   int getSecret() -> get int secret; // <- decapsulation warning was masked by above @SuppressWarnings\n"
                    + "                              ^^^^^^\n"
                    + "Access restriction of private field secret in type TB11sh67 is overridden by this binding (OTJLD 3.5(e)).\n"
                    + "----------\n",
            customOptions);
}

From source file:org.eclipse.objectteams.otdt.tests.otjld.regression.ReportedBugs.java

License:Open Source License

public void testB11_sh68() {
    Map customOptions = getCompilerOptions();
    customOptions.put(CompilerOptions.OPTION_ReportUnusedParameter, CompilerOptions.WARNING);
    customOptions.put(CompilerOptions.OPTION_ReportUnusedPrivateMember, CompilerOptions.WARNING);
    customOptions.put(CompilerOptions.OPTION_ReportUnusedDeclaredThrownException, CompilerOptions.WARNING);
    customOptions.put(CompilerOptions.OPTION_ReportUnusedTypeArgumentsForMethodInvocation,
            CompilerOptions.WARNING);/*  w  w  w  .  j  a v  a  2 s .  co  m*/
    customOptions.put(CompilerOptions.OPTION_ReportUnusedLabel, CompilerOptions.WARNING);
    customOptions.put(CompilerOptions.OPTION_ReportUnusedImport, CompilerOptions.WARNING);
    customOptions.put(CompilerOptions.OPTION_ReportUnusedLocal, CompilerOptions.WARNING);
    customOptions.put(CompilerOptions.OPTION_ReportUnusedWarningToken, CompilerOptions.WARNING);
    runTestExpectingWarnings(new String[] { "TB11sh68.java", "\n" + "public class TB11sh68 {\n"
            + "    @SuppressWarnings(\"unused\")\n" + "    private int secret;\n" + "}\n" + "    \n",
            "TeamB11sh68.java",
            "\n" + "@SuppressWarnings({\"unused\",\"basecall\",\"restriction\"}) // last one is unnecessary\n"
                    + "public team class TeamB11sh68 {\n" + "    void bar(int unused) {}\n"
                    + "    @SuppressWarnings(\"basecall\") // unnesserary\n"
                    + "    protected class R playedBy TB11sh68 {\n"
                    + "        int getSecret() -> get int secret; // <- decapsulation warning was masked by above @SuppressWarnings\n"
                    + "        callin void noBaseCall() {\n" + "        }\n" + "    }\n" + "}\n" + "    \n" },
            "----------\n" + "1. WARNING in TeamB11sh68.java (at line 2)\n"
                    + "   @SuppressWarnings({\"unused\",\"basecall\",\"restriction\"}) // last one is unnecessary\n"
                    + "                               ^^^^^^^^^^\n"
                    + "Unnecessary @SuppressWarnings(\"basecall\")\n" + "----------\n"
                    + "2. WARNING in TeamB11sh68.java (at line 2)\n"
                    + "   @SuppressWarnings({\"unused\",\"basecall\",\"restriction\"}) // last one is unnecessary\n"
                    + "                                          ^^^^^^^^^^^^^\n"
                    + "Unnecessary @SuppressWarnings(\"restriction\")\n" + "----------\n"
                    + "3. WARNING in TeamB11sh68.java (at line 7)\n"
                    + "   int getSecret() -> get int secret; // <- decapsulation warning was masked by above @SuppressWarnings\n"
                    + "                              ^^^^^^\n"
                    + "Access restriction of private field secret in type TB11sh68 is overridden by this binding (OTJLD 3.5(e)).\n"
                    + "----------\n",
            customOptions);
}

From source file:org.eclipse.objectteams.otdt.tests.otjld.roleplaying.PlayedByRelation.java

License:Open Source License

public void test2110_baseImport7() {
    Map customOptions = getCompilerOptions();
    customOptions.put(CompilerOptions.OPTION_ReportUnusedParameter, CompilerOptions.WARNING);
    customOptions.put(CompilerOptions.OPTION_ReportUnusedPrivateMember, CompilerOptions.WARNING);
    customOptions.put(CompilerOptions.OPTION_ReportUnusedDeclaredThrownException, CompilerOptions.WARNING);
    customOptions.put(CompilerOptions.OPTION_ReportUnusedTypeArgumentsForMethodInvocation,
            CompilerOptions.WARNING);/*w w  w . ja  va2 s  . c  om*/
    customOptions.put(CompilerOptions.OPTION_ReportUnusedLabel, CompilerOptions.WARNING);
    customOptions.put(CompilerOptions.OPTION_ReportUnusedImport, CompilerOptions.WARNING);
    customOptions.put(CompilerOptions.OPTION_ReportUnusedLocal, CompilerOptions.WARNING);
    runTestExpectingWarnings(
            new String[] { "p1/T2110bi7.java", "\n" + "package p1;\n" + "public class T2110bi7 {}\n" + "    \n",
                    "Team2110bi7.java",
                    "\n" + "import base p1.T2110bi7;\n" + "import base java.util.List;\n"
                            + "public team class Team2110bi7 {\n"
                            + "    protected class R playedBy T2110bi7 {}\n" + "}\n" + "    \n" },
            "----------\n" + "1. WARNING in Team2110bi7.java (at line 3)\n" + "   import base java.util.List;\n"
                    + "               ^^^^^^^^^^^^^^\n" + "The import java.util.List is never used\n"
                    + "----------\n",
            customOptions);
}