Skip to content

Commit

Permalink
Make ICodeActionParticipant members default
Browse files Browse the repository at this point in the history
  • Loading branch information
vrubezhny authored and angelozerr committed May 16, 2023
1 parent 13099ea commit 92210e6
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 14 deletions.
2 changes: 1 addition & 1 deletion org.eclipse.lemminx/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<groupId>org.eclipse.lemminx</groupId>
<artifactId>lemminx-parent</artifactId>
<version>0.25.1-SNAPSHOT</version>
<version>0.26.0-SNAPSHOT</version>
</parent>
<artifactId>org.eclipse.lemminx</artifactId>
<properties>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
package org.eclipse.lemminx.services.extensions.codeaction;

import java.util.List;
import java.util.concurrent.CancellationException;

import org.eclipse.lsp4j.CodeAction;
import org.eclipse.lsp4j.jsonrpc.CancelChecker;
Expand All @@ -32,8 +33,11 @@ public interface ICodeActionParticipant {
* @param request the code action request.
* @param codeActions list of code actions to fill.
* @param cancelChecker the cancel checker.
* @throws CancellationException if the computation was cancelled
*/
void doCodeAction(ICodeActionRequest request, List<CodeAction> codeActions, CancelChecker cancelChecker);
default void doCodeAction(ICodeActionRequest request, List<CodeAction> codeActions, CancelChecker cancelChecker)
throws CancellationException {
}

/**
* Collect the code action in the given <code>codeActions</code> for the given
Expand All @@ -42,8 +46,12 @@ public interface ICodeActionParticipant {
* @param request the code action request.
* @param codeActions list of code actions to fill.
* @param cancelChecker the cancel checker.
* @throws CancellationException if the computation was cancelled
*
* @since 0.26
*/
default void doCodeActionUnconditional(ICodeActionRequest request, List<CodeAction> codeActions, CancelChecker cancelChecker) {
default void doCodeActionUnconditional(ICodeActionRequest request, List<CodeAction> codeActions,
CancelChecker cancelChecker) throws CancellationException {
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,20 +113,21 @@ static class ErrorParticipantLanguageService extends XMLLanguageService {
public ErrorParticipantLanguageService() {
super();

this.registerCodeActionParticipant((request, codeActions, cancelChecker) -> {
throw new RuntimeException("This participant is broken");
});
this.registerCodeActionParticipant((request, codeActions, cancelChecker) -> {
// This Code Action Participant should add its code actions based on diagnostic code
Diagnostic diagnostic = request.getDiagnostic();
if (diagnostic != null) {
codeActions.add(ca(diagnostic, te(0, 0, 0, 0, "a")));
this.registerCodeActionParticipant(new ICodeActionParticipant() {
public void doCodeAction(ICodeActionRequest request, List<CodeAction> codeActions, CancelChecker cancelChecker) {
throw new RuntimeException("This participant is broken");
}
});
this.registerCodeActionParticipant(new ICodeActionParticipant () {
this.registerCodeActionParticipant(new ICodeActionParticipant() {
public void doCodeAction(ICodeActionRequest request, List<CodeAction> codeActions, CancelChecker cancelChecker) {
// Nothing to do for a diagnostic, even if provided
// This Code Action Participant should add its code actions based on diagnostic code
Diagnostic diagnostic = request.getDiagnostic();
if (diagnostic != null) {
codeActions.add(ca(diagnostic, te(0, 0, 0, 0, "a")));
}
}
});
this.registerCodeActionParticipant(new ICodeActionParticipant () {
public void doCodeActionUnconditional(ICodeActionRequest request, List<CodeAction> codeActions, CancelChecker cancelChecker) {
// This Code Action Participant should add its code actions independently of
// diagnostic provided
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.eclipse.lemminx</groupId>
<artifactId>lemminx-parent</artifactId>
<version>0.25.1-SNAPSHOT</version>
<version>0.26.0-SNAPSHOT</version>
<packaging>pom</packaging>
<name>Eclipse LemMinX</name>
<description>LemMinX is a XML Language Server Protocol (LSP), and can be used with any editor that supports LSP, to offer an outstanding XML editing experience</description>
Expand Down

0 comments on commit 92210e6

Please sign in to comment.