Skip to content

Commit

Permalink
chore: clean LSP supported features
Browse files Browse the repository at this point in the history
Signed-off-by: azerr <[email protected]>
  • Loading branch information
angelozerr committed Jul 28, 2023
1 parent 8ba367a commit 256f05b
Showing 1 changed file with 36 additions and 48 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,46 +15,7 @@
import java.util.Arrays;
import java.util.List;

import org.eclipse.lsp4j.CodeActionCapabilities;
import org.eclipse.lsp4j.CodeActionKind;
import org.eclipse.lsp4j.CodeActionKindCapabilities;
import org.eclipse.lsp4j.CodeActionLiteralSupportCapabilities;
import org.eclipse.lsp4j.CodeActionResolveSupportCapabilities;
import org.eclipse.lsp4j.CodeLensCapabilities;
import org.eclipse.lsp4j.ColorProviderCapabilities;
import org.eclipse.lsp4j.CompletionCapabilities;
import org.eclipse.lsp4j.CompletionItemCapabilities;
import org.eclipse.lsp4j.CompletionItemInsertTextModeSupportCapabilities;
import org.eclipse.lsp4j.CompletionItemResolveSupportCapabilities;
import org.eclipse.lsp4j.DefinitionCapabilities;
import org.eclipse.lsp4j.DocumentHighlightCapabilities;
import org.eclipse.lsp4j.DocumentLinkCapabilities;
import org.eclipse.lsp4j.DocumentSymbolCapabilities;
import org.eclipse.lsp4j.ExecuteCommandCapabilities;
import org.eclipse.lsp4j.FailureHandlingKind;
import org.eclipse.lsp4j.FoldingRangeCapabilities;
import org.eclipse.lsp4j.FormattingCapabilities;
import org.eclipse.lsp4j.HoverCapabilities;
import org.eclipse.lsp4j.InlayHintCapabilities;
import org.eclipse.lsp4j.InsertTextMode;
import org.eclipse.lsp4j.MarkupKind;
import org.eclipse.lsp4j.RangeFormattingCapabilities;
import org.eclipse.lsp4j.ReferencesCapabilities;
import org.eclipse.lsp4j.RenameCapabilities;
import org.eclipse.lsp4j.ResourceOperationKind;
import org.eclipse.lsp4j.SelectionRangeCapabilities;
import org.eclipse.lsp4j.ShowDocumentCapabilities;
import org.eclipse.lsp4j.SignatureHelpCapabilities;
import org.eclipse.lsp4j.SymbolCapabilities;
import org.eclipse.lsp4j.SymbolKind;
import org.eclipse.lsp4j.SymbolKindCapabilities;
import org.eclipse.lsp4j.SynchronizationCapabilities;
import org.eclipse.lsp4j.TextDocumentClientCapabilities;
import org.eclipse.lsp4j.TypeDefinitionCapabilities;
import org.eclipse.lsp4j.WindowClientCapabilities;
import org.eclipse.lsp4j.WindowShowMessageRequestCapabilities;
import org.eclipse.lsp4j.WorkspaceClientCapabilities;
import org.eclipse.lsp4j.WorkspaceEditCapabilities;
import org.eclipse.lsp4j.*;

import javax.annotation.Nonnull;

