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; 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.editor.Editor;
import com.intellij.openapi.util.SystemInfo; import com.intellij.openapi.util.SystemInfo;
import cz.adamh.utils.NativeUtils; import cz.adamh.utils.NativeUtils;
@ -33,7 +29,6 @@ public class CodeMP {
LOGGER.info("Loaded CodeMP library!"); LOGGER.info("Loaded CodeMP library!");
loadedLibrary = false; loadedLibrary = false;
} }
} }
} }
} }

View file

@ -9,7 +9,7 @@ import com.intellij.openapi.ui.Messages;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
public class ConnectAction extends AnAction { 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 CodeMP.loadLibrary(); //will only load it the first time
CodeMPHandler.connect(url); CodeMPHandler.connect(url);

View file

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

View file

@ -12,7 +12,7 @@ import com.intellij.openapi.ui.Messages;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
public class BufferAttachAction extends AnAction { 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); BufferHandler bufferHandler = CodeMPHandler.attach(buffer);
if(!silent) ActionUtil.notify(e, "Success", if(!silent) ActionUtil.notify(e, "Success",
String.format("Successfully attached to buffer to buffer to %s!", buffer) 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; import org.jetbrains.annotations.NotNull;
public class BufferCreateAction extends AnAction { 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); CodeMPHandler.create(buffer);
if(!silent) ActionUtil.notify(e, "Success", if(!silent) ActionUtil.notify(e, "Success",
String.format("Created buffer %s!", buffer) String.format("Created buffer %s!", buffer)

View file

@ -10,7 +10,7 @@ import org.jetbrains.annotations.NotNull;
public class BufferCreateWithContentAction extends AnAction { 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(); String content = ActionUtil.getCurrentEditor(event).getDocument().getText();
CodeMPHandler.createWithContent(buffer, content); CodeMPHandler.createWithContent(buffer, content);

View file

@ -12,7 +12,7 @@ import com.intellij.openapi.ui.Messages;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
public class BufferDetachAction extends AnAction { 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); boolean res = CodeMPHandler.detach(buffer);
if(!res) throw new BufferDetachException(buffer); if(!res) throw new BufferDetachException(buffer);

View file

@ -14,7 +14,7 @@ import com.intellij.openapi.ui.Messages;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
public class WorkspaceJoinAction extends AnAction { 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); CursorHandler cursorHandler = CodeMPHandler.join(workspace);
if(!silent) ActionUtil.notify(e, if(!silent) ActionUtil.notify(e,

View file

@ -9,7 +9,7 @@ import com.intellij.openapi.ui.Messages;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
public class WorkspaceLeaveAction extends AnAction { 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(); CodeMPHandler.leaveWorkspace();
if(!silent) ActionUtil.notify(e, "Success", "Left workspace"); if(!silent) ActionUtil.notify(e, "Success", "Left workspace");

View file

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

View file

@ -22,7 +22,6 @@ public class CursorEventListener implements CaretListener {
if(caret == null) if(caret == null)
return; return;
try {
VisualPosition startPos = caret.getSelectionStartPosition(); VisualPosition startPos = caret.getSelectionStartPosition();
VisualPosition endPos = caret.getSelectionEndPosition(); VisualPosition endPos = caret.getSelectionEndPosition();
CodeMP.LOGGER.debug("Caret moved from {}x {}y to {}x {}y", CodeMP.LOGGER.debug("Caret moved from {}x {}y to {}x {}y",
@ -32,8 +31,5 @@ public class CursorEventListener implements CaretListener {
startPos.line, startPos.column, startPos.line, startPos.column,
endPos.line, endPos.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 { try {
while(true) { while(true) {
try {
String buffer = CodeMPHandler.selectBuffer(); String buffer = CodeMPHandler.selectBuffer();
BufferHandler handler = CodeMPHandler.getBuffer(buffer); 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 "codemp-buffer-receive", //TODO: mark this with the name
bufferEditor.getDocument() bufferEditor.getDocument()
))); )));
} catch(Exception ex) {
throw new RuntimeException(ex);
}
} }
} catch(Exception ex) { } catch(Exception ex) {
TaskManager.nullBufferTask(); TaskManager.nullBufferTask();

View file

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