Skip to content

Commit

Permalink
Build: get rid of the internal API calls
Browse files Browse the repository at this point in the history
  • Loading branch information
ForNeVeR committed Nov 17, 2024
1 parent 778018e commit 5279899
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 27 deletions.
18 changes: 18 additions & 0 deletions src/main/kotlin/com/intellij/plugin/powershell/ide/LoggerEx.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.intellij.plugin.powershell.ide

import com.intellij.openapi.diagnostic.Logger
import kotlin.coroutines.cancellation.CancellationException

/**
* See [IJPL-171743](https://youtrack.jetbrains.com/issue/IJPL-171743) for details: IntelliJ has a similar function, but
* it's marked as internal.
*/
inline fun <T> Logger.runAndLogException(action: () -> T): T? {
try {
return action()
} catch (t: Throwable) {
if (t is CancellationException) throw t
error(t)
return null
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,55 +4,33 @@ import com.intellij.execution.DefaultExecutionResult
import com.intellij.execution.ExecutionException
import com.intellij.execution.ExecutionResult
import com.intellij.execution.Executor
import com.intellij.execution.configurations.GeneralCommandLine
import com.intellij.execution.configurations.PtyCommandLine
import com.intellij.execution.configurations.RunProfileState
import com.intellij.execution.executors.DefaultDebugExecutor
import com.intellij.execution.executors.DefaultRunExecutor
import com.intellij.execution.process.KillableProcessHandler
import com.intellij.execution.process.ProcessHandler
import com.intellij.execution.runners.ExecutionEnvironment
import com.intellij.execution.runners.ProgramRunner
import com.intellij.execution.util.ProgramParametersUtil
import com.intellij.openapi.application.readAction
import com.intellij.openapi.diagnostic.logger
import com.intellij.openapi.diagnostic.runAndLogException
import com.intellij.openapi.options.advanced.AdvancedSettings
import com.intellij.openapi.project.Project
import com.intellij.openapi.roots.ProjectRootManager
import com.intellij.openapi.util.io.NioFiles.toPath
import com.intellij.openapi.util.text.StringUtil
import com.intellij.openapi.vfs.LocalFileSystem
import com.intellij.openapi.vfs.VfsUtil
import com.intellij.plugin.powershell.ide.PluginProjectRoot
import com.intellij.plugin.powershell.ide.debugger.PowerShellBreakpointType
import com.intellij.plugin.powershell.ide.debugger.PowerShellDebugSession
import com.intellij.plugin.powershell.lang.debugger.PSDebugClient
import com.intellij.plugin.powershell.ide.runAndLogException
import com.intellij.plugin.powershell.lang.lsp.LSPInitMain
import com.intellij.plugin.powershell.lang.lsp.languagehost.EditorServicesLanguageHostStarter
import com.intellij.plugin.powershell.lang.lsp.languagehost.PowerShellNotInstalled
import com.intellij.terminal.TerminalExecutionConsole
import com.intellij.util.io.await
import com.intellij.util.text.nullize
import com.intellij.xdebugger.XDebugSession
import com.intellij.xdebugger.XDebuggerManager
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.runBlocking
import kotlinx.coroutines.withContext
import org.eclipse.lsp4j.debug.*
import org.eclipse.lsp4j.debug.launch.DSPLauncher
import org.eclipse.lsp4j.debug.services.IDebugProtocolServer
import org.eclipse.lsp4j.jsonrpc.Launcher
import org.jetbrains.annotations.TestOnly
import java.io.File
import java.io.InputStream
import java.io.OutputStream
import java.nio.charset.Charset
import java.nio.file.Path
import java.util.concurrent.TimeUnit
import java.util.regex.Pattern


class PowerShellScriptCommandLineState(
val runConfiguration: PowerShellRunConfiguration,
private val environment: ExecutionEnvironment
Expand Down Expand Up @@ -134,8 +112,6 @@ class PowerShellScriptCommandLineState(
}
}



private fun getTerminalCharSet(): Charset {
val name = AdvancedSettings.getString("terminal.character.encoding")
return logger.runAndLogException { charset(name) } ?: Charsets.UTF_8
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ package com.intellij.plugin.powershell.lang.lsp.ide
import com.intellij.codeInsight.daemon.DaemonCodeAnalyzer
import com.intellij.openapi.application.ApplicationManager
import com.intellij.openapi.diagnostic.logger
import com.intellij.openapi.diagnostic.runAndLogException
import com.intellij.openapi.editor.Editor
import com.intellij.openapi.editor.event.DocumentEvent
import com.intellij.openapi.project.Project
import com.intellij.openapi.util.Key
import com.intellij.openapi.util.removeUserData
import com.intellij.openapi.util.text.StringUtil
import com.intellij.plugin.powershell.ide.runAndLogException
import com.intellij.plugin.powershell.lang.PowerShellLanguage
import com.intellij.plugin.powershell.lang.lsp.ide.listeners.DocumentListenerImpl
import com.intellij.plugin.powershell.lang.lsp.ide.listeners.EditorMouseListenerImpl
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import com.intellij.ide.actions.ShowSettingsUtilImpl
import com.intellij.notification.*
import com.intellij.openapi.Disposable
import com.intellij.openapi.diagnostic.logger
import com.intellij.openapi.diagnostic.runAndLogException
import com.intellij.openapi.editor.Editor
import com.intellij.openapi.fileEditor.FileDocumentManager
import com.intellij.openapi.project.Project
Expand All @@ -20,6 +19,7 @@ import com.intellij.openapi.vfs.newvfs.events.VFileEvent
import com.intellij.plugin.powershell.PowerShellIcons
import com.intellij.plugin.powershell.ide.MessagesBundle
import com.intellij.plugin.powershell.ide.PluginProjectRoot
import com.intellij.plugin.powershell.ide.runAndLogException
import com.intellij.plugin.powershell.lang.lsp.client.PSLanguageClientImpl
import com.intellij.plugin.powershell.lang.lsp.ide.DEFAULT_DID_CHANGE_CONFIGURATION_PARAMS
import com.intellij.plugin.powershell.lang.lsp.ide.EditorEventManager
Expand Down

0 comments on commit 5279899

Please sign in to comment.