package p.studio.compiler.models;

import lombok.Builder;
import lombok.Getter;
import p.studio.utilities.structures.ReadOnlySet;

import java.util.List;

@Builder
@Getter
public class FrontendSpec {
    private final String languageId;
    private final ReadOnlySet<String> allowedExtensions;
    private final ReadOnlySet<String> sourceRoots;
    private final boolean caseSensitive;
    @Builder.Default
    private final List<Stdlib> stdlibVersions = List.of();
    @Builder.Default
    private final FrontendSemanticPresentationSpec semanticPresentation = FrontendSemanticPresentationSpec.empty();

    public String toString() {
        return String.format("FrontendSpec(language=%s)", languageId);
    }

    public enum StdlibType {
        DEFAULT,
        STABLE,
        EXPERIMENTAL,
    }

    public record Stdlib(int version, StdlibType type) {
        public static Stdlib asDefault(final int version) {
            return new Stdlib(version, StdlibType.DEFAULT);
        }

        public static Stdlib asStable(final int version) {
            return new Stdlib(version, StdlibType.STABLE);
        }

        public static Stdlib of(final int version) {
            return asStable(version);
        }

        public static Stdlib asExperimental(final int version) {
            return new Stdlib(version, StdlibType.EXPERIMENTAL);
        }
    }
}
