Java Code Examples for org.eclipse.core.resources.IMarker#SEVERITY_ERROR
The following examples show how to use
org.eclipse.core.resources.IMarker#SEVERITY_ERROR .
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: ProblemsLabelDecorator.java From Pydev with Eclipse Public License 1.0 | 6 votes |
@Override public void decorate(Object element, IDecoration decoration) { int errorState = getErrorState(element); if (errorState == IMarker.SEVERITY_ERROR) { decoration.addOverlay( ImageCache.asImageDescriptor( SharedUiPlugin.getImageCache().getDescriptor(UIConstants.ERROR_DECORATION)), IDecoration.BOTTOM_LEFT); } else if (errorState == IMarker.SEVERITY_WARNING) { decoration.addOverlay( ImageCache.asImageDescriptor( SharedUiPlugin.getImageCache().getDescriptor(UIConstants.WARNING_DECORATION)), IDecoration.BOTTOM_LEFT); } }
Example 2
Source File: ASTReader.java From JDeodorant with MIT License | 6 votes |
private List<IMarker> buildProject(IJavaProject iJavaProject, IProgressMonitor pm) { ArrayList<IMarker> result = new ArrayList<IMarker>(); try { IProject project = iJavaProject.getProject(); project.refreshLocal(IResource.DEPTH_INFINITE, pm); project.build(IncrementalProjectBuilder.INCREMENTAL_BUILD, pm); IMarker[] markers = null; markers = project.findMarkers(IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER, true, IResource.DEPTH_INFINITE); for (IMarker marker: markers) { Integer severityType = (Integer) marker.getAttribute(IMarker.SEVERITY); if (severityType.intValue() == IMarker.SEVERITY_ERROR) { result.add(marker); } } } catch (CoreException e) { e.printStackTrace(); } return result; }
Example 3
Source File: DerivedResourceMarkerCopier.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
private int getMaxSeverity(IFile srcFile) { URI resourceURI = URI.createPlatformResourceURI(srcFile.getFullPath().toString(), true); IResourceServiceProvider serviceProvider = serviceProviderRegistry.getResourceServiceProvider(resourceURI); if (serviceProvider == null) return Integer.MAX_VALUE; IssueSeveritiesProvider severitiesProvider = serviceProvider.get(IssueSeveritiesProvider.class); Severity severity = severitiesProvider.getIssueSeverities(new ResourceImpl(resourceURI)).getSeverity( COPY_JAVA_PROBLEMS_ISSUECODE); switch (severity) { case WARNING: return IMarker.SEVERITY_WARNING; case ERROR: return IMarker.SEVERITY_ERROR; case INFO: case IGNORE: return Integer.MAX_VALUE; default: break; } return Integer.MAX_VALUE; }
Example 4
Source File: ActiveAnnotationsInSameProjectTest.java From xtext-xtend with Eclipse Public License 2.0 | 6 votes |
public void assertHasErrors(final IFile file, final String msgPart) { try { final IMarker[] findMarkers = file.findMarkers(IMarker.PROBLEM, true, IResource.DEPTH_INFINITE); for (final IMarker iMarker : findMarkers) { { final String message = MarkerUtilities.getMessage(iMarker); if (((MarkerUtilities.getSeverity(iMarker) == IMarker.SEVERITY_ERROR) && message.contains(msgPart))) { return; } } } IPath _fullPath = file.getFullPath(); String _plus = ((("Expected an error marker containing \'" + msgPart) + "\' on ") + _fullPath); String _plus_1 = (_plus + " but found "); final Function1<IMarker, String> _function = (IMarker it) -> { return MarkerUtilities.getMessage(it); }; String _join = IterableExtensions.join(ListExtensions.<IMarker, String>map(((List<IMarker>)Conversions.doWrapArray(findMarkers)), _function), ","); String _plus_2 = (_plus_1 + _join); Assert.fail(_plus_2); } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }
Example 5
Source File: Problem.java From cppcheclipse with Apache License 2.0 | 6 votes |
public void deserializeNonFinalFields(String serialization) throws NoSuchElementException, IllegalArgumentException { StringTokenizer tokenizer = new StringTokenizer(serialization, DELIMITER); String token = tokenizer.nextToken(); boolean isEnabled = Boolean.parseBoolean(token); token = tokenizer.nextToken(); int severity = Integer.parseInt(token); // range check for severity if (severity < IMarker.SEVERITY_INFO || severity > IMarker.SEVERITY_ERROR) { throw new IllegalArgumentException( "Found invalid severity value of " + String.valueOf(severity)); } this.isEnabled = isEnabled; this.severity = ProblemSeverity.values()[severity]; }
Example 6
Source File: CrossflowMarkerNavigationProvider.java From scava with Eclipse Public License 2.0 | 6 votes |
/** * @generated */ public static IMarker addMarker(IFile file, String elementId, String location, String message, int statusSeverity) { IMarker marker = null; try { marker = file.createMarker(MARKER_TYPE); marker.setAttribute(IMarker.MESSAGE, message); marker.setAttribute(IMarker.LOCATION, location); marker.setAttribute(org.eclipse.gmf.runtime.common.ui.resources.IMarker.ELEMENT_ID, elementId); int markerSeverity = IMarker.SEVERITY_INFO; if (statusSeverity == IStatus.WARNING) { markerSeverity = IMarker.SEVERITY_WARNING; } else if (statusSeverity == IStatus.ERROR || statusSeverity == IStatus.CANCEL) { markerSeverity = IMarker.SEVERITY_ERROR; } marker.setAttribute(IMarker.SEVERITY, markerSeverity); } catch (CoreException e) { CrossflowDiagramEditorPlugin.getInstance().logError("Failed to create validation marker", e); //$NON-NLS-1$ } return marker; }
Example 7
Source File: BatchValidationOperation.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
private int toStatusSeverity(final int markerSeverity) { switch (markerSeverity) { case IMarker.SEVERITY_INFO: return IStatus.INFO; case IMarker.SEVERITY_WARNING: return IStatus.WARNING; case IMarker.SEVERITY_ERROR: return IStatus.ERROR; default: return IStatus.INFO; } }
Example 8
Source File: ResourceUtils.java From xds-ide with Eclipse Public License 1.0 | 5 votes |
public static int findMaxProblemSeverity(IResource[] resources, String type, boolean includeSubtypes, int depth) throws CoreException { int max = -1; for (IResource res : resources) { if (res.getProject().isOpen() && res.exists()) { max = Math.max(max, res.findMaxProblemSeverity(type, includeSubtypes, depth)); if (max >= IMarker.SEVERITY_ERROR) { break; } } } return max; }
Example 9
Source File: AnnotationIssueProcessor.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
protected int getMarkerSeverity(Severity severity) { switch (severity) { case ERROR: return IMarker.SEVERITY_ERROR; case WARNING: return IMarker.SEVERITY_WARNING; case INFO: return IMarker.SEVERITY_INFO; default: throw new IllegalArgumentException(); } }
Example 10
Source File: TopLevelFolder.java From gama with GNU General Public License v3.0 | 5 votes |
@Override public int findMaxProblemSeverity() { int severity = NO_PROBLEM; for (final WrappedProject p : children) { final int s = p.findMaxProblemSeverity(); if (s > severity) { severity = s; } if (severity == IMarker.SEVERITY_ERROR) { break; } } return severity; }
Example 11
Source File: JavaProjectBasedBuilderParticipant.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
protected boolean shouldGenerate(Resource resource, IBuildContext context) { try { Iterable<Pair<IStorage, IProject>> storages = storage2UriMapper.getStorages(resource.getURI()); for (Pair<IStorage, IProject> pair : storages) { if (pair.getFirst() instanceof IFile && pair.getSecond().equals(context.getBuiltProject())) { return((IFile) pair.getFirst()).findMaxProblemSeverity(null, true, IResource.DEPTH_INFINITE) != IMarker.SEVERITY_ERROR; } } return false; } catch (CoreException exc) { throw new WrappedException(exc); } }
Example 12
Source File: IDETypeScriptProject.java From typescript.java with MIT License | 5 votes |
private int getSeverity(DiagnosticCategory category) { switch (category) { case Message: return IMarker.SEVERITY_INFO; case Warning: return IMarker.SEVERITY_WARNING; default: return IMarker.SEVERITY_ERROR; } }
Example 13
Source File: ResolvingCrossReferenceDuringIndexingTest.java From xtext-xtend with Eclipse Public License 2.0 | 5 votes |
public void assertNoErrorsInWorkspace() { try { final IMarker[] findMarkers = ResourcesPlugin.getWorkspace().getRoot().findMarkers(IMarker.PROBLEM, true, IResource.DEPTH_INFINITE); for (final IMarker iMarker : findMarkers) { String _message = MarkerUtilities.getMessage(iMarker); int _severity = MarkerUtilities.getSeverity(iMarker); boolean _equals = (_severity == IMarker.SEVERITY_ERROR); Assert.assertFalse(_message, _equals); } } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }
Example 14
Source File: IDETypeScriptCompilerMessageHandler.java From typescript.java with MIT License | 5 votes |
private int getSeverity(Severity severity) { switch (severity) { case error: return IMarker.SEVERITY_ERROR; case info: return IMarker.SEVERITY_INFO; default: return IMarker.SEVERITY_WARNING; } }
Example 15
Source File: ProblemsLabelDecorator.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private int getPackageErrorTicksFromMarkers(IPackageFragment pack) throws CoreException { // Packages are special: They must not consider markers on subpackages. IResource res= pack.getResource(); if (res == null || !res.isAccessible()) { return 0; } // markers on package itself (e.g. missing @NonNullByDefault) int severity= res.findMaxProblemSeverity(IMarker.PROBLEM, true, IResource.DEPTH_ZERO); if (severity == IMarker.SEVERITY_ERROR) return ERRORTICK_ERROR; // markers on CUs for (ICompilationUnit cu : pack.getCompilationUnits()) { severity= Math.max(severity, cu.getResource().findMaxProblemSeverity(IMarker.PROBLEM, true, IResource.DEPTH_ZERO)); if (severity == IMarker.SEVERITY_ERROR) return ERRORTICK_ERROR; } // markers on files and folders for (Object object : pack.getNonJavaResources()) { if (object instanceof IResource) { IResource resource= (IResource) object; severity= Math.max(severity, resource.findMaxProblemSeverity(IMarker.PROBLEM, true, IResource.DEPTH_INFINITE)); if (severity == IMarker.SEVERITY_ERROR) return ERRORTICK_ERROR; } } // SEVERITY_ERROR already handled above if (severity == IMarker.SEVERITY_WARNING) { return ERRORTICK_WARNING; } return 0; }
Example 16
Source File: ProcessValidationDecoratorProvider.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
/** * @generated */ private Image getImage(int severity) { String imageName = ISharedImages.IMG_OBJS_ERROR_TSK; switch (severity) { case IMarker.SEVERITY_ERROR: imageName = ISharedImages.IMG_OBJS_ERROR_TSK; break; case IMarker.SEVERITY_WARNING: imageName = ISharedImages.IMG_OBJS_WARN_TSK; break; default: imageName = ISharedImages.IMG_OBJS_INFO_TSK; } return PlatformUI.getWorkbench().getSharedImages().getImage(imageName); }
Example 17
Source File: JarFileExportOperation.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
/** * Tells whether the given resource (or its children) have compile errors. * The method acts on the current build state and does not recompile. * * @param resource the resource to check for errors * @return <code>true</code> if the resource (and its children) are error free * @throws CoreException import org.eclipse.core.runtime.CoreException if there's a marker problem */ private boolean hasCompileErrors(IResource resource) throws CoreException { IMarker[] problemMarkers= resource.findMarkers(IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER, true, IResource.DEPTH_INFINITE); for (int i= 0; i < problemMarkers.length; i++) { if (problemMarkers[i].getAttribute(IMarker.SEVERITY, -1) == IMarker.SEVERITY_ERROR) return true; } return false; }
Example 18
Source File: AbstractBuildParticipant.java From APICloud-Studio with GNU General Public License v3.0 | 4 votes |
protected IProblem createError(String message, int lineNumber, int offset, int length, String sourcePath) { return new Problem(IMarker.SEVERITY_ERROR, message, offset, length, lineNumber, sourcePath); }
Example 19
Source File: JavaServletElement.java From google-cloud-eclipse with Apache License 2.0 | 4 votes |
public JavaServletElement(DocumentLocation start, int length) { super(MESSAGE, MARKERID, IMarker.SEVERITY_ERROR, IMessage.HIGH_SEVERITY, start, length, null /* No source quick fix */); }
Example 20
Source File: InternalBuilderTest.java From xtext-eclipse with Eclipse Public License 2.0 | 4 votes |
@Test public void test() throws CoreException, FileNotFoundException { System.out.println("JDT Version:" + JavaCore.getPlugin().getBundle().getVersion()); System.out.println("JDT UI Version:" + JavaPlugin.getDefault().getBundle().getVersion()); reportMemoryState("Starting build."); try { dumpMemoryIndex("Initial Memory Index state"); dumpDiskIndex(); clearJdtIndex(); dumpMemoryIndex("Memory Index state after clear disk"); dumpDiskIndex(); JavaModelManager.getIndexManager().resetIndex(new Path("/org.eclipse.xtext")); dumpMemoryIndex("Memory Index state after reset project"); dumpDiskIndex(); System.out.println("Saving index."); JavaModelManager.getIndexManager().saveIndexes(); dumpMemoryIndex("Memory Index state after save"); dumpDiskIndex(); setAutoBuild(true); waitForAutoBuild(); } finally { setAutoBuild(false); System.out.println("Stopping background indexing."); JavaModelManager.getIndexManager().shutdown(); clearJdtIndex(); reportMemoryState("Finished build."); } final IMarker[] markers = ResourcesPlugin.getWorkspace().getRoot() .findMarkers(IMarker.PROBLEM, true, IResource.DEPTH_INFINITE); List<String> errors = new ArrayList<String>(); for (IMarker marker : markers) { String msg = MarkerUtilities.getMessage(marker); if (MarkerUtilities.getSeverity(marker) == IMarker.SEVERITY_ERROR) { errors.add(msg + " in " + marker.getResource().getFullPath() + " line: " + MarkerUtilities.getLineNumber(marker)); } } List<String> top10; if (errors.size() > 10) { top10 = toList(take(errors, 10)); } else { top10 = errors; } assertTrue("Problems found (" + top10.size() + " of " + errors.size() + "): " + join(errors, ", "), errors.isEmpty()); }