implements PLN-0134
Intrepid/Prometeu/Studio/pipeline/pr-master Build started...
JaCoCo Coverage #### Project Overview
No changes detected, that affect the code coverage.
* Line Coverage: 63.37% (18783/29640)
* Branch Coverage: 53.99% (7369/13648)
* Lines of Code: 29640
* Cyclomatic Complexity: 11938
#### Quality Gates Summary
Output truncated.
Test / Build skipped: 15, passed: 674
Intrepid/Prometeu/Studio/pipeline/head This commit looks good
Intrepid/Prometeu/Studio/pipeline/pr-master Build started...
JaCoCo Coverage #### Project Overview
No changes detected, that affect the code coverage.
* Line Coverage: 63.37% (18783/29640)
* Branch Coverage: 53.99% (7369/13648)
* Lines of Code: 29640
* Cyclomatic Complexity: 11938
#### Quality Gates Summary
Output truncated.
Test / Build skipped: 15, passed: 674
Intrepid/Prometeu/Studio/pipeline/head This commit looks good
Add PBS workspace symbols as a physical flatten of the outline named-declaration set on FrontendLanguageService. Regular files only; virtual stdlib, barrels, imports, locals, and compile-only frontends stay empty. Advertise workspaceSymbolProvider with flat SymbolInformation. workspace/symbol does not require an open document. Housekeep DSC-0042 with LSN-0071.
This commit is contained in:
+60
@@ -56,6 +56,9 @@ class CompilerLanguageServiceBridgeTest {
|
||||
final var documentSymbols = bridge.documentSymbols(context, documentUri, "fn main() {}");
|
||||
assertTrue(documentSymbols.symbols().isEmpty());
|
||||
|
||||
final var workspaceSymbols = bridge.workspaceSymbols(context, "frame");
|
||||
assertTrue(workspaceSymbols.symbols().isEmpty());
|
||||
|
||||
final var semanticTokens = bridge.semanticTokens(context, documentUri, "fn main() {}");
|
||||
assertTrue(semanticTokens.legend().isEmpty());
|
||||
assertTrue(semanticTokens.tokens().isEmpty());
|
||||
@@ -520,6 +523,62 @@ class CompilerLanguageServiceBridgeTest {
|
||||
assertNotEquals(symbols.get(1).detail(), symbols.get(2).detail());
|
||||
}
|
||||
|
||||
@Test
|
||||
void workspaceSymbolsSearchPhysicalNamedDeclarationsWithoutAnOpenDocument() {
|
||||
final Path projectRoot = findRepoRoot(Path.of("").toAbsolutePath().normalize())
|
||||
.resolve("test-projects")
|
||||
.resolve("main")
|
||||
.toAbsolutePath()
|
||||
.normalize();
|
||||
final CompilerLanguageServiceBridge bridge = new CompilerLanguageServiceBridge();
|
||||
final var context = new LspProjectContext("main", "pbs", projectRoot);
|
||||
|
||||
final var frameHits = bridge.workspaceSymbols(context, "frame");
|
||||
assertTrue(frameHits.symbols().stream().anyMatch(symbol ->
|
||||
symbol.name().equals("frame") && symbol.containerName().isEmpty()));
|
||||
assertTrue(frameHits.symbols().stream().allMatch(symbol ->
|
||||
symbol.uri().contains("main.pbs")));
|
||||
|
||||
final var caseInsensitive = bridge.workspaceSymbols(context, "BLA");
|
||||
assertTrue(caseInsensitive.symbols().stream().anyMatch(symbol ->
|
||||
symbol.name().equals("Bla") && symbol.containerName().isEmpty()));
|
||||
|
||||
final var all = bridge.workspaceSymbols(context, "");
|
||||
assertTrue(all.symbols().stream().anyMatch(symbol ->
|
||||
symbol.name().equals("a") && symbol.containerName().equals("Bla")));
|
||||
assertTrue(all.symbols().stream().anyMatch(symbol -> symbol.name().equals("init")));
|
||||
assertTrue(all.symbols().stream().noneMatch(symbol ->
|
||||
symbol.name().equals("Gfx")
|
||||
|| symbol.name().equals("Log")
|
||||
|| symbol.name().equals("Composer")));
|
||||
assertTrue(isSortedByNameThenUriThenOffset(all.symbols()));
|
||||
|
||||
final var stdlibMiss = bridge.workspaceSymbols(context, "Gfx");
|
||||
assertTrue(stdlibMiss.symbols().isEmpty());
|
||||
}
|
||||
|
||||
private boolean isSortedByNameThenUriThenOffset(
|
||||
final List<p.studio.lsp.messages.BaselineWorkspaceSymbol> symbols) {
|
||||
for (int index = 1; index < symbols.size(); index += 1) {
|
||||
final var previous = symbols.get(index - 1);
|
||||
final var current = symbols.get(index);
|
||||
final int nameOrder = String.CASE_INSENSITIVE_ORDER.compare(previous.name(), current.name());
|
||||
if (nameOrder > 0) {
|
||||
return false;
|
||||
}
|
||||
if (nameOrder == 0) {
|
||||
final int uriOrder = previous.uri().compareTo(current.uri());
|
||||
if (uriOrder > 0) {
|
||||
return false;
|
||||
}
|
||||
if (uriOrder == 0 && previous.startLine() > current.startLine()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Test
|
||||
void describeServerPublishesFrontendVisualThemes() {
|
||||
final CompilerLanguageServiceBridge bridge = new CompilerLanguageServiceBridge();
|
||||
@@ -533,6 +592,7 @@ class CompilerLanguageServiceBridgeTest {
|
||||
assertTrue(description.definitionSupported());
|
||||
assertTrue(description.referencesSupported());
|
||||
assertTrue(description.documentSymbolsSupported());
|
||||
assertTrue(description.workspaceSymbolsSupported());
|
||||
assertEquals(1, description.semanticHostProjections().size());
|
||||
assertEquals("vscode", description.semanticHostProjections().getFirst().hostId());
|
||||
assertTrue(description.semanticHostProjections().getFirst().tokenProjections().stream()
|
||||
|
||||
+14
@@ -102,6 +102,7 @@ class PrometeuLanguageServerTest {
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
List.of(),
|
||||
List.of(new BaselineSemanticHostProjection(
|
||||
"vscode",
|
||||
@@ -178,6 +179,13 @@ class PrometeuLanguageServerTest {
|
||||
return p.studio.lsp.messages.BaselineDocumentSymbols.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public p.studio.lsp.messages.BaselineWorkspaceSymbols workspaceSymbols(
|
||||
final LspProjectContext project,
|
||||
final String query) {
|
||||
return p.studio.lsp.messages.BaselineWorkspaceSymbols.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaselineSignatureHelp signatureHelp(
|
||||
final LspProjectContext project,
|
||||
@@ -241,6 +249,12 @@ class PrometeuLanguageServerTest {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public java.util.List<org.eclipse.lsp4j.SymbolInformation> mapWorkspaceSymbols(
|
||||
final p.studio.lsp.messages.BaselineWorkspaceSymbols symbols) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.eclipse.lsp4j.CompletionList mapCompletion(final BaselineCompletion completion) {
|
||||
throw new UnsupportedOperationException();
|
||||
|
||||
+13
@@ -217,6 +217,13 @@ final class PrometeuTextDocumentServiceTest {
|
||||
List.of())));
|
||||
}
|
||||
|
||||
@Override
|
||||
public p.studio.lsp.messages.BaselineWorkspaceSymbols workspaceSymbols(
|
||||
final LspProjectContext context,
|
||||
final String query) {
|
||||
return p.studio.lsp.messages.BaselineWorkspaceSymbols.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaselineSignatureHelp signatureHelp(
|
||||
final LspProjectContext context,
|
||||
@@ -290,6 +297,12 @@ final class PrometeuTextDocumentServiceTest {
|
||||
return documentSymbols;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<org.eclipse.lsp4j.SymbolInformation> mapWorkspaceSymbols(
|
||||
final p.studio.lsp.messages.BaselineWorkspaceSymbols symbols) {
|
||||
return List.of();
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletionList mapCompletion(final BaselineCompletion completion) {
|
||||
return completionList;
|
||||
|
||||
+229
@@ -0,0 +1,229 @@
|
||||
package p.studio.lsp.services.protocol;
|
||||
|
||||
import org.eclipse.lsp4j.SymbolInformation;
|
||||
import org.eclipse.lsp4j.WorkspaceSymbolParams;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import p.studio.lsp.messages.BaselineCompletion;
|
||||
import p.studio.lsp.messages.BaselineDefinition;
|
||||
import p.studio.lsp.messages.BaselineDocumentAnalysis;
|
||||
import p.studio.lsp.messages.BaselineDocumentSymbols;
|
||||
import p.studio.lsp.messages.BaselineDocumentSymbolKind;
|
||||
import p.studio.lsp.messages.BaselineHover;
|
||||
import p.studio.lsp.messages.BaselineReferences;
|
||||
import p.studio.lsp.messages.BaselineSemanticTokens;
|
||||
import p.studio.lsp.messages.BaselineServerDescription;
|
||||
import p.studio.lsp.messages.BaselineSignatureHelp;
|
||||
import p.studio.lsp.messages.BaselineWorkspaceSymbol;
|
||||
import p.studio.lsp.messages.BaselineWorkspaceSymbols;
|
||||
import p.studio.lsp.messages.LspProjectContext;
|
||||
import p.studio.lsp.services.LanguageServiceBridge;
|
||||
import p.studio.lsp.services.protocol.mapping.ProtocolMessageMapper;
|
||||
|
||||
import java.nio.file.Path;
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertSame;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
final class PrometeuWorkspaceServiceTest {
|
||||
|
||||
@Test
|
||||
void symbolDelegatesQueryWithoutADocumentUri() {
|
||||
final var bridge = new RecordingBridge();
|
||||
final var mapper = new RecordingMapper();
|
||||
final var project = new LspProjectContext("main", "pbs", Path.of("."));
|
||||
final var service = new PrometeuWorkspaceService(project, bridge, mapper);
|
||||
|
||||
final var result = service.symbol(new WorkspaceSymbolParams("blend")).join();
|
||||
|
||||
assertTrue(result.isLeft());
|
||||
assertSame(mapper.workspaceSymbols, result.getLeft());
|
||||
assertEquals("blend", bridge.lastQuery);
|
||||
assertSame(project, bridge.lastContext);
|
||||
}
|
||||
|
||||
private static final class RecordingBridge implements LanguageServiceBridge {
|
||||
private LspProjectContext lastContext;
|
||||
private String lastQuery;
|
||||
|
||||
@Override
|
||||
public BaselineServerDescription describeServer(final LspProjectContext context) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaselineDocumentAnalysis analyzeDocument(
|
||||
final LspProjectContext context,
|
||||
final String documentUri,
|
||||
final String text) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaselineCompletion completion(
|
||||
final LspProjectContext context,
|
||||
final String documentUri,
|
||||
final String text,
|
||||
final int line,
|
||||
final int character) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaselineHover hover(
|
||||
final LspProjectContext context,
|
||||
final String documentUri,
|
||||
final String text,
|
||||
final int line,
|
||||
final int character) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaselineDefinition definition(
|
||||
final LspProjectContext context,
|
||||
final String documentUri,
|
||||
final String text,
|
||||
final int line,
|
||||
final int character) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaselineReferences references(
|
||||
final LspProjectContext context,
|
||||
final String documentUri,
|
||||
final String text,
|
||||
final int line,
|
||||
final int character,
|
||||
final boolean includeDeclaration) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaselineDocumentSymbols documentSymbols(
|
||||
final LspProjectContext context,
|
||||
final String documentUri,
|
||||
final String text) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaselineWorkspaceSymbols workspaceSymbols(
|
||||
final LspProjectContext context,
|
||||
final String query) {
|
||||
lastContext = context;
|
||||
lastQuery = query;
|
||||
return new BaselineWorkspaceSymbols(List.of(new BaselineWorkspaceSymbol(
|
||||
"blend",
|
||||
BaselineDocumentSymbolKind.METHOD,
|
||||
"",
|
||||
"Vec",
|
||||
"file:///tmp/demo.pbs",
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
5)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaselineSignatureHelp signatureHelp(
|
||||
final LspProjectContext context,
|
||||
final String documentUri,
|
||||
final String text,
|
||||
final int line,
|
||||
final int character) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaselineSemanticTokens semanticTokens(
|
||||
final LspProjectContext context,
|
||||
final String documentUri,
|
||||
final String text) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String onSave(final LspProjectContext context, final String documentUri) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
}
|
||||
|
||||
private static final class RecordingMapper implements ProtocolMessageMapper {
|
||||
private final List<SymbolInformation> workspaceSymbols = List.of(new SymbolInformation());
|
||||
|
||||
@Override
|
||||
public org.eclipse.lsp4j.InitializeResult mapInitializeResult(final BaselineServerDescription description) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.eclipse.lsp4j.PublishDiagnosticsParams mapDiagnostics(
|
||||
final String uri,
|
||||
final BaselineDocumentAnalysis analysis) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.eclipse.lsp4j.PublishDiagnosticsParams emptyDiagnostics(final String uri) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.eclipse.lsp4j.Hover mapHover(final BaselineHover hover) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<org.eclipse.lsp4j.Location> mapDefinition(final BaselineDefinition definition) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<org.eclipse.lsp4j.Location> mapReferences(final BaselineReferences references) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<org.eclipse.lsp4j.DocumentSymbol> mapDocumentSymbols(final BaselineDocumentSymbols symbols) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SymbolInformation> mapWorkspaceSymbols(final BaselineWorkspaceSymbols symbols) {
|
||||
return workspaceSymbols;
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.eclipse.lsp4j.CompletionList mapCompletion(final BaselineCompletion completion) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.eclipse.lsp4j.SignatureHelp mapSignatureHelp(final BaselineSignatureHelp signatureHelp) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.eclipse.lsp4j.SemanticTokens mapSemanticTokens(final BaselineSemanticTokens semanticTokens) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.eclipse.lsp4j.MessageParams mapInfoMessage(final String message) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.eclipse.lsp4j.MessageParams mapErrorMessage(final String message) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.eclipse.lsp4j.MessageParams mapWarningMessage(final String message) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
}
|
||||
}
|
||||
+38
@@ -45,6 +45,7 @@ final class Lsp4jProtocolMessageMapperTest {
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
List.of("demo-keyword"),
|
||||
List.of(new BaselineSemanticHostProjection(
|
||||
"vscode",
|
||||
@@ -68,6 +69,7 @@ final class Lsp4jProtocolMessageMapperTest {
|
||||
assertEquals(Boolean.TRUE, result.getCapabilities().getDefinitionProvider().getLeft());
|
||||
assertEquals(Boolean.TRUE, result.getCapabilities().getReferencesProvider().getLeft());
|
||||
assertEquals(Boolean.TRUE, result.getCapabilities().getDocumentSymbolProvider().getLeft());
|
||||
assertEquals(Boolean.TRUE, result.getCapabilities().getWorkspaceSymbolProvider().getLeft());
|
||||
|
||||
final var experimental = assertInstanceOf(Map.class, result.getCapabilities().getExperimental());
|
||||
final var semanticPayload = assertInstanceOf(Map.class, experimental.get("prometeuSemanticHostProjections"));
|
||||
@@ -208,4 +210,40 @@ final class Lsp4jProtocolMessageMapperTest {
|
||||
assertEquals(SymbolKind.Field, mapped.get(1).getChildren().getFirst().getKind());
|
||||
assertTrue(mapper.mapDocumentSymbols(BaselineDocumentSymbols.empty()).isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
void workspaceSymbolsMapToFlatSymbolInformation() {
|
||||
final var mapper = new Lsp4jProtocolMessageMapper();
|
||||
final var mapped = mapper.mapWorkspaceSymbols(new p.studio.lsp.messages.BaselineWorkspaceSymbols(List.of(
|
||||
new p.studio.lsp.messages.BaselineWorkspaceSymbol(
|
||||
"blend",
|
||||
BaselineDocumentSymbolKind.METHOD,
|
||||
"(dx: int, dy: int) -> int",
|
||||
"Vec",
|
||||
"file:///tmp/demo.pbs",
|
||||
3,
|
||||
2,
|
||||
3,
|
||||
7),
|
||||
new p.studio.lsp.messages.BaselineWorkspaceSymbol(
|
||||
"Idle",
|
||||
BaselineDocumentSymbolKind.ENUM,
|
||||
"0",
|
||||
"Mode",
|
||||
"file:///tmp/demo.pbs",
|
||||
0,
|
||||
19,
|
||||
0,
|
||||
23))));
|
||||
|
||||
assertEquals(2, mapped.size());
|
||||
assertEquals("blend", mapped.getFirst().getName());
|
||||
assertEquals("Vec", mapped.getFirst().getContainerName());
|
||||
assertEquals(SymbolKind.Method, mapped.getFirst().getKind());
|
||||
assertEquals("file:///tmp/demo.pbs", mapped.getFirst().getLocation().getUri());
|
||||
assertEquals(2, mapped.getFirst().getLocation().getRange().getStart().getCharacter());
|
||||
assertEquals("Idle", mapped.get(1).getName());
|
||||
assertEquals(SymbolKind.EnumMember, mapped.get(1).getKind());
|
||||
assertTrue(mapper.mapWorkspaceSymbols(p.studio.lsp.messages.BaselineWorkspaceSymbols.empty()).isEmpty());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user