1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

@Override annotations and spaces

This commit is contained in:
Andrew Gvozdev 2011-12-10 16:47:53 -05:00
parent b62f1b0e6a
commit 72bf0af67c

View file

@ -46,19 +46,19 @@ import org.eclipse.cdt.internal.ui.util.IProblemChangedListener;
import org.eclipse.cdt.internal.ui.util.ImageDescriptorRegistry;
/**
* LabelDecorator that decorates an element's image with error and warning overlays that
* represent the severity of markers attached to the element's underlying resource. To see
* LabelDecorator that decorates an element's image with error and warning overlays that
* represent the severity of markers attached to the element's underlying resource. To see
* a problem decoration for a marker, the marker needs to be a subtype of <code>IMarker.PROBLEM</code>.
* <p>
* Note: Only images for elements in Java projects are currently updated on marker changes.
* </p>
*
*
* @since 2.0
*/
public class ProblemsLabelDecorator implements ILabelDecorator, ILightweightLabelDecorator {
/**
* This is a special <code>LabelProviderChangedEvent</code> carring additional
* This is a special <code>LabelProviderChangedEvent</code> carring additional
* information whether the event orgins from a maker change.
* <p>
* <code>ProblemsLabelChangedEvent</code>s are only generated by <code>
@ -76,12 +76,12 @@ public class ProblemsLabelDecorator implements ILabelDecorator, ILightweightLabe
super(source, changedResource);
fMarkerChange= isMarkerChange;
}
/**
* Returns whether this event origins from marker changes. If <code>false</code> an annotation
* model change is the origin. In this case viewers not displaying working copies can ignore these
* Returns whether this event origins from marker changes. If <code>false</code> an annotation
* model change is the origin. In this case viewers not displaying working copies can ignore these
* events.
*
*
* @return if this event origins from a marker change.
*/
public boolean isMarkerChange() {
@ -91,13 +91,13 @@ public class ProblemsLabelDecorator implements ILabelDecorator, ILightweightLabe
}
private static final int ERRORTICK_WARNING= CElementImageDescriptor.WARNING;
private static final int ERRORTICK_ERROR= CElementImageDescriptor.ERROR;
private static final int TICK_CONFIGURATION = CElementImageDescriptor.SETTINGS;
private static final int ERRORTICK_ERROR= CElementImageDescriptor.ERROR;
private static final int TICK_CONFIGURATION = CElementImageDescriptor.SETTINGS;
private ImageDescriptorRegistry fRegistry;
private boolean fUseNewRegistry= false;
private IProblemChangedListener fProblemChangedListener;
private ListenerList fListeners;
/**
@ -107,10 +107,10 @@ public class ProblemsLabelDecorator implements ILabelDecorator, ILightweightLabe
this(null);
fUseNewRegistry= true;
}
/*
* Creates decorator with a shared image registry.
*
*
* @param registry The registry to use or <code>null</code> to use the Java plugin's
* image registry.
*/
@ -121,25 +121,27 @@ public class ProblemsLabelDecorator implements ILabelDecorator, ILightweightLabe
fRegistry= registry;
fProblemChangedListener= null;
}
private ImageDescriptorRegistry getRegistry() {
if (fRegistry == null) {
fRegistry= fUseNewRegistry ? new ImageDescriptorRegistry() : CUIPlugin.getImageDescriptorRegistry();
}
return fRegistry;
}
/* (non-Javadoc)
* @see ILabelDecorator#decorateText(String, Object)
*/
@Override
public String decorateText(String text, Object element) {
return text;
}
}
/* (non-Javadoc)
* @see ILabelDecorator#decorateImage(Image, Object)
*/
@Override
public Image decorateImage(Image image, Object obj) {
int adornmentFlags= computeAdornmentFlags(obj);
if (adornmentFlags != 0) {
@ -188,7 +190,7 @@ public class ProblemsLabelDecorator implements ILabelDecorator, ILightweightLabe
if (e.getStatus().getCode() == IResourceStatus.MARKER_NOT_FOUND) {
return 0;
}
CUIPlugin.log(e);
}
return 0;
@ -199,7 +201,7 @@ public class ProblemsLabelDecorator implements ILabelDecorator, ILightweightLabe
return 0;
}
int info= 0;
IMarker[] markers= res.findMarkers(IMarker.PROBLEM, true, depth);
if (markers != null) {
for (int i= 0; i < markers.length && (info != ERRORTICK_ERROR); i++) {
@ -212,7 +214,7 @@ public class ProblemsLabelDecorator implements ILabelDecorator, ILightweightLabe
info= ERRORTICK_ERROR;
}
}
}
}
}
return info;
}
@ -227,12 +229,12 @@ public class ProblemsLabelDecorator implements ILabelDecorator, ILightweightLabe
}
}
return isInside(pos, -1, sourceElement);
}
return false;
}
// private int getErrorTicksFromWorkingCopy(ITranslationUnit original, ISourceReference sourceElement) throws CoreException {
// int info= 0;
// FileEditorInput editorInput= new FileEditorInput((IFile) original.getResource());
@ -254,7 +256,7 @@ public class ProblemsLabelDecorator implements ILabelDecorator, ILightweightLabe
// }
// return info;
// }
// private IMarker isAnnotationInRange(IAnnotationModel model, Annotation annot, ISourceReference sourceElement) throws CoreException {
// if (annot instanceof MarkerAnnotation) {
// IMarker marker= ((MarkerAnnotation) annot).getMarker();
@ -267,17 +269,17 @@ public class ProblemsLabelDecorator implements ILabelDecorator, ILightweightLabe
// }
// return null;
// }
/**
* Tests if a position is inside the source range of an element. Usually this is done
* by looking at the offset. In case the offset equals <code>-1</code>, the line is
* by looking at the offset. In case the offset equals <code>-1</code>, the line is
* tested.
* @param offSet offset to be tested
* @param line line to be tested
* @param sourceElement Source element (must be a ICElement)
* @return boolean Return <code>true</code> if position is located inside the source element.
* @throws CoreException Exception thrown if element range could not be accessed.
*
*
* @since 2.1
*/
protected boolean isInside(int offSet, int line, ISourceReference sourceElement) throws CoreException {
@ -287,14 +289,15 @@ public class ProblemsLabelDecorator implements ILabelDecorator, ILightweightLabe
return (line >= range.getStartLine() && line <= range.getEndLine());
}
int rangeOffset= range.getStartPos();
return (rangeOffset <= offSet && rangeOffset + range.getLength() > offSet);
return (rangeOffset <= offSet && rangeOffset + range.getLength() > offSet);
}
return false;
}
}
/* (non-Javadoc)
* @see IBaseLabelProvider#dispose()
*/
@Override
public void dispose() {
if (fProblemChangedListener != null) {
CUIPlugin.getDefault().getProblemMarkerManager().removeListener(fProblemChangedListener);
@ -308,13 +311,15 @@ public class ProblemsLabelDecorator implements ILabelDecorator, ILightweightLabe
/* (non-Javadoc)
* @see IBaseLabelProvider#isLabelProperty(Object, String)
*/
@Override
public boolean isLabelProperty(Object element, String property) {
return true;
}
/* (non-Javadoc)
* @see IBaseLabelProvider#addListener(ILabelProviderListener)
*/
@Override
public void addListener(ILabelProviderListener listener) {
if (fListeners == null) {
fListeners= new ListenerList();
@ -322,17 +327,19 @@ public class ProblemsLabelDecorator implements ILabelDecorator, ILightweightLabe
fListeners.add(listener);
if (fProblemChangedListener == null) {
fProblemChangedListener= new IProblemChangedListener() {
@Override
public void problemsChanged(IResource[] changedResources, boolean isMarkerChange) {
fireProblemsChanged(changedResources, isMarkerChange);
}
};
CUIPlugin.getDefault().getProblemMarkerManager().addListener(fProblemChangedListener);
}
}
}
/* (non-Javadoc)
* @see IBaseLabelProvider#removeListener(ILabelProviderListener)
*/
@Override
public void removeListener(ILabelProviderListener listener) {
if (fListeners != null) {
fListeners.remove(listener);
@ -342,7 +349,7 @@ public class ProblemsLabelDecorator implements ILabelDecorator, ILightweightLabe
}
}
}
protected void fireProblemsChanged(IResource[] changedResources, boolean isMarkerChange) {
if (fListeners != null && !fListeners.isEmpty()) {
LabelProviderChangedEvent event= new ProblemsLabelChangedEvent(this, changedResources, isMarkerChange);
@ -352,23 +359,24 @@ public class ProblemsLabelDecorator implements ILabelDecorator, ILightweightLabe
}
}
}
/* (non-Javadoc)
* @see org.eclipse.jface.viewers.ILightweightLabelDecorator#decorate(java.lang.Object, org.eclipse.jface.viewers.IDecoration)
*/
public void decorate(Object element, IDecoration decoration) {
@Override
public void decorate(Object element, IDecoration decoration) {
int adornmentFlags= computeAdornmentFlags(element);
if ((adornmentFlags & TICK_CONFIGURATION) != 0) {
decoration.addOverlay(CPluginImages.DESC_OVR_SETTING);
adornmentFlags &= ~TICK_CONFIGURATION;
}
if (adornmentFlags == ERRORTICK_ERROR) {
decoration.addOverlay(CPluginImages.DESC_OVR_ERROR);
} else if (adornmentFlags == ERRORTICK_WARNING) {
decoration.addOverlay(CPluginImages.DESC_OVR_WARNING);
}
}
}
/**