add AppMode for best boundaries over stdlib
JaCoCo Coverage #### Project Overview No changes detected, that affect the code coverage. * Line Coverage: 61.98% (17344/27983) * Branch Coverage: 53.07% (6720/12663) * Lines of Code: 27983 * Cyclomatic Complexity: 11207 #### Quality Gates Summary Output truncated.
Test / Build skipped: 11, passed: 581
Intrepid/Prometeu/Studio/pipeline/head This commit looks good
Intrepid/Prometeu/Studio/pipeline/pr-master This commit looks good

This commit is contained in:
2026-05-14 11:15:00 +01:00
parent 22887b56cd
commit 991863d086
54 changed files with 700 additions and 546 deletions
@@ -2,6 +2,7 @@ package p.studio.compiler.pbs;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;
import p.studio.AppMode;
import p.studio.compiler.messages.BuildingIssueSink;
import p.studio.compiler.messages.FrontendPhaseContext;
import p.studio.compiler.models.*;
@@ -460,7 +461,8 @@ class PbsGateUSdkInterfaceConformanceTest {
projectTable,
fileTable,
new BuildStack(ReadOnlyList.wrap(List.of(projectId))),
stdlibVersion);
stdlibVersion,
AppMode.Game);
final var diagnostics = DiagnosticSink.empty();
final var irBackend = new PBSFrontendPhaseService().compile(
@@ -2,6 +2,7 @@ package p.studio.compiler.pbs;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.MethodSource;
import p.studio.AppMode;
import p.studio.compiler.messages.BuildingIssueSink;
import p.studio.compiler.messages.FrontendPhaseContext;
import p.studio.compiler.models.BuildStack;
@@ -79,7 +80,8 @@ class PbsGateUStdlibCompileTest {
projectTable,
fileTable,
new BuildStack(ReadOnlyList.wrap(projectIds)),
stdlibVersion);
stdlibVersion,
AppMode.Game);
final var diagnostics = DiagnosticSink.empty();
new PBSFrontendPhaseService().compile(
@@ -96,7 +98,7 @@ class PbsGateUStdlibCompileTest {
private Map<String, StdlibProjectFiles> discoverStdlibProjects(
final int stdlibVersion) throws Exception {
final var resourcePath = "stdlib/" + stdlibVersion;
final var resourcePath = "game/stdlib/" + stdlibVersion;
final var classLoader = PbsGateUStdlibCompileTest.class.getClassLoader();
final var resource = classLoader.getResource(resourcePath);
assertNotNull(resource, "Stdlib version " + stdlibVersion + " was not found on classpath at " + resourcePath);
@@ -2,16 +2,12 @@ package p.studio.compiler.services;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;
import p.studio.AppMode;
import p.studio.compiler.messages.Addressable;
import p.studio.compiler.messages.BuildingIssueSink;
import p.studio.compiler.messages.FESurfaceContext;
import p.studio.compiler.messages.FrontendPhaseContext;
import p.studio.compiler.models.IRGlobalVisibility;
import p.studio.compiler.models.BuildStack;
import p.studio.compiler.models.IRHiddenGlobalKind;
import p.studio.compiler.models.ProjectDescriptor;
import p.studio.compiler.models.SourceHandle;
import p.studio.compiler.models.SourceKind;
import p.studio.compiler.models.*;
import p.studio.compiler.pbs.PbsHostAdmissionErrors;
import p.studio.compiler.pbs.linking.PbsLinkErrors;
import p.studio.compiler.pbs.semantics.PbsSemanticsErrors;
@@ -78,6 +74,7 @@ class PBSFrontendPhaseServiceTest {
fileTable,
new BuildStack(ReadOnlyList.wrap(List.of(projectId))),
1,
AppMode.Game,
p.studio.compiler.messages.HostAdmissionContext.permissiveDefault(),
new FESurfaceContext(ReadOnlyList.from(new Addressable("assets.ui.panel", 91))));
final var diagnostics = DiagnosticSink.empty();
@@ -134,7 +131,8 @@ class PBSFrontendPhaseServiceTest {
final var ctx = new FrontendPhaseContext(
projectTable,
fileTable,
new BuildStack(ReadOnlyList.wrap(List.of(projectId))));
new BuildStack(ReadOnlyList.wrap(List.of(projectId))),
AppMode.Game);
final var diagnostics = DiagnosticSink.empty();
final var irBackend = new PBSFrontendPhaseService().compile(
@@ -185,7 +183,8 @@ class PBSFrontendPhaseServiceTest {
final var ctx = new FrontendPhaseContext(
projectTable,
fileTable,
new BuildStack(ReadOnlyList.wrap(List.of(projectId))));
new BuildStack(ReadOnlyList.wrap(List.of(projectId))),
AppMode.Game);
final var diagnostics = DiagnosticSink.empty();
final var irBackend = new PBSFrontendPhaseService().compile(
@@ -238,7 +237,8 @@ class PBSFrontendPhaseServiceTest {
final var ctx = new FrontendPhaseContext(
projectTable,
fileTable,
new BuildStack(ReadOnlyList.wrap(List.of(projectId))));
new BuildStack(ReadOnlyList.wrap(List.of(projectId))),
AppMode.Game);
final var diagnostics = DiagnosticSink.empty();
final var irBackend = new PBSFrontendPhaseService().compile(
@@ -308,7 +308,8 @@ class PBSFrontendPhaseServiceTest {
final var ctx = new FrontendPhaseContext(
projectTable,
fileTable,
new BuildStack(ReadOnlyList.wrap(List.of(projectId))));
new BuildStack(ReadOnlyList.wrap(List.of(projectId))),
AppMode.Game);
final var diagnostics = DiagnosticSink.empty();
final var irBackend = new PBSFrontendPhaseService().compile(
@@ -372,7 +373,8 @@ class PBSFrontendPhaseServiceTest {
final var ctx = new FrontendPhaseContext(
projectTable,
fileTable,
new BuildStack(ReadOnlyList.wrap(List.of(projectId))));
new BuildStack(ReadOnlyList.wrap(List.of(projectId))),
AppMode.Game);
final var diagnostics = DiagnosticSink.empty();
final var irBackend = new PBSFrontendPhaseService().compile(
@@ -416,7 +418,8 @@ class PBSFrontendPhaseServiceTest {
final var ctx = new FrontendPhaseContext(
projectTable,
fileTable,
new BuildStack(ReadOnlyList.wrap(List.of(projectId))));
new BuildStack(ReadOnlyList.wrap(List.of(projectId))),
AppMode.Game);
final var diagnostics = DiagnosticSink.empty();
new PBSFrontendPhaseService().compile(
@@ -469,7 +472,8 @@ class PBSFrontendPhaseServiceTest {
final var ctx = new FrontendPhaseContext(
projectTable,
fileTable,
new BuildStack(ReadOnlyList.wrap(List.of(projectId))));
new BuildStack(ReadOnlyList.wrap(List.of(projectId))),
AppMode.Game);
final var diagnostics = DiagnosticSink.empty();
final var irBackend = new PBSFrontendPhaseService().compile(
@@ -557,7 +561,8 @@ class PBSFrontendPhaseServiceTest {
final var ctx = new FrontendPhaseContext(
projectTable,
fileTable,
new BuildStack(ReadOnlyList.wrap(List.of(projectId))));
new BuildStack(ReadOnlyList.wrap(List.of(projectId))),
AppMode.Game);
final var diagnostics = DiagnosticSink.empty();
final var irBackend = new PBSFrontendPhaseService().compile(
@@ -607,7 +612,8 @@ class PBSFrontendPhaseServiceTest {
final var ctx = new FrontendPhaseContext(
projectTable,
fileTable,
new BuildStack(ReadOnlyList.wrap(List.of(projectId))));
new BuildStack(ReadOnlyList.wrap(List.of(projectId))),
AppMode.Game);
final var diagnostics = DiagnosticSink.empty();
final var irBackend = new PBSFrontendPhaseService().compile(
@@ -664,7 +670,8 @@ class PBSFrontendPhaseServiceTest {
final var ctx = new FrontendPhaseContext(
projectTable,
fileTable,
new BuildStack(ReadOnlyList.wrap(List.of(projectId))));
new BuildStack(ReadOnlyList.wrap(List.of(projectId))),
AppMode.Game);
final var diagnostics = DiagnosticSink.empty();
final var irBackend = new PBSFrontendPhaseService().compile(
@@ -728,7 +735,8 @@ class PBSFrontendPhaseServiceTest {
projectTable,
fileTable,
new BuildStack(ReadOnlyList.wrap(List.of(projectId))),
7);
7,
AppMode.Game);
final var diagnostics = DiagnosticSink.empty();
final var irBackend = frontendService.compile(
@@ -779,7 +787,8 @@ class PBSFrontendPhaseServiceTest {
projectTable,
fileTable,
new BuildStack(ReadOnlyList.wrap(List.of(projectId))),
7);
7,
AppMode.Game);
final var diagnostics = DiagnosticSink.empty();
final var irBackend = frontendService.compile(
@@ -826,7 +835,8 @@ class PBSFrontendPhaseServiceTest {
projectTable,
fileTable,
new BuildStack(ReadOnlyList.wrap(List.of(projectId))),
1);
1,
AppMode.Game);
final var diagnostics = DiagnosticSink.empty();
final var irBackend = new PBSFrontendPhaseService().compile(
@@ -879,7 +889,8 @@ class PBSFrontendPhaseServiceTest {
projectTable,
fileTable,
new BuildStack(ReadOnlyList.wrap(List.of(projectId))),
1);
1,
AppMode.Game);
final var diagnostics = DiagnosticSink.empty();
final var irBackend = new PBSFrontendPhaseService().compile(
@@ -932,7 +943,8 @@ class PBSFrontendPhaseServiceTest {
projectTable,
fileTable,
new BuildStack(ReadOnlyList.wrap(List.of(projectId))),
1);
1,
AppMode.Game);
final var diagnostics = DiagnosticSink.empty();
final var irBackend = new PBSFrontendPhaseService().compile(
@@ -991,7 +1003,8 @@ class PBSFrontendPhaseServiceTest {
projectTable,
fileTable,
new BuildStack(ReadOnlyList.wrap(List.of(projectId))),
1);
1,
AppMode.Game);
final var diagnostics = DiagnosticSink.empty();
final var irBackend = new PBSFrontendPhaseService().compile(
@@ -1050,7 +1063,8 @@ class PBSFrontendPhaseServiceTest {
projectTable,
fileTable,
new BuildStack(ReadOnlyList.wrap(List.of(projectId))),
1);
1,
AppMode.Game);
final var diagnostics = DiagnosticSink.empty();
final var irBackend = new PBSFrontendPhaseService().compile(
@@ -1121,7 +1135,8 @@ class PBSFrontendPhaseServiceTest {
projectTable,
fileTable,
new BuildStack(ReadOnlyList.wrap(List.of(projectId))),
1);
1,
AppMode.Game);
final var diagnostics = DiagnosticSink.empty();
final var irBackend = new PBSFrontendPhaseService().compile(
@@ -1193,7 +1208,8 @@ class PBSFrontendPhaseServiceTest {
projectTable,
fileTable,
new BuildStack(ReadOnlyList.wrap(List.of(projectId))),
1);
1,
AppMode.Game);
final var diagnostics = DiagnosticSink.empty();
final var irBackend = new PBSFrontendPhaseService().compile(
@@ -1256,7 +1272,8 @@ class PBSFrontendPhaseServiceTest {
projectTable,
fileTable,
new BuildStack(ReadOnlyList.wrap(List.of(projectId))),
1);
1,
AppMode.Game);
final var diagnostics = DiagnosticSink.empty();
final var irBackend = frontendService.compile(
@@ -1320,7 +1337,8 @@ class PBSFrontendPhaseServiceTest {
projectTable,
fileTable,
new BuildStack(ReadOnlyList.wrap(List.of(projectId))),
1);
1,
AppMode.Game);
final var diagnostics = DiagnosticSink.empty();
final var irBackend = frontendService.compile(
@@ -1401,7 +1419,8 @@ class PBSFrontendPhaseServiceTest {
final var ctx = new FrontendPhaseContext(
projectTable,
fileTable,
new BuildStack(ReadOnlyList.wrap(List.of(projectId))));
new BuildStack(ReadOnlyList.wrap(List.of(projectId))),
AppMode.Game);
final var diagnostics = DiagnosticSink.empty();
final var irBackend = new PBSFrontendPhaseService().compile(
@@ -1473,7 +1492,8 @@ class PBSFrontendPhaseServiceTest {
projectTable,
fileTable,
new BuildStack(ReadOnlyList.wrap(List.of(projectId))),
9);
9,
AppMode.Game);
final var diagnostics = DiagnosticSink.empty();
final var irBackend = frontendService.compile(
@@ -1527,7 +1547,8 @@ class PBSFrontendPhaseServiceTest {
projectTable,
fileTable,
new BuildStack(ReadOnlyList.wrap(List.of(projectId))),
1);
1,
AppMode.Game);
final var diagnostics = DiagnosticSink.empty();
final var irBackend = new PBSFrontendPhaseService().compile(
@@ -1557,7 +1578,7 @@ class PBSFrontendPhaseServiceTest {
final var callableCalls = frameExecutable.instructions().stream()
.filter(instruction ->
instruction.kind() == p.studio.compiler.models.IRBackendExecutableFunction.InstructionKind.CALL_FUNC)
.map(instruction -> instruction.calleeCallableName())
.map(IRBackendExecutableFunction.Instruction::calleeCallableName)
.toList();
final var intrinsicCalls = frameExecutable.instructions().stream()
.filter(instruction ->
@@ -1624,7 +1645,8 @@ class PBSFrontendPhaseServiceTest {
projectTable,
fileTable,
new BuildStack(ReadOnlyList.wrap(List.of(projectId))),
1);
1,
AppMode.Game);
final var diagnostics = DiagnosticSink.empty();
final var irBackend = new PBSFrontendPhaseService().compile(
@@ -1643,7 +1665,7 @@ class PBSFrontendPhaseServiceTest {
final var callableCalls = frameExecutable.instructions().stream()
.filter(instruction ->
instruction.kind() == p.studio.compiler.models.IRBackendExecutableFunction.InstructionKind.CALL_FUNC)
.map(instruction -> instruction.calleeCallableName())
.map(IRBackendExecutableFunction.Instruction::calleeCallableName)
.toList();
final var intrinsicCalls = frameExecutable.instructions().stream()
.filter(instruction ->
@@ -1717,7 +1739,8 @@ class PBSFrontendPhaseServiceTest {
projectTable,
fileTable,
new BuildStack(ReadOnlyList.wrap(List.of(projectId))),
1);
1,
AppMode.Game);
final var diagnostics = DiagnosticSink.empty();
final var irBackend = new PBSFrontendPhaseService().compile(
@@ -1736,7 +1759,7 @@ class PBSFrontendPhaseServiceTest {
final var callableCalls = frameExecutable.instructions().stream()
.filter(instruction ->
instruction.kind() == p.studio.compiler.models.IRBackendExecutableFunction.InstructionKind.CALL_FUNC)
.map(instruction -> instruction.calleeCallableName())
.map(IRBackendExecutableFunction.Instruction::calleeCallableName)
.toList();
final var intrinsicCalls = frameExecutable.instructions().stream()
.filter(instruction ->
@@ -1804,7 +1827,8 @@ class PBSFrontendPhaseServiceTest {
final var ctx = new FrontendPhaseContext(
projectTable,
fileTable,
new BuildStack(ReadOnlyList.wrap(List.of(projectId))));
new BuildStack(ReadOnlyList.wrap(List.of(projectId))),
AppMode.Game);
final var diagnostics = DiagnosticSink.empty();
new PBSFrontendPhaseService().compile(
@@ -1861,7 +1885,8 @@ class PBSFrontendPhaseServiceTest {
final var ctx = new FrontendPhaseContext(
projectTable,
fileTable,
new BuildStack(ReadOnlyList.wrap(List.of(projectId))));
new BuildStack(ReadOnlyList.wrap(List.of(projectId))),
AppMode.Game);
final var diagnostics = DiagnosticSink.empty();
new PBSFrontendPhaseService().compile(
@@ -1932,7 +1957,8 @@ class PBSFrontendPhaseServiceTest {
projectTable,
fileTable,
new BuildStack(ReadOnlyList.wrap(List.of(projectId))),
11);
11,
AppMode.Game);
final var deniedDiagnostics = DiagnosticSink.empty();
deniedFrontendService.compile(
@@ -1998,7 +2024,8 @@ class PBSFrontendPhaseServiceTest {
allowedProjectTable,
allowedFileTable,
new BuildStack(ReadOnlyList.wrap(List.of(allowedProjectId))),
12);
12,
AppMode.Game);
final var allowedDiagnostics = DiagnosticSink.empty();
allowedFrontendService.compile(
@@ -2056,7 +2083,8 @@ class PBSFrontendPhaseServiceTest {
final var ctx = new FrontendPhaseContext(
projectTable,
fileTable,
new BuildStack(ReadOnlyList.wrap(List.of(projectId))));
new BuildStack(ReadOnlyList.wrap(List.of(projectId))),
AppMode.Game);
final var diagnostics = DiagnosticSink.empty();
final var inlineHintsByFile = PBSFrontendPhaseService.inlineHintsByFile(
@@ -2113,7 +2141,8 @@ class PBSFrontendPhaseServiceTest {
final var ctx = new FrontendPhaseContext(
projectTable,
fileTable,
new BuildStack(ReadOnlyList.wrap(List.of(projectId))));
new BuildStack(ReadOnlyList.wrap(List.of(projectId))),
AppMode.Game);
final var diagnostics = DiagnosticSink.empty();
final var inlineHints = PBSFrontendPhaseService.inlineHintsByFile(
@@ -2148,7 +2177,7 @@ class PBSFrontendPhaseServiceTest {
for (final var module : modules) {
byModuleKey.put(moduleKey(module.project(), module.pathSegments()), module);
}
return stdlib -> {
return (stdlib, target) -> {
if (stdlib != acceptedStdlib) {
return (project, pathSegments) -> Optional.empty();
}