Connect minimal hosts to snapshots, target workers and shared Kit editing

This commit is contained in:
2026-11-12 11:07:45 +01:00
parent 28c1e47c95
commit 7db7218a6e
52 changed files with 4236 additions and 29 deletions
@@ -9,7 +9,8 @@ public final class IntellijDocumentsTest extends BasePlatformTestCase {
public void testNativeDocumentTransactionUndoAndIndependentHandles() throws Exception {
Path file = Files.createTempFile("designer-document-", ".fxml");
Files.writeString(file, "abcdef");
com.intellij.openapi.vfs.newvfs.impl.VfsRootAccess.allowRootAccess(getTestRootDisposable(), file.toRealPath().toString());
com.intellij.openapi.vfs.newvfs.impl.VfsRootAccess.allowRootAccess(
getTestRootDisposable(), file.toRealPath().toString());
try (var docs = new IntellijDocuments(getProject())) {
var a = docs.open(file.toUri()).toCompletableFuture().get();
var b = docs.open(file.toUri()).toCompletableFuture().get();
@@ -48,7 +49,8 @@ public final class IntellijDocumentsTest extends BasePlatformTestCase {
public void testExternalChangesDoNotLoseDraft() throws Exception {
Path file = Files.createTempFile("designer-conflict-", ".fxml");
Files.writeString(file, "old");
com.intellij.openapi.vfs.newvfs.impl.VfsRootAccess.allowRootAccess(getTestRootDisposable(), file.toRealPath().toString());
com.intellij.openapi.vfs.newvfs.impl.VfsRootAccess.allowRootAccess(
getTestRootDisposable(), file.toRealPath().toString());
try (var docs = new IntellijDocuments(getProject())) {
var d = docs.open(file.toUri()).toCompletableFuture().get();
var changed =
@@ -69,4 +71,42 @@ public final class IntellijDocumentsTest extends BasePlatformTestCase {
Files.deleteIfExists(file);
}
}
public void testKeepsNativeDocumentOpenedThroughAlias() throws Exception {
Path directory = Files.createTempDirectory("designer-alias-");
Path real = directory.resolve("real");
Files.createDirectory(real);
Path alias = directory.resolve("alias");
Files.createSymbolicLink(alias, real);
Path file = real.resolve("View.fxml");
Files.writeString(file, "before");
com.intellij.openapi.vfs.newvfs.impl.VfsRootAccess.allowRootAccess(
getTestRootDisposable(), directory.toRealPath().toString(), directory.toString());
var virtual =
com.intellij.openapi.vfs.LocalFileSystem.getInstance()
.refreshAndFindFileByNioFile(alias.resolve("View.fxml"));
var nativeDocument =
com.intellij.openapi.fileEditor.FileDocumentManager.getInstance().getDocument(virtual);
try (var docs = new IntellijDocuments(getProject());
var handle = docs.open(alias.resolve("View.fxml").toUri()).toCompletableFuture().get()) {
var before = handle.snapshot().toCompletableFuture().get();
var after =
handle
.apply(
new EditBatch(
before.revision(),
"Alias edit",
List.of(new EditBatch.Replacement(0, before.text().length(), "after"))))
.toCompletableFuture()
.get();
assertEquals("after", nativeDocument.getText());
assertEquals(file.toRealPath().toUri(), after.document());
handle.save(after.revision()).toCompletableFuture().get();
} finally {
Files.deleteIfExists(alias);
Files.deleteIfExists(file);
Files.deleteIfExists(real);
Files.deleteIfExists(directory);
}
}
}