chore: general cleanup of now useless RuntimeException wrapping

This commit is contained in:
zaaarf 2023-11-27 16:15:40 +01:00
parent 7ceb7eb998
commit e64939d156
No known key found for this signature in database
GPG key ID: 6445A5CD15E5B40C
13 changed files with 98 additions and 120 deletions

View file

@ -1,9 +1,5 @@
package com.codemp.intellij;
import com.codemp.intellij.exceptions.lib.ChannelException;
import com.codemp.intellij.exceptions.lib.DeadlockedException;
import com.codemp.intellij.exceptions.lib.InvalidStateException;
import com.codemp.intellij.exceptions.lib.TransportException;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.util.SystemInfo;
import cz.adamh.utils.NativeUtils;
@ -33,7 +29,6 @@ public class CodeMP {
LOGGER.info("Loaded CodeMP library!");
loadedLibrary = false;
}
}
}
}

View file

@ -9,7 +9,7 @@ import com.intellij.openapi.ui.Messages;
import org.jetbrains.annotations.NotNull;
public class ConnectAction extends AnAction {
public static void connect(AnActionEvent e, String url, boolean silent) throws Exception {
public static void connect(AnActionEvent e, String url, boolean silent) {
CodeMP.loadLibrary(); //will only load it the first time
CodeMPHandler.connect(url);

View file

@ -1,5 +1,6 @@
package com.codemp.intellij.actions;
import com.codemp.intellij.CodeMP;
import com.codemp.intellij.actions.buffer.BufferAttachAction;
import com.codemp.intellij.actions.workspace.WorkspaceJoinAction;
import com.intellij.openapi.actionSystem.AnAction;
@ -12,12 +13,9 @@ import org.jetbrains.annotations.NotNull;
public class FastForwardAction extends AnAction {
@Override
public void actionPerformed(@NotNull AnActionEvent e) {
try {
ConnectAction.connect(e, "http://alemi.dev:50052", true);
WorkspaceJoinAction.join(e, "default", true);
BufferAttachAction.attach(e, "test", true);
} catch(Exception ex) {
throw new RuntimeException(ex);
}
BufferAttachAction.attach(e, "fucl", true);
CodeMP.LOGGER.debug("Completed quick startup for testing!");
}
}

View file

@ -12,7 +12,7 @@ import com.intellij.openapi.ui.Messages;
import org.jetbrains.annotations.NotNull;
public class BufferAttachAction extends AnAction {
public static void attach(AnActionEvent e, String buffer, boolean silent) throws Exception {
public static void attach(AnActionEvent e, String buffer, boolean silent) {
BufferHandler bufferHandler = CodeMPHandler.attach(buffer);
if(!silent) ActionUtil.notify(e, "Success",
String.format("Successfully attached to buffer to buffer to %s!", buffer)

View file

@ -9,7 +9,7 @@ import com.intellij.openapi.ui.Messages;
import org.jetbrains.annotations.NotNull;
public class BufferCreateAction extends AnAction {
public static void create(AnActionEvent e, String buffer, boolean silent) throws Exception {
public static void create(AnActionEvent e, String buffer, boolean silent) {
CodeMPHandler.create(buffer);
if(!silent) ActionUtil.notify(e, "Success",
String.format("Created buffer %s!", buffer)

View file

@ -10,7 +10,7 @@ import org.jetbrains.annotations.NotNull;
public class BufferCreateWithContentAction extends AnAction {
public static void createWithContent(AnActionEvent event, String buffer, boolean silent) throws Exception {
public static void createWithContent(AnActionEvent event, String buffer, boolean silent) {
String content = ActionUtil.getCurrentEditor(event).getDocument().getText();
CodeMPHandler.createWithContent(buffer, content);

View file

@ -12,7 +12,7 @@ import com.intellij.openapi.ui.Messages;
import org.jetbrains.annotations.NotNull;
public class BufferDetachAction extends AnAction {
public static void detach(AnActionEvent e, String buffer, boolean silent) throws Exception {
public static void detach(AnActionEvent e, String buffer, boolean silent) {
boolean res = CodeMPHandler.detach(buffer);
if(!res) throw new BufferDetachException(buffer);

View file

@ -14,7 +14,7 @@ import com.intellij.openapi.ui.Messages;
import org.jetbrains.annotations.NotNull;
public class WorkspaceJoinAction extends AnAction {
public static void join(AnActionEvent e, String workspace, boolean silent) throws Exception {
public static void join(AnActionEvent e, String workspace, boolean silent) {
CursorHandler cursorHandler = CodeMPHandler.join(workspace);
if(!silent) ActionUtil.notify(e,

View file

@ -9,7 +9,7 @@ import com.intellij.openapi.ui.Messages;
import org.jetbrains.annotations.NotNull;
public class WorkspaceLeaveAction extends AnAction {
public static void leave(AnActionEvent e, boolean silent) throws Exception {
public static void leave(AnActionEvent e, boolean silent) {
CodeMPHandler.leaveWorkspace();
if(!silent) ActionUtil.notify(e, "Success", "Left workspace");

View file

@ -1,6 +1,7 @@
package com.codemp.intellij.listeners;
import com.codemp.intellij.CodeMP;
import com.codemp.intellij.exceptions.CodeMPException;
import com.codemp.intellij.jni.BufferHandler;
import com.intellij.openapi.command.CommandProcessor;
import com.intellij.openapi.editor.event.DocumentEvent;
@ -16,7 +17,7 @@ public class BufferEventListener implements DocumentListener {
}
@Override
public void documentChanged(@NotNull DocumentEvent event) {
public void documentChanged(@NotNull DocumentEvent event) throws CodeMPException {
CodeMP.LOGGER.debug("Changed {} to {} at offset {}",
event.getOldFragment(), event.getNewFragment(), event.getOffset());
@ -24,14 +25,11 @@ public class BufferEventListener implements DocumentListener {
if(group instanceof String groupString && groupString.startsWith("codemp-buffer-receive"))
return;
try { //TODO move actions break
//TODO move actions break
int changeOffset = event.getOffset();
CharSequence newFragment = event.getNewFragment();
this.bufferHandler.send(changeOffset,
changeOffset + event.getOldFragment().length(),
newFragment.toString());
} catch(Exception e) {
throw new RuntimeException(e);
}
}
}

View file

@ -22,7 +22,6 @@ public class CursorEventListener implements CaretListener {
if(caret == null)
return;
try {
VisualPosition startPos = caret.getSelectionStartPosition();
VisualPosition endPos = caret.getSelectionEndPosition();
CodeMP.LOGGER.debug("Caret moved from {}x {}y to {}x {}y",
@ -32,8 +31,5 @@ public class CursorEventListener implements CaretListener {
startPos.line, startPos.column,
endPos.line, endPos.column
);
} catch(Exception ex) {
throw new RuntimeException(ex);
}
}
}

View file

@ -59,7 +59,6 @@ public class BufferEventAwaiterTask extends Task.Backgroundable implements Dispo
try {
while(true) {
try {
String buffer = CodeMPHandler.selectBuffer();
BufferHandler handler = CodeMPHandler.getBuffer(buffer);
@ -94,9 +93,6 @@ public class BufferEventAwaiterTask extends Task.Backgroundable implements Dispo
"codemp-buffer-receive", //TODO: mark this with the name
bufferEditor.getDocument()
)));
} catch(Exception ex) {
throw new RuntimeException(ex);
}
}
} catch(Exception ex) {
TaskManager.nullBufferTask();

View file

@ -1,6 +1,7 @@
package com.codemp.intellij.task;
import com.codemp.intellij.CodeMP;
import com.codemp.intellij.exceptions.CodeMPException;
import com.codemp.intellij.jni.CursorEventWrapper;
import com.codemp.intellij.jni.CursorHandler;
import com.codemp.intellij.util.ColorUtil;
@ -41,7 +42,6 @@ public class CursorEventAwaiterTask extends Task.Backgroundable implements Dispo
assert myProject != null; //will never fail
try {
while(true) {
try {
CursorEventWrapper event = handler.recv();
Editor editor = CodeMP.ACTIVE_BUFFERS.get(event.getBuffer());
@ -82,13 +82,8 @@ public class CursorEventAwaiterTask extends Task.Backgroundable implements Dispo
//suppress if the cursor only exceeds length by one, it's probably just him adding something at EOF
if(endOffset - editor.getDocument().getTextLength() != 1)
throw ex;
} catch(Exception ex) {
throw new RuntimeException(ex);
}
});
} catch(Exception ex) {
throw new RuntimeException(ex);
}
}
} catch(Exception ex) { //exited
this.highlighterMap.forEach((s, r) -> r.dispose());