vcs annotate: cleanup - remove unnecessary user data key

This commit is contained in:
Aleksey Pivovarov
2015-09-03 19:28:02 +03:00
parent 6eca3c94c9
commit 2fbbcbf39c
4 changed files with 6 additions and 22 deletions
@@ -46,6 +46,8 @@ public interface EditorGutter {
*/
void registerTextAnnotation(@NotNull TextAnnotationGutterProvider provider, @NotNull EditorGutterAction action);
boolean isAnnotationsShown();
/**
* Removes all text annotations from the gutter.
*/
@@ -32,8 +32,6 @@ public abstract class EditorGutterComponentEx extends JComponent implements Edit
public abstract boolean isLineMarkersShown();
public abstract boolean isAnnotationsShown();
@Nullable
public abstract FoldRegion findFoldingAnchorAt(int x, int y);
@@ -61,7 +61,6 @@ import java.util.List;
*/
public class AnnotateToggleAction extends ToggleAction implements DumbAware, AnnotationColors {
private static final Logger LOG = Logger.getInstance("#com.intellij.openapi.vcs.actions.AnnotateToggleAction");
protected static final Key<Collection<ActiveAnnotationGutter>> KEY_IN_EDITOR = Key.create("Annotations");
@Override
public void update(@NotNull AnActionEvent e) {
@@ -126,8 +125,7 @@ public class AnnotateToggleAction extends ToggleAction implements DumbAware, Ann
}
private static boolean isAnnotated(@NotNull Editor editor) {
Collection annotations = editor.getUserData(KEY_IN_EDITOR);
return annotations != null && !annotations.isEmpty();
return editor.getGutter().isAnnotationsShown();
}
@Override
@@ -223,10 +221,10 @@ public class AnnotateToggleAction extends ToggleAction implements DumbAware, Ann
final Project project,
final VirtualFile file,
final FileAnnotation fileAnnotation,
final AbstractVcs vcs, final boolean onCurrentRevision) {
final AbstractVcs vcs,
final boolean onCurrentRevision) {
final UpToDateLineNumberProvider getUpToDateLineNumber = new UpToDateLineNumberProviderImpl(editor.getDocument(), project);
editor.getGutter().closeAllAnnotations();
final VcsAnnotationLocalChangesListener listener = ProjectLevelVcsManager.getInstance(project).getAnnotationLocalChangesListener();
fileAnnotation.setCloser(new Runnable() {
@Override
@@ -242,14 +240,7 @@ public class AnnotateToggleAction extends ToggleAction implements DumbAware, Ann
}
});
if (onCurrentRevision) {
listener.registerAnnotation(file, fileAnnotation);
}
// be careful, not proxies but original items are put there (since only their presence not behaviour is important)
Collection<ActiveAnnotationGutter> annotations = editor.getUserData(KEY_IN_EDITOR);
if (annotations == null) {
annotations = new HashSet<ActiveAnnotationGutter>();
editor.putUserData(KEY_IN_EDITOR, annotations);
ProjectLevelVcsManager.getInstance(project).getAnnotationLocalChangesListener().registerAnnotation(file, fileAnnotation);
}
final EditorGutterComponentEx editorGutter = (EditorGutterComponentEx)editor.getGutter();
@@ -318,7 +309,6 @@ public class AnnotateToggleAction extends ToggleAction implements DumbAware, Ann
else {
editor.getGutter().registerTextAnnotation(proxy);
}
annotations.add(gutter);
}
}
@@ -41,7 +41,6 @@ import java.util.Map;
*/
public class AnnotationFieldGutter implements ActiveAnnotationGutter {
protected final FileAnnotation myAnnotation;
private final Editor myEditor;
protected final LineAnnotationAspect myAspect;
private final TextAnnotationPresentation myPresentation;
private final boolean myIsGutterAction;
@@ -53,7 +52,6 @@ public class AnnotationFieldGutter implements ActiveAnnotationGutter {
final TextAnnotationPresentation presentation,
Couple<Map<VcsRevisionNumber, Color>> colorScheme) {
myAnnotation = annotation;
myEditor = editor;
myAspect = aspect;
myPresentation = presentation;
myIsGutterAction = myAspect instanceof EditorGutterAction;
@@ -137,10 +135,6 @@ public class AnnotationFieldGutter implements ActiveAnnotationGutter {
public void gutterClosed() {
myAnnotation.unregister();
myAnnotation.dispose();
final Collection<ActiveAnnotationGutter> gutters = myEditor.getUserData(AnnotateToggleAction.KEY_IN_EDITOR);
if (gutters != null) {
gutters.remove(this);
}
}
@Nullable