Add reviewed FXML View generation in both hosts

This commit is contained in:
2026-11-13 21:39:06 +01:00
parent 1856f69637
commit 9ab1a4f530
18 changed files with 1463 additions and 9 deletions
@@ -104,6 +104,15 @@ public final class IntellijDocuments implements HostServices.Documents, AutoClos
return future;
}
public CompletionStage<DocumentSession> create(URI uri, String text) {
return edt(() -> {
Files.writeString(
Path.of(uri), text, StandardOpenOption.CREATE_NEW, StandardOpenOption.WRITE);
return uri;
})
.thenCompose(this::open);
}
public CompletionStage<DocumentSession> open(URI uri) {
return edt(
() -> {
@@ -6,6 +6,31 @@ import java.nio.file.*;
import java.util.*;
public final class IntellijDocumentsTest extends BasePlatformTestCase {
public void testCreateNeverOverwritesAndSupportsNativeHistory() throws Exception {
Path folder = Files.createTempDirectory("designer-create-");
com.intellij.openapi.vfs.newvfs.impl.VfsRootAccess.allowRootAccess(
getTestRootDisposable(), folder.toRealPath().toString(), folder.toString());
var uri = folder.resolve("New.fxml").toUri();
try (var docs = new IntellijDocuments(getProject());
var d = docs.create(uri, "before").toCompletableFuture().get()) {
try {
docs.create(uri, "overwrite").toCompletableFuture().get();
fail("Existing file overwritten");
} catch (java.util.concurrent.ExecutionException expected) {
assertInstanceOf(expected.getCause(), FileAlreadyExistsException.class);
}
d.apply(new EditBatch(0, "edit", List.of(new EditBatch.Replacement(0, 6, "after"))))
.toCompletableFuture()
.get();
assertEquals("before", d.undo().toCompletableFuture().get().text());
assertEquals("after", d.redo().toCompletableFuture().get().text());
assertEquals("before", Files.readString(Path.of(uri)));
} finally {
Files.deleteIfExists(Path.of(uri));
Files.deleteIfExists(folder);
}
}
/** Keeps real VFS writes queued until its per-file flush executes them. */
public void testSaveWaitsForQueuedVfsWrites() throws Exception {
var fs = com.intellij.openapi.vfs.LocalFileSystem.getInstance();