mirror of
https://github.com/hexedtech/codemp-intellij.git
synced 2024-11-21 22:54:48 +01:00
fix: cargo build now completes without errors
...but it does get a shit ton of warnings.
This commit is contained in:
parent
85b00c4335
commit
e7604e237b
4 changed files with 55 additions and 33 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -46,3 +46,6 @@ bin/
|
|||
Cargo.lock
|
||||
.cargo/*
|
||||
target/*
|
||||
|
||||
# Do not inclue generated code
|
||||
src/main/java/com/codemp/intellij/jni
|
||||
|
|
16
build.rs
16
build.rs
|
@ -3,13 +3,14 @@ use std::{env, path::Path};
|
|||
use rifgen::{Generator, TypeCases, Language};
|
||||
|
||||
fn main() {
|
||||
let out_dir = Path::new(&env::var("OUT_DIR")
|
||||
.expect("no OUT_DIR, but cargo should provide it"));
|
||||
let out_dir_var = env::var("OUT_DIR")
|
||||
.expect("no OUT_DIR, but cargo should provide it");
|
||||
let out_dir = Path::new(&out_dir_var);
|
||||
let source_folder = "src/main/rust/";
|
||||
|
||||
let glue_file = out_dir.join("glue.in");
|
||||
Generator::new(TypeCases::CamelCase,Language::Java,source_folder)
|
||||
.generate_interface(glue_file.to_str());
|
||||
.generate_interface(&glue_file);
|
||||
|
||||
let java_gen = flapigen::Generator::new(LanguageConfig::JavaConfig(
|
||||
JavaConfig::new(
|
||||
|
@ -18,18 +19,19 @@ fn main() {
|
|||
.join("java")
|
||||
.join("com")
|
||||
.join("codemp")
|
||||
.join("intellij"),
|
||||
"com.codemp.intellij".into()
|
||||
.join("intellij")
|
||||
.join("jni"),
|
||||
"com.codemp.intellij.jni".into()
|
||||
))).rustfmt_bindings(true);
|
||||
|
||||
java_gen.expand(
|
||||
"codemp-intellij",
|
||||
glue_file,
|
||||
&glue_file,
|
||||
out_dir.join("glue.rs"),
|
||||
);
|
||||
|
||||
println!(
|
||||
"cargo:rerun-if-changed={}",
|
||||
Path::new("src/main").join(glue_file).display()
|
||||
Path::new("src/main").join(&glue_file).display()
|
||||
);
|
||||
}
|
|
@ -11,7 +11,7 @@ impl From::<CodempError> for ErrorWrapper {
|
|||
}
|
||||
|
||||
impl ErrorWrapper {
|
||||
pub(crate) fn throw(&self, mut env: JNIEnv) {
|
||||
pub fn throw(&self, mut env: JNIEnv) {
|
||||
let exception_package: String = format!("{}/exceptions", JAVA_FOLDER);
|
||||
let res = match &self.0 {
|
||||
CodempError::Transport { status, message } => env.throw_new(format!("{}/TransportException", exception_package), format!("Error {}: {}", status, message)),
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
mod error;
|
||||
|
||||
use std::ffi::c_char;
|
||||
use std::sync::Arc;
|
||||
use codemp::prelude::*;
|
||||
use rifgen::rifgen_attr::generate_interface;
|
||||
|
@ -18,17 +19,18 @@ impl CodeMPHandler {
|
|||
}
|
||||
|
||||
#[generate_interface]
|
||||
fn connect(addr: String) {
|
||||
match CODEMP_INSTANCE.connect(&addr) {
|
||||
async fn connect(addr: String) {
|
||||
CODEMP_INSTANCE.connect(&addr).await;
|
||||
/*match CODEMP_INSTANCE.connect(&addr) {
|
||||
Ok(()) => (),
|
||||
Err(err) => ErrorWrapper(err) //.throw(env)
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
#[generate_interface]
|
||||
fn join(session: String) -> CursorHandler {
|
||||
let controller = CODEMP_INSTANCE.join(&session)?.unwrap();
|
||||
CursorHandler { controller } //TODO error handling
|
||||
async fn join(session: String) -> CursorHandler {
|
||||
let controller = CODEMP_INSTANCE.join(&session).await.unwrap();
|
||||
CursorHandler { cursor: Some(controller) } //TODO error handling
|
||||
/*match CODEMP_INSTANCE.join(&session) {
|
||||
Ok(cursor) => CursorHandler { cursor },
|
||||
//Err(err) => ErrorWrapper(err)
|
||||
|
@ -36,48 +38,63 @@ impl CodeMPHandler {
|
|||
}
|
||||
|
||||
#[generate_interface]
|
||||
fn create(path: String) {
|
||||
CODEMP_INSTANCE.create(&path, None);
|
||||
async fn create(path: String) {
|
||||
CODEMP_INSTANCE.create(&path, None).await;
|
||||
}
|
||||
|
||||
#[generate_interface]
|
||||
fn create_with_content(path: String, content: String) {
|
||||
CODEMP_INSTANCE.create(&path, Some(&content))
|
||||
async fn create_with_content(path: String, content: String) {
|
||||
CODEMP_INSTANCE.create(&path, Some(&content)).await;
|
||||
}
|
||||
|
||||
#[generate_interface]
|
||||
fn attach(path: String) -> BufferHandler {
|
||||
let controller = CODEMP_INSTANCE.attach(&path)?.unwrap();
|
||||
BufferHandler { controller }
|
||||
async fn attach(path: String) -> BufferHandler {
|
||||
let controller = CODEMP_INSTANCE.attach(&path).await.unwrap();
|
||||
BufferHandler { buffer: Some(controller) }
|
||||
}
|
||||
|
||||
#[generate_interface]
|
||||
fn get_cursor() -> CursorHandler {
|
||||
let controller = CODEMP_INSTANCE.get_cursor()?.unwrap();
|
||||
CursorHandler { controller }
|
||||
async fn get_cursor() -> CursorHandler {
|
||||
let controller = CODEMP_INSTANCE.get_cursor().await.unwrap();
|
||||
CursorHandler { cursor: Some(controller) }
|
||||
}
|
||||
|
||||
#[generate_interface]
|
||||
fn get_buffer(path: String) -> BufferHandler {
|
||||
let controller = CODEMP_INSTANCE.get_buffer(&path)?.unwrap();
|
||||
BufferHandler { controller }
|
||||
async fn get_buffer(path: String) -> BufferHandler {
|
||||
let controller = CODEMP_INSTANCE.get_buffer(&path).await.unwrap();
|
||||
BufferHandler { buffer: Some(controller) }
|
||||
}
|
||||
|
||||
#[generate_interface]
|
||||
fn leave_workspace() {
|
||||
CODEMP_INSTANCE.leave_workspace()?.unwrap()
|
||||
async fn leave_workspace() {
|
||||
CODEMP_INSTANCE.leave_workspace().await.unwrap()
|
||||
}
|
||||
|
||||
#[generate_interface]
|
||||
fn disconnect_buffer(path: String) -> bool {
|
||||
CODEMP_INSTANCE.disconnect_buffer(&path)?.unwrap();
|
||||
async fn disconnect_buffer(path: String) -> bool {
|
||||
CODEMP_INSTANCE.disconnect_buffer(&path).await.unwrap()
|
||||
}
|
||||
}
|
||||
|
||||
struct CursorHandler {
|
||||
controller: Arc<CodempCursorController>
|
||||
cursor: Option<Arc<CodempCursorController>>
|
||||
}
|
||||
|
||||
impl CursorHandler {
|
||||
#[generate_interface(constructor)]
|
||||
fn new() -> CursorHandler { //TODO this sucks but whatever
|
||||
CursorHandler { cursor: None }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
struct BufferHandler {
|
||||
buffer: Arc<CodempBufferController>
|
||||
buffer: Option<Arc<CodempBufferController>>
|
||||
}
|
||||
|
||||
impl BufferHandler {
|
||||
#[generate_interface(constructor)]
|
||||
fn new() -> BufferHandler { //TODO this sucks but whatever
|
||||
BufferHandler { buffer: None }
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue