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); }
/** * 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); }
int markerStart= MarkerUtilities.getCharStart(marker); int markerEnd= MarkerUtilities.getCharEnd(marker); MarkerUtilities.setCharStart(marker, offset); offsetsChanged= true; MarkerUtilities.setCharEnd(marker, offset); offsetsChanged= true; if (!offsetsInitialized || (offsetsChanged && MarkerUtilities.getLineNumber(marker) != -1)) { try { MarkerUtilities.setLineNumber(marker, document.getLineOfOffset(position.getOffset()) + 1); } catch (BadLocationException x) {
/** * Computes the annotation type that corresponds to the state of * the given marker. * * @param marker the marker * @return the annotation type or <code>null</code> */ public String getAnnotationType(IMarker marker) { String markerType= MarkerUtilities.getMarkerType(marker); if (markerType != null) { int severity= MarkerUtilities.getSeverity(marker); return getAnnotationType(markerType, severity); } return null; }
/** * Returns the attributes with which a newly created marker will be initialized. * * @return the initial marker attributes */ private Map<String, Object> getMarkerAttributes(IProblem problem) { Map<String, Object> attributes = new HashMap<>(11); int severity = IMarker.SEVERITY_ERROR; if (problem.isWarning()) { severity = IMarker.SEVERITY_WARNING; } // marker line numbers are 1-based MarkerUtilities.setMessage(attributes, problem.getUnmodifiedMessage()); MarkerUtilities.setLineNumber(attributes, problem.getLineNumber()); MarkerUtilities.setCharStart(attributes, problem.getOffset()); MarkerUtilities.setCharEnd(attributes, problem.getOffset() + problem.getLength()); attributes.put(IMarker.SEVERITY, Integer.valueOf(severity)); return attributes; }
int start= MarkerUtilities.getCharStart(marker); int end= MarkerUtilities.getCharEnd(marker); int line= MarkerUtilities.getLineNumber(marker); if (line > 0 && fDocument != null) { try {
/** * @since 2.3 */ protected CheckType getCheckType(IMarker marker) { String markerType = MarkerUtilities.getMarkerType(marker); if (markerTypeProvider != null) return markerTypeProvider.getCheckType(markerType); return MarkerTypes.toCheckType(markerType); }
public Issue createIssue(IMarker marker) { Issue.IssueImpl issue = new Issue.IssueImpl(); issue.setMessage(MarkerUtilities.getMessage(marker)); issue.setLineNumber(MarkerUtilities.getLineNumber(marker) - 1); issue.setOffset(MarkerUtilities.getCharStart(marker)); issue.setLength(MarkerUtilities.getCharEnd(marker)-MarkerUtilities.getCharStart(marker)); issue.setCode(getCode(marker)); issue.setData(getIssueData(marker)); issue.setUriToProblem(getUriToProblem(marker)); issue.setSeverity(getSeverity(marker)); issue.setType(getCheckType(marker)); // Note, isSyntaxError is unset, but currently the api does not allow fixing // syntax errors anyway. return issue; }
private IMarker createMarker(int pos, int lineNumber, Match match, IFile file, ITextEditor textEditor) throws CoreException { if( file == null ) return null; IMarker marker = null; marker = file.createMarker(NewSearchUI.SEARCH_MARKER); marker.setAttribute(IMarker.TRANSIENT, true); marker.setAttribute(IMarker.MESSAGE, match.getElement()); MarkerUtilities.setLineNumber(marker, lineNumber); MarkerUtilities.setCharStart(marker, pos + match.getOffset()); MarkerUtilities.setCharEnd(marker, pos + match.getOffset() + match.getLength()); return marker; }
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));
@Override public String getText() { return MarkerUtilities.getMessage(fMarker); } }
String name= getUnknownImageName(marker); if (MarkerUtilities.isMarkerType(marker, IMarker.TASK)) { name= IDE.SharedImages.IMG_OBJS_TASK_TSK; } else if (MarkerUtilities.isMarkerType(marker, IMarker.BOOKMARK)) { name= IDE.SharedImages.IMG_OBJS_BKMRK_TSK; } else if (MarkerUtilities.isMarkerType(marker, IMarker.PROBLEM)) { switch (MarkerUtilities.getSeverity(marker)) { case IMarker.SEVERITY_INFO: name= ISharedImages.IMG_OBJS_INFO_TSK;
/** * Checks whether a marker updater is registered for the type of the * given marker but not yet instantiated. If so, the method instantiates * the marker updater and registers it with this model. * * @param marker the marker for which to look for an updater * @since 2.0 */ private void checkMarkerUpdaters(IMarker marker) { List<IConfigurationElement> toBeDeleted= new ArrayList<>(); for (int i= 0; i < fMarkerUpdaterSpecifications.size(); i++) { IConfigurationElement spec= fMarkerUpdaterSpecifications.get(i); String markerType= spec.getAttribute("markerType"); //$NON-NLS-1$ if (markerType == null || MarkerUtilities.isMarkerType(marker, markerType)) { toBeDeleted.add(spec); IMarkerUpdater updater= createMarkerUpdater(spec); if (updater != null) addMarkerUpdater(updater); } } for (int i= 0; i < toBeDeleted.size(); i++) fMarkerUpdaterSpecifications.remove(toBeDeleted.get(i)); }
/** * Returns the attributes with which a newly created marker will be * initialized. * * @return the initial marker attributes */ protected Map getInitialAttributes() { Map attributes= new HashMap(11); IDocumentProvider provider= fTextEditor.getDocumentProvider(); IDocument document= provider.getDocument(fTextEditor.getEditorInput()); int line= fRuler.getLineOfLastMouseButtonActivity(); int start= -1; int end= -1; int length= 0; try { IRegion lineInformation= document.getLineInformation(line); start= lineInformation.getOffset(); length= lineInformation.getLength(); end= start + length; } catch (BadLocationException x) { } // marker line numbers are 1-based MarkerUtilities.setMessage(attributes, getLabelProposal(document, start, length)); MarkerUtilities.setLineNumber(attributes, line + 1); MarkerUtilities.setCharStart(attributes, start); MarkerUtilities.setCharEnd(attributes, end); return attributes; }
int start= MarkerUtilities.getCharStart(marker); int end= MarkerUtilities.getCharEnd(marker); int line= MarkerUtilities.getLineNumber(marker); if (line > 0 && fDocument != null) { try {
@Override protected MarkerAnnotation createMarkerAnnotation(IMarker marker) { String markerType = MarkerUtilities.getMarkerType(marker); if (AntEditorMarkerUpdater.BUILDFILE_PROBLEM_MARKER.equals(markerType)) { // we currently do not show Ant buildfile problem markers in the Ant editor as we have no notion of // annotation overlays // bug return null; } return new MarkerAnnotation(EditorsUI.getAnnotationTypeLookup().getAnnotationType(marker), marker); }
/** * Computes the annotation type that corresponds to the state of * the given marker. * * @param marker the marker * @return the annotation type or <code>null</code> */ public String getAnnotationType(IMarker marker) { String markerType= MarkerUtilities.getMarkerType(marker); if (markerType != null) { int severity= MarkerUtilities.getSeverity(marker); return getAnnotationType(markerType, severity); } return null; }
public String getText() { return MarkerUtilities.getMessage(fMarker); } }
String name= getUnknownImageName(marker); if (MarkerUtilities.isMarkerType(marker, IMarker.TASK)) { name= IDE.SharedImages.IMG_OBJS_TASK_TSK; } else if (MarkerUtilities.isMarkerType(marker, IMarker.BOOKMARK)) { name= IDE.SharedImages.IMG_OBJS_BKMRK_TSK; } else if (MarkerUtilities.isMarkerType(marker, IMarker.PROBLEM)) { switch (MarkerUtilities.getSeverity(marker)) { case IMarker.SEVERITY_INFO: name= ISharedImages.IMG_OBJS_INFO_TSK;
/** * Checks whether a marker updater is registered for the type of the * given marker but not yet instantiated. If so, the method instantiates * the marker updater and registers it with this model. * * @param marker the marker for which to look for an updater * @since 2.0 */ private void checkMarkerUpdaters(IMarker marker) { List toBeDeleted= new ArrayList(); for (int i= 0; i < fMarkerUpdaterSpecifications.size(); i++) { IConfigurationElement spec= (IConfigurationElement) fMarkerUpdaterSpecifications.get(i); String markerType= spec.getAttribute("markerType"); //$NON-NLS-1$ if (markerType == null || MarkerUtilities.isMarkerType(marker, markerType)) { toBeDeleted.add(spec); IMarkerUpdater updater= createMarkerUpdater(spec); if (updater != null) addMarkerUpdater(updater); } } for (int i= 0; i < toBeDeleted.size(); i++) fMarkerUpdaterSpecifications.remove(toBeDeleted.get(i)); }