Skip to content

Commit

Permalink
Issue 651 - Fresh branch from main for changes from PR #699 to facili…
Browse files Browse the repository at this point in the history
…tate a clean merge.
  • Loading branch information
SCWells72 committed Dec 10, 2024
1 parent 42c0b46 commit 4e4bc31
Show file tree
Hide file tree
Showing 16 changed files with 915 additions and 97 deletions.
10 changes: 10 additions & 0 deletions docs/LSPApi.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ The [LSPClientFeatures](https://github.com/redhat-developer/lsp4ij/blob/main/src
- [LSP documentSymbol feature](#lsp-documentSymbol-feature)
- [LSP foldingRange feature](#lsp-foldingRange-feature)
- [LSP formatting feature](#lsp-formatting-feature)
- [LSP selection feature](#lsp-selection-feature)
- [LSP hover feature](#lsp-hover-feature)
- [LSP implementation feature](#lsp-implementation-feature)
- [LSP inlayHint feature](#lsp-inlayHint-feature)
Expand Down Expand Up @@ -401,6 +402,15 @@ public class MyLSPFormattingFeature extends LSPFormattingFeature {
}
```

## LSP Selection Feature

Integrates the LSP [`textDocument/selectionRange`](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#textDocument_selectionRange) feature.

| API | Description | Default Behaviour |
|-------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------|
| boolean isEnabled(PsiFile file) | Returns `true` if the LSP feature is enabled for the given file and `false` otherwise. | `true` |
| boolean isSupported(PsiFile file) | Returns `true` if the LSP feature is supported for the given file and `false` otherwise. <br/>This supported state is called after starting the language server, which matches the file and user with the LSP server capabilities. | Check the server capability |

## LSP Hover Feature

| API | Description | Default Behaviour |
Expand Down
11 changes: 10 additions & 1 deletion docs/LSPSupport.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ Current state of [Language Features]( https://microsoft.github.io/language-serve
*[typeHierarchy/subtypes](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#typeHierarchy_subtypes).
*[typeHierarchy/supertypes](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#typeHierarchy_supertypes).
*[textDocument/foldingRange](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#textDocument_foldingRange) (see [implementation details](#folding-range))
* [textDocument/selectionRange](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#textDocument_selectionRange).
* [textDocument/selectionRange](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#textDocument_selectionRange) (see [implementation details](#selection-range))
*[textDocument/documentSymbol](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#textDocument_documentSymbol) (see [implementation details](#document-symbol))
*[textDocument/semanticTokens (experimental)](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#textDocument_semanticTokens) (see [implementation details](#semantic-tokens))
*[textDocument/inlineValue](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#textDocument_inlineValue).
Expand Down Expand Up @@ -382,6 +382,15 @@ system to trigger these actions.

![codeBlockProvider](./images/lsp-support/codeBlockProvider.gif)

### Selection range

[textDocument/selectionRange](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#textDocument_selectionRange) is implemented with
the `extendWordSelectionHandler` extension point and used via the IDE's **Extend Selection** (**Ctrl+W** on Windows/Linux; **Opt+Up** on Mac) and **Shrink Selection** (**Ctrl+Shift+W** on Windows/Linux; **Opt+Down** on Mac) actions.

Here is an example with the [TypeScript Language Server](https://github.com/typescript-language-server/typescript-language-server) showing **Extend/Shrink Selection** using `textDocument/selectionRange`:

![textDocument/selectionRange](./images/lsp-support/textDocument_selectionRange.gif)

### Publish Diagnostics

[textDocument/publishDiagnostics](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#textDocument_publishDiagnostics) is implemented with an `externalAnnotator` extension point. As this extension point supports `any` language, it works out-of-the-box.
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 16 additions & 2 deletions src/main/java/com/redhat/devtools/lsp4ij/LSPFileSupport.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import com.redhat.devtools.lsp4ij.features.references.LSPReferenceSupport;
import com.redhat.devtools.lsp4ij.features.rename.LSPPrepareRenameSupport;
import com.redhat.devtools.lsp4ij.features.rename.LSPRenameSupport;
import com.redhat.devtools.lsp4ij.features.selectionRange.LSPSelectionRangeSupport;
import com.redhat.devtools.lsp4ij.features.semanticTokens.LSPSemanticTokensSupport;
import com.redhat.devtools.lsp4ij.features.signatureHelp.LSPSignatureHelpSupport;
import com.redhat.devtools.lsp4ij.features.typeDefinition.LSPTypeDefinitionSupport;
Expand Down Expand Up @@ -61,6 +62,8 @@ public class LSPFileSupport extends UserDataHolderBase implements Disposable {

private final LSPFoldingRangeSupport foldingRangeSupport;

private final LSPSelectionRangeSupport selectionRangeSupport;

private final LSPFormattingSupport formattingSupport;

private final LSPHighlightSupport highlightSupport;
Expand All @@ -84,7 +87,7 @@ public class LSPFileSupport extends UserDataHolderBase implements Disposable {
private final LSPReferenceSupport referenceSupport;

private final LSPDefinitionSupport definitionSupport;

private final LSPDeclarationSupport declarationSupport;

private final LSPTypeDefinitionSupport typeDefinitionSupport;
Expand All @@ -107,6 +110,7 @@ private LSPFileSupport(@NotNull PsiFile file) {
this.inlayHintsSupport = new LSPInlayHintsSupport(file);
this.colorSupport = new LSPColorSupport(file);
this.foldingRangeSupport = new LSPFoldingRangeSupport(file);
this.selectionRangeSupport = new LSPSelectionRangeSupport(file);
this.formattingSupport = new LSPFormattingSupport(file);
this.highlightSupport = new LSPHighlightSupport(file);
this.signatureHelpSupport = new LSPSignatureHelpSupport(file);
Expand Down Expand Up @@ -140,6 +144,7 @@ public void dispose() {
getInlayHintsSupport().cancel();
getColorSupport().cancel();
getFoldingRangeSupport().cancel();
getSelectionRangeSupport().cancel();
getFormattingSupport().cancel();
getHighlightSupport().cancel();
getSignatureHelpSupport().cancel();
Expand Down Expand Up @@ -206,6 +211,15 @@ public LSPFoldingRangeSupport getFoldingRangeSupport() {
return foldingRangeSupport;
}

/**
* Returns the LSP selection range support.
*
* @return the LSP selection range support.
*/
public LSPSelectionRangeSupport getSelectionRangeSupport() {
return selectionRangeSupport;
}

/**
* Returns the LSP formatting support.
*
Expand Down Expand Up @@ -313,7 +327,7 @@ public LSPReferenceSupport getReferenceSupport() {
public LSPDefinitionSupport getDefinitionSupport() {
return definitionSupport;
}

/**
* Returns the LSP declaration support.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public class LSPRequestConstants {
public static final String TEXT_DOCUMENT_DEFINITION = "textDocument/definition";
public static final String TEXT_DOCUMENT_DOCUMENT_LINK = "textDocument/documentLink";
public static final String TEXT_DOCUMENT_FOLDING_RANGE = "textDocument/foldingRange";
public static final String TEXT_DOCUMENT_SELECTION_RANGE = "textDocument/selectionRange";
public static final String TEXT_DOCUMENT_SEMANTIC_TOKENS_FULL = "textDocument/semanticTokens/full";
public static final String TEXT_DOCUMENT_TYPE_DEFINITION = "textDocument/typeDefinition";
public static final String TEXT_DOCUMENT_CODE_ACTION = "textDocument/codeAction";
Expand Down
Loading

0 comments on commit 4e4bc31

Please sign in to comment.