mirror of
https://github.com/hexedtech/codemp.git
synced 2024-11-22 15:24:48 +01:00
fix(java): new filetree, mistake in create_buffer
This commit is contained in:
parent
4004f2011f
commit
21f1948f04
2 changed files with 19 additions and 8 deletions
14
dist/java/src/mp/code/Workspace.java
vendored
14
dist/java/src/mp/code/Workspace.java
vendored
|
@ -28,14 +28,14 @@ public class Workspace {
|
||||||
return Optional.ofNullable(get_buffer(this.ptr, path));
|
return Optional.ofNullable(get_buffer(this.ptr, path));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static native String[] get_file_tree(long self);
|
private static native String[] get_file_tree(long self, String filter);
|
||||||
public String[] getFileTree() {
|
public String[] getFileTree(Optional<String> filter) {
|
||||||
return get_file_tree(this.ptr);
|
return get_file_tree(this.ptr, filter.orElse(null));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static native long create_buffer(String path) throws CodeMPException;
|
private static native void create_buffer(String path) throws CodeMPException;
|
||||||
public BufferController createBuffer(String path) throws CodeMPException {
|
public void createBuffer(String path) throws CodeMPException {
|
||||||
return new BufferController(create_buffer(path));
|
create_buffer(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static native BufferController attach_to_buffer(long self, String path) throws CodeMPException;
|
private static native BufferController attach_to_buffer(long self, String path) throws CodeMPException;
|
||||||
|
@ -93,7 +93,7 @@ public class Workspace {
|
||||||
this.argument = argument;
|
this.argument = argument;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Optional<String> getUserJoined() {
|
public Optional<String > getUserJoined() {
|
||||||
if(this.type == Type.USER_JOIN) {
|
if(this.type == Type.USER_JOIN) {
|
||||||
return Optional.of(this.argument);
|
return Optional.of(this.argument);
|
||||||
} else return Optional.empty();
|
} else return Optional.empty();
|
||||||
|
|
|
@ -69,9 +69,20 @@ pub extern "system" fn Java_mp_code_Workspace_get_1file_1tree(
|
||||||
mut env: JNIEnv,
|
mut env: JNIEnv,
|
||||||
_class: JClass,
|
_class: JClass,
|
||||||
self_ptr: jlong,
|
self_ptr: jlong,
|
||||||
|
filter: JString
|
||||||
) -> jobjectArray {
|
) -> jobjectArray {
|
||||||
let workspace = unsafe { Box::leak(Box::from_raw(self_ptr as *mut Workspace)) };
|
let workspace = unsafe { Box::leak(Box::from_raw(self_ptr as *mut Workspace)) };
|
||||||
let file_tree = workspace.filetree();
|
let filter: Option<String> = if filter.is_null() {
|
||||||
|
None
|
||||||
|
} else {
|
||||||
|
Some(
|
||||||
|
env.get_string(&filter)
|
||||||
|
.map(|s| s.into())
|
||||||
|
.jexcept(&mut env)
|
||||||
|
)
|
||||||
|
};
|
||||||
|
|
||||||
|
let file_tree = workspace.filetree(filter.as_deref());
|
||||||
env.find_class("java/lang/String")
|
env.find_class("java/lang/String")
|
||||||
.and_then(|class| env.new_object_array(file_tree.len() as i32, class, JObject::null()))
|
.and_then(|class| env.new_object_array(file_tree.len() as i32, class, JObject::null()))
|
||||||
.map(|arr| {
|
.map(|arr| {
|
||||||
|
|
Loading…
Reference in a new issue