chore: slimmed down glue boilerplate

This commit is contained in:
zaaarf 2023-11-18 18:28:53 +01:00
parent 81529bb0b0
commit c9b9eb2ae1
No known key found for this signature in database
GPG key ID: 82240E075E31FA4C
6 changed files with 13 additions and 67 deletions

View file

@ -13,8 +13,8 @@ import java.util.concurrent.ConcurrentHashMap;
public class CodeMP {
public static Logger LOGGER = LoggerFactory.getLogger(CodeMP.class);
public static Map<String, Editor> ACTIVE_BUFFERS = new ConcurrentHashMap<>();
public static Map<Editor, String> ACTIVE_BUFFERS_REVERSE = new ConcurrentHashMap<>(); //TODO jank
public static final Map<String, Editor> ACTIVE_BUFFERS = new ConcurrentHashMap<>();
public static final Map<Editor, String> ACTIVE_BUFFERS_REVERSE = new ConcurrentHashMap<>();
private static boolean loadedLibrary = false;
public static void loadLibrary() {
@ -29,6 +29,7 @@ public class CodeMP {
LOGGER.info("Loaded CodeMP library!");
loadedLibrary = false;
}
}
}
}

View file

@ -1,4 +1,4 @@
package com.codemp.intellij.exceptions.rust;
package com.codemp.intellij.exceptions.lib;
import com.codemp.intellij.exceptions.CodeMPException;

View file

@ -1,4 +1,4 @@
package com.codemp.intellij.exceptions.rust;
package com.codemp.intellij.exceptions.lib;
import com.codemp.intellij.exceptions.CodeMPException;
@ -6,4 +6,4 @@ public class InvalidStateException extends CodeMPException {
public InvalidStateException(String message) {
super(message);
}
}
}

View file

@ -1,4 +1,4 @@
package com.codemp.intellij.exceptions.rust;
package com.codemp.intellij.exceptions.lib;
import com.codemp.intellij.exceptions.CodeMPException;
@ -6,4 +6,4 @@ public class TransportException extends CodeMPException {
public TransportException(String message) {
super(message);
}
}
}

View file

@ -27,3 +27,4 @@ impl ErrorWrapper {
}
}
}

View file

@ -2,10 +2,10 @@ mod error;
use std::sync::Arc;
use codemp::prelude::*;
use rifgen::rifgen_attr::{generate_interface, generate_interface_doc};
use rifgen::rifgen_attr::{generate_access_methods, generate_interface, generate_interface_doc};
use crate::error::ErrorWrapper;
pub mod glue {
pub mod glue { //rifgen generated code
include!(concat!(env!("OUT_DIR"), "/glue.rs"));
}
@ -87,6 +87,7 @@ fn convert<T>(result: Result<T, CodempError>) -> Result<T, String> {
}
#[generate_interface_doc]
#[generate_access_methods]
struct CursorEventWrapper {
user: String,
buffer: String,
@ -96,42 +97,6 @@ struct CursorEventWrapper {
end_col: i32
}
impl CursorEventWrapper {
#[generate_interface(constructor)]
fn new() -> CursorEventWrapper {
panic!("Default constructor for CursorEventWrapper should never be called!")
}
#[generate_interface]
fn get_user(&self) -> &str {
&self.user
}
#[generate_interface]
fn get_buffer(&self) -> &str {
&self.buffer
}
#[generate_interface]
fn get_start_row(&self) -> i32 {
self.start_row
}
#[generate_interface]
fn get_start_col(&self) -> i32 {
self.start_col
}
#[generate_interface]
fn get_end_row(&self) -> i32 {
self.end_row
}
#[generate_interface]
fn get_end_col(&self) -> i32 {
self.end_col
}
}
#[generate_interface_doc]
struct CursorHandler {
@ -171,34 +136,13 @@ impl CursorHandler {
}
#[generate_interface_doc]
#[generate_access_methods]
struct TextChangeWrapper {
start: usize,
end: usize, //not inclusive
content: String
}
impl TextChangeWrapper {
#[generate_interface(constructor)]
fn new() -> TextChangeWrapper {
panic!("Default constructor for TextChangeWrapper should never be called!")
}
#[generate_interface]
fn get_start(&self) -> usize {
self.start
}
#[generate_interface]
fn get_end(&self) -> usize {
self.end
}
#[generate_interface]
fn get_content(&self) -> String {
self.content.clone()
}
}
#[generate_interface_doc]
struct BufferHandler {
#[allow(unused)]