diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 693e5541..6425127e 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -5,13 +5,6 @@ updates: directory: "/" schedule: interval: "daily" - ignore: - # Prevent Dependabot from updating LSP4J to new versions - # TODO[#232]: Remove this block after updating to the new PSES - - dependency-name: "org.eclipse.lsp4j:org.eclipse.lsp4j" - update-types: - - version-update:semver-major - - version-update:semver-minor - package-ecosystem: "github-actions" directory: "/" schedule: diff --git a/CHANGELOG.md b/CHANGELOG.md index f9258ed3..d747554d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/). - [#229](https://github.com/ant-druha/intellij-powershell/issues/229): the **PowerShell** run configuration will now save all the files before executing This fixes the cases when the started configuration wasn't using the latest version of an edited script file. +- [#51: Update PowerShellEditorServices](https://github.com/ant-druha/intellij-powershell/issues/51) to v3.18.0 ## [2.5.0] - 2024-03-12 ### Fixed diff --git a/build.gradle.kts b/build.gradle.kts index 1fd1776d..65ea45d7 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -122,14 +122,17 @@ tasks { dest(destination) doLast { + println("Calculating hash for $dependencyName") val data = destination.asFile.readBytes() val hash = MessageDigest.getInstance("SHA-256").let { sha256 -> sha256.update(data) sha256.digest().joinToString("") { "%02x".format(it) } } + println("Expected hash for $dependencyName = $expectedHash") + println("Calculated hash for $dependencyName = $hash") if (!hash.equals(expectedHash, ignoreCase = true)) { destination.asFile.toPath().deleteExisting() - error("$dependencyName hash check failed. Expected $expectedHash, but got $hash\n" + + error("$dependencyName hash check failed.\n" + "The downloaded file has been deleted.\n" + "Please try running the task again, or update the expected hash in the gradle.properties file.") } @@ -189,9 +192,9 @@ tasks { ), downloads.file("PowerShellEditorServices.zip") ) { - include("PowerShellEditorServices/PowerShellEditorServices/**") + include("PowerShellEditorServices/**") eachFile { - relativePath = RelativePath(true, *relativePath.segments.drop(2).toTypedArray()) + relativePath = RelativePath(true, *relativePath.segments.drop(1).toTypedArray()) } } diff --git a/gradle.properties b/gradle.properties index 0f567ef4..a952b0c4 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,10 +1,10 @@ kotlin.stdlib.default.dependency=false -# 20 MiB: -maxUnpackedPluginBytes=20971520 +# 30 MiB: +maxUnpackedPluginBytes=31457280 psScriptAnalyzerVersion=1.21.0 psScriptAnalyzerSha256Hash=66353f139f4f1ffaa532fdeed965e70afbb8400b4810b6b2b91e091119aa6fad -psesVersion=1.10.1 -psesSha256Hash=1c2ec9bbe40142df370497f72a8c33aafa8328462f204b4e1c5986ea7a59a40e +psesVersion=3.18.0 +psesSha256Hash=b5624eeae84e4a23e1ef2b9516d29a9e0df02640470987a9f95757c05faee926 diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 8a5343fe..135d4197 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -5,7 +5,7 @@ junixsocket = "2.9.0" [libraries] junixsocket-common = { module = "com.kohlschutter.junixsocket:junixsocket-common", version.ref = "junixsocket" } junixsocket-native-common = { module = "com.kohlschutter.junixsocket:junixsocket-native-common", version.ref = "junixsocket" } -lsp4j = "org.eclipse.lsp4j:org.eclipse.lsp4j:0.3.1" +lsp4j = "org.eclipse.lsp4j:org.eclipse.lsp4j:0.22.0" junit = "junit:junit:4.13.2" [bundles] diff --git a/src/main/kotlin/com/intellij/plugin/powershell/lang/lsp/ide/EditorEventManager.kt b/src/main/kotlin/com/intellij/plugin/powershell/lang/lsp/ide/EditorEventManager.kt index 50abac90..3e6d039f 100644 --- a/src/main/kotlin/com/intellij/plugin/powershell/lang/lsp/ide/EditorEventManager.kt +++ b/src/main/kotlin/com/intellij/plugin/powershell/lang/lsp/ide/EditorEventManager.kt @@ -49,10 +49,6 @@ class EditorEventManager( editor.putUserData(EDITOR_EVENT_MANAGER_KEY, this) } - fun getEditor(): Editor { - return editor - } - fun getDiagnostics(): List = diagnosticsInfo companion object { @@ -111,7 +107,6 @@ class EditorEventManager( TextDocumentSyncKind.Incremental -> { val newText = event.newFragment val offset = event.offset - val newTextLength = event.newLength val lspPosition: Position = offsetToLSPPos(editor, offset) val startLine = lspPosition.line val startColumn = lspPosition.character @@ -128,7 +123,6 @@ class EditorEventManager( val range = Range(Position(startLine, startColumn), Position(endLine, endColumn)) TextDocumentContentChangeEvent( range, - newTextLength, newText.toString() ) } @@ -138,9 +132,7 @@ class EditorEventManager( } return DidChangeTextDocumentParams( - VersionedTextDocumentIdentifier(incVersion()).apply { - uri = identifier.uri - }, + VersionedTextDocumentIdentifier(identifier.uri, incVersion()), listOf(change) ) } @@ -155,7 +147,7 @@ class EditorEventManager( suspend fun completion(pos: Position): CompletionList { val completions = CompletionList() logger.runAndLogException { - val res = requestManager.completion(TextDocumentPositionParams(identifier, pos)) ?: return completions + val res = requestManager.completion(CompletionParams(identifier, pos)) ?: return completions if (res.isLeft) { completions.items = res.left } else if (res.isRight) { diff --git a/src/main/kotlin/com/intellij/plugin/powershell/lang/lsp/ide/LSPRequestManager.kt b/src/main/kotlin/com/intellij/plugin/powershell/lang/lsp/ide/LSPRequestManager.kt index 98a1b216..fa5073f0 100644 --- a/src/main/kotlin/com/intellij/plugin/powershell/lang/lsp/ide/LSPRequestManager.kt +++ b/src/main/kotlin/com/intellij/plugin/powershell/lang/lsp/ide/LSPRequestManager.kt @@ -45,7 +45,7 @@ class LSPRequestManager( } } - suspend fun completion(params: TextDocumentPositionParams): Either, CompletionList>? { + suspend fun completion(params: CompletionParams): Either, CompletionList>? { if (checkStatus()) { return handleServerError { if (capabilities.completionProvider != null) diff --git a/src/main/kotlin/com/intellij/plugin/powershell/lang/lsp/languagehost/TextDocumentServiceQueue.kt b/src/main/kotlin/com/intellij/plugin/powershell/lang/lsp/languagehost/TextDocumentServiceQueue.kt index 85f96238..764098b3 100644 --- a/src/main/kotlin/com/intellij/plugin/powershell/lang/lsp/languagehost/TextDocumentServiceQueue.kt +++ b/src/main/kotlin/com/intellij/plugin/powershell/lang/lsp/languagehost/TextDocumentServiceQueue.kt @@ -64,7 +64,7 @@ class TextDocumentServiceQueue(private val textDocumentService: () -> TextDocume } } - suspend fun completion(params: TextDocumentPositionParams): Either, CompletionList>? = + suspend fun completion(params: CompletionParams): Either, CompletionList>? = executeTask("completion request", params) { service?.completion(params)?.await() } diff --git a/src/main/kotlin/com/intellij/plugin/powershell/lang/lsp/psi/LSPWrapperPsiElementImpl.kt b/src/main/kotlin/com/intellij/plugin/powershell/lang/lsp/psi/LSPWrapperPsiElementImpl.kt index 050b13bc..8ce5de72 100644 --- a/src/main/kotlin/com/intellij/plugin/powershell/lang/lsp/psi/LSPWrapperPsiElementImpl.kt +++ b/src/main/kotlin/com/intellij/plugin/powershell/lang/lsp/psi/LSPWrapperPsiElementImpl.kt @@ -1,6 +1,7 @@ package com.intellij.plugin.powershell.lang.lsp.psi import com.intellij.navigation.ItemPresentation +import com.intellij.openapi.diagnostic.logger import com.intellij.openapi.util.text.StringUtil import com.intellij.plugin.powershell.ide.search.PowerShellComponentType import com.intellij.plugin.powershell.psi.PowerShellIdentifier @@ -8,6 +9,7 @@ import com.intellij.psi.PsiElement import com.intellij.psi.impl.FakePsiElement import org.eclipse.lsp4j.CompletionItem import org.eclipse.lsp4j.CompletionItemKind +import org.eclipse.lsp4j.MarkupKind import javax.swing.Icon class LSPWrapperPsiElementImpl(private val myName: String, private val myParent: PsiElement, kind: CompletionItemKind?) : FakePsiElement(), LSPWrapperPsiElement { @@ -30,7 +32,18 @@ class LSPWrapperPsiElementImpl(private val myName: String, private val myParent: override fun getCompletionItem(): CompletionItem? = myCompletionItem override fun getDocumentation(): String? { - val doc = myCompletionItem?.documentation + val doc = myCompletionItem?.documentation?.let { + val right = it.right + when { + it.left != null -> it.left + right != null && right.kind == MarkupKind.PLAINTEXT -> right.value + right != null -> { + logger.warn("Received markup kind ${right.kind} instead of ${MarkupKind.PLAINTEXT}.") + right.value + } + else -> null + } + } return if (StringUtil.isEmpty(doc)) myCompletionItem?.detail else doc } @@ -40,11 +53,13 @@ class LSPWrapperPsiElementImpl(private val myName: String, private val myParent: return object : ItemPresentation { override fun getLocationString(): String? = null override fun getIcon(unused: Boolean): Icon = getType().getIcon() - override fun getPresentableText(): String? = name + override fun getPresentableText(): String = name } } - override fun getName(): String? = myName - override fun getParent(): PsiElement? = myParent + override fun getName(): String = myName + override fun getParent(): PsiElement = myParent + +} -} \ No newline at end of file +private val logger = logger()