Expand All @@ -65,34 +26,54 @@ public class SupportedFeatures {

public static @Nonnull TextDocumentClientCapabilities getTextDocumentClientCapabilities() {
final var textDocumentClientCapabilities = new TextDocumentClientCapabilities();

// Code Action support
final var codeAction = new CodeActionCapabilities(new CodeActionLiteralSupportCapabilities(
new CodeActionKindCapabilities(Arrays.asList(CodeActionKind.QuickFix, CodeActionKind.Refactor,
CodeActionKind.RefactorExtract, CodeActionKind.RefactorInline,
CodeActionKind.RefactorRewrite, CodeActionKind.Source,
CodeActionKind.SourceOrganizeImports))),
true);
codeAction.setDataSupport(true);
codeAction.setResolveSupport(new CodeActionResolveSupportCapabilities(List.of("edit"))); //$NON-NLS-1$
codeAction.setResolveSupport(new CodeActionResolveSupportCapabilities(List.of("edit")));
textDocumentClientCapabilities.setCodeAction(codeAction);

// Code Lens support
textDocumentClientCapabilities.setCodeLens(new CodeLensCapabilities());

// Inlay Hint support
textDocumentClientCapabilities.setInlayHint(new InlayHintCapabilities());

// TODO : support textDocument/colorPresentation
// textDocumentClientCapabilities.setColorProvider(new ColorProviderCapabilities());

// Completion support
final var completionItemCapabilities = new CompletionItemCapabilities(Boolean.TRUE);
completionItemCapabilities
.setDocumentationFormat(Arrays.asList(MarkupKind.MARKDOWN, MarkupKind.PLAINTEXT));
completionItemCapabilities.setInsertTextModeSupport(new CompletionItemInsertTextModeSupportCapabilities(List.of(InsertTextMode.AsIs, InsertTextMode.AdjustIndentation)));

// completionItemCapabilities.setResolveSupport(new CompletionItemResolveSupportCapabilities(List.of("documentation", "detail", "additionalTextEdits"))); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
textDocumentClientCapabilities.setCompletion(new CompletionCapabilities(completionItemCapabilities));
CompletionCapabilities completionCapabilities = new CompletionCapabilities(completionItemCapabilities);
completionCapabilities.setCompletionList(new CompletionListCapabilities(List.of("editRange")));
textDocumentClientCapabilities.setCompletion(completionCapabilities);

// Definition support
final var definitionCapabilities = new DefinitionCapabilities();
definitionCapabilities.setLinkSupport(Boolean.TRUE);
textDocumentClientCapabilities.setDefinition(definitionCapabilities);
final var typeDefinitionCapabilities = new TypeDefinitionCapabilities();
typeDefinitionCapabilities.setLinkSupport(Boolean.TRUE);
textDocumentClientCapabilities.setTypeDefinition(typeDefinitionCapabilities);

// TODO support type definition
//final var typeDefinitionCapabilities = new TypeDefinitionCapabilities();
//typeDefinitionCapabilities.setLinkSupport(Boolean.TRUE);
//textDocumentClientCapabilities.setTypeDefinition(typeDefinitionCapabilities);

// DocumentHighlight support
textDocumentClientCapabilities.setDocumentHighlight(new DocumentHighlightCapabilities());
// TODO : support textDocument/documentLink
// textDocumentClientCapabilities.setDocumentLink(new DocumentLinkCapabilities());

// DocumentLink support
textDocumentClientCapabilities.setDocumentLink(new DocumentLinkCapabilities());

// TODO : support textDocument/documentSymbol
/** final var documentSymbol = new DocumentSymbolCapabilities();
documentSymbol.setHierarchicalDocumentSymbolSupport(true);
Expand All @@ -109,10 +90,14 @@ public class SupportedFeatures {
// textDocumentClientCapabilities.setFoldingRange(new FoldingRangeCapabilities());
// TODO : support textDocument/formatting
// textDocumentClientCapabilities.setFormatting(new FormattingCapabilities(Boolean.TRUE));

// Hover support
final var hoverCapabilities = new HoverCapabilities();
hoverCapabilities.setContentFormat(Arrays.asList(MarkupKind.MARKDOWN, MarkupKind.PLAINTEXT));
textDocumentClientCapabilities.setHover(hoverCapabilities);
textDocumentClientCapabilities.setOnTypeFormatting(null); // TODO

// TODO: support onTypeFormatting
// textDocumentClientCapabilities.setOnTypeFormatting(null); // TODO
// TODO : support textDocument/rangeFormatting
// textDocumentClientCapabilities.setRangeFormatting(new RangeFormattingCapabilities());
// TODO : support textDocument/references
Expand All @@ -123,8 +108,11 @@ public class SupportedFeatures {
//textDocumentClientCapabilities.setRename(renameCapabilities);
// TODO : support textDocument/signatureHelp
// textDocumentClientCapabilities.setSignatureHelp(new SignatureHelpCapabilities());

// Synchronization support
textDocumentClientCapabilities
.setSynchronization(new SynchronizationCapabilities(Boolean.TRUE, Boolean.TRUE, Boolean.TRUE));

// TODO
// SelectionRangeCapabilities selectionRange = new SelectionRangeCapabilities();
// textDocumentClientCapabilities.setSelectionRange(selectionRange);
Expand Down

0 comments on commit 256f05b

Please sign in to comment.