Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make ICodeActionParticipant members default #1518

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
vrubezhny marked this conversation as resolved.
Show resolved Hide resolved
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