org.eclipse.ui.texteditor.MarkerUtilities Java Examples
The following examples show how to use
org.eclipse.ui.texteditor.MarkerUtilities.
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: MarkerIdentity.java From dsl-devkit with Eclipse Public License 1.0 | 6 votes |
/** * Instantiates a new MarkerIdentity. * * @param annotation * the Annotation * @return MarkerIdentity - this */ public MarkerIdentity create(final Annotation annotation) { MarkerIdentity result = provider.get(); if (annotation instanceof XtextAnnotation) { Issue issue = ((XtextAnnotation) annotation).getIssue(); result.start = issue.getOffset(); result.end = result.start == ATTRIBUTE_MISSING ? ATTRIBUTE_MISSING : result.start + issue.getLength(); result.message = issue.getMessage(); } else if (annotation instanceof org.eclipse.ui.texteditor.MarkerAnnotation) { result.start = MarkerUtilities.getCharStart(((org.eclipse.ui.texteditor.MarkerAnnotation) annotation).getMarker()); result.end = MarkerUtilities.getCharEnd(((org.eclipse.ui.texteditor.MarkerAnnotation) annotation).getMarker()); result.message = MarkerUtilities.getMessage(((org.eclipse.ui.texteditor.MarkerAnnotation) annotation).getMarker()); } else { result.end = ATTRIBUTE_MISSING; result.start = ATTRIBUTE_MISSING; result.message = null; // NOPMD } result.problemCode = issueUtil.getCode(annotation); result.problemURI = issueUtil.getUriToProblem(annotation); result.resourceURI = result.problemURI == null ? null : result.problemURI.trimFragment(); return result; }
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: XBookmarksDialogHandler.java From xds-ide with Eclipse Public License 1.0 | 6 votes |
protected XBookmarksDialog.Model.Row getDescription (IMarker marker) { if (marker!= null && marker.exists()) { int markerNumber = marker.getAttribute(XBookmarksPlugin.BOOKMARK_NUMBER_ATTR, -1); if (markerNumber >=0 && markerNumber <= 9) { int line = MarkerUtilities.getLineNumber(marker); String resName = marker.getResource().getName(); String markerName = MarkerUtilities.getMessage(marker); String prefix = mkBookmarkNamePrefix(markerNumber); if (markerName.startsWith(prefix)) { markerName = markerName.substring(prefix.length()); if (markerName.startsWith(": ")) { //$NON-NLS-1$ markerName = markerName.substring(2); } markerName = markerName.trim(); if (markerName.isEmpty()) { markerName = prefix; } } return new XBookmarksDialog.Model.Row(new String[]{ "" + markerNumber + "." //$NON-NLS-1$ //$NON-NLS-2$ , resName + ":" + line //$NON-NLS-1$ , markerName}).setData(markerNumber); } } return null; }
Example #6
Source File: AbstractProgramRunner.java From texlipse with Eclipse Public License 1.0 | 6 votes |
/** * Create a layout warning marker to the given resource. * * @param resource the file where the problem occurred * @param message error message * @param lineNumber line number * @param markerType * @param severity Severity of the error */ @SuppressWarnings("unchecked") protected static void createMarker(IResource resource, Integer lineNumber, String message, String markerType, int severity) { int lineNr = -1; if (lineNumber != null) { lineNr = lineNumber; } IMarker marker = AbstractProgramRunner.findMarker(resource, lineNr, message, markerType); if (marker == null) { try { HashMap map = new HashMap(); map.put(IMarker.MESSAGE, message); map.put(IMarker.SEVERITY, new Integer (severity)); if (lineNumber != null) map.put(IMarker.LINE_NUMBER, lineNumber); MarkerUtilities.createMarker(resource, map, markerType); } catch (CoreException e) { throw new RuntimeException(e); } } }
Example #7
Source File: MarkerHandler.java From texlipse with Eclipse Public License 1.0 | 6 votes |
/** * Creates warning markers for undefined references. * * @param editor The editor to add the errors to * @param errors The errors to add as instances of <code>DocumentReference</code> */ public void createReferencingErrorMarkers(ITextEditor editor, List<DocumentReference> errors) { IResource resource = (IResource) editor.getEditorInput().getAdapter(IResource.class); if (resource == null) return; IDocument document = editor.getDocumentProvider().getDocument(editor.getEditorInput()); for (DocumentReference msg : errors) { try { int beginOffset = document.getLineOffset(msg.getLine() - 1) + msg.getPos(); Map<String, ? super Object> map = new HashMap<String, Object>(); map.put(IMarker.LINE_NUMBER, Integer.valueOf(msg.getLine())); map.put(IMarker.CHAR_START, Integer.valueOf(beginOffset)); map.put(IMarker.CHAR_END, Integer.valueOf(beginOffset + msg.getLength())); map.put(IMarker.MESSAGE, "Key " + msg.getKey() + " is undefined"); map.put(IMarker.SEVERITY, Integer.valueOf(IMarker.SEVERITY_WARNING)); MarkerUtilities.createMarker(resource, map, IMarker.PROBLEM); } catch (CoreException ce) { TexlipsePlugin.log("Creating marker", ce); } catch (BadLocationException ble) { TexlipsePlugin.log("Creating marker", ble); } } }
Example #8
Source File: SootAttrJavaIconGenerator.java From JAADAS with GNU General Public License v3.0 | 6 votes |
public void addSootAttributeMarkers(){//SootAttributesHandler handler, IFile rec) { if (getHandler().getAttrList() == null) return; Iterator it = getHandler().getAttrList().iterator(); HashMap markerAttr = new HashMap(); while (it.hasNext()) { SootAttribute sa = (SootAttribute)it.next(); if (getHandler().isShowAllTypes() || typesContainsOneOf(sa.getAnalysisTypes())) { if (((sa.getAllTextAttrs("<br>") == null) || (sa.getAllTextAttrs("<br>").length() == 0)) && ((sa.getAllLinkAttrs() == null) || (sa.getAllLinkAttrs().size() ==0))) continue; markerAttr.put(IMarker.LINE_NUMBER, new Integer(sa.getJavaStartLn())); try { MarkerUtilities.createMarker(getRec(), markerAttr, "ca.mcgill.sable.soot.sootattributemarker"); } catch(CoreException e) { System.out.println(e.getMessage()); } } } }
Example #9
Source File: SootAttrJimpleIconGenerator.java From JAADAS with GNU General Public License v3.0 | 6 votes |
public void addSootAttributeMarkers(){//SootAttributesHandler handler, IFile rec) { if (getHandler().getAttrList() == null) return; Iterator it = getHandler().getAttrList().iterator(); HashMap markerAttr = new HashMap(); while (it.hasNext()) { SootAttribute sa = (SootAttribute)it.next(); if (getHandler().isShowAllTypes() || typesContainsOneOf(sa.getAnalysisTypes())){ if (((sa.getAllTextAttrs("") == null) || (sa.getAllTextAttrs("").length() == 0)) && ((sa.getAllLinkAttrs() == null) || (sa.getAllLinkAttrs().size() ==0))) continue; markerAttr.put(IMarker.LINE_NUMBER, new Integer(sa.getJimpleStartLn())); try { MarkerUtilities.createMarker(getRec(), markerAttr, "ca.mcgill.sable.soot.sootattributemarker"); } catch(CoreException e) { System.out.println(e.getMessage()); } } } }
Example #10
Source File: SootAttributesJavaHover.java From JAADAS with GNU General Public License v3.0 | 6 votes |
protected void addSootAttributeMarkers() { if (getAttrsHandler() == null)return; if (getAttrsHandler().getAttrList() == null) return; Iterator it = getAttrsHandler().getAttrList().iterator(); HashMap markerAttr = new HashMap(); while (it.hasNext()) { SootAttribute sa = (SootAttribute)it.next(); if (((sa.getAllTextAttrs("<br>") == null) || (sa.getAllTextAttrs("<br>").length() == 0)) && ((sa.getAllLinkAttrs() == null) || (sa.getAllLinkAttrs().size() ==0))) continue; markerAttr.put(IMarker.LINE_NUMBER, new Integer(sa.getJavaStartLn())); try { MarkerUtilities.createMarker(getRec(), markerAttr, "ca.mcgill.sable.soot.sootattributemarker"); } catch(CoreException e) { System.out.println(e.getMessage()); } } }
Example #11
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 #12
Source File: ProjectTestsUtils.java From n4js with Eclipse Public License 1.0 | 6 votes |
/***/ @SafeVarargs public static IMarker[] assertMarkers(String assertMessage, final IResource resource, String markerType, int count, final Predicate<IMarker>... markerPredicates) throws CoreException { IMarker[] markers = resource.findMarkers(markerType, true, IResource.DEPTH_INFINITE); List<IMarker> markerList = from(Arrays.asList(markers)) .filter(m -> allPredicatesApply(markerPredicates, m)) .toList(); if (markerList.size() != count) { StringBuilder message = new StringBuilder(assertMessage); message.append("\nbut was:"); for (IMarker marker : markerList) { message.append("\n"); message.append("line " + MarkerUtilities.getLineNumber(marker) + ": "); message.append(marker.getAttribute(IMarker.MESSAGE, "<no message>")); } Assert.assertEquals(message.toString(), count, markerList.size()); } return markers; }
Example #13
Source File: ImportedProjectNamePluginTest.java From n4js with Eclipse Public License 1.0 | 6 votes |
/** * Asserts that the given {@code resource} has at least one marker with the given {@code issueCode}. */ private static void assertHasMarker(IResource resource, String issueCode) throws CoreException { final IMarker[] markers = resource.findMarkers(null, true, IResource.DEPTH_INFINITE); final StringBuilder allMarkersDescription = new StringBuilder(); for (IMarker marker : markers) { final String markerIssueCode = marker.getAttribute(Issue.CODE_KEY, ""); if (issueCode.equals(markerIssueCode)) { // assertion fulfilled return; } allMarkersDescription.append("\n"); allMarkersDescription.append("line " + MarkerUtilities.getLineNumber(marker) + ": "); allMarkersDescription.append(marker.getAttribute(IMarker.MESSAGE, "<no message>")); } Assert.fail("Expected resource " + resource.getFullPath() + " to have at least one marker with issue code " + issueCode + " but was " + allMarkersDescription.toString()); }
Example #14
Source File: ProjectTestsUtils.java From n4js with Eclipse Public License 1.0 | 6 votes |
/** * Asserts that the given resource (usually an N4JS file) contains issues with the given messages and no other * issues. Each message given should be prefixed with the line numer where the issues occurs, e.g.: * * <pre> * line 5: Couldn't resolve reference to identifiable element 'unknown'. * </pre> * * Column information is not provided, so this method is not intended for several issues within a single line. * * @param msg * human-readable, informative message prepended to the standard message in case of assertion failure. * @param resource * resource to be validated. * @param expectedMessages * expected issues messages to check or empty array to assert no issues. * @throws CoreException * in case of mishap. */ public static void assertIssues(String msg, final IResource resource, String... expectedMessages) throws CoreException { waitForAutoBuild(); final IMarker[] markers = resource.findMarkers(MarkerTypes.ANY_VALIDATION, true, IResource.DEPTH_INFINITE); final String[] actualMessages = new String[markers.length]; for (int i = 0; i < markers.length; i++) { final IMarker m = markers[i]; actualMessages[i] = "line " + MarkerUtilities.getLineNumber(m) + ": " + m.getAttribute(IMarker.MESSAGE); } Set<String> actual = new TreeSet<>(Arrays.asList(actualMessages)); Set<String> expected = new TreeSet<>(Arrays.asList(expectedMessages)); if (!actual.equals(expected)) { StringBuilder message = new StringBuilder(msg != null ? msg : ""); message.append("\nexpected:\n"); message.append(expectedMessages.length > 0 ? Joiner.on('\n').join(expectedMessages) : "<none>"); message.append("\nactual:\n"); message.append(actualMessages.length > 0 ? Joiner.on('\n').join(actualMessages) : "<none>"); Assert.fail(message.toString()); } }
Example #15
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 #16
Source File: ExternalBreakpointWatcher.java From goclipse with Eclipse Public License 1.0 | 5 votes |
protected int getMarkerPosition(IMarker marker) throws BadLocationException { int line = MarkerUtilities.getLineNumber(marker); if (line > 0) { return document.getLineOffset(line - 1); } throw new BadLocationException(); }
Example #17
Source File: PyMarkerUIUtils.java From Pydev with Eclipse Public License 1.0 | 5 votes |
/** * @return the position for a marker. */ public static Position getMarkerPosition(IDocument document, IMarker marker, IAnnotationModel model) { if (model instanceof AbstractMarkerAnnotationModel) { Position ret = ((AbstractMarkerAnnotationModel) model).getMarkerPosition(marker); if (ret != null) { return ret; } } int start = MarkerUtilities.getCharStart(marker); int end = MarkerUtilities.getCharEnd(marker); if (start > end) { end = start + end; start = end - start; end = end - start; } if (start == -1 && end == -1) { // marker line number is 1-based int line = MarkerUtilities.getLineNumber(marker); if (line > 0 && document != null) { try { start = document.getLineOffset(line - 1); end = start; } catch (BadLocationException x) { } } } if (start > -1 && end > -1) { return new Position(start, end - start); } return null; }
Example #18
Source File: JavaMarkerAnnotation.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
public String getMarkerType() { IMarker marker= getMarker(); if (marker == null || !marker.exists()) return null; return MarkerUtilities.getMarkerType(getMarker()); }
Example #19
Source File: JavaMarkerAnnotation.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
/** * Tells whether the given marker can be treated as a Java annotation * which will later be update by JDT Core problems. * * @param marker the marker * @return <code>true</code> if the marker can be treated as a Java annotation * @since 3.3.2 */ static final boolean isJavaAnnotation(IMarker marker) { // Performance String markerType= MarkerUtilities.getMarkerType(marker); if (IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER.equals(markerType) || IJavaModelMarker.TASK_MARKER.equals(markerType) || IJavaModelMarker.TRANSIENT_PROBLEM.equals(markerType) || IJavaModelMarker.BUILDPATH_PROBLEM_MARKER.equals(markerType)) return true; return MarkerUtilities.isMarkerType(marker, IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER); }
Example #20
Source File: MarkerIdentity.java From dsl-devkit with Eclipse Public License 1.0 | 5 votes |
/** * Instantiates a new MarkerIdentity. * * @param marker * the marker * @return MarkerIdentity - this */ public MarkerIdentity create(final IMarker marker) { MarkerIdentity result = provider.get(); result.start = MarkerUtilities.getCharStart(marker); result.end = MarkerUtilities.getCharEnd(marker); result.problemCode = issueUtil.getCode(marker); result.problemURI = issueUtil.getUriToProblem(marker); result.resourceURI = result.problemURI == null ? null : result.problemURI.trimFragment(); result.message = MarkerUtilities.getMessage(marker); return result; }
Example #21
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 #22
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 #23
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 #24
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 #25
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 #26
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 #27
Source File: IssueUtil.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
/** * @deprecated As we are using IMarker.getAttributes() in {@link #createIssue(IMarker)}, we do not call this method any more * @since 2.3 */ @Deprecated protected CheckType getCheckType(IMarker marker) { String markerType = MarkerUtilities.getMarkerType(marker); if (markerTypeProvider != null) return markerTypeProvider.getCheckType(markerType); return MarkerTypes.toCheckType(markerType); }
Example #28
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 #29
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 #30
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; }