implements PLN-0020
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
package p.studio.vfs;
|
||||
|
||||
import java.nio.file.Path;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public interface ProjectDocumentVfs extends AutoCloseable {
|
||||
VfsProjectContext projectContext();
|
||||
@@ -13,6 +15,26 @@ public interface ProjectDocumentVfs extends AutoCloseable {
|
||||
|
||||
VfsDocumentOpenResult openDocument(Path path);
|
||||
|
||||
default VfsDocumentAccessContext accessContext(final Path path) {
|
||||
throw new UnsupportedOperationException("Document access context is not supported by this VFS implementation.");
|
||||
}
|
||||
|
||||
default VfsDocumentAccessContext updateAccessContext(final Path path, final Map<String, String> attributes) {
|
||||
throw new UnsupportedOperationException("Document access context updates are not supported by this VFS implementation.");
|
||||
}
|
||||
|
||||
default VfsTextDocument updateDocument(final Path path, final String content) {
|
||||
throw new UnsupportedOperationException("Document mutation is not supported by this VFS implementation.");
|
||||
}
|
||||
|
||||
default VfsDocumentSaveResult saveDocument(final Path path) {
|
||||
throw new UnsupportedOperationException("Document save is not supported by this VFS implementation.");
|
||||
}
|
||||
|
||||
default List<VfsDocumentSaveResult> saveAllDocuments() {
|
||||
return List.of();
|
||||
}
|
||||
|
||||
@Override
|
||||
default void close() {
|
||||
}
|
||||
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
package p.studio.vfs;
|
||||
|
||||
import java.nio.file.Path;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
public record VfsDocumentAccessContext(
|
||||
Path path,
|
||||
String typeId,
|
||||
boolean frontendDocument,
|
||||
VfsDocumentAccessMode accessMode,
|
||||
Map<String, String> attributes) {
|
||||
|
||||
public VfsDocumentAccessContext {
|
||||
path = Objects.requireNonNull(path, "path").toAbsolutePath().normalize();
|
||||
Objects.requireNonNull(typeId, "typeId");
|
||||
Objects.requireNonNull(accessMode, "accessMode");
|
||||
attributes = Map.copyOf(Objects.requireNonNull(attributes, "attributes"));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
package p.studio.vfs;
|
||||
|
||||
public enum VfsDocumentAccessMode {
|
||||
READ_ONLY,
|
||||
EDITABLE
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package p.studio.vfs;
|
||||
|
||||
import java.nio.file.Path;
|
||||
import java.util.Objects;
|
||||
|
||||
public record VfsDocumentSaveResult(
|
||||
Path path,
|
||||
String typeId,
|
||||
VfsDocumentSaveStatus status) {
|
||||
|
||||
public VfsDocumentSaveResult {
|
||||
path = Objects.requireNonNull(path, "path").toAbsolutePath().normalize();
|
||||
Objects.requireNonNull(typeId, "typeId");
|
||||
Objects.requireNonNull(status, "status");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package p.studio.vfs;
|
||||
|
||||
public enum VfsDocumentSaveStatus {
|
||||
SAVED,
|
||||
NO_CHANGES,
|
||||
READ_ONLY
|
||||
}
|
||||
@@ -3,6 +3,7 @@ package p.studio.vfs;
|
||||
public final class VfsDocumentTypeIds {
|
||||
public static final String TEXT = "text";
|
||||
public static final String JSON = "json";
|
||||
public static final String NDJSON = "ndjson";
|
||||
public static final String BASH = "bash";
|
||||
|
||||
private VfsDocumentTypeIds() {
|
||||
|
||||
@@ -8,7 +8,9 @@ public record VfsTextDocument(
|
||||
String documentName,
|
||||
String typeId,
|
||||
String content,
|
||||
String lineSeparator) implements VfsDocumentOpenResult {
|
||||
String lineSeparator,
|
||||
boolean dirty,
|
||||
VfsDocumentAccessContext accessContext) implements VfsDocumentOpenResult {
|
||||
|
||||
public VfsTextDocument {
|
||||
path = Objects.requireNonNull(path, "path").toAbsolutePath().normalize();
|
||||
@@ -16,5 +18,6 @@ public record VfsTextDocument(
|
||||
Objects.requireNonNull(typeId, "typeId");
|
||||
Objects.requireNonNull(content, "content");
|
||||
Objects.requireNonNull(lineSeparator, "lineSeparator");
|
||||
Objects.requireNonNull(accessContext, "accessContext");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user