diff --git a/platform/editor-ui-api/src/com/intellij/openapi/editor/GutterMarkPreprocessor.java b/platform/editor-ui-api/src/com/intellij/openapi/editor/GutterMarkPreprocessor.java new file mode 100644 index 000000000000..9912400f5dd6 --- /dev/null +++ b/platform/editor-ui-api/src/com/intellij/openapi/editor/GutterMarkPreprocessor.java @@ -0,0 +1,29 @@ +/* + * Copyright 2000-2016 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.openapi.editor; + +import com.intellij.codeInsight.daemon.GutterMark; +import com.intellij.openapi.extensions.ExtensionPointName; +import com.sun.istack.internal.NotNull; + +import java.util.List; + +public interface GutterMarkPreprocessor { + ExtensionPointName EP_NAME = ExtensionPointName.create("com.intellij.gutterMarkPreprocessor"); + + @NotNull + List processMarkers(@NotNull List list); +} diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorGutterComponentImpl.java b/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorGutterComponentImpl.java index f112110da92a..b0fd67a95176 100644 --- a/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorGutterComponentImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorGutterComponentImpl.java @@ -68,6 +68,7 @@ import gnu.trove.TIntArrayList; import gnu.trove.TIntFunction; import gnu.trove.TIntObjectHashMap; import gnu.trove.TIntObjectProcedure; +import gnu.trove.TObjectFunction; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -114,6 +115,7 @@ import java.util.List; */ class EditorGutterComponentImpl extends EditorGutterComponentEx implements MouseListener, MouseMotionListener, DataProvider { private static final Logger LOG = Logger.getInstance("#com.intellij.openapi.editor.impl.EditorGutterComponentImpl"); + private static final int START_ICON_AREA_WIDTH = JBUI.scale(17); private static final int FREE_PAINTERS_LEFT_AREA_WIDTH = JBUI.scale(8); private static final int FREE_PAINTERS_RIGHT_AREA_WIDTH = JBUI.scale(5); private static final int GAP_BETWEEN_ICONS = JBUI.scale(3); @@ -775,9 +777,23 @@ class EditorGutterComponentImpl extends EditorGutterComponentEx implements Mouse myLineToGutterRenderers.put(line, renderers); } - if (renderers.size() < 5) { // Don't allow more than 5 icons per line - renderers.add(renderer); + renderers.add(renderer); + } + }); + + myLineToGutterRenderers.transformValues(new TObjectFunction, List>() { + @Override + public List execute(List value) { + List newValue = value; + for (GutterMarkPreprocessor preprocessor : GutterMarkPreprocessor.EP_NAME.getExtensions()) { + newValue = preprocessor.processMarkers(value); } + + if (newValue.size() >= 5) { // Don't allow more than 5 icons per line + newValue = newValue.subList(0, 4); + } + + return newValue; } }); } @@ -804,10 +820,11 @@ class EditorGutterComponentImpl extends EditorGutterComponentEx implements Mouse return; } + int minWidth = (int)(START_ICON_AREA_WIDTH * myEditor.getScale()); if (canShrink) { - myIconsAreaWidth = myEditor.getLineHeight(); + myIconsAreaWidth = minWidth; } else { - myIconsAreaWidth = Math.max(myIconsAreaWidth, myEditor.getLineHeight()); + myIconsAreaWidth = Math.max(myIconsAreaWidth, minWidth); } processGutterRenderers((line, renderers) -> { diff --git a/platform/platform-resources/src/META-INF/PlatformExtensionPoints.xml b/platform/platform-resources/src/META-INF/PlatformExtensionPoints.xml index 002c919fe209..656e1ca5ec4a 100644 --- a/platform/platform-resources/src/META-INF/PlatformExtensionPoints.xml +++ b/platform/platform-resources/src/META-INF/PlatformExtensionPoints.xml @@ -261,6 +261,7 @@ +