mirror of
https://github.com/carlrobertoh/ProxyAI.git
synced 2026-05-12 05:51:28 +00:00
* fix: plugin since/until build versions * add necessary kotlin deps * migrate to new inline completions api * remove previous implementation * replace build and platform versions * bump gradle-intellij-plugin version
41 lines
1.6 KiB
Java
41 lines
1.6 KiB
Java
package ee.carlrobert.codegpt.actions;
|
|
|
|
import static ee.carlrobert.codegpt.settings.service.ServiceType.LLAMA_CPP;
|
|
import static ee.carlrobert.codegpt.settings.service.ServiceType.OPENAI;
|
|
|
|
import com.intellij.openapi.actionSystem.ActionUpdateThread;
|
|
import com.intellij.openapi.actionSystem.AnAction;
|
|
import com.intellij.openapi.actionSystem.AnActionEvent;
|
|
import com.intellij.openapi.application.ApplicationManager;
|
|
import ee.carlrobert.codegpt.settings.GeneralSettings;
|
|
import ee.carlrobert.codegpt.settings.configuration.ConfigurationSettings;
|
|
import java.util.List;
|
|
import org.jetbrains.annotations.NotNull;
|
|
|
|
/**
|
|
* Disables code-completion.<br/> Publishes message to {@link CodeCompletionEnabledListener#TOPIC}
|
|
*/
|
|
public class DisableCompletionsAction extends AnAction {
|
|
|
|
@Override
|
|
public void actionPerformed(@NotNull AnActionEvent e) {
|
|
ConfigurationSettings.getCurrentState().setCodeCompletionsEnabled(false);
|
|
ApplicationManager.getApplication()
|
|
.getMessageBus().syncPublisher(CodeCompletionEnabledListener.TOPIC)
|
|
.onCodeCompletionsEnabledChange(false);
|
|
}
|
|
|
|
@Override
|
|
public void update(@NotNull AnActionEvent e) {
|
|
var selectedService = GeneralSettings.getCurrentState().getSelectedService();
|
|
var codeCompletionEnabled = ConfigurationSettings.getCurrentState().isCodeCompletionsEnabled();
|
|
e.getPresentation().setEnabled(codeCompletionEnabled);
|
|
e.getPresentation()
|
|
.setVisible(codeCompletionEnabled && List.of(OPENAI, LLAMA_CPP).contains(selectedService));
|
|
}
|
|
|
|
@Override
|
|
public @NotNull ActionUpdateThread getActionUpdateThread() {
|
|
return ActionUpdateThread.BGT;
|
|
}
|
|
}
|