Added action which disables Kotlin signatures icons.
This commit is contained in:
@@ -63,7 +63,10 @@
|
||||
<add-to-group group-id="CodeMenu" anchor="last"/>
|
||||
</action>
|
||||
|
||||
|
||||
<group id="EditorGutterKotlinPopupMenu">
|
||||
<action id="ShowKotlinSignatures" class="org.jetbrains.jet.plugin.codeInsight.ShowKotlinSignaturesAction"/>
|
||||
<add-to-group group-id="EditorGutterPopupMenu" anchor="last" />
|
||||
</group>
|
||||
</actions>
|
||||
|
||||
<extensions defaultExtensionNs="com.intellij">
|
||||
|
||||
+15
-1
@@ -17,11 +17,14 @@
|
||||
package org.jetbrains.jet.plugin.codeInsight;
|
||||
|
||||
import com.intellij.codeHighlighting.Pass;
|
||||
import com.intellij.codeInsight.daemon.DaemonCodeAnalyzer;
|
||||
import com.intellij.codeInsight.daemon.GutterIconNavigationHandler;
|
||||
import com.intellij.codeInsight.daemon.LineMarkerInfo;
|
||||
import com.intellij.codeInsight.daemon.LineMarkerProvider;
|
||||
import com.intellij.codeInsight.navigation.NavigationUtil;
|
||||
import com.intellij.ide.util.PropertiesComponent;
|
||||
import com.intellij.openapi.fileEditor.OpenFileDescriptor;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.util.Function;
|
||||
@@ -40,6 +43,8 @@ import java.util.List;
|
||||
* @since 3 August 2012
|
||||
*/
|
||||
public class KotlinSignatureInJavaMarkerProvider implements LineMarkerProvider {
|
||||
private static final String SHOW_MARKERS_PROPERTY = "kotlin.signature.markers.enabled";
|
||||
|
||||
private static final Function<PsiElement,String> TOOLTIP_PROVIDER = new Function<PsiElement, String>() {
|
||||
@Override
|
||||
public String fun(PsiElement element) {
|
||||
@@ -112,7 +117,7 @@ public class KotlinSignatureInJavaMarkerProvider implements LineMarkerProvider {
|
||||
@Override
|
||||
@Nullable
|
||||
public LineMarkerInfo getLineMarkerInfo(@NotNull PsiElement element) {
|
||||
if (findKotlinSignatureAnnotation(element) != null) {
|
||||
if (isMarkersEnabled(element.getProject()) && findKotlinSignatureAnnotation(element) != null) {
|
||||
return new LineMarkerInfo<PsiMethod>((PsiMethod) element, element.getTextOffset(), JetIcons.SMALL_LOGO, Pass.UPDATE_ALL,
|
||||
TOOLTIP_PROVIDER, NAVIGATION_HANDLER);
|
||||
}
|
||||
@@ -122,4 +127,13 @@ public class KotlinSignatureInJavaMarkerProvider implements LineMarkerProvider {
|
||||
@Override
|
||||
public void collectSlowLineMarkers(@NotNull List<PsiElement> elements, @NotNull Collection<LineMarkerInfo> result) {
|
||||
}
|
||||
|
||||
public static boolean isMarkersEnabled(@NotNull Project project) {
|
||||
return PropertiesComponent.getInstance(project).getBoolean(SHOW_MARKERS_PROPERTY, true);
|
||||
}
|
||||
|
||||
public static void setMarkersEnabled(@NotNull Project project, boolean value) {
|
||||
PropertiesComponent.getInstance(project).setValue(SHOW_MARKERS_PROPERTY, Boolean.toString(value));
|
||||
DaemonCodeAnalyzer.getInstance(project).restart();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* Copyright 2010-2012 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 org.jetbrains.jet.plugin.codeInsight;
|
||||
|
||||
import com.intellij.lang.java.JavaLanguage;
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.openapi.actionSystem.LangDataKeys;
|
||||
import com.intellij.openapi.actionSystem.ToggleAction;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.psi.PsiFile;
|
||||
|
||||
public class ShowKotlinSignaturesAction extends ToggleAction {
|
||||
public ShowKotlinSignaturesAction() {
|
||||
super("Show Kotlin Signatures");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSelected(AnActionEvent e) {
|
||||
Project project = e.getProject();
|
||||
return project != null && KotlinSignatureInJavaMarkerProvider.isMarkersEnabled(project);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(AnActionEvent e) {
|
||||
super.update(e);
|
||||
e.getPresentation().setVisible(false);
|
||||
PsiFile psiFile = e.getData(LangDataKeys.PSI_FILE);
|
||||
if (psiFile != null && psiFile.getLanguage() == JavaLanguage.INSTANCE) {
|
||||
e.getPresentation().setVisible(true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSelected(AnActionEvent e, boolean state) {
|
||||
Project project = e.getProject();
|
||||
assert project != null;
|
||||
KotlinSignatureInJavaMarkerProvider.setMarkersEnabled(project, state);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user