List of usage examples for org.eclipse.jdt.core JavaCore WARNING
String WARNING
To view the source code for org.eclipse.jdt.core JavaCore WARNING.
Click Source Link
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//from w w w . ja v a2 s . co 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 w w w .ja v a2s. c o 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.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.// w w w . j a va2 s.c o m * * @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
/** * Checks if the current value stored in the map is less severe than the given minimum value. If * the minimum value is higher, the map will be updated with the minimum. If the minimum value * is <code>null</code>, the existing value remains. * /*from w ww. j a v a2s.c o m*/ * @param map the map to check the value in * @param key the key to get the current value out of the map * @param minimumValue the minimum value allowed or <code>null</code> * @param override whether an existing value in the map should be replaced */ private static void setMinimumCompliance(Map map, String key, String minimumValue, boolean override) { if (minimumValue != null && (override || !map.containsKey(key))) { if (fSeverityTable == null) { fSeverityTable = new HashMap(3); fSeverityTable.put(JavaCore.IGNORE, new Integer(SEVERITY_IGNORE)); fSeverityTable.put(JavaCore.WARNING, new Integer(SEVERITY_WARNING)); fSeverityTable.put(JavaCore.ERROR, new Integer(SEVERITY_ERROR)); } String currentValue = (String) map.get(key); int current = currentValue != null && fSeverityTable.containsKey(currentValue) ? ((Integer) fSeverityTable.get(currentValue)).intValue() : 0; int minimum = minimumValue != null && fSeverityTable.containsKey(minimumValue) ? ((Integer) fSeverityTable.get(minimumValue)).intValue() : 0; if (current < minimum) { map.put(key, minimumValue); } } }
From source file:in.software.analytics.parichayana.core.internal.preferences.ParichayanaPreferencesInitializer.java
License:Open Source License
@Override public void initializeDefaultPreferences() { IEclipsePreferences preferences = DefaultScope.INSTANCE.getNode(ParichayanaActivator.PLUGIN_ID); preferences.putBoolean(Constants.ENABLE_PARICHAYANA, true); preferences.put(Constants.TEST_PSTE, JavaCore.WARNING); preferences.put(Constants.TEST_LGTE, JavaCore.WARNING); preferences.put(Constants.TEST_LGRN, JavaCore.WARNING); preferences.put(Constants.TEST_PSRN, JavaCore.WARNING); preferences.put(Constants.TEST_MLLM, JavaCore.WARNING); preferences.put(Constants.TEST_RNHR, JavaCore.WARNING); preferences.put(Constants.TEST_THGE, JavaCore.WARNING); preferences.put(Constants.TEST_WEPG, JavaCore.WARNING); preferences.put(Constants.TEST_RRGC, JavaCore.WARNING); preferences.put(Constants.TEST_INEE, JavaCore.WARNING); preferences.put(Constants.TEST_LGFT, JavaCore.WARNING); preferences.put(Constants.TEST_CNPE, JavaCore.WARNING); preferences.put(Constants.TEST_TNPE, JavaCore.WARNING); preferences.put(Constants.TEST_CTGE, JavaCore.WARNING); preferences.put(Constants.INCLUDE_EXPRESSION, ""); preferences.put(Constants.EXCLUDE_EXPRESSION, ""); }
From source file:net.sf.j2s.core.builder.AbstractImageBuilder.java
License:Open Source License
protected void createProblemFor(IResource resource, IMember javaElement, String message, String problemSeverity) { try {/*from www . j a va2s. co m*/ IMarker marker = resource.createMarker(IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER); int severity = problemSeverity.equals(JavaCore.WARNING) ? IMarker.SEVERITY_WARNING : IMarker.SEVERITY_ERROR; ISourceRange range = null; if (javaElement != null) { try { range = javaElement.getNameRange(); } catch (JavaModelException e) { if (e.getJavaModelStatus().getCode() != IJavaModelStatusConstants.ELEMENT_DOES_NOT_EXIST) { throw e; } if (!CharOperation.equals(javaElement.getElementName().toCharArray(), TypeConstants.PACKAGE_INFO_NAME)) { throw e; } // else silently swallow the exception as the synthetic interface type package-info has no // source range really. See https://bugs.eclipse.org/bugs/show_bug.cgi?id=258145 } } int start = range == null ? 0 : range.getOffset(); int end = range == null ? 1 : start + range.getLength(); marker.setAttributes( new String[] { IMarker.MESSAGE, IMarker.SEVERITY, IMarker.CHAR_START, IMarker.CHAR_END, IMarker.SOURCE_ID }, new Object[] { message, new Integer(severity), new Integer(start), new Integer(end), JavaBuilder.SOURCE_ID }); } catch (CoreException e) { throw internalException(e); } }
From source file:net.sf.j2s.core.builder.JavaBuilder.java
License:Open Source License
private boolean isWorthBuilding() throws CoreException { boolean abortBuilds = JavaCore.ABORT .equals(this.javaProject.getOption(JavaCore.CORE_JAVA_BUILD_INVALID_CLASSPATH, true)); if (!abortBuilds) return true; // Abort build only if there are classpath errors if (isClasspathBroken(this.javaProject.getRawClasspath(), this.currentProject)) { if (DEBUG) System.out.println(//from w w w .j a v a 2s . com "JavaBuilder: Aborted build because project has classpath errors (incomplete or involved in cycle)"); //$NON-NLS-1$ removeProblemsAndTasksFor(this.currentProject); // remove all compilation problems IMarker marker = this.currentProject.createMarker(IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER); marker.setAttributes( new String[] { IMarker.MESSAGE, IMarker.SEVERITY, IJavaModelMarker.CATEGORY_ID, IMarker.SOURCE_ID }, new Object[] { Messages.build_abortDueToClasspathProblems, new Integer(IMarker.SEVERITY_ERROR), new Integer(CategorizedProblem.CAT_BUILDPATH), JavaBuilder.SOURCE_ID }); return false; } if (JavaCore.WARNING.equals(this.javaProject.getOption(JavaCore.CORE_INCOMPLETE_CLASSPATH, true))) return true; // make sure all prereq projects have valid build states... only when aborting builds since projects in cycles do not have build states // except for projects involved in a 'warning' cycle (see below) IProject[] requiredProjects = getRequiredProjects(false); for (int i = 0, l = requiredProjects.length; i < l; i++) { IProject p = requiredProjects[i]; if (getLastState(p) == null) { // The prereq project has no build state: if this prereq project has a 'warning' cycle marker then allow build (see bug id 23357) JavaProject prereq = (JavaProject) JavaCore.create(p); if (prereq.hasCycleMarker() && JavaCore.WARNING .equals(this.javaProject.getOption(JavaCore.CORE_CIRCULAR_CLASSPATH, true))) { if (DEBUG) System.out .println("JavaBuilder: Continued to build even though prereq project " + p.getName() //$NON-NLS-1$ + " was not built since its part of a cycle"); //$NON-NLS-1$ continue; } if (!hasJavaBuilder(p)) { if (DEBUG) System.out .println("JavaBuilder: Continued to build even though prereq project " + p.getName() //$NON-NLS-1$ + " is not built by JavaBuilder"); //$NON-NLS-1$ continue; } if (DEBUG) System.out.println("JavaBuilder: Aborted build because prereq project " + p.getName() //$NON-NLS-1$ + " was not built"); //$NON-NLS-1$ removeProblemsAndTasksFor(this.currentProject); // make this the only problem for this project IMarker marker = this.currentProject.createMarker(IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER); marker.setAttributes( new String[] { IMarker.MESSAGE, IMarker.SEVERITY, IJavaModelMarker.CATEGORY_ID, IMarker.SOURCE_ID }, new Object[] { isClasspathBroken(prereq.getRawClasspath(), p) ? Messages.bind(Messages.build_prereqProjectHasClasspathProblems, p.getName()) : Messages.bind(Messages.build_prereqProjectMustBeRebuilt, p.getName()), new Integer(IMarker.SEVERITY_ERROR), new Integer(CategorizedProblem.CAT_BUILDPATH), JavaBuilder.SOURCE_ID }); return false; } } return true; }
From source file:org.eclipse.ajdt.ui.tests.preferences.AJCompilerPreferencePageTest.java
License:Open Source License
public void testNewXlintOptions() throws Exception { IPreferenceStore preferenceStore = AspectJUIPlugin.getDefault().getPreferenceStore(); try {//from ww w. j a v a 2s.c o m // Use a logger to which we have access TestLogger testLog = new TestLogger(); AspectJPlugin.getDefault().setAJLogger(testLog); /* * These projects are only used for this test, so it seems * misleading and pointless to initialise them in setup. */ createPredefinedProject("ThirdPartyLibrary"); //$NON-NLS-1$ IProject userLibraryProject = createPredefinedProject("UserLibrary"); //$NON-NLS-1$ createPredefinedProject("UserLibraryAspects"); //$NON-NLS-1$ // 1. Check for expected error marker - default checkProjectForExpectedMarker(userLibraryProject, IMarker.SEVERITY_ERROR, "[Xlint:cantFindType]"); //$NON-NLS-1$ /* * 2. Change AspectJ Compiler Preferences Change them in the store * as this is what the code does - I guess we really want to change * the preferences via the GUI, but that's on the 'To Do' list... * -spyoung */ preferenceStore.setValue(AspectJPreferences.OPTION_cantFindType, JavaCore.WARNING); AJCompilerPreferencePage.initDefaults(preferenceStore); // Re-build from clean IWorkspace workspace = AspectJPlugin.getWorkspace(); workspace.build(IncrementalProjectBuilder.CLEAN_BUILD, null); waitForJobsToComplete(); // 3. Check for expected warning marker, post preferences change checkProjectForExpectedMarker(userLibraryProject, IMarker.SEVERITY_WARNING, "[Xlint:cantFindType]"); //$NON-NLS-1$ } finally { // 4. Tidy up state preferenceStore.setValue(AspectJPreferences.OPTION_cantFindType, JavaCore.ERROR); AJCompilerPreferencePage.initDefaults(preferenceStore); AspectJPlugin.getDefault().setAJLogger(null); } }
From source file:org.eclipse.che.jdt.quickfix.LocalCorrectionsQuickFixTest.java
License:Open Source License
@Override @Before//from w w w .j av a 2 s . c o m public void setUp() throws Exception { super.setUp(); Hashtable options = TestOptions.getDefaultOptions(); options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.SPACE); options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE, "4"); options.put(DefaultCodeFormatterConstants.FORMATTER_NUMBER_OF_EMPTY_LINES_TO_PRESERVE, String.valueOf(99)); options.put(JavaCore.COMPILER_PB_STATIC_ACCESS_RECEIVER, JavaCore.ERROR); options.put(JavaCore.COMPILER_PB_UNCHECKED_TYPE_OPERATION, JavaCore.IGNORE); options.put(JavaCore.COMPILER_PB_MISSING_HASHCODE_METHOD, JavaCore.WARNING); JavaCore.setOptions(options); IPreferenceStore store = JavaPlugin.getDefault().getPreferenceStore(); store.setValue(PreferenceConstants.CODEGEN_ADD_COMMENTS, false); StubUtility.setCodeTemplate(CodeTemplateContextType.CATCHBLOCK_ID, "", null); StubUtility.setCodeTemplate(CodeTemplateContextType.CONSTRUCTORSTUB_ID, "", null); StubUtility.setCodeTemplate(CodeTemplateContextType.METHODSTUB_ID, "", null); fJProject1 = ProjectTestSetup.getProject(); fSourceFolder = JavaProjectHelper.addSourceContainer(fJProject1, "src"); }
From source file:org.eclipse.che.jdt.quickfix.LocalCorrectionsQuickFixTest.java
License:Open Source License
@Test public void testRemoveDeadCodeIfThen() throws Exception { Hashtable options = JavaCore.getOptions(); options.put(JavaCore.COMPILER_PB_DEAD_CODE, JavaCore.WARNING); JavaCore.setOptions(options);/*from w w w. jav a 2 s .co 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 foo() {\n"); buf.append(" if (false) {\n"); buf.append(" System.out.println(\"a\");\n"); buf.append(" } else {\n"); buf.append(" System.out.println(\"b\");\n"); buf.append(" }\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, 2); assertCorrectLabels(proposals); CUCorrectionProposal proposal = (CUCorrectionProposal) proposals.get(0); String preview1 = getPreviewContent(proposal); buf = new StringBuffer(); buf.append("package test1;\n"); buf.append("public class E {\n"); buf.append(" public void foo() {\n"); buf.append(" System.out.println(\"b\");\n"); buf.append(" }\n"); buf.append("}\n"); String expected1 = buf.toString(); proposal = (CUCorrectionProposal) proposals.get(1); String preview2 = getPreviewContent(proposal); buf = new StringBuffer(); buf.append("package test1;\n"); buf.append("public class E {\n"); buf.append(" @SuppressWarnings(\"unused\")\n"); buf.append(" public void foo() {\n"); buf.append(" if (false) {\n"); buf.append(" System.out.println(\"a\");\n"); buf.append(" } else {\n"); buf.append(" System.out.println(\"b\");\n"); buf.append(" }\n"); buf.append(" }\n"); buf.append("}\n"); String expected2 = buf.toString(); assertEqualStringsIgnoreOrder(new String[] { preview1, preview2 }, new String[] { expected1, expected2 }); }