List of usage examples for org.eclipse.jdt.core JavaCore COMPILER_PB_ENUM_IDENTIFIER
String COMPILER_PB_ENUM_IDENTIFIER
To view the source code for org.eclipse.jdt.core JavaCore COMPILER_PB_ENUM_IDENTIFIER.
Click Source Link
'enum'
Identifier. From source file:com.buglabs.dragonfly.ui.actions.ConvertProjectActionDelegate.java
License:Open Source License
public void run(IAction action) { Job job = new Job("Convert Project") { @Override//www . j av a 2 s. c o m protected IStatus run(IProgressMonitor monitor) { try { IJavaProject jproj = JavaCore.create(project); jproj.setOption(JavaCore.COMPILER_PB_ASSERT_IDENTIFIER, JavaCore.WARNING); jproj.setOption(JavaCore.COMPILER_PB_ENUM_IDENTIFIER, JavaCore.WARNING); IClasspathEntry[] importCP = jproj.getRawClasspath(); List cpl = new ArrayList(); IClasspathEntry jre = JavaCore.newContainerEntry(JavaRuntime.newDefaultJREContainerPath()); IClasspathEntry pde = JavaCore .newContainerEntry(new Path("org.eclipse.pde.core.requiredPlugins")); for (int i = 0; i < importCP.length; ++i) { String cpName = importCP[i].getPath().toString(); if (cpName.equals("com.buglabs.osgi.concierge.jdt.ConciergeClasspathContainerInitializer") || cpName.equals("com.buglabs.phoneme.personal.PhoneMEClasspathContainer") || cpName.equals( "com.buglabs.osgi.concierge.jdt.OSGiBundleClassPathContainerInitializer") || cpName.equals("org.eclipse.jdt.launching.JRE_CONTAINER")) { if (!cpl.contains(jre)) { cpl.add(jre); } if (!cpl.contains(pde)) { cpl.add(pde); } } else { System.out.println(cpName); cpl.add(importCP[i]); } } jproj.setRawClasspath((IClasspathEntry[]) cpl.toArray(new IClasspathEntry[cpl.size()]), monitor); ConciergeUtils.addNatureToProject(project, "org.eclipse.pde.PluginNature", monitor); ConciergeUtils.removeNatureFromProject(project, "com.buglabs.osgi.concierge.natures.ConciergeProjectNature", monitor); project.build(IncrementalProjectBuilder.CLEAN_BUILD, monitor); return Status.OK_STATUS; } catch (Exception e) { return new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Unable to convert BUG project.", e); } } }; job.schedule(); }
From source file:com.buglabs.dragonfly.ui.jobs.CreateBUGProjectJob.java
License:Open Source License
protected void execute(IProgressMonitor monitor) throws CoreException, InvocationTargetException, InterruptedException { IWorkspaceRoot wsroot = ResourcesPlugin.getWorkspace().getRoot(); IProject proj = wsroot.getProject(projInfo.getProjectName()); proj.create(monitor);/*from ww w.j a v a2 s .co m*/ proj.open(monitor); addNatures(proj, monitor); createBinFolder(proj, monitor); createSrcFolder(proj, monitor); setProjectClassPath(proj, monitor); createManifest(proj, monitor); if (projInfo.isGenerateActivator()) { generateActivator(monitor); } // Set the java version for BUG jvm compatibility IJavaProject jproj = JavaCore.create(getProject()); setJava16Options(jproj); jproj.setOption(JavaCore.COMPILER_PB_ASSERT_IDENTIFIER, JavaCore.WARNING); jproj.setOption(JavaCore.COMPILER_PB_ENUM_IDENTIFIER, JavaCore.WARNING); if (getBugProjectInfo().getOSGiServices().size() > 0 || getBugProjectInfo().getModuleServices().size() > 0) { if (getBugProjectInfo().isGenerateSeparateApplicationClass()) { createApplication(monitor); } } }
From source file:com.sabre.buildergenerator.TestHelper.java
License:Open Source License
/** * @param projectName name of the project * @param sourcePath e.g. "src"/*from ww w . j a va 2s . c o m*/ * @param javaVMVersion e.g. JavaCore.VERSION_1_6; null indicates default * @param targetPlatform e.g. JavaCore.VERSION_1_5; must not be null * @throws CoreException error * @throws JavaModelException error */ @SuppressWarnings("unchecked") public static IJavaProject createJavaProject(String projectName, String sourcePath, String javaVMVersion, String targetPlatform) throws CoreException, JavaModelException { // create project IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName); project.create(null); project.open(null); // create source folder IPath srcPath = new Path(sourcePath); IFolder srcFolder = project.getFolder(srcPath); srcFolder.create(true, true, null); // class path IClasspathEntry sourceEntry = JavaCore.newSourceEntry(project.getFullPath().append(srcPath)); IClasspathEntry[] jreLibrary = null; if (javaVMVersion != null) { vmType: for (IVMInstallType vmInstallType : JavaRuntime.getVMInstallTypes()) { for (IVMInstall vmInstall : vmInstallType.getVMInstalls()) { if (javaVMVersion.equals(((AbstractVMInstall) vmInstall).getJavaVersion())) { IPath containerPath = new Path(JavaRuntime.JRE_CONTAINER); IPath vmPath = containerPath.append(vmInstall.getVMInstallType().getId()) .append(vmInstall.getName()); jreLibrary = new IClasspathEntry[] { JavaCore.newContainerEntry(vmPath) }; break vmType; } } } } if (jreLibrary == null) { jreLibrary = PreferenceConstants.getDefaultJRELibrary(); } // create java project IJavaProject javaProject = JavaCore.create(project); IProjectDescription description = project.getDescription(); String[] natureIds = description.getNatureIds(); String[] newNatureIds = new String[natureIds.length + 1]; System.arraycopy(natureIds, 0, newNatureIds, 0, natureIds.length); newNatureIds[newNatureIds.length - 1] = JavaCore.NATURE_ID; description.setNatureIds(newNatureIds); project.setDescription(description, null); // create binary folder String binName = PreferenceConstants.getPreferenceStore().getString(PreferenceConstants.SRCBIN_BINNAME); IFolder binFolder = project.getFolder(binName); binFolder.create(IResource.FORCE | IResource.DERIVED, true, null); binFolder.setDerived(true); project.refreshLocal(IResource.DEPTH_INFINITE, null); // set project class path javaProject.setRawClasspath(merge(jreLibrary, new IClasspathEntry[] { sourceEntry }), binFolder.getFullPath(), null); // set options Map<String, String> options = javaProject.getOptions(true); options.put(JavaCore.COMPILER_COMPLIANCE, targetPlatform); options.put(JavaCore.COMPILER_SOURCE, targetPlatform); options.put(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, targetPlatform); options.put(JavaCore.COMPILER_PB_ASSERT_IDENTIFIER, JavaCore.ERROR); options.put(JavaCore.COMPILER_PB_ENUM_IDENTIFIER, JavaCore.ERROR); javaProject.setOptions(options); return javaProject; }
From source file:com.siteview.mde.internal.core.builders.BuildErrorReporter.java
License:Open Source License
/** * Matches the javacWarnings and javacErrors entries in build.properties with the * project specific Java compliance properties and reports the errors found. Since java * compiler settings are set on a per project basis, any special javacWarnings/javacErrors * must be set for each library.//from www .j a va 2 s. com * * @param complianceLevel the compliance level to check settings against, used to get default values * @param javacWarningsEntries list of build entries with the java compiler warnings prefix javacWarnings. * @param javacErrorsEntries list of build entries with the java compiler errors prefix javacErrors. * @param libraryNames list of String library names */ private void checkJavaComplianceSettings(String complianceLevel, ArrayList javacWarningsEntries, ArrayList javacErrorsEntries, List libraryNames) { List complianceWarnSettings = new ArrayList(3); List complianceErrorSettings = new ArrayList(3); IJavaProject project = JavaCore.create(fProject); if (project.exists()) { Map defaultComplianceOptions = new HashMap(); JavaCore.setComplianceOptions(complianceLevel, defaultComplianceOptions); //look for assertIdentifier and enumIdentifier entries in javacWarnings. If any is present let it be, if not warn. String assertIdentifier = project.getOption(JavaCore.COMPILER_PB_ASSERT_IDENTIFIER, false); String defaultAssert = (String) defaultComplianceOptions.get(JavaCore.COMPILER_PB_ASSERT_IDENTIFIER); if (assertIdentifier != null && !assertIdentifier.equalsIgnoreCase(defaultAssert)) { if (JavaCore.ERROR.equalsIgnoreCase(assertIdentifier)) { complianceErrorSettings.add(ASSERT_IDENTIFIER); } else if (JavaCore.WARNING.equalsIgnoreCase(assertIdentifier)) { complianceWarnSettings.add(ASSERT_IDENTIFIER); } } String enumIdentifier = project.getOption(JavaCore.COMPILER_PB_ENUM_IDENTIFIER, false); String defaultEnum = (String) defaultComplianceOptions.get(JavaCore.COMPILER_PB_ENUM_IDENTIFIER); if (enumIdentifier != null && !enumIdentifier.equalsIgnoreCase(defaultEnum)) { if (JavaCore.ERROR.equalsIgnoreCase(enumIdentifier)) { complianceErrorSettings.add(ENUM_IDENTIFIER); } else if (JavaCore.WARNING.equalsIgnoreCase(enumIdentifier)) { complianceWarnSettings.add(ENUM_IDENTIFIER); } } // If a warnings entry is required, make sure there is one for each library with the correct content if (complianceWarnSettings.size() > 0) { for (Iterator iterator = libraryNames.iterator(); iterator.hasNext();) { String libName = (String) iterator.next(); IBuildEntry matchingEntry = null; for (Iterator iterator2 = javacWarningsEntries.iterator(); iterator2.hasNext();) { IBuildEntry candidate = (IBuildEntry) iterator2.next(); if (candidate.getName().equals(PROPERTY_JAVAC_WARNINGS_PREFIX + libName)) { matchingEntry = candidate; break; } } if (matchingEntry == null) { String missingTokens = ""; //$NON-NLS-1$ for (Iterator iterator2 = complianceWarnSettings.iterator(); iterator2.hasNext();) { String currentIdentifier = (String) iterator2.next(); missingTokens = join(missingTokens, '-' + currentIdentifier); } String message = NLS.bind( MDECoreMessages.BuildErrorReporter_ProjectSpecificJavaComplianceMissingEntry, PROPERTY_JAVAC_WARNINGS_PREFIX + libName); prepareError(PROPERTY_JAVAC_WARNINGS_PREFIX + libName, missingTokens, message, MDEMarkerFactory.B_JAVA_ADDDITION, fJavaComplianceSeverity, MDEMarkerFactory.CAT_EE); } else { String missingTokens = ""; //$NON-NLS-1$ for (Iterator iterator2 = complianceWarnSettings.iterator(); iterator2.hasNext();) { String currentIdentifier = (String) iterator2.next(); if (!matchingEntry.contains(currentIdentifier) && !matchingEntry.contains('+' + currentIdentifier) && !matchingEntry.contains('-' + currentIdentifier)) { join(missingTokens, '-' + currentIdentifier); } } if (missingTokens.length() > 0) { String message = NLS.bind( MDECoreMessages.BuildErrorReporter_ProjectSpecificJavaComplianceDifferentToken, PROPERTY_JAVAC_WARNINGS_PREFIX + libName); prepareError(PROPERTY_JAVAC_WARNINGS_PREFIX + libName, missingTokens, message, MDEMarkerFactory.B_JAVA_ADDDITION, fJavaComplianceSeverity, MDEMarkerFactory.CAT_EE); } } } } // If a warnings entry is required, make sure there is one for each library with the correct content if (complianceErrorSettings.size() > 0) { for (Iterator iterator = libraryNames.iterator(); iterator.hasNext();) { String libName = (String) iterator.next(); IBuildEntry matchingEntry = null; for (Iterator iterator2 = javacErrorsEntries.iterator(); iterator2.hasNext();) { IBuildEntry candidate = (IBuildEntry) iterator2.next(); if (candidate.getName().equals(PROPERTY_JAVAC_ERRORS_PREFIX + libName)) { matchingEntry = candidate; break; } } if (matchingEntry == null) { String missingTokens = ""; //$NON-NLS-1$ for (Iterator iterator2 = complianceErrorSettings.iterator(); iterator2.hasNext();) { String currentIdentifier = (String) iterator2.next(); missingTokens = join(missingTokens, '-' + currentIdentifier); } String message = NLS.bind( MDECoreMessages.BuildErrorReporter_ProjectSpecificJavaComplianceMissingEntry, PROPERTY_JAVAC_ERRORS_PREFIX + libName); prepareError(PROPERTY_JAVAC_ERRORS_PREFIX + libName, missingTokens, message, MDEMarkerFactory.B_JAVA_ADDDITION, fJavaComplianceSeverity, MDEMarkerFactory.CAT_EE); } else { String missingTokens = ""; //$NON-NLS-1$ for (Iterator iterator2 = complianceErrorSettings.iterator(); iterator2.hasNext();) { String currentIdentifier = (String) iterator2.next(); if (!matchingEntry.contains(currentIdentifier) && !matchingEntry.contains('+' + currentIdentifier) && !matchingEntry.contains('-' + currentIdentifier)) { missingTokens = join(missingTokens, '-' + currentIdentifier); } } if (missingTokens.length() > 0) { String message = NLS.bind( MDECoreMessages.BuildErrorReporter_ProjectSpecificJavaComplianceDifferentToken, PROPERTY_JAVAC_ERRORS_PREFIX + libName); prepareError(PROPERTY_JAVAC_ERRORS_PREFIX + libName, missingTokens, message, MDEMarkerFactory.B_JAVA_ADDDITION, fJavaComplianceSeverity, MDEMarkerFactory.CAT_EE); } } } } } }
From source file:com.siteview.mde.internal.core.ClasspathComputer.java
License:Open Source License
/** * Sets compiler compliance options on the given project to match the default compliance settings * for the specified execution environment. Only sets options that do not already have an explicit * setting based on the given override flag. * <p>/*w w w.j a v a 2 s . co m*/ * If the specified execution environment is <code>null</code> and override is <code>true</code>, * all compliance options are removed from the options map before applying to the project. * </p> * @param project project to set compiler compliance options for * @param eeId execution environment identifier, or <code>null</code> * @param overrideExisting whether to override a setting if already present */ public static void setComplianceOptions(IJavaProject project, String eeId, boolean overrideExisting) { Map projectMap = project.getOptions(false); IExecutionEnvironment ee = null; Map options = null; if (eeId != null) { ee = JavaRuntime.getExecutionEnvironmentsManager().getEnvironment(eeId); if (ee != null) { options = ee.getComplianceOptions(); } } if (options == null) { if (overrideExisting && projectMap.size() > 0) { projectMap.remove(JavaCore.COMPILER_COMPLIANCE); projectMap.remove(JavaCore.COMPILER_SOURCE); projectMap.remove(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM); projectMap.remove(JavaCore.COMPILER_PB_ASSERT_IDENTIFIER); projectMap.remove(JavaCore.COMPILER_PB_ENUM_IDENTIFIER); } else { return; } } else { String compliance = (String) options.get(JavaCore.COMPILER_COMPLIANCE); Iterator iterator = options.entrySet().iterator(); while (iterator.hasNext()) { Entry entry = (Entry) iterator.next(); String option = (String) entry.getKey(); String value = (String) entry.getValue(); if (JavaCore.VERSION_1_3.equals(compliance) || JavaCore.VERSION_1_4.equals(compliance)) { if (JavaCore.COMPILER_PB_ASSERT_IDENTIFIER.equals(option) || JavaCore.COMPILER_PB_ENUM_IDENTIFIER.equals(option)) { // for 1.3 & 1.4 projects, only override the existing setting if the default setting // is a greater severity than the existing setting setMinimumCompliance(projectMap, option, value, overrideExisting); } else { setCompliance(projectMap, option, value, overrideExisting); } } else { setCompliance(projectMap, option, value, overrideExisting); } } } project.setOptions(projectMap); }
From source file:io.sarl.tests.api.WorkbenchTestHelper.java
License:Apache License
/** Make the given project compliant for the given version. * * @param javaProject the project.//from w ww .j av a 2 s .c o m * @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); }
From source file:org.eclipse.jst.j2ee.internal.common.operations.JavaModelUtil.java
License:Open Source License
public static void setCompilanceOptions(Map map, String compliance) { if (JavaCore.VERSION_1_6.equals(compliance)) { map.put(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_1_6); map.put(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_1_6); map.put(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, JavaCore.VERSION_1_6); map.put(JavaCore.COMPILER_PB_ASSERT_IDENTIFIER, JavaCore.ERROR); map.put(JavaCore.COMPILER_PB_ENUM_IDENTIFIER, JavaCore.ERROR); } else if (JavaCore.VERSION_1_5.equals(compliance)) { map.put(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_1_5); map.put(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_1_5); map.put(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, JavaCore.VERSION_1_5); map.put(JavaCore.COMPILER_PB_ASSERT_IDENTIFIER, JavaCore.ERROR); map.put(JavaCore.COMPILER_PB_ENUM_IDENTIFIER, JavaCore.ERROR); } else if (JavaCore.VERSION_1_4.equals(compliance)) { map.put(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_1_4); map.put(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_1_3); map.put(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, JavaCore.VERSION_1_2); map.put(JavaCore.COMPILER_PB_ASSERT_IDENTIFIER, JavaCore.WARNING); map.put(JavaCore.COMPILER_PB_ENUM_IDENTIFIER, JavaCore.WARNING); } else if (JavaCore.VERSION_1_3.equals(compliance)) { map.put(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_1_3); map.put(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_1_3); map.put(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, JavaCore.VERSION_1_1); map.put(JavaCore.COMPILER_PB_ASSERT_IDENTIFIER, JavaCore.IGNORE); map.put(JavaCore.COMPILER_PB_ENUM_IDENTIFIER, JavaCore.IGNORE); } else {// w ww . j a v a2 s.c o m throw new IllegalArgumentException("Unsupported compliance: " + compliance); //$NON-NLS-1$ } }
From source file:org.eclipse.jst.j2ee.internal.project.WTPJETEmitter.java
License:Open Source License
/** * @param progressMonitor/* www . j av a2s . co m*/ * @param project * @param javaProject * @throws CoreException * @throws JavaModelException * @throws BackingStoreException */ protected void initializeJavaProject(IProgressMonitor progressMonitor, final IProject project, IJavaProject javaProject) throws CoreException, JavaModelException, BackingStoreException { progressMonitor.subTask(CodeGenPlugin.getPlugin().getString("_UI_JETInitializingProject_message", //$NON-NLS-1$ new Object[] { project.getName() })); IClasspathEntry classpathEntry = JavaCore.newSourceEntry(new Path("/" + project.getName() + "/src")); //$NON-NLS-1$ //$NON-NLS-2$ //IClasspathEntry jreClasspathEntry = JavaCore.newVariableEntry(new Path(JavaRuntime.JRELIB_VARIABLE), new Path(JavaRuntime.JRESRC_VARIABLE), new Path(JavaRuntime.JRESRCROOT_VARIABLE)); IClasspathEntry jreClasspathEntry = JavaRuntime.getDefaultJREContainerEntry(); List classpath = new ArrayList(); classpath.add(classpathEntry); classpath.add(jreClasspathEntry); classpath.addAll(classpathEntries); IFolder sourceFolder = project.getFolder(new Path("src")); //$NON-NLS-1$ if (!sourceFolder.exists()) { sourceFolder.create(false, true, new SubProgressMonitor(progressMonitor, 1)); } IFolder runtimeFolder = project.getFolder(new Path("runtime")); //$NON-NLS-1$ if (!runtimeFolder.exists()) { runtimeFolder.create(false, true, new SubProgressMonitor(progressMonitor, 1)); } IClasspathEntry[] classpathEntryArray = (IClasspathEntry[]) classpath .toArray(new IClasspathEntry[classpath.size()]); javaProject.setRawClasspath(classpathEntryArray, new SubProgressMonitor(progressMonitor, 1)); javaProject.setOutputLocation(new Path("/" + project.getName() + "/runtime"), //$NON-NLS-1$//$NON-NLS-2$ new SubProgressMonitor(progressMonitor, 1)); // appended from previous implementation createClasspathEntries(project); IScopeContext context = new ProjectScope(project); IEclipsePreferences prefs = context.getNode(JavaCore.PLUGIN_ID); prefs.put(JavaCore.COMPILER_PB_RAW_TYPE_REFERENCE, JavaCore.IGNORE); prefs.put(JavaCore.COMPILER_PB_UNCHECKED_TYPE_OPERATION, JavaCore.IGNORE); // set Java compiler compliance level to 1.5 prefs.put(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_1_5); prefs.put(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, JavaCore.VERSION_1_5); prefs.put(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_1_5); prefs.put(JavaCore.COMPILER_PB_ASSERT_IDENTIFIER, JavaCore.ERROR); prefs.put(JavaCore.COMPILER_PB_ENUM_IDENTIFIER, JavaCore.ERROR); // set Javadoc validation to the default ignore level prefs.put(JavaCore.COMPILER_PB_INVALID_JAVADOC, JavaCore.IGNORE); prefs.put(JavaCore.COMPILER_PB_INVALID_JAVADOC_TAGS, JavaCore.DISABLED); prefs.put(JavaCore.COMPILER_PB_INVALID_JAVADOC_TAGS__DEPRECATED_REF, JavaCore.DISABLED); prefs.put(JavaCore.COMPILER_PB_INVALID_JAVADOC_TAGS__NOT_VISIBLE_REF, JavaCore.DISABLED); prefs.put(JavaCore.COMPILER_PB_INVALID_JAVADOC_TAGS_VISIBILITY, JavaCore.PUBLIC); prefs.put(JavaCore.COMPILER_PB_MISSING_JAVADOC_TAG_DESCRIPTION, JavaCore.COMPILER_PB_MISSING_JAVADOC_TAG_DESCRIPTION_RETURN_TAG); prefs.put(JavaCore.COMPILER_PB_MISSING_JAVADOC_TAGS, JavaCore.IGNORE); prefs.put(JavaCore.COMPILER_PB_MISSING_JAVADOC_TAGS_VISIBILITY, JavaCore.PUBLIC); prefs.put(JavaCore.COMPILER_PB_MISSING_JAVADOC_TAGS_OVERRIDING, JavaCore.DISABLED); prefs.put(JavaCore.COMPILER_PB_MISSING_JAVADOC_COMMENTS, JavaCore.IGNORE); prefs.put(JavaCore.COMPILER_PB_MISSING_JAVADOC_COMMENTS_VISIBILITY, JavaCore.PUBLIC); prefs.put(JavaCore.COMPILER_PB_MISSING_JAVADOC_COMMENTS_OVERRIDING, JavaCore.DISABLED); // store changed properties permanently prefs.flush(); }
From source file:org.eclipse.m2m.internal.qvt.oml.ui.wizards.project.NewProjectCreationOperation.java
License:Open Source License
@SuppressWarnings("unchecked") private static void setComplianceOptions(IJavaProject project, String eeId, boolean overrideExisting) { Map<String, String> projectMap = project.getOptions(false); IExecutionEnvironment ee = null;//w w w . j a v a2s . c o m Map<String, String> options = null; if (eeId != null) { ee = JavaRuntime.getExecutionEnvironmentsManager().getEnvironment(eeId); if (ee != null) { options = ee.getComplianceOptions(); } } if (options == null) { if (overrideExisting && projectMap.size() > 0) { projectMap.remove(JavaCore.COMPILER_COMPLIANCE); projectMap.remove(JavaCore.COMPILER_SOURCE); projectMap.remove(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM); projectMap.remove(JavaCore.COMPILER_PB_ASSERT_IDENTIFIER); projectMap.remove(JavaCore.COMPILER_PB_ENUM_IDENTIFIER); } else { return; } } else { String compliance = options.get(JavaCore.COMPILER_COMPLIANCE); Iterator<?> iterator = options.entrySet().iterator(); while (iterator.hasNext()) { Entry<?, ?> entry = (Entry<?, ?>) iterator.next(); String option = (String) entry.getKey(); String value = (String) entry.getValue(); if (JavaCore.VERSION_1_3.equals(compliance) || JavaCore.VERSION_1_4.equals(compliance)) { if (JavaCore.COMPILER_PB_ASSERT_IDENTIFIER.equals(option) || JavaCore.COMPILER_PB_ENUM_IDENTIFIER.equals(option)) { // for 1.3 & 1.4 projects, only override the existing setting if the default setting // is a greater severity than the existing setting setMinimumCompliance(projectMap, option, value, overrideExisting); } else { setCompliance(projectMap, option, value, overrideExisting); } } else { setCompliance(projectMap, option, value, overrideExisting); } } } project.setOptions(projectMap); }
From source file:org.eclipse.objectteams.otdt.core.ext.OTREContainer.java
License:Open Source License
/** * Adds the ObjectTeams classes to the given JavaProject's classpath, * and ensures the Java compliance is >= 1.5 * Handles both variants, OTRE and OTDRE. *//*from ww w . jav a 2s. c o m*/ public static void initializeOTJProject(IProject project) throws CoreException { if (project == null) { return; } if (project.hasNature(JavaCore.NATURE_ID)) { IJavaProject javaPrj = (IJavaProject) project.getNature(JavaCore.NATURE_ID); IClasspathEntry[] classpath = javaPrj.getRawClasspath(); if (!isOTREAlreadyInClasspath(classpath)) { addOTREToClasspath(javaPrj, classpath); } String javaVersion = javaPrj.getOption(JavaCore.COMPILER_COMPLIANCE, true); if (javaVersion.compareTo(JavaCore.VERSION_1_5) < 0) { javaPrj.setOption(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_1_5); javaPrj.setOption(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_1_5); javaPrj.setOption(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, JavaCore.VERSION_1_5); javaPrj.setOption(JavaCore.COMPILER_PB_ASSERT_IDENTIFIER, JavaCore.ERROR); javaPrj.setOption(JavaCore.COMPILER_PB_ENUM_IDENTIFIER, JavaCore.ERROR); javaPrj.setOption(JavaCore.COMPILER_CODEGEN_INLINE_JSR_BYTECODE, JavaCore.ENABLED); } } }