implements PLN-0024

This commit is contained in:
2026-03-31 17:14:57 +01:00
parent 8dd3b58f39
commit bcc89dcfbd
25 changed files with 1049 additions and 13 deletions
@@ -78,6 +78,10 @@ public enum I18n {
CODE_EDITOR_NAVIGATOR_DETAIL("codeEditor.navigator.detail"),
CODE_EDITOR_OUTLINE_TITLE("codeEditor.outline.title"),
CODE_EDITOR_OUTLINE_PLACEHOLDER("codeEditor.outline.placeholder"),
CODE_EDITOR_OUTLINE_DIAGNOSTICS("codeEditor.outline.diagnostics"),
CODE_EDITOR_OUTLINE_SYMBOLS("codeEditor.outline.symbols"),
CODE_EDITOR_OUTLINE_EMPTY_DIAGNOSTICS("codeEditor.outline.emptyDiagnostics"),
CODE_EDITOR_OUTLINE_EMPTY_SYMBOLS("codeEditor.outline.emptySymbols"),
CODE_EDITOR_HELPER_TITLE("codeEditor.helper.title"),
CODE_EDITOR_HELPER_PLACEHOLDER("codeEditor.helper.placeholder"),
CODE_EDITOR_TABS_PLACEHOLDER("codeEditor.tabs.placeholder"),
@@ -28,7 +28,10 @@ public final class MainView extends BorderPane {
setTop(new StudioShellTopBarControl(menuBar));
host.register(new AssetWorkspace(projectReference));
host.register(new EditorWorkspace(projectReference, projectSession.projectDocumentVfs()));
host.register(new EditorWorkspace(
projectReference,
projectSession.projectDocumentVfs(),
projectSession.prometeuLspService()));
// host.register(new PlaceholderWorkspace(WorkspaceId.DEBUG, I18n.WORKSPACE_DEBUG, "Debug"));
host.register(new ShipperWorkspace(projectReference));
@@ -2,15 +2,24 @@ package p.studio.workspaces.editor;
import javafx.geometry.Insets;
import javafx.scene.control.Label;
import javafx.scene.control.ScrollPane;
import javafx.scene.layout.VBox;
import p.lsp.dtos.PrometeuLspDiagnosticDTO;
import p.lsp.dtos.PrometeuLspSymbolDTO;
import p.studio.Container;
import p.studio.controls.WorkspaceDockPane;
import p.studio.utilities.i18n.I18n;
import java.nio.file.Path;
import java.util.List;
public final class EditorOutlinePanel extends WorkspaceDockPane {
private static final double COLLAPSED_HEIGHT = 34.0;
private static final double MINIMUM_EXPANDED_HEIGHT = 120.0;
private static final double DEFAULT_HEIGHT = 180.0;
private final Label summary = new Label();
private final VBox diagnosticsBox = new VBox(6);
private final VBox symbolsBox = new VBox(6);
public EditorOutlinePanel() {
super(
@@ -21,14 +30,107 @@ public final class EditorOutlinePanel extends WorkspaceDockPane {
true,
"editor-workspace-outline-panel");
final var placeholder = new Label();
placeholder.textProperty().bind(Container.i18n().bind(I18n.CODE_EDITOR_OUTLINE_PLACEHOLDER));
placeholder.getStyleClass().add("editor-workspace-placeholder");
placeholder.setWrapText(true);
summary.getStyleClass().addAll("editor-workspace-placeholder", "editor-workspace-outline-summary");
summary.setWrapText(true);
final var content = new VBox(8, placeholder);
final var diagnosticsTitle = sectionTitle(I18n.CODE_EDITOR_OUTLINE_DIAGNOSTICS);
final var symbolsTitle = sectionTitle(I18n.CODE_EDITOR_OUTLINE_SYMBOLS);
diagnosticsBox.getStyleClass().add("editor-workspace-outline-list");
symbolsBox.getStyleClass().add("editor-workspace-outline-list");
final var content = new VBox(10,
summary,
diagnosticsTitle,
diagnosticsBox,
symbolsTitle,
symbolsBox);
content.getStyleClass().add("editor-workspace-panel-content");
content.setPadding(new Insets(10, 16, 14, 16));
setDockContent(content);
final var scrollPane = new ScrollPane(content);
scrollPane.setFitToWidth(true);
scrollPane.getStyleClass().add("editor-workspace-outline-scroll");
setDockContent(scrollPane);
showPlaceholder();
}
public void showPlaceholder() {
summary.textProperty().unbind();
summary.textProperty().bind(Container.i18n().bind(I18n.CODE_EDITOR_OUTLINE_PLACEHOLDER));
diagnosticsBox.getChildren().setAll(placeholderLabel(I18n.CODE_EDITOR_OUTLINE_EMPTY_DIAGNOSTICS));
symbolsBox.getChildren().setAll(placeholderLabel(I18n.CODE_EDITOR_OUTLINE_EMPTY_SYMBOLS));
}
public void showSemanticReadResult(
final Path documentPath,
final List<PrometeuLspDiagnosticDTO> diagnostics,
final List<PrometeuLspSymbolDTO> symbols) {
summary.textProperty().unbind();
summary.setText(documentPath.getFileName() + " • semantic read-only");
rebuildDiagnostics(diagnostics);
rebuildSymbols(symbols);
}
private void rebuildDiagnostics(final List<PrometeuLspDiagnosticDTO> diagnostics) {
diagnosticsBox.getChildren().clear();
if (diagnostics.isEmpty()) {
diagnosticsBox.getChildren().add(placeholderLabel(I18n.CODE_EDITOR_OUTLINE_EMPTY_DIAGNOSTICS));
return;
}
for (final PrometeuLspDiagnosticDTO diagnostic : diagnostics) {
final var label = new Label(formatDiagnostic(diagnostic));
label.setWrapText(true);
label.getStyleClass().addAll(
"editor-workspace-outline-item",
diagnostic.severity().name().equals("ERROR")
? "editor-workspace-outline-diagnostic-error"
: "editor-workspace-outline-diagnostic-warning");
diagnosticsBox.getChildren().add(label);
}
}
private void rebuildSymbols(final List<PrometeuLspSymbolDTO> symbols) {
symbolsBox.getChildren().clear();
if (symbols.isEmpty()) {
symbolsBox.getChildren().add(placeholderLabel(I18n.CODE_EDITOR_OUTLINE_EMPTY_SYMBOLS));
return;
}
for (final PrometeuLspSymbolDTO symbol : symbols) {
appendSymbol(symbol, 0);
}
}
private void appendSymbol(final PrometeuLspSymbolDTO symbol, final int depth) {
final var label = new Label(symbol.name() + " • " + symbol.kind().name().toLowerCase());
label.setWrapText(true);
label.setPadding(new Insets(0, 0, 0, depth * 12));
label.getStyleClass().add("editor-workspace-outline-item");
symbolsBox.getChildren().add(label);
for (final PrometeuLspSymbolDTO child : symbol.children()) {
appendSymbol(child, depth + 1);
}
}
private Label sectionTitle(final I18n key) {
final var label = new Label();
label.textProperty().bind(Container.i18n().bind(key));
label.getStyleClass().add("editor-workspace-outline-section-title");
return label;
}
private Label placeholderLabel(final I18n key) {
final var label = new Label();
label.textProperty().bind(Container.i18n().bind(key));
label.setWrapText(true);
label.getStyleClass().addAll("editor-workspace-placeholder", "editor-workspace-outline-item");
return label;
}
private String formatDiagnostic(final PrometeuLspDiagnosticDTO diagnostic) {
return "%s [%d,%d) %s".formatted(
diagnostic.severity().name(),
diagnostic.range().startOffset(),
diagnostic.range().endOffset(),
diagnostic.message());
}
}
@@ -12,6 +12,9 @@ import javafx.scene.layout.Region;
import javafx.scene.layout.VBox;
import org.fxmisc.richtext.CodeArea;
import org.fxmisc.richtext.LineNumberFactory;
import p.lsp.PrometeuLspService;
import p.lsp.messages.PrometeuLspAnalyzeDocumentRequest;
import p.lsp.messages.PrometeuLspAnalyzeDocumentResult;
import p.studio.projects.ProjectReference;
import p.studio.utilities.i18n.I18n;
import p.studio.vfs.ProjectDocumentVfs;
@@ -38,6 +41,7 @@ public final class EditorWorkspace extends Workspace {
private final EditorStatusBar statusBar = new EditorStatusBar();
private final EditorTabStrip tabStrip = new EditorTabStrip();
private final EditorDocumentPresentationRegistry presentationRegistry = new EditorDocumentPresentationRegistry();
private final PrometeuLspService prometeuLspService;
private final ProjectDocumentVfs projectDocumentVfs;
private final EditorOpenFileSession openFileSession = new EditorOpenFileSession();
private final List<String> activePresentationStylesheets = new ArrayList<>();
@@ -45,9 +49,11 @@ public final class EditorWorkspace extends Workspace {
public EditorWorkspace(
final ProjectReference projectReference,
final ProjectDocumentVfs projectDocumentVfs) {
final ProjectDocumentVfs projectDocumentVfs,
final PrometeuLspService prometeuLspService) {
super(projectReference);
this.projectDocumentVfs = Objects.requireNonNull(projectDocumentVfs, "projectDocumentVfs");
this.prometeuLspService = Objects.requireNonNull(prometeuLspService, "prometeuLspService");
root.getStyleClass().add("editor-workspace");
codeArea.setParagraphGraphicFactory(LineNumberFactory.get(codeArea));
codeArea.setEditable(false);
@@ -116,6 +122,7 @@ public final class EditorWorkspace extends Workspace {
applyPresentationStylesheets(presentation);
EditorDocumentPresentationStyles.applyToCodeArea(codeArea, presentation);
statusBar.showPlaceholder(presentation);
outlinePanel.showPlaceholder();
return;
}
@@ -133,6 +140,7 @@ public final class EditorWorkspace extends Workspace {
EditorDocumentPresentationStyles.applyToCodeArea(codeArea, presentation);
refreshCommandSurfaces(fileBuffer);
statusBar.showFile(projectReference, fileBuffer, presentation);
refreshSemanticOutline(fileBuffer);
}
private void revealActiveFileInNavigator() {
@@ -172,6 +180,7 @@ public final class EditorWorkspace extends Workspace {
saveAllButton.setDisable(true);
readOnlyWarning.setVisible(false);
readOnlyWarning.setManaged(false);
outlinePanel.showPlaceholder();
}
private void applyPresentationStylesheets(final EditorDocumentPresentation presentation) {
@@ -307,4 +316,17 @@ public final class EditorWorkspace extends Workspace {
textDocument.accessContext().accessMode(),
textDocument.dirty());
}
private void refreshSemanticOutline(final EditorOpenFileBuffer fileBuffer) {
if (!fileBuffer.frontendDocument()) {
outlinePanel.showPlaceholder();
return;
}
final PrometeuLspAnalyzeDocumentResult analysis = prometeuLspService.analyzeDocument(
new PrometeuLspAnalyzeDocumentRequest(fileBuffer.path()));
outlinePanel.showSemanticReadResult(
fileBuffer.path(),
analysis.diagnostics(),
analysis.documentSymbols());
}
}
@@ -68,7 +68,11 @@ codeEditor.navigator.revealActive=Reveal active file
codeEditor.navigator.placeholder=Project navigation lands in the next implementation slice.
codeEditor.navigator.detail=This first shell reserves the full navigator surface, its refresh action, and the left-column composition without wiring project-tree data yet.
codeEditor.outline.title=Outline
codeEditor.outline.placeholder=Outline is reserved for a future semantic-aware wave.
codeEditor.outline.placeholder=Open a frontend document to inspect read-only diagnostics and symbols.
codeEditor.outline.diagnostics=Diagnostics
codeEditor.outline.symbols=Symbols
codeEditor.outline.emptyDiagnostics=No diagnostics for the active frontend document.
codeEditor.outline.emptySymbols=No semantic symbols are currently available for the active frontend document.
codeEditor.helper.title=Editor Helper
codeEditor.helper.placeholder=This region is intentionally passive in the first read-only wave.
codeEditor.tabs.placeholder=no-file-open.txt
@@ -510,6 +510,43 @@
-fx-min-height: 0;
}
.editor-workspace-outline-scroll {
-fx-background-color: transparent;
-fx-background-insets: 0;
}
.editor-workspace-outline-scroll > .viewport {
-fx-background-color: transparent;
}
.editor-workspace-outline-summary {
-fx-text-fill: #dce6f0;
}
.editor-workspace-outline-section-title {
-fx-font-size: 11px;
-fx-font-weight: 700;
-fx-text-fill: #8fb1d2;
-fx-padding: 4 0 0 0;
}
.editor-workspace-outline-list {
-fx-spacing: 6;
}
.editor-workspace-outline-item {
-fx-text-fill: #d7e2ec;
-fx-font-size: 12px;
}
.editor-workspace-outline-diagnostic-error {
-fx-text-fill: #ff9a9a;
}
.editor-workspace-outline-diagnostic-warning {
-fx-text-fill: #f6d78f;
}
.editor-workspace-tab-strip {
-fx-padding: 8 12 8 12;
-fx-background-color: #1b1f25;
@@ -5,6 +5,10 @@ import p.lsp.PrometeuLspProjectContext;
import p.lsp.PrometeuLspService;
import p.lsp.PrometeuLspServiceFactory;
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.projects.ProjectReference;
import p.studio.vfs.ProjectDocumentVfs;
import p.studio.vfs.ProjectDocumentVfsFactory;
@@ -112,5 +116,15 @@ final class StudioProjectSessionFactoryTest {
public PrometeuLspSessionStateDTO snapshot() {
throw new UnsupportedOperationException();
}
@Override
public PrometeuLspAnalyzeDocumentResult analyzeDocument(final PrometeuLspAnalyzeDocumentRequest request) {
throw new UnsupportedOperationException();
}
@Override
public PrometeuLspDefinitionResult definition(final PrometeuLspDefinitionRequest request) {
throw new UnsupportedOperationException();
}
}
}
@@ -4,6 +4,10 @@ import org.junit.jupiter.api.Test;
import p.lsp.PrometeuLspProjectContext;
import p.lsp.PrometeuLspService;
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.projects.ProjectReference;
import p.studio.vfs.ProjectDocumentVfs;
import p.studio.vfs.VfsDocumentOpenResult;
@@ -90,6 +94,16 @@ final class StudioProjectSessionTest {
throw new UnsupportedOperationException();
}
@Override
public PrometeuLspAnalyzeDocumentResult analyzeDocument(final PrometeuLspAnalyzeDocumentRequest request) {
throw new UnsupportedOperationException();
}
@Override
public PrometeuLspDefinitionResult definition(final PrometeuLspDefinitionRequest request) {
throw new UnsupportedOperationException();
}
@Override
public void close() {
closeCalls++;