Search in sources :

Example 1 with GoTestFramework

use of com.goide.runconfig.testing.GoTestFramework in project go-lang-idea-plugin by go-lang-plugin-org.

the class GoGenerateTestMethodActionGroup method getChildren.

@NotNull
@Override
public AnAction[] getChildren(@Nullable AnActionEvent e) {
    if (e == null) {
        return AnAction.EMPTY_ARRAY;
    }
    Project project = e.getProject();
    Editor editor = e.getData(CommonDataKeys.EDITOR);
    if (project == null || editor == null)
        return AnAction.EMPTY_ARRAY;
    PsiFile file = PsiUtilBase.getPsiFileInEditor(editor, project);
    ArrayList<AnAction> children = ContainerUtil.newArrayList();
    for (GoTestFramework framework : GoTestFramework.all()) {
        if (framework.isAvailableOnFile(file)) {
            children.addAll(framework.getGenerateMethodActions());
        }
    }
    return !children.isEmpty() ? children.toArray(new AnAction[children.size()]) : AnAction.EMPTY_ARRAY;
}
Also used : Project(com.intellij.openapi.project.Project) GoTestFramework(com.goide.runconfig.testing.GoTestFramework) PsiFile(com.intellij.psi.PsiFile) Editor(com.intellij.openapi.editor.Editor) AnAction(com.intellij.openapi.actionSystem.AnAction) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

GoTestFramework (com.goide.runconfig.testing.GoTestFramework)1 AnAction (com.intellij.openapi.actionSystem.AnAction)1 Editor (com.intellij.openapi.editor.Editor)1 Project (com.intellij.openapi.project.Project)1 PsiFile (com.intellij.psi.PsiFile)1 NotNull (org.jetbrains.annotations.NotNull)1