/** * @param resource may be the file open in the editor or the workspace root (if it is an external * file) * @param document is the document opened in the editor * @param externalFileEditorInput is not-null if this is an external file * @param info is the vertical ruler info (only used if this is not an external file) * @param onlyIncludeLastLineActivity if only the markers that are in the last mouse-click should * be included * @return the markers that correspond to the markers from the current editor. */ @SuppressWarnings({"unchecked", "rawtypes"}) public static List<Tuple<IMarker, IBreakpoint>> getMarkersAndBreakpointsFromEditorResource( IResource resource, IDocument document, IEditorInput externalFileEditorInput, int lastLineActivity, boolean onlyIncludeLastLineActivity, IAnnotationModel annotationModel) { List<Tuple<IMarker, IBreakpoint>> breakpoints = new ArrayList<Tuple<IMarker, IBreakpoint>>(); try { List<IMarker> markers = new ArrayList<IMarker>(); boolean isExternalFile = false; markers.addAll( Arrays.asList( resource.findMarkers(PyBreakpoint.PY_BREAK_MARKER, true, IResource.DEPTH_INFINITE))); markers.addAll( Arrays.asList( resource.findMarkers( PyBreakpoint.PY_CONDITIONAL_BREAK_MARKER, true, IResource.DEPTH_INFINITE))); if (!(resource instanceof IFile)) { // it was created from an external file isExternalFile = true; } IBreakpointManager breakpointManager = DebugPlugin.getDefault().getBreakpointManager(); for (IMarker marker : markers) { if (marker == null) { continue; } IBreakpoint breakpoint = breakpointManager.getBreakpoint(marker); if (breakpoint != null && breakpointManager.isRegistered(breakpoint)) { Position pos = PyMarkerUtils.getMarkerPosition(document, marker, annotationModel); if (!isExternalFile) { if (!onlyIncludeLastLineActivity) { breakpoints.add(new Tuple(marker, breakpoint)); } else if (includesRulerLine(pos, document, lastLineActivity)) { breakpoints.add(new Tuple(marker, breakpoint)); } } else { if (isInSameExternalEditor(marker, externalFileEditorInput)) { if (!onlyIncludeLastLineActivity) { breakpoints.add(new Tuple(marker, breakpoint)); } else if (includesRulerLine(pos, document, lastLineActivity)) { breakpoints.add(new Tuple(marker, breakpoint)); } } } } } } catch (CoreException x) { PydevDebugPlugin.log(IStatus.ERROR, "Unexpected getMarkers error (recovered properly)", x); } return breakpoints; }
public static List<IMarker> getMarkersFromCurrentFile(PyEdit edit, int line) { return getMarkersFromEditorResource( PyMarkerUtils.getResourceForTextEditor(edit), edit.getDocument(), getExternalFileEditorInput(edit), line, true, edit.getAnnotationModel()); }
protected IResource getResourceForDebugMarkers() { return PyMarkerUtils.getResourceForTextEditor(fTextEditor); }