implements PLN-0075
This commit is contained in:
+30
@@ -0,0 +1,30 @@
|
||||
package p.studio.compiler.pbs.semantics;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public record PbsEditorialCompletionCandidate(
|
||||
String label,
|
||||
PbsEditorialSymbolKind kind,
|
||||
String detail,
|
||||
String origin) {
|
||||
public PbsEditorialCompletionCandidate {
|
||||
label = requireText(label, "label");
|
||||
kind = Objects.requireNonNull(kind, "kind");
|
||||
detail = normalize(detail);
|
||||
origin = normalize(origin);
|
||||
}
|
||||
|
||||
private static String requireText(
|
||||
final String value,
|
||||
final String field) {
|
||||
final String candidate = normalize(value);
|
||||
if (candidate.isEmpty()) {
|
||||
throw new IllegalArgumentException(field + " must not be blank");
|
||||
}
|
||||
return candidate;
|
||||
}
|
||||
|
||||
private static String normalize(final String value) {
|
||||
return value == null ? "" : value.trim();
|
||||
}
|
||||
}
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
package p.studio.compiler.pbs.semantics;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
public record PbsEditorialResolvedSymbol(
|
||||
String displayName,
|
||||
PbsEditorialSymbolKind kind,
|
||||
String detail,
|
||||
String origin,
|
||||
List<PbsEditorialSignature> signatures,
|
||||
String documentation) {
|
||||
public PbsEditorialResolvedSymbol {
|
||||
displayName = requireText(displayName, "displayName");
|
||||
kind = Objects.requireNonNull(kind, "kind");
|
||||
detail = normalize(detail);
|
||||
origin = normalize(origin);
|
||||
signatures = List.copyOf(Objects.requireNonNull(signatures, "signatures"));
|
||||
documentation = normalize(documentation);
|
||||
}
|
||||
|
||||
private static String requireText(
|
||||
final String value,
|
||||
final String field) {
|
||||
final String candidate = normalize(value);
|
||||
if (candidate.isEmpty()) {
|
||||
throw new IllegalArgumentException(field + " must not be blank");
|
||||
}
|
||||
return candidate;
|
||||
}
|
||||
|
||||
private static String normalize(final String value) {
|
||||
return value == null ? "" : value.trim();
|
||||
}
|
||||
}
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
package p.studio.compiler.pbs.semantics;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
public record PbsEditorialSignature(
|
||||
String callableName,
|
||||
String label,
|
||||
List<String> parameterLabels,
|
||||
String returnLabel) {
|
||||
public PbsEditorialSignature {
|
||||
callableName = requireText(callableName, "callableName");
|
||||
label = requireText(label, "label");
|
||||
parameterLabels = List.copyOf(Objects.requireNonNull(parameterLabels, "parameterLabels"));
|
||||
returnLabel = requireText(returnLabel, "returnLabel");
|
||||
}
|
||||
|
||||
private static String requireText(
|
||||
final String value,
|
||||
final String field) {
|
||||
final String candidate = Objects.requireNonNull(value, field).trim();
|
||||
if (candidate.isEmpty()) {
|
||||
throw new IllegalArgumentException(field + " must not be blank");
|
||||
}
|
||||
return candidate;
|
||||
}
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
package p.studio.compiler.pbs.semantics;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
public record PbsEditorialSignatureHelp(
|
||||
List<PbsEditorialSignature> signatures,
|
||||
int activeSignature,
|
||||
int activeParameter) {
|
||||
public PbsEditorialSignatureHelp {
|
||||
signatures = List.copyOf(Objects.requireNonNull(signatures, "signatures"));
|
||||
if (signatures.isEmpty()) {
|
||||
throw new IllegalArgumentException("signatures must not be empty");
|
||||
}
|
||||
if (activeSignature < 0 || activeSignature >= signatures.size()) {
|
||||
throw new IllegalArgumentException("activeSignature must reference one of the provided signatures");
|
||||
}
|
||||
if (activeParameter < 0) {
|
||||
throw new IllegalArgumentException("activeParameter must be >= 0");
|
||||
}
|
||||
}
|
||||
}
|
||||
+1303
File diff suppressed because it is too large
Load Diff
+21
@@ -0,0 +1,21 @@
|
||||
package p.studio.compiler.pbs.semantics;
|
||||
|
||||
public enum PbsEditorialSymbolKind {
|
||||
KEYWORD,
|
||||
LOCAL,
|
||||
PARAMETER,
|
||||
FIELD,
|
||||
FUNCTION,
|
||||
METHOD,
|
||||
CONSTRUCTOR,
|
||||
STRUCT,
|
||||
BUILTIN_TYPE,
|
||||
SERVICE,
|
||||
HOST,
|
||||
CONTRACT,
|
||||
CALLBACK,
|
||||
ENUM,
|
||||
ERROR,
|
||||
GLOBAL,
|
||||
CONST
|
||||
}
|
||||
+4
@@ -584,5 +584,9 @@ final class PbsFlowSemanticSupport {
|
||||
final var symbol = names.get(name);
|
||||
return symbol != null && symbol.mutable();
|
||||
}
|
||||
|
||||
Map<String, LocalSymbol> entries() {
|
||||
return Map.copyOf(names);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+4
@@ -133,12 +133,14 @@ public class PBSFrontendPhaseService implements FrontendPhaseService {
|
||||
assembly.parsedSourceFiles(),
|
||||
assembly.moduleTable());
|
||||
final var flowSemanticsValidator = new PbsFlowSemanticsValidator();
|
||||
final Map<FileId, p.studio.compiler.pbs.ast.PbsAst.File> astByFile = new LinkedHashMap<>();
|
||||
final Map<FileId, ReadOnlyList<p.studio.compiler.pbs.ast.PbsAst.TopDecl>> supplementalTopDeclsByFile = new LinkedHashMap<>();
|
||||
final Map<FileId, ReadOnlyList<PbsInlineHintSurface>> inlineHintsByFile = new LinkedHashMap<>();
|
||||
for (final var entry : importedSemanticContexts.entrySet()) {
|
||||
supplementalTopDeclsByFile.put(entry.getKey(), entry.getValue().supplementalTopDecls());
|
||||
}
|
||||
for (final var parsedSourceFile : assembly.parsedSourceFiles()) {
|
||||
astByFile.put(parsedSourceFile.fileId(), parsedSourceFile.ast());
|
||||
final var importedSemanticContext = importedSemanticContexts.getOrDefault(
|
||||
parsedSourceFile.fileId(),
|
||||
PbsImportedSemanticContext.empty());
|
||||
@@ -152,11 +154,13 @@ public class PBSFrontendPhaseService implements FrontendPhaseService {
|
||||
}
|
||||
}
|
||||
return new PbsSemanticReadSurface(
|
||||
Map.copyOf(astByFile),
|
||||
Map.copyOf(supplementalTopDeclsByFile),
|
||||
Map.copyOf(inlineHintsByFile));
|
||||
}
|
||||
|
||||
public record PbsSemanticReadSurface(
|
||||
Map<FileId, p.studio.compiler.pbs.ast.PbsAst.File> astByFile,
|
||||
Map<FileId, ReadOnlyList<p.studio.compiler.pbs.ast.PbsAst.TopDecl>> supplementalTopDeclsByFile,
|
||||
Map<FileId, ReadOnlyList<PbsInlineHintSurface>> inlineHintsByFile) {
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user