Skip to content

Commit

Permalink
Remove folding range providers for now
Browse files Browse the repository at this point in the history
  • Loading branch information
hegyibalint committed Jul 26, 2024
1 parent 4e8982e commit 12321ae
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package org.gradle.declarative.lsp

import org.eclipse.lsp4j.*
import org.eclipse.lsp4j.services.*
import org.gradle.declarative.lsp.logging.LoggingUtils
import org.gradle.declarative.lsp.tapi.ConnectionHandler
import java.io.File
import java.net.URI
Expand Down Expand Up @@ -33,7 +34,6 @@ class DeclarativeLanguageServer : LanguageServer, LanguageClientAware {
val serverCapabilities = ServerCapabilities()
serverCapabilities.setTextDocumentSync(TextDocumentSyncKind.Full)
serverCapabilities.setHoverProvider(true)
// serverCapabilities.setFoldingRangeProvider(true)

val workspaceFolder = params!!.workspaceFolders[0]
val workspaceFolderFile = File(URI.create(workspaceFolder.uri))
Expand All @@ -43,6 +43,8 @@ class DeclarativeLanguageServer : LanguageServer, LanguageClientAware {
textDocumentService.setResources(declarativeBuildModel)
}

LoggingUtils.useLspLogger(client)

initialized = true
System.err.println("Gradle Declartive Language Server: initialized")
return CompletableFuture.completedFuture(InitializeResult(serverCapabilities))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,20 +109,6 @@ class DeclarativeTextDocumentService : TextDocumentService, LanguageClientAware
return CompletableFuture.completedFuture(hover)
}

override fun foldingRange(params: FoldingRangeRequestParams?): CompletableFuture<MutableList<FoldingRange>> {
System.err.println("Asking for folding ranges")
params?.let { nonNullParams ->
val uri = URI(nonNullParams.textDocument.uri)
val foldingRanges = withDom(uri) { dom ->
val visitor = FoldingRangeVisitor()
dom.visit(visitor)
visitor.foldingRanges
}
return CompletableFuture.completedFuture(foldingRanges)
}
return CompletableFuture.completedFuture(mutableListOf())
}

// Utility and other member functions -------------------------------------

private fun parse(uri: URI, text: String): DeclarativeDocument {
Expand All @@ -133,7 +119,8 @@ class DeclarativeTextDocumentService : TextDocumentService, LanguageClientAware
)

System.err.println("Parsed declarative model for document: $uri")
return AnalysisDocumentUtils.documentWithConventions(settingsSchema, fileSchema)!!.document
val document = AnalysisDocumentUtils.documentWithModelDefaults(settingsSchema, fileSchema)
return document!!.document
}

private fun <T> withDom(uri: URI, work: (DeclarativeDocument) -> T): T? {
Expand Down

0 comments on commit 12321ae

Please sign in to comment.