implements PLN-0135
Intrepid/Prometeu/Studio/pipeline/pr-master Build started...
JaCoCo Coverage #### Project Overview
No changes detected, that affect the code coverage.
* Line Coverage: 63.56% (19159/30145)
* Branch Coverage: 54.14% (7612/14060)
* Lines of Code: 30145
* Cyclomatic Complexity: 12214
#### Quality Gates Summary
Output truncated.
Test / Build skipped: 15, passed: 678
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.56% (19159/30145)
* Branch Coverage: 54.14% (7612/14060)
* Lines of Code: 30145
* Cyclomatic Complexity: 12214
#### Quality Gates Summary
Output truncated.
Test / Build skipped: 15, passed: 678
Intrepid/Prometeu/Studio/pipeline/head This commit looks good
Add PBS rename as a validated WorkspaceEdit of physical identifier sites on FrontendLanguageService. Identity is definition; locals and params rename from their name span. Refuse aliases, virtual stdlib, builtins, error labels, keywords, and collisions. Advertise renameProvider with prepareProvider; refused cursors are LSP errors, not empty success. Housekeep DSC-0043 with LSN-0072.
This commit is contained in:
+28
@@ -110,4 +110,32 @@ public interface FrontendLanguageService {
|
||||
final FrontendEditorialContext editorialContext) {
|
||||
return workspaceSymbols(request);
|
||||
}
|
||||
|
||||
default Optional<FrontendDefinitionLocation> prepareRename(
|
||||
final FrontendDocumentRequest request,
|
||||
final int offset) {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
default Optional<FrontendDefinitionLocation> prepareRename(
|
||||
final FrontendDocumentRequest request,
|
||||
final FrontendEditorialContext editorialContext,
|
||||
final int offset) {
|
||||
return prepareRename(request, offset);
|
||||
}
|
||||
|
||||
default FrontendRenameResult rename(
|
||||
final FrontendDocumentRequest request,
|
||||
final int offset,
|
||||
final String newName) {
|
||||
return FrontendRenameResult.unsupported();
|
||||
}
|
||||
|
||||
default FrontendRenameResult rename(
|
||||
final FrontendDocumentRequest request,
|
||||
final FrontendEditorialContext editorialContext,
|
||||
final int offset,
|
||||
final String newName) {
|
||||
return rename(request, offset, newName);
|
||||
}
|
||||
}
|
||||
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
package p.studio.compiler.services;
|
||||
|
||||
import java.nio.file.Path;
|
||||
import java.util.Objects;
|
||||
|
||||
public record FrontendRenameEdit(
|
||||
Path path,
|
||||
int startOffset,
|
||||
int endOffset,
|
||||
String newText) {
|
||||
|
||||
public FrontendRenameEdit {
|
||||
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");
|
||||
}
|
||||
newText = Objects.requireNonNull(newText, "newText");
|
||||
}
|
||||
}
|
||||
+45
@@ -0,0 +1,45 @@
|
||||
package p.studio.compiler.services;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
public record FrontendRenameResult(
|
||||
Status status,
|
||||
String message,
|
||||
List<FrontendRenameEdit> edits) {
|
||||
|
||||
public enum Status {
|
||||
UNSUPPORTED,
|
||||
REFUSED,
|
||||
APPLIED
|
||||
}
|
||||
|
||||
public FrontendRenameResult {
|
||||
status = Objects.requireNonNull(status, "status");
|
||||
message = message == null ? "" : message.trim();
|
||||
edits = edits == null ? List.of() : List.copyOf(edits);
|
||||
if (status == Status.APPLIED && edits.isEmpty()) {
|
||||
throw new IllegalArgumentException("applied rename must include at least one edit");
|
||||
}
|
||||
if (status != Status.APPLIED && !edits.isEmpty()) {
|
||||
throw new IllegalArgumentException("refused or unsupported rename must not include edits");
|
||||
}
|
||||
}
|
||||
|
||||
public static FrontendRenameResult unsupported() {
|
||||
return new FrontendRenameResult(Status.UNSUPPORTED, "unsupported", List.of());
|
||||
}
|
||||
|
||||
public static FrontendRenameResult refused(final String message) {
|
||||
final String reason = message == null || message.isBlank() ? "not renameable" : message.trim();
|
||||
return new FrontendRenameResult(Status.REFUSED, reason, List.of());
|
||||
}
|
||||
|
||||
public static FrontendRenameResult applied(final List<FrontendRenameEdit> edits) {
|
||||
return new FrontendRenameResult(Status.APPLIED, "", edits);
|
||||
}
|
||||
|
||||
public boolean applied() {
|
||||
return status == Status.APPLIED;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user