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:
+15
@@ -11,6 +11,11 @@ import java.util.Optional;
|
||||
* Optional frontend-owned editor services.
|
||||
*/
|
||||
public interface FrontendLanguageService {
|
||||
default Optional<FrontendEditorialContext> prepareEditorialContext(
|
||||
final FrontendPhaseContext phaseContext) {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
default Optional<FrontendEditorialContext> prepareEditorialContext(
|
||||
final FrontendPhaseContext phaseContext,
|
||||
final FileId fileId) {
|
||||
@@ -95,4 +100,14 @@ public interface FrontendLanguageService {
|
||||
final FrontendEditorialContext editorialContext) {
|
||||
return documentSymbols(request);
|
||||
}
|
||||
|
||||
default List<FrontendWorkspaceSymbol> workspaceSymbols(final FrontendWorkspaceRequest request) {
|
||||
return List.of();
|
||||
}
|
||||
|
||||
default List<FrontendWorkspaceSymbol> workspaceSymbols(
|
||||
final FrontendWorkspaceRequest request,
|
||||
final FrontendEditorialContext editorialContext) {
|
||||
return workspaceSymbols(request);
|
||||
}
|
||||
}
|
||||
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
package p.studio.compiler.services;
|
||||
|
||||
import java.nio.file.Path;
|
||||
import java.util.Objects;
|
||||
|
||||
public record FrontendWorkspaceRequest(
|
||||
Path projectRoot,
|
||||
String query) {
|
||||
|
||||
public FrontendWorkspaceRequest {
|
||||
projectRoot = Objects.requireNonNull(projectRoot, "projectRoot").toAbsolutePath().normalize();
|
||||
query = query == null ? "" : query;
|
||||
}
|
||||
}
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
package p.studio.compiler.services;
|
||||
|
||||
import java.nio.file.Path;
|
||||
import java.util.Objects;
|
||||
|
||||
public record FrontendWorkspaceSymbol(
|
||||
String name,
|
||||
FrontendSymbolKind kind,
|
||||
String detail,
|
||||
String containerName,
|
||||
Path path,
|
||||
int startOffset,
|
||||
int endOffset) {
|
||||
|
||||
public FrontendWorkspaceSymbol {
|
||||
name = requireText(name, "name");
|
||||
kind = Objects.requireNonNull(kind, "kind");
|
||||
detail = detail == null ? "" : detail.trim();
|
||||
containerName = containerName == null ? "" : containerName.trim();
|
||||
path = Objects.requireNonNull(path, "path").toAbsolutePath().normalize();
|
||||
if (startOffset < 0) {
|
||||
throw new IllegalArgumentException("startOffset must not be negative");
|
||||
}
|
||||
if (endOffset < startOffset) {
|
||||
throw new IllegalArgumentException("endOffset must not be before startOffset");
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
+52
@@ -25,6 +25,8 @@ class FrontendLanguageServiceTest {
|
||||
assertTrue(service.definition(request, 0).isEmpty());
|
||||
assertTrue(service.references(request, 0).isEmpty());
|
||||
assertTrue(service.documentSymbols(request).isEmpty());
|
||||
assertTrue(service.workspaceSymbols(new FrontendWorkspaceRequest(Path.of("."), "frame")).isEmpty());
|
||||
assertTrue(service.prepareEditorialContext(null).isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -90,6 +92,56 @@ class FrontendLanguageServiceTest {
|
||||
List.of()));
|
||||
}
|
||||
|
||||
@Test
|
||||
void workspaceSymbolNormalizesOptionalTextAndRejectsBlankNameOrInvertedOffsets() {
|
||||
final Path path = Path.of("src/main.pbs").toAbsolutePath();
|
||||
final var symbol = new FrontendWorkspaceSymbol(
|
||||
" blend ",
|
||||
FrontendSymbolKind.METHOD,
|
||||
" (dx: int) -> int ",
|
||||
" Vec ",
|
||||
path,
|
||||
4,
|
||||
9);
|
||||
assertEquals("blend", symbol.name());
|
||||
assertEquals("(dx: int) -> int", symbol.detail());
|
||||
assertEquals("Vec", symbol.containerName());
|
||||
assertEquals(path.normalize(), symbol.path());
|
||||
|
||||
assertThrows(IllegalArgumentException.class, () -> new FrontendWorkspaceSymbol(
|
||||
" ",
|
||||
FrontendSymbolKind.FUNCTION,
|
||||
"",
|
||||
"",
|
||||
path,
|
||||
0,
|
||||
1));
|
||||
assertThrows(NullPointerException.class, () -> new FrontendWorkspaceSymbol(
|
||||
"fn",
|
||||
FrontendSymbolKind.FUNCTION,
|
||||
"",
|
||||
"",
|
||||
null,
|
||||
0,
|
||||
1));
|
||||
assertThrows(IllegalArgumentException.class, () -> new FrontendWorkspaceSymbol(
|
||||
"fn",
|
||||
FrontendSymbolKind.FUNCTION,
|
||||
"",
|
||||
"",
|
||||
path,
|
||||
-1,
|
||||
0));
|
||||
assertThrows(IllegalArgumentException.class, () -> new FrontendWorkspaceSymbol(
|
||||
"fn",
|
||||
FrontendSymbolKind.FUNCTION,
|
||||
"",
|
||||
"",
|
||||
path,
|
||||
5,
|
||||
4));
|
||||
}
|
||||
|
||||
@Test
|
||||
void definitionLocationRejectsBlankPathAndInvertedOffsets() {
|
||||
final Path path = Path.of("src/main.pbs").toAbsolutePath();
|
||||
|
||||
Reference in New Issue
Block a user