Merge remote-tracking branch 'origin/dev' into dev

This commit is contained in:
cschen 2024-08-22 16:55:28 +02:00
commit 88f4ace04a
2 changed files with 19 additions and 8 deletions

View file

@ -28,14 +28,14 @@ public class Workspace {
return Optional.ofNullable(get_buffer(this.ptr, path));
}
private static native String[] get_file_tree(long self);
public String[] getFileTree() {
return get_file_tree(this.ptr);
private static native String[] get_file_tree(long self, String filter);
public String[] getFileTree(Optional<String> filter) {
return get_file_tree(this.ptr, filter.orElse(null));
}
private static native long create_buffer(String path) throws CodeMPException;
public BufferController createBuffer(String path) throws CodeMPException {
return new BufferController(create_buffer(path));
private static native void create_buffer(String path) throws CodeMPException;
public void createBuffer(String path) throws CodeMPException {
create_buffer(path);
}
private static native BufferController attach_to_buffer(long self, String path) throws CodeMPException;

View file

@ -69,9 +69,20 @@ pub extern "system" fn Java_mp_code_Workspace_get_1file_1tree(
mut env: JNIEnv,
_class: JClass,
self_ptr: jlong,
filter: JString
) -> jobjectArray {
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")
.and_then(|class| env.new_object_array(file_tree.len() as i32, class, JObject::null()))
.map(|arr| {