Search in sources :

Example 1 with PathMappingSettings

use of com.intellij.util.PathMappingSettings in project intellij-community by JetBrains.

the class PydevConsoleRunner method getPathMapper.

@Nullable
static PyRemotePathMapper getPathMapper(@NotNull Project project, Sdk sdk, PyConsoleOptions.PyConsoleSettings consoleSettings) {
    if (PySdkUtil.isRemote(sdk)) {
        PythonRemoteInterpreterManager instance = PythonRemoteInterpreterManager.getInstance();
        if (instance != null) {
            //noinspection ConstantConditions
            PyRemotePathMapper remotePathMapper = instance.setupMappings(project, (PyRemoteSdkAdditionalDataBase) sdk.getSdkAdditionalData(), null);
            PathMappingSettings mappingSettings = consoleSettings.getMappingSettings();
            remotePathMapper.addAll(mappingSettings.getPathMappings(), PyRemotePathMapper.PyPathMappingType.USER_DEFINED);
            return remotePathMapper;
        }
    }
    return null;
}
Also used : PyRemotePathMapper(com.jetbrains.python.remote.PyRemotePathMapper) PathMappingSettings(com.intellij.util.PathMappingSettings) PythonRemoteInterpreterManager(com.jetbrains.python.remote.PythonRemoteInterpreterManager) Nullable(org.jetbrains.annotations.Nullable)

Example 2 with PathMappingSettings

use of com.intellij.util.PathMappingSettings in project intellij-community by JetBrains.

the class PathMappingsComponent method setMappingSettings.

public void setMappingSettings(@Nullable final PathMappingSettings mappingSettings) {
    if (mappingSettings == null) {
        myMappingSettings = new PathMappingSettings();
    } else {
        myMappingSettings = mappingSettings;
    }
    setTextRepresentation(myMappingSettings);
    fireStateChanged();
}
Also used : PathMappingSettings(com.intellij.util.PathMappingSettings)

Example 3 with PathMappingSettings

use of com.intellij.util.PathMappingSettings in project intellij-community by JetBrains.

the class PyRemotePathMapperTest method testFromSettings.

@Test
public void testFromSettings() throws Exception {
    PathMappingSettings settings = new PathMappingSettings();
    PyRemotePathMapper emptyMapper = PyRemotePathMapper.fromSettings(settings, PyPathMappingType.USER_DEFINED);
    assertTrue(emptyMapper.isEmpty());
    settings.add(new PathMappingSettings.PathMapping("C:\\local\\folder", "/remote/folder"));
    settings.add(new PathMappingSettings.PathMapping("C:\\local\\folder\\child", "/remote/child-from-local"));
    settings.add(new PathMappingSettings.PathMapping("C:\\local\\child-from-remote", "/remote/folder/child"));
    PyRemotePathMapper mapper = PyRemotePathMapper.fromSettings(settings, PyPathMappingType.HELPERS);
    assertFalse(mapper.isEmpty());
    assertConvertsOneToAnother(mapper, "C:\\local\\folder\\src\\main.py", "/remote/folder/src/main.py");
    assertConvertsOneToAnother(mapper, "C:\\local\\folder\\child\\test\\all.py", "/remote/child-from-local/test/all.py");
    assertConvertsOneToAnother(mapper, "C:/local/child-from-remote/README", "/remote/folder/child/README");
    assertEquals("/unmapped/list.txt", mapper.convertToLocal("/unmapped/list.txt"));
    assertEquals("C:\\unmapped\\list.txt", mapper.convertToRemote("C:\\unmapped\\list.txt"));
}
Also used : PathMappingSettings(com.intellij.util.PathMappingSettings) Test(org.junit.Test)

Aggregations

PathMappingSettings (com.intellij.util.PathMappingSettings)3 PyRemotePathMapper (com.jetbrains.python.remote.PyRemotePathMapper)1 PythonRemoteInterpreterManager (com.jetbrains.python.remote.PythonRemoteInterpreterManager)1 Nullable (org.jetbrains.annotations.Nullable)1 Test (org.junit.Test)1