refactor, rename and reducing complexity
This commit is contained in:
+3
-1
@@ -1,5 +1,7 @@
|
||||
package p.studio.vfs;
|
||||
|
||||
import p.studio.vfs.messages.VfsProjectContext;
|
||||
|
||||
public interface ProjectDocumentVfsFactory {
|
||||
ProjectDocumentVfs open(VfsProjectContext projectContext);
|
||||
VfsProjectDocument open(VfsProjectContext projectContext);
|
||||
}
|
||||
|
||||
+35
-2
@@ -1,7 +1,40 @@
|
||||
package p.studio.vfs;
|
||||
|
||||
import java.nio.file.Path;
|
||||
import p.studio.vfs.messages.VfsDocumentAccessContext;
|
||||
import p.studio.vfs.messages.VfsUnsupportedReason;
|
||||
|
||||
public sealed interface VfsDocumentOpenResult permits VfsTextDocument, VfsUnsupportedDocument {
|
||||
import java.nio.file.Path;
|
||||
import java.util.Objects;
|
||||
|
||||
public sealed interface VfsDocumentOpenResult permits VfsDocumentOpenResult.VfsUnsupportedDocument, VfsDocumentOpenResult.VfsTextDocument {
|
||||
Path path();
|
||||
|
||||
record VfsUnsupportedDocument(
|
||||
Path path,
|
||||
VfsUnsupportedReason reason) implements VfsDocumentOpenResult {
|
||||
|
||||
public VfsUnsupportedDocument {
|
||||
path = Objects.requireNonNull(path, "path").toAbsolutePath().normalize();
|
||||
Objects.requireNonNull(reason, "reason");
|
||||
}
|
||||
}
|
||||
|
||||
record VfsTextDocument(
|
||||
Path path,
|
||||
String documentName,
|
||||
String typeId,
|
||||
String content,
|
||||
String lineSeparator,
|
||||
boolean dirty,
|
||||
VfsDocumentAccessContext accessContext) implements VfsDocumentOpenResult {
|
||||
|
||||
public VfsTextDocument {
|
||||
path = Objects.requireNonNull(path, "path").toAbsolutePath().normalize();
|
||||
Objects.requireNonNull(documentName, "documentName");
|
||||
Objects.requireNonNull(typeId, "typeId");
|
||||
Objects.requireNonNull(content, "content");
|
||||
Objects.requireNonNull(lineSeparator, "lineSeparator");
|
||||
Objects.requireNonNull(accessContext, "accessContext");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+4
-2
@@ -1,10 +1,12 @@
|
||||
package p.studio.vfs;
|
||||
|
||||
import p.studio.vfs.messages.*;
|
||||
|
||||
import java.nio.file.Path;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public interface ProjectDocumentVfs extends AutoCloseable {
|
||||
public interface VfsProjectDocument extends AutoCloseable {
|
||||
VfsProjectContext projectContext();
|
||||
|
||||
VfsProjectSnapshot snapshot();
|
||||
@@ -23,7 +25,7 @@ public interface ProjectDocumentVfs extends AutoCloseable {
|
||||
throw new UnsupportedOperationException("Document access context updates are not supported by this VFS implementation.");
|
||||
}
|
||||
|
||||
default VfsTextDocument updateDocument(final Path path, final String content) {
|
||||
default VfsDocumentOpenResult.VfsTextDocument updateDocument(final Path path, final String content) {
|
||||
throw new UnsupportedOperationException("Document mutation is not supported by this VFS implementation.");
|
||||
}
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
package p.studio.vfs;
|
||||
|
||||
import java.nio.file.Path;
|
||||
import java.util.Objects;
|
||||
|
||||
public record VfsTextDocument(
|
||||
Path path,
|
||||
String documentName,
|
||||
String typeId,
|
||||
String content,
|
||||
String lineSeparator,
|
||||
boolean dirty,
|
||||
VfsDocumentAccessContext accessContext) implements VfsDocumentOpenResult {
|
||||
|
||||
public VfsTextDocument {
|
||||
path = Objects.requireNonNull(path, "path").toAbsolutePath().normalize();
|
||||
Objects.requireNonNull(documentName, "documentName");
|
||||
Objects.requireNonNull(typeId, "typeId");
|
||||
Objects.requireNonNull(content, "content");
|
||||
Objects.requireNonNull(lineSeparator, "lineSeparator");
|
||||
Objects.requireNonNull(accessContext, "accessContext");
|
||||
}
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
package p.studio.vfs;
|
||||
|
||||
import java.nio.file.Path;
|
||||
import java.util.Objects;
|
||||
|
||||
public record VfsUnsupportedDocument(
|
||||
Path path,
|
||||
VfsUnsupportedReason reason) implements VfsDocumentOpenResult {
|
||||
|
||||
public VfsUnsupportedDocument {
|
||||
path = Objects.requireNonNull(path, "path").toAbsolutePath().normalize();
|
||||
Objects.requireNonNull(reason, "reason");
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package p.studio.vfs;
|
||||
package p.studio.vfs.messages;
|
||||
|
||||
import java.nio.file.Path;
|
||||
import java.util.Map;
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package p.studio.vfs;
|
||||
package p.studio.vfs.messages;
|
||||
|
||||
public enum VfsDocumentAccessMode {
|
||||
READ_ONLY,
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package p.studio.vfs;
|
||||
package p.studio.vfs.messages;
|
||||
|
||||
import java.nio.file.Path;
|
||||
import java.util.Objects;
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package p.studio.vfs;
|
||||
package p.studio.vfs.messages;
|
||||
|
||||
public enum VfsDocumentSaveStatus {
|
||||
SAVED,
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package p.studio.vfs;
|
||||
package p.studio.vfs.messages;
|
||||
|
||||
public final class VfsDocumentTypeIds {
|
||||
public static final String TEXT = "text";
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package p.studio.vfs;
|
||||
package p.studio.vfs.messages;
|
||||
|
||||
import java.nio.file.Path;
|
||||
import java.util.Objects;
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package p.studio.vfs;
|
||||
package p.studio.vfs.messages;
|
||||
|
||||
import java.nio.file.Path;
|
||||
import java.util.List;
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package p.studio.vfs;
|
||||
package p.studio.vfs.messages;
|
||||
|
||||
import java.nio.file.Path;
|
||||
import java.util.Objects;
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package p.studio.vfs;
|
||||
package p.studio.vfs.messages;
|
||||
|
||||
import java.nio.file.Path;
|
||||
import java.util.Objects;
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package p.studio.vfs;
|
||||
package p.studio.vfs.messages;
|
||||
|
||||
public enum VfsUnsupportedReason {
|
||||
OUTSIDE_PROJECT,
|
||||
Reference in New Issue
Block a user