mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
PY-55349 Fix find local paths for target remote files
GitOrigin-RevId: 2b33e4233f353ed0f324362473273527de4ce707
This commit is contained in:
committed by
intellij-monorepo-bot
parent
68947cc4dc
commit
49b4e3d63e
@@ -11,6 +11,7 @@ import com.intellij.util.AbstractPathMapper
|
||||
import com.intellij.util.PathMappingSettings
|
||||
import com.jetbrains.python.debugger.remote.vfs.PyRemotePositionConverter
|
||||
import com.jetbrains.python.remote.PyRemotePathMapper
|
||||
import org.jetbrains.annotations.ApiStatus
|
||||
|
||||
/**
|
||||
* Creates [PyPositionConverter] for [debugProcess]. The converter uses [pathMappingSettings] for paths resolution and upload volumes
|
||||
@@ -29,14 +30,13 @@ import com.jetbrains.python.remote.PyRemotePathMapper
|
||||
* @see getTargetPaths
|
||||
*/
|
||||
internal fun createTargetedPositionConverter(debugProcess: PyDebugProcess,
|
||||
targetEnvironment: TargetEnvironment,
|
||||
pathMappingSettings: PathMappingSettings): PyPositionConverter {
|
||||
val pathMapper = PyTargetPathMapper(targetEnvironment, pathMappingSettings)
|
||||
pathMapper: PyTargetPathMapper): PyPositionConverter {
|
||||
return PyRemotePositionConverter(debugProcess, pathMapper)
|
||||
}
|
||||
|
||||
private class PyTargetPathMapper(private val targetEnvironment: TargetEnvironment,
|
||||
private val pathMappingSettings: PathMappingSettings) : PyRemotePathMapper() {
|
||||
@ApiStatus.Internal
|
||||
internal class PyTargetPathMapper(private val targetEnvironment: TargetEnvironment,
|
||||
private val pathMappingSettings: PathMappingSettings) : PyRemotePathMapper() {
|
||||
override fun convertToLocal(remotePath: String): String {
|
||||
return AbstractPathMapper.convertToLocal(remotePath, pathMappingSettings.pathMappings)
|
||||
?: targetEnvironment.getLocalPaths(remotePath).firstOrNull()
|
||||
@@ -52,4 +52,6 @@ private class PyTargetPathMapper(private val targetEnvironment: TargetEnvironmen
|
||||
override fun isEmpty(): Boolean {
|
||||
return false
|
||||
}
|
||||
|
||||
fun getFileMappings(): MutableList<PathMappingSettings.PathMapping> = pathMappingSettings.pathMappings
|
||||
}
|
||||
@@ -2,20 +2,21 @@
|
||||
package com.jetbrains.python.run
|
||||
|
||||
import com.intellij.execution.process.KillableColoredProcessHandler
|
||||
import com.intellij.execution.target.TargetEnvironment
|
||||
import com.intellij.remote.ProcessControlWithMappings
|
||||
import com.intellij.util.PathMapper
|
||||
import com.intellij.util.PathMappingSettings
|
||||
import com.jetbrains.python.debugger.PositionConverterProvider
|
||||
import com.jetbrains.python.debugger.PyDebugProcess
|
||||
import com.jetbrains.python.debugger.PyPositionConverter
|
||||
import com.jetbrains.python.debugger.createTargetedPositionConverter
|
||||
import com.jetbrains.python.debugger.*
|
||||
import java.nio.charset.Charset
|
||||
|
||||
internal class ProcessHandlerWithPyPositionConverter(process: Process,
|
||||
commandLine: String,
|
||||
charset: Charset,
|
||||
private val targetEnvironment: TargetEnvironment,
|
||||
private val pathMappingSettings: PathMappingSettings)
|
||||
: KillableColoredProcessHandler(process, commandLine, charset), PositionConverterProvider {
|
||||
private val pathMapper: PyTargetPathMapper)
|
||||
: KillableColoredProcessHandler(process, commandLine, charset), PositionConverterProvider, ProcessControlWithMappings {
|
||||
override fun createPositionConverter(debugProcess: PyDebugProcess): PyPositionConverter =
|
||||
createTargetedPositionConverter(debugProcess, targetEnvironment, pathMappingSettings)
|
||||
createTargetedPositionConverter(debugProcess, pathMapper)
|
||||
|
||||
override fun getMappingSettings(): PathMapper = pathMapper
|
||||
|
||||
override fun getFileMappings(): MutableList<PathMappingSettings.PathMapping> = pathMapper.getFileMappings()
|
||||
}
|
||||
@@ -57,6 +57,7 @@ import com.jetbrains.python.PythonHelpersLocator;
|
||||
import com.jetbrains.python.console.PyDebugConsoleBuilder;
|
||||
import com.jetbrains.python.debugger.PyDebugRunner;
|
||||
import com.jetbrains.python.debugger.PyDebuggerOptionsProvider;
|
||||
import com.jetbrains.python.debugger.PyTargetPathMapper;
|
||||
import com.jetbrains.python.facet.LibraryContributingFacet;
|
||||
import com.jetbrains.python.facet.PythonPathContributingFacet;
|
||||
import com.jetbrains.python.library.PythonLibraryType;
|
||||
@@ -484,18 +485,19 @@ public abstract class PythonCommandLineState extends CommandLineState {
|
||||
}
|
||||
return new PythonProcessHandler(process, commandLineString, commandLine.getCharset());
|
||||
}
|
||||
PathMappingSettings consolidatedPathMappings = new PathMappingSettings();
|
||||
PathMappingSettings pathMappingSettings = new PathMappingSettings();
|
||||
// add mappings from run configuration on top
|
||||
PathMappingSettings runConfigurationPathMappings = myConfig.myMappingSettings;
|
||||
if (runConfigurationPathMappings != null) {
|
||||
consolidatedPathMappings.addAll(runConfigurationPathMappings);
|
||||
pathMappingSettings.addAll(runConfigurationPathMappings);
|
||||
}
|
||||
// add path mappings configured in SDK, they will be handled in second place
|
||||
PathMappingSettings sdkPathMappings = getSdkPathMappings();
|
||||
if (sdkPathMappings != null) {
|
||||
consolidatedPathMappings.addAll(sdkPathMappings);
|
||||
pathMappingSettings.addAll(sdkPathMappings);
|
||||
}
|
||||
return new ProcessHandlerWithPyPositionConverter(process, commandLineString, commandLine.getCharset(), targetEnvironment,
|
||||
PyTargetPathMapper consolidatedPathMappings = new PyTargetPathMapper(targetEnvironment, pathMappingSettings);
|
||||
return new ProcessHandlerWithPyPositionConverter(process, commandLineString, commandLine.getCharset(),
|
||||
consolidatedPathMappings);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user