mirror of
https://github.com/hexedtech/codemp-intellij.git
synced 2024-11-22 07:04:49 +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.lock
|
||||||
.cargo/*
|
.cargo/*
|
||||||
target/*
|
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};
|
use rifgen::{Generator, TypeCases, Language};
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let out_dir = Path::new(&env::var("OUT_DIR")
|
let out_dir_var = env::var("OUT_DIR")
|
||||||
.expect("no OUT_DIR, but cargo should provide it"));
|
.expect("no OUT_DIR, but cargo should provide it");
|
||||||
|
let out_dir = Path::new(&out_dir_var);
|
||||||
let source_folder = "src/main/rust/";
|
let source_folder = "src/main/rust/";
|
||||||
|
|
||||||
let glue_file = out_dir.join("glue.in");
|
let glue_file = out_dir.join("glue.in");
|
||||||
Generator::new(TypeCases::CamelCase,Language::Java,source_folder)
|
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(
|
let java_gen = flapigen::Generator::new(LanguageConfig::JavaConfig(
|
||||||
JavaConfig::new(
|
JavaConfig::new(
|
||||||
|
@ -18,18 +19,19 @@ fn main() {
|
||||||
.join("java")
|
.join("java")
|
||||||
.join("com")
|
.join("com")
|
||||||
.join("codemp")
|
.join("codemp")
|
||||||
.join("intellij"),
|
.join("intellij")
|
||||||
"com.codemp.intellij".into()
|
.join("jni"),
|
||||||
|
"com.codemp.intellij.jni".into()
|
||||||
))).rustfmt_bindings(true);
|
))).rustfmt_bindings(true);
|
||||||
|
|
||||||
java_gen.expand(
|
java_gen.expand(
|
||||||
"codemp-intellij",
|
"codemp-intellij",
|
||||||
glue_file,
|
&glue_file,
|
||||||
out_dir.join("glue.rs"),
|
out_dir.join("glue.rs"),
|
||||||
);
|
);
|
||||||
|
|
||||||
println!(
|
println!(
|
||||||
"cargo:rerun-if-changed={}",
|
"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 {
|
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 exception_package: String = format!("{}/exceptions", JAVA_FOLDER);
|
||||||
let res = match &self.0 {
|
let res = match &self.0 {
|
||||||
CodempError::Transport { status, message } => env.throw_new(format!("{}/TransportException", exception_package), format!("Error {}: {}", status, message)),
|
CodempError::Transport { status, message } => env.throw_new(format!("{}/TransportException", exception_package), format!("Error {}: {}", status, message)),
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
mod error;
|
mod error;
|
||||||
|
|
||||||
|
use std::ffi::c_char;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use codemp::prelude::*;
|
use codemp::prelude::*;
|
||||||
use rifgen::rifgen_attr::generate_interface;
|
use rifgen::rifgen_attr::generate_interface;
|
||||||
|
@ -18,17 +19,18 @@ impl CodeMPHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[generate_interface]
|
#[generate_interface]
|
||||||
fn connect(addr: String) {
|
async fn connect(addr: String) {
|
||||||
match CODEMP_INSTANCE.connect(&addr) {
|
CODEMP_INSTANCE.connect(&addr).await;
|
||||||
|
/*match CODEMP_INSTANCE.connect(&addr) {
|
||||||
Ok(()) => (),
|
Ok(()) => (),
|
||||||
Err(err) => ErrorWrapper(err) //.throw(env)
|
Err(err) => ErrorWrapper(err) //.throw(env)
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
#[generate_interface]
|
#[generate_interface]
|
||||||
fn join(session: String) -> CursorHandler {
|
async fn join(session: String) -> CursorHandler {
|
||||||
let controller = CODEMP_INSTANCE.join(&session)?.unwrap();
|
let controller = CODEMP_INSTANCE.join(&session).await.unwrap();
|
||||||
CursorHandler { controller } //TODO error handling
|
CursorHandler { cursor: Some(controller) } //TODO error handling
|
||||||
/*match CODEMP_INSTANCE.join(&session) {
|
/*match CODEMP_INSTANCE.join(&session) {
|
||||||
Ok(cursor) => CursorHandler { cursor },
|
Ok(cursor) => CursorHandler { cursor },
|
||||||
//Err(err) => ErrorWrapper(err)
|
//Err(err) => ErrorWrapper(err)
|
||||||
|
@ -36,48 +38,63 @@ impl CodeMPHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[generate_interface]
|
#[generate_interface]
|
||||||
fn create(path: String) {
|
async fn create(path: String) {
|
||||||
CODEMP_INSTANCE.create(&path, None);
|
CODEMP_INSTANCE.create(&path, None).await;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[generate_interface]
|
#[generate_interface]
|
||||||
fn create_with_content(path: String, content: String) {
|
async fn create_with_content(path: String, content: String) {
|
||||||
CODEMP_INSTANCE.create(&path, Some(&content))
|
CODEMP_INSTANCE.create(&path, Some(&content)).await;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[generate_interface]
|
#[generate_interface]
|
||||||
fn attach(path: String) -> BufferHandler {
|
async fn attach(path: String) -> BufferHandler {
|
||||||
let controller = CODEMP_INSTANCE.attach(&path)?.unwrap();
|
let controller = CODEMP_INSTANCE.attach(&path).await.unwrap();
|
||||||
BufferHandler { controller }
|
BufferHandler { buffer: Some(controller) }
|
||||||
}
|
}
|
||||||
|
|
||||||
#[generate_interface]
|
#[generate_interface]
|
||||||
fn get_cursor() -> CursorHandler {
|
async fn get_cursor() -> CursorHandler {
|
||||||
let controller = CODEMP_INSTANCE.get_cursor()?.unwrap();
|
let controller = CODEMP_INSTANCE.get_cursor().await.unwrap();
|
||||||
CursorHandler { controller }
|
CursorHandler { cursor: Some(controller) }
|
||||||
}
|
}
|
||||||
|
|
||||||
#[generate_interface]
|
#[generate_interface]
|
||||||
fn get_buffer(path: String) -> BufferHandler {
|
async fn get_buffer(path: String) -> BufferHandler {
|
||||||
let controller = CODEMP_INSTANCE.get_buffer(&path)?.unwrap();
|
let controller = CODEMP_INSTANCE.get_buffer(&path).await.unwrap();
|
||||||
BufferHandler { controller }
|
BufferHandler { buffer: Some(controller) }
|
||||||
}
|
}
|
||||||
|
|
||||||
#[generate_interface]
|
#[generate_interface]
|
||||||
fn leave_workspace() {
|
async fn leave_workspace() {
|
||||||
CODEMP_INSTANCE.leave_workspace()?.unwrap()
|
CODEMP_INSTANCE.leave_workspace().await.unwrap()
|
||||||
}
|
}
|
||||||
|
|
||||||
#[generate_interface]
|
#[generate_interface]
|
||||||
fn disconnect_buffer(path: String) -> bool {
|
async fn disconnect_buffer(path: String) -> bool {
|
||||||
CODEMP_INSTANCE.disconnect_buffer(&path)?.unwrap();
|
CODEMP_INSTANCE.disconnect_buffer(&path).await.unwrap()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct CursorHandler {
|
struct CursorHandler {
|
||||||
controller: Arc<CodempCursorController>
|
cursor: Option<Arc<CodempCursorController>>
|
||||||
}
|
}
|
||||||
|
|
||||||
struct BufferHandler {
|
impl CursorHandler {
|
||||||
buffer: Arc<CodempBufferController>
|
#[generate_interface(constructor)]
|
||||||
|
fn new() -> CursorHandler { //TODO this sucks but whatever
|
||||||
|
CursorHandler { cursor: None }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
struct BufferHandler {
|
||||||
|
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