Java Code Examples for org.eclipse.ui.texteditor.MarkerUtilities#getSeverity()
The following examples show how to use
org.eclipse.ui.texteditor.MarkerUtilities#getSeverity() .
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: MarkerStatsView.java From eclipse-cs with GNU Lesser General Public License v2.1 | 6 votes |
@Override public Image getColumnImage(Object obj, int index) { Image image = null; IMarker marker = (IMarker) obj; if (index == 0) { int severity = MarkerUtilities.getSeverity(marker); ISharedImages sharedImages = PlatformUI.getWorkbench().getSharedImages(); if (IMarker.SEVERITY_ERROR == severity) { image = sharedImages.getImage(ISharedImages.IMG_OBJS_ERROR_TSK); } else if (IMarker.SEVERITY_WARNING == severity) { image = sharedImages.getImage(ISharedImages.IMG_OBJS_WARN_TSK); } else if (IMarker.SEVERITY_INFO == severity) { image = sharedImages.getImage(ISharedImages.IMG_OBJS_INFO_TSK); } } return image; }
Example 2
Source File: GraphStatsView.java From eclipse-cs with GNU Lesser General Public License v2.1 | 6 votes |
/** * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnImage(java.lang.Object, * int) */ @Override public Image getColumnImage(Object obj, int index) { Image image = null; IMarker marker = (IMarker) obj; if (index == 0) { int severity = MarkerUtilities.getSeverity(marker); ISharedImages sharedImages = PlatformUI.getWorkbench().getSharedImages(); if (IMarker.SEVERITY_ERROR == severity) { image = sharedImages.getImage(ISharedImages.IMG_OBJS_ERROR_TSK); } else if (IMarker.SEVERITY_WARNING == severity) { image = sharedImages.getImage(ISharedImages.IMG_OBJS_WARN_TSK); } else if (IMarker.SEVERITY_INFO == severity) { image = sharedImages.getImage(ISharedImages.IMG_OBJS_INFO_TSK); } } return image; }
Example 3
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 4
Source File: RebuildAffectedResourcesTest.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) { if (((MarkerUtilities.getSeverity(iMarker) == IMarker.SEVERITY_ERROR) && MarkerUtilities.getMessage(iMarker).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: PerformanceTest.java From xtext-xtend with Eclipse Public License 2.0 | 5 votes |
protected static void assertNoErrorsInWorkspace() throws CoreException { final IMarker[] markers = PerformanceTestProjectSetup.testProject.getProject().findMarkers(IMarker.PROBLEM, true, IResource.DEPTH_INFINITE); for (final IMarker marker : markers) { String _message = MarkerUtilities.getMessage(marker); int _severity = MarkerUtilities.getSeverity(marker); boolean _equals = (_severity == IMarker.SEVERITY_ERROR); Assert.assertFalse(_message, _equals); } }
Example 6
Source File: ActiveAnnotationsInSameProjectTest.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 7
Source File: JavaVersionSettingTest.java From xtext-xtend with Eclipse Public License 2.0 | 5 votes |
private void assertNoErrors(final IFile file) { try { final IMarker[] findMarkers = file.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 8
Source File: RebuildAffectedResourcesTest.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 9
Source File: Bug473833Test.java From xtext-xtend with Eclipse Public License 2.0 | 5 votes |
private void assertNoErrors(final IFile file) { try { final IMarker[] findMarkers = file.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 10
Source File: Bug452821Test.java From xtext-xtend with Eclipse Public License 2.0 | 5 votes |
private void assertNoErrors(final IFile file) { try { final IMarker[] findMarkers = file.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 11
Source File: CircularDepsBetweenJavaAndXtendTest.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 12
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 13
Source File: IResourcesSetupUtil.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
public static void assertNoErrorsInWorkspace() throws CoreException { IMarker[] findMarkers = root().findMarkers(IMarker.PROBLEM, true, IResource.DEPTH_INFINITE); String msg = ""; for (IMarker iMarker : findMarkers) { if (MarkerUtilities.getSeverity(iMarker) == IMarker.SEVERITY_ERROR) msg += "\n - "+iMarker.getResource().getName()+":"+MarkerUtilities.getLineNumber(iMarker)+" - "+MarkerUtilities.getMessage(iMarker) + "("+MarkerUtilities.getMarkerType(iMarker)+")"; } if (msg.length()>0) Assert.fail("Workspace contained errors: "+msg); }
Example 14
Source File: DerivedResourceMarkerCopier.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
/** * @return <code>true</code> if srcFile contains none-derived problem marker >= <code>maxSeverity</code> */ private boolean hasPlainXtextProblemMarker(IFile srcFile, int maxSeverity) throws CoreException { for (IMarker iMarker : srcFile.findMarkers(MarkerTypes.ANY_VALIDATION, true, IResource.DEPTH_ZERO)) { if (MarkerUtilities.getSeverity(iMarker) >= maxSeverity && iMarker.getAttribute(COPIED_FROM_FILE) == null) { return true; } } return false; }
Example 15
Source File: DerivedResourceMarkerCopier.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
private Set<IMarker> findJavaProblemMarker(IFile javaFile, int maxSeverity) throws CoreException { Set<IMarker> problems = newHashSet(); for (IMarker marker : javaFile.findMarkers(IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER, true, IResource.DEPTH_ZERO)) { if (MarkerUtilities.getSeverity(marker) >= maxSeverity) { problems.add(marker); } } return problems; }
Example 16
Source File: DerivedResourceMarkerCopier.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
private void copyProblemMarker(IFile javaFile, IEclipseTrace traceToSource, Set<IMarker> problemsInJava, IFile srcFile) throws CoreException { String sourceMarkerType = null; for (IMarker marker : problemsInJava) { String message = (String) marker.getAttribute(IMarker.MESSAGE); if (message == null) { continue; } Integer charStart = marker.getAttribute(IMarker.CHAR_START, 0); Integer charEnd = marker.getAttribute(IMarker.CHAR_END, 0); int severity = MarkerUtilities.getSeverity(marker); ILocationInEclipseResource associatedLocation = traceToSource.getBestAssociatedLocation(new TextRegion(charStart, charEnd - charStart)); if (associatedLocation != null) { if (sourceMarkerType == null) { sourceMarkerType = determinateMarkerTypeByURI(associatedLocation.getSrcRelativeResourceURI()); } if (!srcFile.equals(findIFile(associatedLocation, srcFile.getWorkspace()))) { LOG.error("File in associated location is not the same as main source file."); } IMarker xtendMarker = srcFile.createMarker(sourceMarkerType); xtendMarker.setAttribute(IMarker.MESSAGE, "Java problem: " + message); xtendMarker.setAttribute(IMarker.SEVERITY, severity); ITextRegionWithLineInformation region = associatedLocation.getTextRegion(); xtendMarker.setAttribute(IMarker.LINE_NUMBER, region.getLineNumber()); xtendMarker.setAttribute(IMarker.CHAR_START, region.getOffset()); xtendMarker.setAttribute(IMarker.CHAR_END, region.getOffset() + region.getLength()); xtendMarker.setAttribute(COPIED_FROM_FILE, javaFile.getFullPath().toString()); } } }
Example 17
Source File: IResourcesSetupUtil.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
public static void assertNoErrorsInWorkspace() throws CoreException { IMarker[] findMarkers = ResourcesPlugin.getWorkspace().getRoot().findMarkers(IMarker.PROBLEM, true, IResource.DEPTH_INFINITE); String msg = ""; for (IMarker iMarker : findMarkers) { if (MarkerUtilities.getSeverity(iMarker) == IMarker.SEVERITY_ERROR) msg += "\n - "+iMarker.getResource().getName()+":"+MarkerUtilities.getLineNumber(iMarker)+" - "+MarkerUtilities.getMessage(iMarker) + "("+MarkerUtilities.getMarkerType(iMarker)+")"; } if (msg.length()>0) Assert.fail("Workspace contained errors: "+msg); }
Example 18
Source File: MarkerStat.java From eclipse-cs with GNU Lesser General Public License v2.1 | 5 votes |
/** * Reference the marker as one fo this category. * * @param marker * : the marker to add to this category */ public void addMarker(IMarker marker) { mMarkers.add(marker); int severity = MarkerUtilities.getSeverity(marker); if (severity > mMaxSeverity) { mMaxSeverity = severity; } }
Example 19
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()); }