Codebase refactoring (#226)

* Refactor codebase
This commit is contained in:
Carl-Robert 2023-10-05 02:43:06 +03:00 committed by GitHub
parent 4c8b8d4e4f
commit 7dfe62b96d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
51 changed files with 244 additions and 247 deletions

View file

@ -0,0 +1,47 @@
package ee.carlrobert.codegpt.actions;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.editor.Editor;
import ee.carlrobert.codegpt.actions.ActionType;
import ee.carlrobert.codegpt.telemetry.TelemetryAction;
import javax.swing.Icon;
import org.jetbrains.annotations.NotNull;
public abstract class TrackableAction extends AnAction {
private final ActionType actionType;
protected final Editor editor;
public TrackableAction(
@NotNull Editor editor,
String text,
String description,
Icon icon,
ActionType actionType) {
super(text, description, icon);
this.editor = editor;
this.actionType = actionType;
}
public abstract void handleAction(@NotNull AnActionEvent e);
@Override
public void actionPerformed(@NotNull AnActionEvent e) {
try {
handleAction(e);
} catch (Exception ex) {
TelemetryAction.IDE_ACTION_ERROR
.createActionMessage()
.error(ex)
.send();
throw ex;
} finally {
TelemetryAction.IDE_ACTION
.createActionMessage()
.property("group", null)
.property("action", actionType.name())
.send();
}
}
}