implements PLN-0024
This commit is contained in:
@@ -1,6 +1,10 @@
|
||||
package p.lsp;
|
||||
|
||||
import p.lsp.dtos.PrometeuLspSessionStateDTO;
|
||||
import p.lsp.messages.PrometeuLspAnalyzeDocumentRequest;
|
||||
import p.lsp.messages.PrometeuLspAnalyzeDocumentResult;
|
||||
import p.lsp.messages.PrometeuLspDefinitionRequest;
|
||||
import p.lsp.messages.PrometeuLspDefinitionResult;
|
||||
import p.studio.vfs.ProjectDocumentVfs;
|
||||
|
||||
public interface PrometeuLspService extends AutoCloseable {
|
||||
@@ -10,6 +14,10 @@ public interface PrometeuLspService extends AutoCloseable {
|
||||
|
||||
PrometeuLspSessionStateDTO snapshot();
|
||||
|
||||
PrometeuLspAnalyzeDocumentResult analyzeDocument(PrometeuLspAnalyzeDocumentRequest request);
|
||||
|
||||
PrometeuLspDefinitionResult definition(PrometeuLspDefinitionRequest request);
|
||||
|
||||
@Override
|
||||
default void close() {
|
||||
}
|
||||
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
package p.lsp.dtos;
|
||||
|
||||
import java.nio.file.Path;
|
||||
import java.util.Objects;
|
||||
|
||||
public record PrometeuLspDefinitionTargetDTO(
|
||||
String name,
|
||||
Path documentPath,
|
||||
PrometeuLspRangeDTO range) {
|
||||
|
||||
public PrometeuLspDefinitionTargetDTO {
|
||||
name = Objects.requireNonNull(name, "name");
|
||||
documentPath = Objects.requireNonNull(documentPath, "documentPath").toAbsolutePath().normalize();
|
||||
range = Objects.requireNonNull(range, "range");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package p.lsp.dtos;
|
||||
|
||||
import java.nio.file.Path;
|
||||
import java.util.Objects;
|
||||
|
||||
public record PrometeuLspDiagnosticDTO(
|
||||
Path documentPath,
|
||||
PrometeuLspRangeDTO range,
|
||||
PrometeuLspDiagnosticSeverityDTO severity,
|
||||
String phase,
|
||||
String code,
|
||||
String message) {
|
||||
|
||||
public PrometeuLspDiagnosticDTO {
|
||||
documentPath = Objects.requireNonNull(documentPath, "documentPath").toAbsolutePath().normalize();
|
||||
range = Objects.requireNonNull(range, "range");
|
||||
severity = Objects.requireNonNull(severity, "severity");
|
||||
phase = phase == null ? "" : phase;
|
||||
code = code == null ? "" : code;
|
||||
message = Objects.requireNonNull(message, "message");
|
||||
}
|
||||
}
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
package p.lsp.dtos;
|
||||
|
||||
public enum PrometeuLspDiagnosticSeverityDTO {
|
||||
ERROR,
|
||||
WARNING
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package p.lsp.dtos;
|
||||
|
||||
public record PrometeuLspRangeDTO(
|
||||
int startOffset,
|
||||
int endOffset) {
|
||||
|
||||
public PrometeuLspRangeDTO {
|
||||
startOffset = Math.max(0, startOffset);
|
||||
endOffset = Math.max(startOffset, endOffset);
|
||||
}
|
||||
|
||||
public boolean contains(final int offset) {
|
||||
return startOffset <= offset && offset < endOffset;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package p.lsp.dtos;
|
||||
|
||||
import java.nio.file.Path;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
public record PrometeuLspSymbolDTO(
|
||||
String name,
|
||||
PrometeuLspSymbolKindDTO kind,
|
||||
Path documentPath,
|
||||
PrometeuLspRangeDTO range,
|
||||
List<PrometeuLspSymbolDTO> children) {
|
||||
|
||||
public PrometeuLspSymbolDTO {
|
||||
name = Objects.requireNonNull(name, "name");
|
||||
kind = Objects.requireNonNull(kind, "kind");
|
||||
documentPath = Objects.requireNonNull(documentPath, "documentPath").toAbsolutePath().normalize();
|
||||
range = Objects.requireNonNull(range, "range");
|
||||
children = List.copyOf(Objects.requireNonNull(children, "children"));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package p.lsp.dtos;
|
||||
|
||||
public enum PrometeuLspSymbolKindDTO {
|
||||
FUNCTION,
|
||||
METHOD,
|
||||
CONSTRUCTOR,
|
||||
GLOBAL,
|
||||
CONST,
|
||||
STRUCT,
|
||||
CONTRACT,
|
||||
HOST,
|
||||
BUILTIN_TYPE,
|
||||
SERVICE,
|
||||
ERROR,
|
||||
ENUM,
|
||||
CALLBACK,
|
||||
IMPLEMENTS,
|
||||
UNKNOWN
|
||||
}
|
||||
+10
-1
@@ -1,13 +1,22 @@
|
||||
package p.lsp.messages;
|
||||
|
||||
import p.lsp.dtos.PrometeuLspDiagnosticDTO;
|
||||
import p.lsp.dtos.PrometeuLspSessionStateDTO;
|
||||
import p.lsp.dtos.PrometeuLspSymbolDTO;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
public record PrometeuLspAnalyzeDocumentResult(
|
||||
PrometeuLspSessionStateDTO sessionState) {
|
||||
PrometeuLspSessionStateDTO sessionState,
|
||||
List<PrometeuLspDiagnosticDTO> diagnostics,
|
||||
List<PrometeuLspSymbolDTO> documentSymbols,
|
||||
List<PrometeuLspSymbolDTO> workspaceSymbols) {
|
||||
|
||||
public PrometeuLspAnalyzeDocumentResult {
|
||||
Objects.requireNonNull(sessionState, "sessionState");
|
||||
diagnostics = List.copyOf(Objects.requireNonNull(diagnostics, "diagnostics"));
|
||||
documentSymbols = List.copyOf(Objects.requireNonNull(documentSymbols, "documentSymbols"));
|
||||
workspaceSymbols = List.copyOf(Objects.requireNonNull(workspaceSymbols, "workspaceSymbols"));
|
||||
}
|
||||
}
|
||||
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
package p.lsp.messages;
|
||||
|
||||
import java.nio.file.Path;
|
||||
import java.util.Objects;
|
||||
|
||||
public record PrometeuLspDefinitionRequest(
|
||||
Path documentPath,
|
||||
int offset) {
|
||||
|
||||
public PrometeuLspDefinitionRequest {
|
||||
documentPath = Objects.requireNonNull(documentPath, "documentPath").toAbsolutePath().normalize();
|
||||
offset = Math.max(0, offset);
|
||||
}
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
package p.lsp.messages;
|
||||
|
||||
import p.lsp.dtos.PrometeuLspDefinitionTargetDTO;
|
||||
|
||||
import java.nio.file.Path;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
public record PrometeuLspDefinitionResult(
|
||||
Path documentPath,
|
||||
int offset,
|
||||
List<PrometeuLspDefinitionTargetDTO> targets) {
|
||||
|
||||
public PrometeuLspDefinitionResult {
|
||||
documentPath = Objects.requireNonNull(documentPath, "documentPath").toAbsolutePath().normalize();
|
||||
offset = Math.max(0, offset);
|
||||
targets = List.copyOf(Objects.requireNonNull(targets, "targets"));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user