Skip to content

Commit be0009f

Browse files
committed
(#51) Dependencies: update PSES to v3.18.0
1 parent 1e2b43b commit be0009f

File tree

8 files changed

+36
-25
lines changed

8 files changed

+36
-25
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
99
- [#229](https://github.com/ant-druha/intellij-powershell/issues/229): the **PowerShell** run configuration will now save all the files before executing
1010

1111
This fixes the cases when the started configuration wasn't using the latest version of an edited script file.
12+
- [#51: Update PowerShellEditorServices](https://github.com/ant-druha/intellij-powershell/issues/51) to v3.18.0
1213

1314
## [2.5.0] - 2024-03-12
1415
### Fixed

build.gradle.kts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,14 +122,17 @@ tasks {
122122
dest(destination)
123123

124124
doLast {
125+
println("Calculating hash for $dependencyName")
125126
val data = destination.asFile.readBytes()
126127
val hash = MessageDigest.getInstance("SHA-256").let { sha256 ->
127128
sha256.update(data)
128129
sha256.digest().joinToString("") { "%02x".format(it) }
129130
}
131+
println("Expected hash for $dependencyName = $expectedHash")
132+
println("Calculated hash for $dependencyName = $hash")
130133
if (!hash.equals(expectedHash, ignoreCase = true)) {
131134
destination.asFile.toPath().deleteExisting()
132-
error("$dependencyName hash check failed. Expected $expectedHash, but got $hash\n" +
135+
error("$dependencyName hash check failed.\n" +
133136
"The downloaded file has been deleted.\n" +
134137
"Please try running the task again, or update the expected hash in the gradle.properties file.")
135138
}
@@ -189,9 +192,9 @@ tasks {
189192
),
190193
downloads.file("PowerShellEditorServices.zip")
191194
) {
192-
include("PowerShellEditorServices/PowerShellEditorServices/**")
195+
include("PowerShellEditorServices/**")
193196
eachFile {
194-
relativePath = RelativePath(true, *relativePath.segments.drop(2).toTypedArray())
197+
relativePath = RelativePath(true, *relativePath.segments.drop(1).toTypedArray())
195198
}
196199
}
197200

gradle.properties

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
kotlin.stdlib.default.dependency=false
22

3-
# 20 MiB:
4-
maxUnpackedPluginBytes=20971520
3+
# 30 MiB:
4+
maxUnpackedPluginBytes=31457280
55

66
psScriptAnalyzerVersion=1.21.0
77
psScriptAnalyzerSha256Hash=66353f139f4f1ffaa532fdeed965e70afbb8400b4810b6b2b91e091119aa6fad
88

9-
psesVersion=1.10.1
10-
psesSha256Hash=1c2ec9bbe40142df370497f72a8c33aafa8328462f204b4e1c5986ea7a59a40e
9+
psesVersion=3.18.0
10+
psesSha256Hash=b5624eeae84e4a23e1ef2b9516d29a9e0df02640470987a9f95757c05faee926

gradle/libs.versions.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ junixsocket = "2.9.0"
55
[libraries]
66
junixsocket-common = { module = "com.kohlschutter.junixsocket:junixsocket-common", version.ref = "junixsocket" }
77
junixsocket-native-common = { module = "com.kohlschutter.junixsocket:junixsocket-native-common", version.ref = "junixsocket" }
8-
lsp4j = "org.eclipse.lsp4j:org.eclipse.lsp4j:0.3.1"
8+
lsp4j = "org.eclipse.lsp4j:org.eclipse.lsp4j:0.22.0"
99
junit = "junit:junit:4.13.2"
1010

1111
[bundles]

src/main/kotlin/com/intellij/plugin/powershell/lang/lsp/ide/EditorEventManager.kt

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,6 @@ class EditorEventManager(
4949
editor.putUserData(EDITOR_EVENT_MANAGER_KEY, this)
5050
}
5151

52-
fun getEditor(): Editor {
53-
return editor
54-
}
55-
5652
fun getDiagnostics(): List<Diagnostic> = diagnosticsInfo
5753

5854
companion object {
@@ -111,7 +107,6 @@ class EditorEventManager(
111107
TextDocumentSyncKind.Incremental -> {
112108
val newText = event.newFragment
113109
val offset = event.offset
114-
val newTextLength = event.newLength
115110
val lspPosition: Position = offsetToLSPPos(editor, offset)
116111
val startLine = lspPosition.line
117112
val startColumn = lspPosition.character
@@ -128,7 +123,6 @@ class EditorEventManager(
128123
val range = Range(Position(startLine, startColumn), Position(endLine, endColumn))
129124
TextDocumentContentChangeEvent(
130125
range,
131-
newTextLength,
132126
newText.toString()
133127
)
134128
}
@@ -138,9 +132,7 @@ class EditorEventManager(
138132
}
139133

140134
return DidChangeTextDocumentParams(
141-
VersionedTextDocumentIdentifier(incVersion()).apply {
142-
uri = identifier.uri
143-
},
135+
VersionedTextDocumentIdentifier(identifier.uri, incVersion()),
144136
listOf(change)
145137
)
146138
}
@@ -155,7 +147,7 @@ class EditorEventManager(
155147
suspend fun completion(pos: Position): CompletionList {
156148
val completions = CompletionList()
157149
logger.runAndLogException {
158-
val res = requestManager.completion(TextDocumentPositionParams(identifier, pos)) ?: return completions
150+
val res = requestManager.completion(CompletionParams(identifier, pos)) ?: return completions
159151
if (res.isLeft) {
160152
completions.items = res.left
161153
} else if (res.isRight) {

src/main/kotlin/com/intellij/plugin/powershell/lang/lsp/ide/LSPRequestManager.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ class LSPRequestManager(
4545
}
4646
}
4747

48-
suspend fun completion(params: TextDocumentPositionParams): Either<List<CompletionItem>, CompletionList>? {
48+
suspend fun completion(params: CompletionParams): Either<List<CompletionItem>, CompletionList>? {
4949
if (checkStatus()) {
5050
return handleServerError {
5151
if (capabilities.completionProvider != null)

src/main/kotlin/com/intellij/plugin/powershell/lang/lsp/languagehost/TextDocumentServiceQueue.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ class TextDocumentServiceQueue(private val textDocumentService: () -> TextDocume
6464
}
6565
}
6666

67-
suspend fun completion(params: TextDocumentPositionParams): Either<List<CompletionItem>, CompletionList>? =
67+
suspend fun completion(params: CompletionParams): Either<List<CompletionItem>, CompletionList>? =
6868
executeTask("completion request", params) {
6969
service?.completion(params)?.await()
7070
}

src/main/kotlin/com/intellij/plugin/powershell/lang/lsp/psi/LSPWrapperPsiElementImpl.kt

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
package com.intellij.plugin.powershell.lang.lsp.psi
22

33
import com.intellij.navigation.ItemPresentation
4+
import com.intellij.openapi.diagnostic.logger
45
import com.intellij.openapi.util.text.StringUtil
56
import com.intellij.plugin.powershell.ide.search.PowerShellComponentType
67
import com.intellij.plugin.powershell.psi.PowerShellIdentifier
78
import com.intellij.psi.PsiElement
89
import com.intellij.psi.impl.FakePsiElement
910
import org.eclipse.lsp4j.CompletionItem
1011
import org.eclipse.lsp4j.CompletionItemKind
12+
import org.eclipse.lsp4j.MarkupKind
1113
import javax.swing.Icon
1214

1315
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:
3032
override fun getCompletionItem(): CompletionItem? = myCompletionItem
3133

3234
override fun getDocumentation(): String? {
33-
val doc = myCompletionItem?.documentation
35+
val doc = myCompletionItem?.documentation?.let {
36+
val right = it.right
37+
when {
38+
it.left != null -> it.left
39+
right != null && right.kind == MarkupKind.PLAINTEXT -> right.value
40+
right != null -> {
41+
logger.warn("Received markup kind ${right.kind} instead of ${MarkupKind.PLAINTEXT}.")
42+
right.value
43+
}
44+
else -> null
45+
}
46+
}
3447
return if (StringUtil.isEmpty(doc)) myCompletionItem?.detail else doc
3548
}
3649

@@ -40,11 +53,13 @@ class LSPWrapperPsiElementImpl(private val myName: String, private val myParent:
4053
return object : ItemPresentation {
4154
override fun getLocationString(): String? = null
4255
override fun getIcon(unused: Boolean): Icon = getType().getIcon()
43-
override fun getPresentableText(): String? = name
56+
override fun getPresentableText(): String = name
4457
}
4558
}
4659

47-
override fun getName(): String? = myName
48-
override fun getParent(): PsiElement? = myParent
60+
override fun getName(): String = myName
61+
override fun getParent(): PsiElement = myParent
62+
63+
}
4964

50-
}
65+
private val logger = logger<LSPWrapperPsiElementImpl>()

0 commit comments

Comments
 (0)