Skip to content

PowerShellEditorServices v3.18.0 #241

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 6 additions & 3 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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.")
}
Expand Down Expand Up @@ -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())
}
}

Expand Down
8 changes: 4 additions & 4 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,6 @@ class EditorEventManager(
editor.putUserData(EDITOR_EVENT_MANAGER_KEY, this)
}

fun getEditor(): Editor {
return editor
}

fun getDiagnostics(): List<Diagnostic> = diagnosticsInfo

companion object {
Expand Down Expand Up @@ -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
Expand All @@ -128,7 +123,6 @@ class EditorEventManager(
val range = Range(Position(startLine, startColumn), Position(endLine, endColumn))
TextDocumentContentChangeEvent(
range,
newTextLength,
newText.toString()
)
}
Expand All @@ -138,9 +132,7 @@ class EditorEventManager(
}

return DidChangeTextDocumentParams(
VersionedTextDocumentIdentifier(incVersion()).apply {
uri = identifier.uri
},
VersionedTextDocumentIdentifier(identifier.uri, incVersion()),
listOf(change)
)
}
Expand All @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class LSPRequestManager(
}
}

suspend fun completion(params: TextDocumentPositionParams): Either<List<CompletionItem>, CompletionList>? {
suspend fun completion(params: CompletionParams): Either<List<CompletionItem>, CompletionList>? {
if (checkStatus()) {
return handleServerError {
if (capabilities.completionProvider != null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class TextDocumentServiceQueue(private val textDocumentService: () -> TextDocume
}
}

suspend fun completion(params: TextDocumentPositionParams): Either<List<CompletionItem>, CompletionList>? =
suspend fun completion(params: CompletionParams): Either<List<CompletionItem>, CompletionList>? =
executeTask("completion request", params) {
service?.completion(params)?.await()
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
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
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 {
Expand All @@ -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
}

Expand All @@ -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

}

}
private val logger = logger<LSPWrapperPsiElementImpl>()