Java Code Examples for org.eclipse.jdt.core.IJavaProject#setOptions()
The following examples show how to use
org.eclipse.jdt.core.IJavaProject#setOptions() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JavaProjectSetupUtil.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
/** * Java 5 is long dead. */ @Deprecated public static void makeJava5Compliant(IJavaProject javaProject) { Map<String, String> options= javaProject.getOptions(false); options.put(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_1_5); options.put(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_1_5); options.put(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, JavaCore.VERSION_1_5); options.put(JavaCore.COMPILER_PB_ASSERT_IDENTIFIER, JavaCore.ERROR); options.put(JavaCore.COMPILER_PB_ENUM_IDENTIFIER, JavaCore.ERROR); options.put(JavaCore.COMPILER_CODEGEN_INLINE_JSR_BYTECODE, JavaCore.ENABLED); options.put(JavaCore.COMPILER_LOCAL_VARIABLE_ATTR, JavaCore.GENERATE); options.put(JavaCore.COMPILER_LINE_NUMBER_ATTR, JavaCore.GENERATE); options.put(JavaCore.COMPILER_SOURCE_FILE_ATTR, JavaCore.GENERATE); options.put(JavaCore.COMPILER_CODEGEN_UNUSED_LOCAL, JavaCore.PRESERVE); javaProject.setOptions(options); }
Example 2
Source File: TestingEnvironment.java From dacapobench with Apache License 2.0 | 5 votes |
public IPath addProject(String projectName, String compliance) { checkAssertion("a workspace must be open", this.isOpen); //$NON-NLS-1$ IProject project = createProject(projectName); int requiredComplianceFlag = 0; String compilerVersion = null; if ("1.5".equals(compliance)) { requiredComplianceFlag = AbstractCompilerTest.F_1_5; compilerVersion = CompilerOptions.VERSION_1_5; } else if ("1.6".equals(compliance)) { requiredComplianceFlag = AbstractCompilerTest.F_1_6; compilerVersion = CompilerOptions.VERSION_1_6; } else if ("1.7".equals(compliance)) { requiredComplianceFlag = AbstractCompilerTest.F_1_7; compilerVersion = CompilerOptions.VERSION_1_7; } else if (!"1.4".equals(compliance) && !"1.3".equals(compliance)) { throw new UnsupportedOperationException("Test framework doesn't support compliance level: " + compliance); } if (requiredComplianceFlag != 0) { if ((AbstractCompilerTest.getPossibleComplianceLevels() & requiredComplianceFlag) == 0) throw new RuntimeException("This test requires a " + compliance + " JRE"); IJavaProject javaProject = JavaCore.create(project); Map options = new HashMap(); options.put(CompilerOptions.OPTION_Compliance, compilerVersion); options.put(CompilerOptions.OPTION_Source, compilerVersion); options.put(CompilerOptions.OPTION_TargetPlatform, compilerVersion); javaProject.setOptions(options); } return project.getFullPath(); }
Example 3
Source File: MockJavaProjectProvider.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
public static void makeJava8Compliant(IJavaProject javaProject) { Map<String, String> options= javaProject.getOptions(false); options.put(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_1_8); options.put(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_1_8); options.put(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, JavaCore.VERSION_1_8); options.put(JavaCore.COMPILER_PB_ASSERT_IDENTIFIER, JavaCore.ERROR); options.put(JavaCore.COMPILER_PB_ENUM_IDENTIFIER, JavaCore.ERROR); options.put(JavaCore.COMPILER_CODEGEN_INLINE_JSR_BYTECODE, JavaCore.ENABLED); options.put(JavaCore.COMPILER_LOCAL_VARIABLE_ATTR, JavaCore.GENERATE); options.put(JavaCore.COMPILER_LINE_NUMBER_ATTR, JavaCore.GENERATE); options.put(JavaCore.COMPILER_SOURCE_FILE_ATTR, JavaCore.GENERATE); options.put(JavaCore.COMPILER_CODEGEN_UNUSED_LOCAL, JavaCore.PRESERVE); javaProject.setOptions(options); }
Example 4
Source File: JavaProjectSetupUtil.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
public static void makeJava5Compliant(IJavaProject javaProject) { Map<String, String> options= javaProject.getOptions(false); options.put(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_1_5); options.put(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_1_5); options.put(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, JavaCore.VERSION_1_5); options.put(JavaCore.COMPILER_PB_ASSERT_IDENTIFIER, JavaCore.ERROR); options.put(JavaCore.COMPILER_PB_ENUM_IDENTIFIER, JavaCore.ERROR); options.put(JavaCore.COMPILER_CODEGEN_INLINE_JSR_BYTECODE, JavaCore.ENABLED); options.put(JavaCore.COMPILER_LOCAL_VARIABLE_ATTR, JavaCore.GENERATE); options.put(JavaCore.COMPILER_LINE_NUMBER_ATTR, JavaCore.GENERATE); options.put(JavaCore.COMPILER_SOURCE_FILE_ATTR, JavaCore.GENERATE); options.put(JavaCore.COMPILER_CODEGEN_UNUSED_LOCAL, JavaCore.PRESERVE); javaProject.setOptions(options); }
Example 5
Source File: JavaProjectSetupUtil.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
/** * @since 2.21 */ public static void makeJava8Compliant(IJavaProject javaProject) { Map<String, String> options= javaProject.getOptions(false); options.put(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_1_8); options.put(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_1_8); options.put(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, JavaCore.VERSION_1_8); options.put(JavaCore.COMPILER_PB_ASSERT_IDENTIFIER, JavaCore.ERROR); options.put(JavaCore.COMPILER_PB_ENUM_IDENTIFIER, JavaCore.ERROR); options.put(JavaCore.COMPILER_CODEGEN_INLINE_JSR_BYTECODE, JavaCore.ENABLED); options.put(JavaCore.COMPILER_LOCAL_VARIABLE_ATTR, JavaCore.GENERATE); options.put(JavaCore.COMPILER_LINE_NUMBER_ATTR, JavaCore.GENERATE); options.put(JavaCore.COMPILER_SOURCE_FILE_ATTR, JavaCore.GENERATE); options.put(JavaCore.COMPILER_CODEGEN_UNUSED_LOCAL, JavaCore.PRESERVE); javaProject.setOptions(options); }
Example 6
Source File: DiagnosticHandlerTest.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 5 votes |
@Test public void testMultipleLineRange() throws Exception { IJavaProject javaProject = newEmptyProject(); Hashtable<String, String> options = JavaCore.getOptions(); options.put(JavaCore.COMPILER_PB_DEAD_CODE, JavaCore.WARNING); javaProject.setOptions(options); IPackageFragmentRoot sourceFolder = javaProject.getPackageFragmentRoot(javaProject.getProject().getFolder("src")); IPackageFragment pack1 = sourceFolder.createPackageFragment("test1", false, null); StringBuilder buf = new StringBuilder(); buf.append("package test1;\n"); buf.append("public class E {\n"); buf.append(" public boolean foo(boolean b1) {\n"); buf.append(" if (false) {\n"); buf.append(" return true;\n"); buf.append(" }\n"); buf.append(" return false;\n"); buf.append(" }\n"); buf.append("}\n"); ICompilationUnit cu = pack1.createCompilationUnit("E.java", buf.toString(), false, null); CompilationUnit astRoot = CoreASTProvider.getInstance().getAST(cu, CoreASTProvider.WAIT_YES, monitor); IProblem[] problems = astRoot.getProblems(); List<Diagnostic> diagnostics = DiagnosticsHandler.toDiagnosticsArray(cu, Arrays.asList(problems), true); assertEquals(1, diagnostics.size()); Range range = diagnostics.get(0).getRange(); assertNotEquals(range.getStart().getLine(), range.getEnd().getLine()); }
Example 7
Source File: UnresolvedMethodsQuickFixTest.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 5 votes |
@Before public void setup() throws Exception { IJavaProject fJProject1 = newEmptyProject(); Map<String, String> options = TestOptions.getDefaultOptions(); options.put(JavaCore.COMPILER_PB_NO_EFFECT_ASSIGNMENT, JavaCore.IGNORE); options.put(JavaCore.COMPILER_PB_INDIRECT_STATIC_ACCESS, JavaCore.ERROR); fJProject1.setOptions(options); fSourceFolder = fJProject1.getPackageFragmentRoot(fJProject1.getProject().getFolder("src")); }
Example 8
Source File: JavaProjectHelper.java From spotbugs with GNU Lesser General Public License v2.1 | 5 votes |
/** * Sets the compiler options to 1.5 for the given project. * * @param project * the java project */ public static void set15CompilerOptions(IJavaProject project) { @SuppressWarnings("rawtypes") Map options = project.getOptions(false); JavaProjectHelper.set15CompilerOptions(options); project.setOptions(options); }
Example 9
Source File: WorkbenchTestHelper.java From xtext-xtend with Eclipse Public License 2.0 | 5 votes |
public static void makeCompliantFor(IJavaProject javaProject, JavaVersion javaVersion) { Map<String, String> options= javaProject.getOptions(false); String jreLevel = javaVersion.getQualifier(); options.put(JavaCore.COMPILER_COMPLIANCE, jreLevel); options.put(JavaCore.COMPILER_SOURCE, jreLevel); options.put(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, jreLevel); options.put(JavaCore.COMPILER_PB_ASSERT_IDENTIFIER, JavaCore.ERROR); options.put(JavaCore.COMPILER_PB_ENUM_IDENTIFIER, JavaCore.ERROR); options.put(JavaCore.COMPILER_CODEGEN_INLINE_JSR_BYTECODE, JavaCore.ENABLED); options.put(JavaCore.COMPILER_LOCAL_VARIABLE_ATTR, JavaCore.GENERATE); options.put(JavaCore.COMPILER_LINE_NUMBER_ATTR, JavaCore.GENERATE); options.put(JavaCore.COMPILER_SOURCE_FILE_ATTR, JavaCore.GENERATE); options.put(JavaCore.COMPILER_CODEGEN_UNUSED_LOCAL, JavaCore.PRESERVE); javaProject.setOptions(options); }
Example 10
Source File: PerformanceTestProjectSetup.java From xtext-xtend with Eclipse Public License 2.0 | 5 votes |
public static void makeJava8Compliant(IJavaProject javaProject) { Map<String, String> options= javaProject.getOptions(false); options.put(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_1_8); options.put(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_1_8); options.put(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, JavaCore.VERSION_1_8); options.put(JavaCore.COMPILER_PB_ASSERT_IDENTIFIER, JavaCore.ERROR); options.put(JavaCore.COMPILER_PB_ENUM_IDENTIFIER, JavaCore.ERROR); options.put(JavaCore.COMPILER_CODEGEN_INLINE_JSR_BYTECODE, JavaCore.ENABLED); options.put(JavaCore.COMPILER_LOCAL_VARIABLE_ATTR, JavaCore.GENERATE); options.put(JavaCore.COMPILER_LINE_NUMBER_ATTR, JavaCore.GENERATE); options.put(JavaCore.COMPILER_SOURCE_FILE_ATTR, JavaCore.GENERATE); options.put(JavaCore.COMPILER_CODEGEN_UNUSED_LOCAL, JavaCore.PRESERVE); javaProject.setOptions(options); }
Example 11
Source File: WorkbenchTestHelper.java From sarl with Apache License 2.0 | 5 votes |
/** Make the given project compliant for the given version. * * @param javaProject the project. * @param javaVersion the Java version. */ public static void makeCompliantFor(IJavaProject javaProject, JavaVersion javaVersion) { Map<String, String> options = javaProject.getOptions(false); String jreLevel; switch (javaVersion) { case JAVA8: jreLevel = JavaCore.VERSION_1_8; break; case JAVA6: jreLevel = JavaCore.VERSION_1_6; break; case JAVA5: jreLevel = JavaCore.VERSION_1_5; break; case JAVA7: default: jreLevel = JavaCore.VERSION_1_7; } options.put(JavaCore.COMPILER_COMPLIANCE, jreLevel); options.put(JavaCore.COMPILER_SOURCE, jreLevel); options.put(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, jreLevel); options.put(JavaCore.COMPILER_PB_ASSERT_IDENTIFIER, JavaCore.ERROR); options.put(JavaCore.COMPILER_PB_ENUM_IDENTIFIER, JavaCore.ERROR); options.put(JavaCore.COMPILER_CODEGEN_INLINE_JSR_BYTECODE, JavaCore.ENABLED); options.put(JavaCore.COMPILER_LOCAL_VARIABLE_ATTR, JavaCore.GENERATE); options.put(JavaCore.COMPILER_LINE_NUMBER_ATTR, JavaCore.GENERATE); options.put(JavaCore.COMPILER_SOURCE_FILE_ATTR, JavaCore.GENERATE); options.put(JavaCore.COMPILER_CODEGEN_UNUSED_LOCAL, JavaCore.PRESERVE); javaProject.setOptions(options); }