generated from oracle/template-repo
-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #308 from sid-srini/jvsc249_code_folding_if_else
[JVSC-249] Fix code-folding for LSP clients that support line-folding only
- Loading branch information
Showing
2 changed files
with
35 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
diff --git a/java/java.lsp.server/src/org/netbeans/modules/java/lsp/server/protocol/TextDocumentServiceImpl.java b/java/java.lsp.server/src/org/netbeans/modules/java/lsp/server/protocol/TextDocumentServiceImpl.java | ||
index 7a5a5f40e4f9..85c223130e32 100644 | ||
--- a/java/java.lsp.server/src/org/netbeans/modules/java/lsp/server/protocol/TextDocumentServiceImpl.java | ||
+++ b/java/java.lsp.server/src/org/netbeans/modules/java/lsp/server/protocol/TextDocumentServiceImpl.java | ||
@@ -128,6 +128,7 @@ | ||
import org.eclipse.lsp4j.DocumentSymbol; | ||
import org.eclipse.lsp4j.DocumentSymbolParams; | ||
import org.eclipse.lsp4j.FoldingRange; | ||
+import org.eclipse.lsp4j.FoldingRangeCapabilities; | ||
import org.eclipse.lsp4j.FoldingRangeKind; | ||
import org.eclipse.lsp4j.FoldingRangeRequestParams; | ||
import org.eclipse.lsp4j.Hover; | ||
@@ -160,6 +161,7 @@ | ||
import org.eclipse.lsp4j.SignatureHelpParams; | ||
import org.eclipse.lsp4j.SignatureInformation; | ||
import org.eclipse.lsp4j.SymbolInformation; | ||
+import org.eclipse.lsp4j.TextDocumentClientCapabilities; | ||
import org.eclipse.lsp4j.TextDocumentContentChangeEvent; | ||
import org.eclipse.lsp4j.TextDocumentEdit; | ||
import org.eclipse.lsp4j.TextEdit; | ||
@@ -1638,7 +1640,12 @@ public CompletableFuture<List<FoldingRange>> foldingRange(FoldingRangeRequestPar | ||
if (source == null) { | ||
return CompletableFuture.completedFuture(Collections.emptyList()); | ||
} | ||
- final boolean lineFoldingOnly = client.getNbCodeCapabilities().getClientCapabilities().getTextDocument().getFoldingRange().getLineFoldingOnly() == Boolean.TRUE; | ||
+ ClientCapabilities clientCapabilities = client.getNbCodeCapabilities() | ||
+ .getClientCapabilities(); | ||
+ TextDocumentClientCapabilities textDocumentCapabilities = clientCapabilities != null ? clientCapabilities.getTextDocument() : null; | ||
+ FoldingRangeCapabilities foldingRangeCapabilities = textDocumentCapabilities != null ? textDocumentCapabilities.getFoldingRange() : null; | ||
+ Boolean lineFoldingOnlyCapability = foldingRangeCapabilities != null ? foldingRangeCapabilities.getLineFoldingOnly() : null; | ||
+ final boolean lineFoldingOnly = lineFoldingOnlyCapability == Boolean.TRUE; | ||
CompletableFuture<List<FoldingRange>> result = new CompletableFuture<>(); | ||
try { | ||
source.runUserActionTask(cc -> { |