Skip to content

Commit

Permalink
JmhRunLineMarkerContributor: remove TooltipProvider
Browse files Browse the repository at this point in the history
Closes #50
  • Loading branch information
stokito committed May 1, 2024
1 parent 76c74af commit 13ce90e
Showing 1 changed file with 9 additions and 26 deletions.
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
package ru.artyushov.jmhPlugin.configuration;

import com.intellij.execution.lineMarker.ExecutorAction;
import com.intellij.execution.lineMarker.RunLineMarkerContributor;
import com.intellij.openapi.actionSystem.ActionManager;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.psi.PsiElement;
import com.intellij.util.Function;
import com.intellij.util.containers.ContainerUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.uast.UClass;
Expand All @@ -31,35 +28,21 @@ public Info getInfo(@NotNull PsiElement psiElement) {
boolean isBenchmarkMethod = isBenchmarkMethod((UMethod) uElement);
if (isBenchmarkMethod) {
// FIXME use something similar to com.intellij.sh.run.ShRunFileAction
final AnAction[] actions = new AnAction[]{ActionManager.getInstance().getAction("RunClass")};
return new Info(ProfileYellow, new TooltipProvider(actions), actions);
// FIXME for some reason this doesn't work anymore https://github.com/artyushov/idea-jmh-plugin/issues/50
// final AnAction[] actions = new AnAction[]{ActionManager.getInstance().getAction("RunClass")};
AnAction[] actions = ExecutorAction.getActions(1);
return new Info(ProfileYellow, actions, null);
}
} else if (uElement instanceof UClass) {
boolean isBenchmarkClass = isBenchmarkClass((UClass) uElement);
if (isBenchmarkClass) {
// FIXME use something similar to com.intellij.sh.run.ShRunFileAction
final AnAction[] actions = new AnAction[]{ActionManager.getInstance().getAction("RunClass")};
return new Info(ProfileYellow, new TooltipProvider(actions), actions);
// FIXME for some reason this doesn't work anymore https://github.com/artyushov/idea-jmh-plugin/issues/50
// final AnAction[] actions = new AnAction[]{ActionManager.getInstance().getAction("RunClass")};
AnAction[] actions = ExecutorAction.getActions(1);
return new Info(ProfileYellow, actions, null);
}
}
return null;
}

private static class TooltipProvider implements com.intellij.util.Function<PsiElement, String> {
private final AnAction[] actions;

private TooltipProvider(AnAction[] actions) {
this.actions = actions;
}

@Override
public String fun(PsiElement element) {
return StringUtil.join(ContainerUtil.mapNotNull(actions, new Function<AnAction, String>() {
@Override
public String fun(AnAction action) {
return getText(action, element);
}
}), "\n");
}
}
}

0 comments on commit 13ce90e

Please # to comment.