forked from redhat-developer/quarkus-ls
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes redhat-developer#531 Signed-off-by: azerr <azerr@redhat.com>
- Loading branch information
1 parent
da79fdb
commit 0d9e039
Showing
8 changed files
with
112 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
76 changes: 76 additions & 0 deletions
76
...qute.ls/src/main/java/com/redhat/qute/services/diagnostics/TemplateCodeActionFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2022 Red Hat Inc. and others. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License v. 2.0 which is available at | ||
* http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 | ||
* which is available at https://www.apache.org/licenses/LICENSE-2.0. | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 | ||
* | ||
* Contributors: | ||
* Red Hat Inc. - initial API and implementation | ||
*******************************************************************************/ | ||
package com.redhat.qute.services.diagnostics; | ||
|
||
import java.util.Collections; | ||
|
||
import org.eclipse.lsp4j.CodeAction; | ||
import org.eclipse.lsp4j.CodeActionKind; | ||
import org.eclipse.lsp4j.Command; | ||
import org.eclipse.lsp4j.Diagnostic; | ||
|
||
import com.redhat.qute.ls.commons.client.ConfigurationItemEdit; | ||
import com.redhat.qute.ls.commons.client.ConfigurationItemEditType; | ||
import com.redhat.qute.ls.commons.client.QuteClientCommandConstants; | ||
|
||
/** | ||
* Specific code action factory for Qute. | ||
* | ||
* @author Angelo ZERR | ||
* | ||
*/ | ||
public class TemplateCodeActionFactory { | ||
|
||
// Enable/Disable Qute validation | ||
|
||
private static final String UNASSIGNED_EXCLUDED_SECTION = "quarkus.tools.qute.validation.enabled"; | ||
|
||
private static final String UNASSIGNED_EXCLUDE_CODE_ACTION_TITLE = "Do you want disable Qute validation?"; | ||
|
||
private static final String UNASSIGNED_EXCLUDE_COMMAND_TITLE = "Disable Qute validation"; | ||
|
||
/** | ||
* Returns a code action for <code>diagnostic</code> that causes | ||
* <code>item</code> to be added to | ||
* <code>microprofile.tools.validation.unassigned.excluded</code> client | ||
* configuration | ||
* | ||
* @param item the item to add to the client configuration array | ||
* @param diagnostic the diagnostic for the <code>CodeAction</code> | ||
* @return a code action that causes <code>item</code> to be added to | ||
* <code>microprofile.tools.validation.unassigned.excluded</code> client | ||
* configuration | ||
*/ | ||
public static CodeAction createValidationEnabledCodeAction(boolean enabled, Diagnostic diagnostic) { | ||
String codeActionTitle = UNASSIGNED_EXCLUDE_CODE_ACTION_TITLE; | ||
String commandTitle = UNASSIGNED_EXCLUDE_COMMAND_TITLE; | ||
ConfigurationItemEditType editType = ConfigurationItemEditType.update; | ||
return createConfigurationUpdateCodeAction(codeActionTitle, commandTitle, UNASSIGNED_EXCLUDED_SECTION, editType, | ||
enabled, diagnostic); | ||
} | ||
|
||
private static CodeAction createConfigurationUpdateCodeAction(String codeActionTitle, String commandTitle, | ||
String section, ConfigurationItemEditType editType, Object item, Diagnostic diagnostic) { | ||
CodeAction updateCodeAction = new CodeAction(codeActionTitle); | ||
|
||
ConfigurationItemEdit configItemEdit = new ConfigurationItemEdit(section, editType, item); | ||
|
||
Command command = new Command(commandTitle, QuteClientCommandConstants.COMMAND_CONFIGURATION_UPDATE, | ||
Collections.singletonList(configItemEdit)); | ||
updateCodeAction.setCommand(command); | ||
updateCodeAction.setKind(CodeActionKind.QuickFix); | ||
updateCodeAction.setDiagnostics(Collections.singletonList(diagnostic)); | ||
return updateCodeAction; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters