mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
put error ticks in outline view
This commit is contained in:
parent
f2b0d8b69c
commit
bae54f4e47
2 changed files with 18 additions and 6 deletions
|
@ -16,6 +16,7 @@ import org.eclipse.cdt.internal.ui.actions.AbstractToggleLinkingAction;
|
|||
import org.eclipse.cdt.internal.ui.actions.ActionMessages;
|
||||
import org.eclipse.cdt.internal.ui.search.actions.SelectionSearchGroup;
|
||||
import org.eclipse.cdt.internal.ui.util.ProblemTreeViewer;
|
||||
import org.eclipse.cdt.internal.ui.viewsupport.DecoratingCLabelProvider;
|
||||
import org.eclipse.cdt.internal.ui.viewsupport.StandardCElementLabelProvider;
|
||||
import org.eclipse.cdt.ui.CUIPlugin;
|
||||
import org.eclipse.cdt.ui.PreferenceConstants;
|
||||
|
@ -231,7 +232,7 @@ public class CContentOutlinePage extends Page implements IContentOutlinePage, IS
|
|||
|
||||
//treeViewer.setContentProvider(new CElementContentProvider(true, true));
|
||||
treeViewer.setContentProvider(new CContentOutlinerProvider(this));
|
||||
treeViewer.setLabelProvider(new StandardCElementLabelProvider());
|
||||
treeViewer.setLabelProvider(new DecoratingCLabelProvider(new StandardCElementLabelProvider(), true));
|
||||
treeViewer.setAutoExpandLevel(AbstractTreeViewer.ALL_LEVELS);
|
||||
treeViewer.addSelectionChangedListener(this);
|
||||
|
||||
|
|
|
@ -41,6 +41,7 @@ import org.eclipse.swt.graphics.Point;
|
|||
import org.eclipse.swt.graphics.Rectangle;
|
||||
import org.eclipse.ui.part.FileEditorInput;
|
||||
import org.eclipse.ui.texteditor.MarkerAnnotation;
|
||||
import org.eclipse.ui.texteditor.MarkerUtilities;
|
||||
|
||||
/**
|
||||
* LabelDecorator that decorates an element's image with error and warning overlays that
|
||||
|
@ -168,7 +169,7 @@ public class ProblemsLabelDecorator implements ILabelDecorator, ILightweightLabe
|
|||
case ICElement.C_METHOD:
|
||||
ITranslationUnit tu= ((ISourceReference)element).getTranslationUnit();
|
||||
if (tu != null && tu.exists()) {
|
||||
return getErrorTicksFromMarkers(tu.getResource(), IResource.DEPTH_ONE, tu);
|
||||
return getErrorTicksFromMarkers(tu.getResource(), IResource.DEPTH_ONE, (ISourceReference)element);
|
||||
}
|
||||
default:
|
||||
}
|
||||
|
@ -216,7 +217,14 @@ public class ProblemsLabelDecorator implements ILabelDecorator, ILightweightLabe
|
|||
private boolean isMarkerInRange(IMarker marker, ISourceReference sourceElement) throws CoreException {
|
||||
if (marker.isSubtypeOf(IMarker.TEXT)) {
|
||||
int pos= marker.getAttribute(IMarker.CHAR_START, -1);
|
||||
return isInside(pos, sourceElement);
|
||||
if (pos == -1) {
|
||||
int line= MarkerUtilities.getLineNumber(marker);
|
||||
if (line >= 0) {
|
||||
return isInside( -1, line, sourceElement);
|
||||
}
|
||||
}
|
||||
return isInside(pos, -1, sourceElement);
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -249,7 +257,7 @@ public class ProblemsLabelDecorator implements ILabelDecorator, ILightweightLabe
|
|||
IMarker marker= ((MarkerAnnotation) annot).getMarker();
|
||||
if (marker.exists() && marker.isSubtypeOf(IMarker.PROBLEM)) {
|
||||
Position pos= model.getPosition(annot);
|
||||
if (pos != null && (sourceElement == null || isInside(pos.getOffset(), sourceElement))) {
|
||||
if (pos != null && (sourceElement == null || isInside(pos.getOffset(), -1, sourceElement))) {
|
||||
return marker;
|
||||
}
|
||||
}
|
||||
|
@ -266,11 +274,14 @@ public class ProblemsLabelDecorator implements ILabelDecorator, ILightweightLabe
|
|||
*
|
||||
* @since 2.1
|
||||
*/
|
||||
protected boolean isInside(int pos, ISourceReference sourceElement) throws CoreException {
|
||||
protected boolean isInside(int offSet, int line, ISourceReference sourceElement) throws CoreException {
|
||||
ISourceRange range= sourceElement.getSourceRange();
|
||||
if (range != null) {
|
||||
if (offSet ==-1) {
|
||||
return (line >= range.getStartLine() && line <= range.getEndLine());
|
||||
}
|
||||
int rangeOffset= range.getStartPos();
|
||||
return (rangeOffset <= pos && rangeOffset + range.getLength() > pos);
|
||||
return (rangeOffset <= offSet && rangeOffset + range.getLength() > offSet);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue