diff --git a/components/ide/jetbrains/backend-plugin/gradle-latest.properties b/components/ide/jetbrains/backend-plugin/gradle-latest.properties index f1e494134b3a3b..a5543ab38f977b 100644 --- a/components/ide/jetbrains/backend-plugin/gradle-latest.properties +++ b/components/ide/jetbrains/backend-plugin/gradle-latest.properties @@ -1,9 +1,9 @@ # See https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html # for insight into build numbers and IntelliJ Platform versions. -pluginSinceBuild=223 +pluginSinceBuild=223.7126 pluginUntilBuild=223.* # Plugin Verifier integration -> https://github.com/JetBrains/gradle-intellij-plugin#plugin-verifier-dsl # See https://jb.gg/intellij-platform-builds-list for available build versions. pluginVerifierIdeVersions=2022.3 # Version from "com.jetbrains.intellij.idea" which can be found at https://www.jetbrains.com/intellij-repository/snapshots -platformVersion=223.6160-EAP-CANDIDATE-SNAPSHOT +platformVersion=223.7126-EAP-CANDIDATE-SNAPSHOT diff --git a/components/ide/jetbrains/backend-plugin/gradle-stable.properties b/components/ide/jetbrains/backend-plugin/gradle-stable.properties index edaf7bd46684b5..fe02fbce20b968 100644 --- a/components/ide/jetbrains/backend-plugin/gradle-stable.properties +++ b/components/ide/jetbrains/backend-plugin/gradle-stable.properties @@ -1,9 +1,9 @@ # See https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html # for insight into build numbers and IntelliJ Platform versions. -pluginSinceBuild=222 +pluginSinceBuild=222.4345 pluginUntilBuild=222.* # Plugin Verifier integration -> https://github.com/JetBrains/gradle-intellij-plugin#plugin-verifier-dsl # See https://jb.gg/intellij-platform-builds-list for available build versions. pluginVerifierIdeVersions=2022.2 # Version from "com.jetbrains.intellij.idea" which can be found at https://www.jetbrains.com/intellij-repository/snapshots -platformVersion=222.3345-EAP-CANDIDATE-SNAPSHOT +platformVersion=222.4345-EAP-CANDIDATE-SNAPSHOT diff --git a/components/ide/jetbrains/backend-plugin/launch-dev-server.sh b/components/ide/jetbrains/backend-plugin/launch-dev-server.sh index 503b7ebe980301..27289d7c9ce8f1 100755 --- a/components/ide/jetbrains/backend-plugin/launch-dev-server.sh +++ b/components/ide/jetbrains/backend-plugin/launch-dev-server.sh @@ -28,8 +28,8 @@ TEST_BACKEND_DIR="/workspace/ide-backend-$JB_QUALIFIER" if [ ! -d "$TEST_BACKEND_DIR" ]; then mkdir -p $TEST_BACKEND_DIR if [[ $RUN_FROM == "snapshot" ]]; then + SNAPSHOT_VERSION=$(grep "platformVersion=" "gradle-$JB_QUALIFIER.properties" | sed 's/platformVersion=//') (cd $TEST_BACKEND_DIR && - SNAPSHOT_VERSION=$(grep "platformVersion=" "gradle-$JB_QUALIFIER.properties" | sed 's/platformVersion=//') && echo "Downloading the $JB_QUALIFIER version of IntelliJ IDEA ($SNAPSHOT_VERSION)..." && curl -sSLo backend.zip "https://www.jetbrains.com/intellij-repository/snapshots/com/jetbrains/intellij/idea/ideaIU/$SNAPSHOT_VERSION/ideaIU-$SNAPSHOT_VERSION.zip" && unzip backend.zip && @@ -37,8 +37,8 @@ if [ ! -d "$TEST_BACKEND_DIR" ]; then ln -s "ideaIU-$SNAPSHOT_VERSION" . && rm -r "ideaIU-$SNAPSHOT_VERSION" && cp -r /ide-desktop/backend/jbr . && - cp /ide-desktop/backend/bin/idea.properties ./bin && - cp /ide-desktop/backend/bin/idea64.vmoptions ./bin) + cp ./bin/linux/idea.properties ./bin && + cp ./bin/linux/idea64.vmoptions ./bin) else if [[ $JB_QUALIFIER == "stable" ]]; then PRODUCT_TYPE="release" diff --git a/components/ide/jetbrains/backend-plugin/src/main/kotlin/io/gitpod/jetbrains/remote/GitpodCLIHelper.kt b/components/ide/jetbrains/backend-plugin/src/main/kotlin/io/gitpod/jetbrains/remote/GitpodCLIHelper.kt new file mode 100644 index 00000000000000..b5276a58e9fedf --- /dev/null +++ b/components/ide/jetbrains/backend-plugin/src/main/kotlin/io/gitpod/jetbrains/remote/GitpodCLIHelper.kt @@ -0,0 +1,11 @@ +// Copyright (c) 2022 Gitpod GmbH. All rights reserved. +// Licensed under the GNU Affero General Public License (AGPL). +// See License-AGPL.txt in the project root for license information. + +package io.gitpod.jetbrains.remote + +import java.nio.file.Path + +interface GitpodCLIHelper { + suspend fun open(file: Path, shouldWait: Boolean) +} diff --git a/components/ide/jetbrains/backend-plugin/src/main/kotlin/io/gitpod/jetbrains/remote/GitpodCLIService.kt b/components/ide/jetbrains/backend-plugin/src/main/kotlin/io/gitpod/jetbrains/remote/GitpodCLIService.kt index 29060c622d25e2..4ef140fad789af 100644 --- a/components/ide/jetbrains/backend-plugin/src/main/kotlin/io/gitpod/jetbrains/remote/GitpodCLIService.kt +++ b/components/ide/jetbrains/backend-plugin/src/main/kotlin/io/gitpod/jetbrains/remote/GitpodCLIService.kt @@ -6,7 +6,6 @@ package io.gitpod.jetbrains.remote import com.intellij.codeWithMe.ClientId import com.intellij.ide.BrowserUtil -import com.intellij.ide.CommandLineProcessor import com.intellij.openapi.application.ApplicationManager import com.intellij.openapi.client.ClientSession import com.intellij.openapi.client.ClientSessionsManager @@ -40,6 +39,7 @@ class GitpodCLIService : RestService() { private val manager = service() private val portsService = service() + private val cliHelperService = service() override fun getServiceName() = SERVICE_NAME @@ -71,7 +71,7 @@ class GitpodCLIService : RestService() { return withClient(request, context) { GlobalScope.launch { withContext(Dispatchers.IO) { - CommandLineProcessor.doOpenFileOrProject(file, shouldWait).future.get() + cliHelperService.open(file, shouldWait) } } } diff --git a/components/ide/jetbrains/backend-plugin/src/main/kotlin/io/gitpod/jetbrains/remote/GitpodClientProjectSessionTracker.kt b/components/ide/jetbrains/backend-plugin/src/main/kotlin/io/gitpod/jetbrains/remote/GitpodClientProjectSessionTracker.kt index 895e0f508993eb..fcc30403cff8f3 100644 --- a/components/ide/jetbrains/backend-plugin/src/main/kotlin/io/gitpod/jetbrains/remote/GitpodClientProjectSessionTracker.kt +++ b/components/ide/jetbrains/backend-plugin/src/main/kotlin/io/gitpod/jetbrains/remote/GitpodClientProjectSessionTracker.kt @@ -9,12 +9,13 @@ import com.intellij.ide.BrowserUtil import com.intellij.notification.NotificationAction import com.intellij.notification.NotificationType import com.intellij.openapi.Disposable -import com.intellij.openapi.client.ClientProjectSession +import com.intellij.openapi.client.ClientSessionsManager import com.intellij.openapi.components.service import com.intellij.openapi.diagnostic.thisLogger import com.intellij.openapi.fileEditor.FileEditorManagerEvent import com.intellij.openapi.fileEditor.FileEditorManagerListener import com.intellij.openapi.fileTypes.LanguageFileType +import com.intellij.openapi.project.Project import com.intellij.remoteDev.util.onTerminationOrNow import com.intellij.util.application import com.jetbrains.rd.util.lifetime.Lifetime @@ -32,12 +33,11 @@ import java.util.concurrent.CancellationException import java.util.concurrent.CompletableFuture @Suppress("UnstableApiUsage", "OPT_IN_USAGE") -class GitpodClientProjectSessionTracker( - private val session: ClientProjectSession -) : Disposable { +class GitpodClientProjectSessionTracker(private val project: Project) : Disposable { private val manager = service() private val portsService = service() + private val session = ClientSessionsManager.getProjectSession(project) private lateinit var info: Info.WorkspaceInfoResponse private val lifetime = Lifetime.Eternal.createNested() @@ -89,7 +89,7 @@ class GitpodClientProjectSessionTracker( notification.addAction(makePublicAction) } - ClientId.withClientId(session.clientId) { + ClientId.withClientId(session?.clientId) { notification.notify(null) } } @@ -108,7 +108,7 @@ class GitpodClientProjectSessionTracker( } private fun openBrowser(url: String) { - ClientId.withClientId(session.clientId) { + ClientId.withClientId(session?.clientId) { BrowserUtil.browse(url) } } @@ -196,7 +196,7 @@ class GitpodClientProjectSessionTracker( private fun registerActiveLanguageAnalytics() { val activeLanguages = mutableSetOf() - session.project.messageBus.connect().subscribe(FileEditorManagerListener.FILE_EDITOR_MANAGER, object : FileEditorManagerListener { + project.messageBus.connect().subscribe(FileEditorManagerListener.FILE_EDITOR_MANAGER, object : FileEditorManagerListener { override fun selectionChanged(event: FileEditorManagerEvent) { super.selectionChanged(event) if (event.manager.selectedEditor == null) { @@ -219,6 +219,7 @@ class GitpodClientProjectSessionTracker( } private fun trackEvent(eventName: String, props: Map) { + if (session == null) return manager.trackEvent(eventName, mapOf( "sessionId" to session.clientId.value ).plus(props)) diff --git a/components/ide/jetbrains/backend-plugin/src/main/kotlin/io/gitpod/jetbrains/remote/GitpodGlobalPortForwardingService.kt b/components/ide/jetbrains/backend-plugin/src/main/kotlin/io/gitpod/jetbrains/remote/GitpodGlobalPortForwardingService.kt new file mode 100644 index 00000000000000..2bc976bdd2b4de --- /dev/null +++ b/components/ide/jetbrains/backend-plugin/src/main/kotlin/io/gitpod/jetbrains/remote/GitpodGlobalPortForwardingService.kt @@ -0,0 +1,11 @@ +// Copyright (c) 2022 Gitpod GmbH. All rights reserved. +// Licensed under the GNU Affero General Public License (AGPL). +// See License-AGPL.txt in the project root for license information. + +package io.gitpod.jetbrains.remote + +import com.intellij.openapi.Disposable + +interface GitpodGlobalPortForwardingService { + fun monitorPortsOfPid(disposable: Disposable, pid: Long) +} diff --git a/components/ide/jetbrains/backend-plugin/src/main/kotlin/io/gitpod/jetbrains/remote/GitpodTerminalService.kt b/components/ide/jetbrains/backend-plugin/src/main/kotlin/io/gitpod/jetbrains/remote/GitpodTerminalService.kt index db39cff08db436..75436cdb495fe9 100644 --- a/components/ide/jetbrains/backend-plugin/src/main/kotlin/io/gitpod/jetbrains/remote/GitpodTerminalService.kt +++ b/components/ide/jetbrains/backend-plugin/src/main/kotlin/io/gitpod/jetbrains/remote/GitpodTerminalService.kt @@ -4,8 +4,9 @@ package io.gitpod.jetbrains.remote -import com.intellij.openapi.client.ClientProjectSession +// import com.intellij.openapi.components.service import com.intellij.openapi.diagnostic.thisLogger +import com.intellij.openapi.project.Project import com.intellij.util.application import com.jediterm.terminal.ui.TerminalWidget import com.jediterm.terminal.ui.TerminalWidgetListener @@ -24,17 +25,17 @@ import java.util.concurrent.CompletableFuture import java.util.concurrent.ExecutionException import java.util.concurrent.TimeUnit -@Suppress("UnstableApiUsage") -class GitpodTerminalService(session: ClientProjectSession) { +class GitpodTerminalService(project: Project) { private companion object { var hasStarted = false } - private val terminalView = TerminalView.getInstance(session.project) - private val backendTerminalManager = BackendTerminalManager.getInstance(session.project) + private val terminalView = TerminalView.getInstance(project) + private val backendTerminalManager = BackendTerminalManager.getInstance(project) private val terminalServiceFutureStub = TerminalServiceGrpc.newFutureStub(GitpodManager.supervisorChannel) private val terminalServiceStub = TerminalServiceGrpc.newStub(GitpodManager.supervisorChannel) private val statusServiceStub = StatusServiceGrpc.newStub(GitpodManager.supervisorChannel) + // private val portForwardingService = service() init { start() @@ -186,6 +187,10 @@ class GitpodTerminalService(session: ClientProjectSession) { exitTaskWhenTerminalWidgetGetsClosed(supervisorTerminal, shellTerminalWidget) listenForTaskTerminationAndTitleChanges(supervisorTerminal, shellTerminalWidget) + + // This works for auto-forwarding ports opened in Gitpod Terminals, but it's currently not useful as we + // have the GitpodPortForwardingService already auto-forwarding all the ports from the workspace. + // portForwardingService.monitorPortsOfPid(shellTerminalWidget, supervisorTerminal.pid) } private fun listenForTaskTerminationAndTitleChanges( diff --git a/components/ide/jetbrains/backend-plugin/src/main/kotlin/io/gitpod/jetbrains/remote/latest/GitpodCLIHelperImpl.kt b/components/ide/jetbrains/backend-plugin/src/main/kotlin/io/gitpod/jetbrains/remote/latest/GitpodCLIHelperImpl.kt new file mode 100644 index 00000000000000..d389f1fe26258a --- /dev/null +++ b/components/ide/jetbrains/backend-plugin/src/main/kotlin/io/gitpod/jetbrains/remote/latest/GitpodCLIHelperImpl.kt @@ -0,0 +1,16 @@ +// Copyright (c) 2022 Gitpod GmbH. All rights reserved. +// Licensed under the GNU Affero General Public License (AGPL). +// See License-AGPL.txt in the project root for license information. + +package io.gitpod.jetbrains.remote.latest + +import com.intellij.ide.CommandLineProcessor +import io.gitpod.jetbrains.remote.GitpodCLIHelper +import java.nio.file.Path + +@Suppress("UnstableApiUsage") +class GitpodCLIHelperImpl : GitpodCLIHelper { + override suspend fun open(file :Path, shouldWait: Boolean) { + CommandLineProcessor.doOpenFileOrProject(file, shouldWait).future.await() + } +} diff --git a/components/ide/jetbrains/backend-plugin/src/main/kotlin/io/gitpod/jetbrains/remote/latest/GitpodGlobalPortForwardingServiceImpl.kt b/components/ide/jetbrains/backend-plugin/src/main/kotlin/io/gitpod/jetbrains/remote/latest/GitpodGlobalPortForwardingServiceImpl.kt new file mode 100644 index 00000000000000..e4c15a0533247c --- /dev/null +++ b/components/ide/jetbrains/backend-plugin/src/main/kotlin/io/gitpod/jetbrains/remote/latest/GitpodGlobalPortForwardingServiceImpl.kt @@ -0,0 +1,48 @@ +// Copyright (c) 2022 Gitpod GmbH. All rights reserved. +// Licensed under the GNU Affero General Public License (AGPL). +// See License-AGPL.txt in the project root for license information. + +package io.gitpod.jetbrains.remote.latest + +import com.intellij.openapi.Disposable +import com.intellij.openapi.components.service +import com.intellij.openapi.diagnostic.thisLogger +import com.intellij.openapi.project.Project +import com.intellij.openapi.util.Disposer +import com.intellij.remoteDev.util.onTerminationOrNow +import com.intellij.ui.RowIcon +import com.intellij.util.application +import com.jetbrains.rd.platform.codeWithMe.portForwarding.* +import com.jetbrains.rd.platform.util.lifetime +import com.jetbrains.rd.util.lifetime.LifetimeStatus +import io.gitpod.jetbrains.remote.GitpodIgnoredPortsForNotificationService +import io.gitpod.jetbrains.remote.GitpodManager +import io.gitpod.jetbrains.remote.GitpodGlobalPortForwardingService +import io.gitpod.jetbrains.remote.GitpodPortsService +import io.gitpod.jetbrains.remote.icons.GitpodIcons +import io.gitpod.supervisor.api.Status +import io.gitpod.supervisor.api.StatusServiceGrpc +import io.grpc.stub.ClientCallStreamObserver +import io.grpc.stub.ClientResponseObserver +import io.ktor.utils.io.* +import java.util.concurrent.CompletableFuture +import java.util.concurrent.TimeUnit +import javax.swing.Icon + +@Suppress("UnstableApiUsage") +class GitpodGlobalPortForwardingServiceImpl: GitpodGlobalPortForwardingService { + private val globalPortForwardingManager = service() + + override fun monitorPortsOfPid(disposable: Disposable, pid: Long) { + globalPortForwardingManager.monitorPortsOfPid( + disposable, + pid, + object : ListeningPortHandler { + override fun onPortListeningStarted(port: ListeningPort) { + thisLogger().warn("gitpod: onPortListeningStarted ${port.portType} ${port.pid} ${port.socketAddress}") + } + }, + PortListeningOptions.INCLUDE_SELF_AND_CHILDREN + ) + } +} diff --git a/components/ide/jetbrains/backend-plugin/src/main/kotlin/io/gitpod/jetbrains/remote/latest/GitpodPortForwardingService.kt b/components/ide/jetbrains/backend-plugin/src/main/kotlin/io/gitpod/jetbrains/remote/latest/GitpodPortForwardingService.kt index 81bb510d2bdde2..9c536ab074a26a 100644 --- a/components/ide/jetbrains/backend-plugin/src/main/kotlin/io/gitpod/jetbrains/remote/latest/GitpodPortForwardingService.kt +++ b/components/ide/jetbrains/backend-plugin/src/main/kotlin/io/gitpod/jetbrains/remote/latest/GitpodPortForwardingService.kt @@ -5,11 +5,12 @@ package io.gitpod.jetbrains.remote.latest import com.intellij.openapi.Disposable -import com.intellij.openapi.client.ClientProjectSession import com.intellij.openapi.components.service import com.intellij.openapi.diagnostic.thisLogger +import com.intellij.openapi.project.Project import com.intellij.openapi.util.Disposer import com.intellij.remoteDev.util.onTerminationOrNow +//import com.intellij.ui.RowIcon import com.intellij.util.application import com.jetbrains.rd.platform.codeWithMe.portForwarding.* import com.jetbrains.rd.platform.util.lifetime @@ -17,6 +18,7 @@ import com.jetbrains.rd.util.lifetime.LifetimeStatus import io.gitpod.jetbrains.remote.GitpodIgnoredPortsForNotificationService import io.gitpod.jetbrains.remote.GitpodManager import io.gitpod.jetbrains.remote.GitpodPortsService +//import io.gitpod.jetbrains.remote.icons.GitpodIcons import io.gitpod.supervisor.api.Status import io.gitpod.supervisor.api.StatusServiceGrpc import io.grpc.stub.ClientCallStreamObserver @@ -27,7 +29,7 @@ import java.util.concurrent.TimeUnit import javax.swing.Icon @Suppress("UnstableApiUsage") -class GitpodPortForwardingService(private val session: ClientProjectSession) { +class GitpodPortForwardingService(private val project: Project) { companion object { const val FORWARDED_PORT_LABEL = "gitpod" } @@ -46,7 +48,7 @@ class GitpodPortForwardingService(private val session: ClientProjectSession) { } private fun observePortsListWhileProjectIsOpen() = application.executeOnPooledThread { - while (session.project.lifetime.status == LifetimeStatus.Alive) { + while (project.lifetime.status == LifetimeStatus.Alive) { try { observePortsList().get() } catch (throwable: Throwable) { @@ -74,7 +76,7 @@ class GitpodPortForwardingService(private val session: ClientProjectSession) { val portsStatusResponseObserver = object : ClientResponseObserver { override fun beforeStart(request: ClientCallStreamObserver) { - session.project.lifetime.onTerminationOrNow { request.cancel("gitpod: Project terminated.", null) } + project.lifetime.onTerminationOrNow { request.cancel("gitpod: Project terminated.", null) } } override fun onNext(response: Status.PortsStatusResponse) { application.invokeLater { updateForwardedPortsList(response) } @@ -104,42 +106,48 @@ class GitpodPortForwardingService(private val session: ClientProjectSession) { hostPort, PortType.TCP, setOf(FORWARDED_PORT_LABEL), - hostPort, - ClientPortPickingStrategy.REASSIGN_WHEN_BUSY - ) { - this.name = port.name - this.description = port.description - this.icon = null - this.tooltip = "Forwarded Port" - } + ClientPortAttributes(hostPort, ClientPortPickingStrategy.REASSIGN_WHEN_BUSY), + ) + + forwardedPort.presentation.name = port.name + forwardedPort.presentation.description = port.description +// forwardedPort.presentation.tooltip = "Forwarded Port" +// val rowIcon = RowIcon(2) +// rowIcon.setIcon(GitpodIcons.Logo, 0) +// rowIcon.setIcon(GitpodIcons.Logo, 1) +// forwardedPort.presentation.icon = rowIcon val portListenerDisposable = portToDisposableMap.getOrPut(hostPort, fun() = Disposer.newDisposable()) forwardedPort.addPortListener(portListenerDisposable, object: ForwardedPortListener { - override fun becameReadOnly(port: ForwardedPort, reason: String?) { - thisLogger().warn("gitpod: becameReadOnly($port, $reason)") - } - - override fun descriptionChanged(port: ForwardedPort, oldDescription: String?, newDescription: String?) { - thisLogger().warn("gitpod: descriptionChanged($port, $oldDescription, $newDescription)") - } - - override fun exposedUrlChanged(port: ForwardedPort, newUrl: String) { - thisLogger().warn("gitpod: exposedUrlChanged($port, $newUrl)") - } - - override fun iconChanged(port: ForwardedPort, oldIcon: Icon?, newIcon: Icon?) { - thisLogger().warn("gitpod: iconChanged($port, $oldIcon, $newIcon)") - } - - override fun nameChanged(port: ForwardedPort, oldName: String?, newName: String?) { - thisLogger().warn("gitpod: nameChanged($port, $oldName, $newName)") - } +// override fun becameReadOnly(port: ForwardedPort, reason: String?) { +// thisLogger().warn("gitpod: becameReadOnly($port, $reason)") +// } +// +// override fun descriptionChanged(port: ForwardedPort, oldDescription: String?, newDescription: String?) { +// thisLogger().warn("gitpod: descriptionChanged($port, $oldDescription, $newDescription)") +// } +// +// override fun exposedUrlChanged(port: ForwardedPort, newUrl: String) { +// thisLogger().warn("gitpod: exposedUrlChanged($port, $newUrl)") +// } +// +// override fun iconChanged(port: ForwardedPort, oldIcon: Icon?, newIcon: Icon?) { +// thisLogger().warn("gitpod: iconChanged($port, $oldIcon, $newIcon)") +// } +// +// override fun nameChanged(port: ForwardedPort, oldName: String?, newName: String?) { +// thisLogger().warn("gitpod: nameChanged($port, $oldName, $newName)") +// } +// +// override fun tooltipChanged(port: ForwardedPort, oldTooltip: String?, newTooltip: String?) { +// thisLogger().warn("gitpod: tooltipChanged($port, $oldTooltip, $newTooltip)") +// } override fun stateChanged(port: ForwardedPort, newState: ClientPortState) { when (newState) { is ClientPortState.Assigned -> { - thisLogger().warn("gitpod: Started forwarding host port $hostPort to client port ${newState.clientPort}.") + thisLogger().info("gitpod: Started forwarding host port $hostPort to client port ${newState.clientPort}.") portsService.setForwardedPort(hostPort, newState.clientPort) } is ClientPortState.FailedToAssign -> { @@ -150,10 +158,6 @@ class GitpodPortForwardingService(private val session: ClientProjectSession) { } } } - - override fun tooltipChanged(port: ForwardedPort, oldTooltip: String?, newTooltip: String?) { - thisLogger().warn("gitpod: tooltipChanged($port, $oldTooltip, $newTooltip)") - } }) } catch (error: Error) { thisLogger().warn("gitpod: ${error.message}") @@ -172,6 +176,25 @@ class GitpodPortForwardingService(private val session: ClientProjectSession) { portsService.removeForwardedPort(hostPort) thisLogger().info("gitpod: Stopped forwarding port $hostPort.") } + +// if (!isServed && !isForwarded) { +// val exposedPort = perClientPortForwardingManager.exposePort( +// hostPort, +// port.exposed.url, +// setOf(FORWARDED_PORT_LABEL), +// ) +// +// exposedPort.presentation.name = port.name +// exposedPort.presentation.description = port.description +// exposedPort.presentation.icon = GitpodIcons.Logo +// exposedPort.presentation.tooltip = "Exposed Port" +// } +// +// perClientPortForwardingManager.getPorts(hostPort).forEach { +// it.presentation.name = port.name +// it.presentation.description = port.description +// thisLogger().warn("gitpod: changing name and description of port $hostPort") +// } } } } diff --git a/components/ide/jetbrains/backend-plugin/src/main/kotlin/io/gitpod/jetbrains/remote/latest/GitpodPortsActionCopyUrl.kt b/components/ide/jetbrains/backend-plugin/src/main/kotlin/io/gitpod/jetbrains/remote/latest/GitpodPortsActionCopyUrl.kt new file mode 100644 index 00000000000000..83a54087580936 --- /dev/null +++ b/components/ide/jetbrains/backend-plugin/src/main/kotlin/io/gitpod/jetbrains/remote/latest/GitpodPortsActionCopyUrl.kt @@ -0,0 +1,25 @@ +// Copyright (c) 2022 Gitpod GmbH. All rights reserved. +// Licensed under the GNU Affero General Public License (AGPL). +// See License-AGPL.txt in the project root for license information. + +package io.gitpod.jetbrains.remote.latest + +import com.intellij.openapi.actionSystem.AnAction +import com.intellij.openapi.actionSystem.AnActionEvent +import com.intellij.openapi.diagnostic.thisLogger +import com.intellij.openapi.ide.CopyPasteManager +import com.jetbrains.rd.platform.codeWithMe.portForwarding.PortForwardingDataKeys +import java.awt.datatransfer.StringSelection + +@Suppress("ComponentNotRegistered", "UnstableApiUsage") +class GitpodPortsActionCopyUrl : AnAction() { + override fun actionPerformed(e: AnActionEvent) { + val port = e.dataContext.getData(PortForwardingDataKeys.PORT) + if (port != null) { + thisLogger().warn("gitpod: Exec GitpodPortsActionCopyUrl: ${port.hostPortNumber}") + CopyPasteManager.getInstance().setContents(StringSelection(port.hostPortNumber.toString())) + } else { + thisLogger().warn("gitpod: Exec: GitpodPortsActionCopyUrl: error unknown port") + } + } +} diff --git a/components/ide/jetbrains/backend-plugin/src/main/kotlin/io/gitpod/jetbrains/remote/stable/GitpodCLIHelperImpl.kt b/components/ide/jetbrains/backend-plugin/src/main/kotlin/io/gitpod/jetbrains/remote/stable/GitpodCLIHelperImpl.kt new file mode 100644 index 00000000000000..07ce428b26d9a9 --- /dev/null +++ b/components/ide/jetbrains/backend-plugin/src/main/kotlin/io/gitpod/jetbrains/remote/stable/GitpodCLIHelperImpl.kt @@ -0,0 +1,16 @@ +// Copyright (c) 2022 Gitpod GmbH. All rights reserved. +// Licensed under the GNU Affero General Public License (AGPL). +// See License-AGPL.txt in the project root for license information. + +package io.gitpod.jetbrains.remote.stable + +import com.intellij.ide.CommandLineProcessor +import io.gitpod.jetbrains.remote.GitpodCLIHelper +import java.nio.file.Path + +@Suppress("UnstableApiUsage") +class GitpodCLIHelperImpl : GitpodCLIHelper { + override suspend fun open(file :Path, shouldWait: Boolean) { + CommandLineProcessor.doOpenFileOrProject(file, shouldWait).future.get() + } +} diff --git a/components/ide/jetbrains/backend-plugin/src/main/kotlin/io/gitpod/jetbrains/remote/stable/GitpodClientProjectGuestSessionTracker.kt b/components/ide/jetbrains/backend-plugin/src/main/kotlin/io/gitpod/jetbrains/remote/stable/GitpodClientProjectGuestSessionTracker.kt new file mode 100644 index 00000000000000..3cf18d395715a2 --- /dev/null +++ b/components/ide/jetbrains/backend-plugin/src/main/kotlin/io/gitpod/jetbrains/remote/stable/GitpodClientProjectGuestSessionTracker.kt @@ -0,0 +1,13 @@ +// Copyright (c) 2022 Gitpod GmbH. All rights reserved. +// Licensed under the GNU Affero General Public License (AGPL). +// See License-AGPL.txt in the project root for license information. + +package io.gitpod.jetbrains.remote.stable + +import com.intellij.openapi.client.ClientProjectSession +import io.gitpod.jetbrains.remote.GitpodClientProjectSessionTracker + +@Suppress("UnstableApiUsage") +class GitpodClientProjectGuestSessionTracker(session: ClientProjectSession) { + init { GitpodClientProjectSessionTracker(session.project) } +} diff --git a/components/ide/jetbrains/backend-plugin/src/main/kotlin/io/gitpod/jetbrains/remote/stable/GitpodGlobalPortForwardingServiceImpl.kt b/components/ide/jetbrains/backend-plugin/src/main/kotlin/io/gitpod/jetbrains/remote/stable/GitpodGlobalPortForwardingServiceImpl.kt new file mode 100644 index 00000000000000..ab3df0b3c038ab --- /dev/null +++ b/components/ide/jetbrains/backend-plugin/src/main/kotlin/io/gitpod/jetbrains/remote/stable/GitpodGlobalPortForwardingServiceImpl.kt @@ -0,0 +1,12 @@ +// Copyright (c) 2022 Gitpod GmbH. All rights reserved. +// Licensed under the GNU Affero General Public License (AGPL). +// See License-AGPL.txt in the project root for license information. + +package io.gitpod.jetbrains.remote.stable + +import com.intellij.openapi.Disposable +import io.gitpod.jetbrains.remote.GitpodGlobalPortForwardingService + +class GitpodGlobalPortForwardingServiceImpl : GitpodGlobalPortForwardingService { + override fun monitorPortsOfPid(disposable: Disposable, pid: Long) = Unit +} diff --git a/components/ide/jetbrains/backend-plugin/src/main/kotlin/io/gitpod/jetbrains/remote/stable/GitpodTerminalGuestService.kt b/components/ide/jetbrains/backend-plugin/src/main/kotlin/io/gitpod/jetbrains/remote/stable/GitpodTerminalGuestService.kt new file mode 100644 index 00000000000000..9a960baf81f70f --- /dev/null +++ b/components/ide/jetbrains/backend-plugin/src/main/kotlin/io/gitpod/jetbrains/remote/stable/GitpodTerminalGuestService.kt @@ -0,0 +1,12 @@ +// Copyright (c) 2022 Gitpod GmbH. All rights reserved. +// Licensed under the GNU Affero General Public License (AGPL). +// See License-AGPL.txt in the project root for license information. + +package io.gitpod.jetbrains.remote.stable +import com.intellij.openapi.client.ClientProjectSession +import io.gitpod.jetbrains.remote.GitpodTerminalService + +@Suppress("UnstableApiUsage") +class GitpodTerminalGuestService(session: ClientProjectSession) { + init { GitpodTerminalService(session.project) } +} diff --git a/components/ide/jetbrains/backend-plugin/src/main/resources-latest/META-INF/extensions.xml b/components/ide/jetbrains/backend-plugin/src/main/resources-latest/META-INF/extensions.xml index 3e2f69929e3abf..dc0495bf538886 100644 --- a/components/ide/jetbrains/backend-plugin/src/main/resources-latest/META-INF/extensions.xml +++ b/components/ide/jetbrains/backend-plugin/src/main/resources-latest/META-INF/extensions.xml @@ -7,6 +7,18 @@ - + + + + + + + + + + + + + diff --git a/components/ide/jetbrains/backend-plugin/src/main/resources-stable/META-INF/extensions.xml b/components/ide/jetbrains/backend-plugin/src/main/resources-stable/META-INF/extensions.xml index a761b1b5842ba1..4d24c8f32980b5 100644 --- a/components/ide/jetbrains/backend-plugin/src/main/resources-stable/META-INF/extensions.xml +++ b/components/ide/jetbrains/backend-plugin/src/main/resources-stable/META-INF/extensions.xml @@ -7,5 +7,9 @@ + + + + diff --git a/components/ide/jetbrains/backend-plugin/src/main/resources/META-INF/plugin.xml b/components/ide/jetbrains/backend-plugin/src/main/resources/META-INF/plugin.xml index 5b8c3c87e86363..aa96802581fb29 100644 --- a/components/ide/jetbrains/backend-plugin/src/main/resources/META-INF/plugin.xml +++ b/components/ide/jetbrains/backend-plugin/src/main/resources/META-INF/plugin.xml @@ -3,6 +3,7 @@ Licensed under the GNU Affero General Public License (AGPL). See License-AGPL.txt in the project root for license information. --> + @@ -28,11 +29,7 @@ - -