Skip to content

Commit

Permalink
Update Platform Version of JetBrains Backend Plugin to 223.7126-EAP-C…
Browse files Browse the repository at this point in the history
…ANDIDATE-SNAPSHOT

Co-authored-by: Andrea Falzetti <[email protected]>
  • Loading branch information
felladrin and Andrea Falzetti committed Oct 21, 2022
1 parent 7b6959d commit 75d4a98
Show file tree
Hide file tree
Showing 12 changed files with 121 additions and 35 deletions.
Original file line number Diff line number Diff line change
@@ -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
6 changes: 3 additions & 3 deletions components/ide/jetbrains/backend-plugin/launch-dev-server.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,17 @@ 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 &&
rm backend.zip &&
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"
Expand Down
Original file line number Diff line number Diff line change
@@ -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)
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -40,6 +39,7 @@ class GitpodCLIService : RestService() {

private val manager = service<GitpodManager>()
private val portsService = service<GitpodPortsService>()
private val cliHelperService = service<GitpodCLIHelper>()

override fun getServiceName() = SERVICE_NAME

Expand Down Expand Up @@ -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)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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<GitpodManager>()
private val portsService = service<GitpodPortsService>()
private val session = ClientSessionsManager.getProjectSession(project)

private lateinit var info: Info.WorkspaceInfoResponse
private val lifetime = Lifetime.Eternal.createNested()
Expand Down Expand Up @@ -89,7 +89,7 @@ class GitpodClientProjectSessionTracker(
notification.addAction(makePublicAction)
}

ClientId.withClientId(session.clientId) {
ClientId.withClientId(session?.clientId) {
notification.notify(null)
}
}
Expand All @@ -108,7 +108,7 @@ class GitpodClientProjectSessionTracker(
}

private fun openBrowser(url: String) {
ClientId.withClientId(session.clientId) {
ClientId.withClientId(session?.clientId) {
BrowserUtil.browse(url)
}
}
Expand Down Expand Up @@ -196,7 +196,7 @@ class GitpodClientProjectSessionTracker(

private fun registerActiveLanguageAnalytics() {
val activeLanguages = mutableSetOf<String>()
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) {
Expand All @@ -219,6 +219,7 @@ class GitpodClientProjectSessionTracker(
}

private fun trackEvent(eventName: String, props: Map<String, Any?>) {
if (session == null) return
manager.trackEvent(eventName, mapOf(
"sessionId" to session.clientId.value
).plus(props))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,16 @@

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
import com.jetbrains.rd.platform.codeWithMe.portForwarding.GlobalPortForwardingManager
import com.jetbrains.rd.platform.codeWithMe.portForwarding.ListeningPort
import com.jetbrains.rd.platform.codeWithMe.portForwarding.ListeningPortHandler
import com.jetbrains.rd.platform.codeWithMe.portForwarding.PortListeningOptions
import com.jetbrains.rdserver.terminal.BackendTerminalManager
import io.gitpod.supervisor.api.Status
import io.gitpod.supervisor.api.StatusServiceGrpc
Expand All @@ -25,16 +30,17 @@ 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 globalPortForwardingManager = service<GlobalPortForwardingManager>()

init {
start()
Expand Down Expand Up @@ -186,6 +192,17 @@ class GitpodTerminalService(session: ClientProjectSession) {
exitTaskWhenTerminalWidgetGetsClosed(supervisorTerminal, shellTerminalWidget)

listenForTaskTerminationAndTitleChanges(supervisorTerminal, shellTerminalWidget)

globalPortForwardingManager.monitorPortsOfPid(
shellTerminalWidget,
supervisorTerminal.pid,
object : ListeningPortHandler {
override fun onPortListeningStarted(port: ListeningPort) {
thisLogger().warn("gitpod: onPortListeningStarted ${port.portType} ${port.pid} ${port.socketAddress}")
}
},
PortListeningOptions.INCLUDE_SELF_AND_CHILDREN
)
}

private fun listenForTaskTerminationAndTitleChanges(
Expand Down
Original file line number Diff line number Diff line change
@@ -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()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,20 @@
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
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
Expand All @@ -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"
}
Expand All @@ -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) {
Expand Down Expand Up @@ -74,7 +76,7 @@ class GitpodPortForwardingService(private val session: ClientProjectSession) {
val portsStatusResponseObserver = object :
ClientResponseObserver<Status.PortsStatusRequest, Status.PortsStatusResponse> {
override fun beforeStart(request: ClientCallStreamObserver<Status.PortsStatusRequest>) {
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) }
Expand Down Expand Up @@ -104,14 +106,16 @@ 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
val rowIcon = RowIcon(2)
rowIcon.setIcon(GitpodIcons.Logo, 0)
rowIcon.setIcon(GitpodIcons.Logo, 1)
forwardedPort.presentation.icon = rowIcon
forwardedPort.presentation.tooltip = "Forwarded Port"

val portListenerDisposable = portToDisposableMap.getOrPut(hostPort, fun() = Disposer.newDisposable())

Expand Down Expand Up @@ -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")
// }
}
}
}
Original file line number Diff line number Diff line change
@@ -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()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
<idea-plugin>
<extensions defaultExtensionNs="com.intellij">
<applicationService serviceInterface="io.gitpod.jetbrains.remote.GitpodIgnoredPortsForNotificationService" serviceImplementation="io.gitpod.jetbrains.remote.latest.GitpodIgnoredPortsForNotificationServiceImpl" preload="true"/>
<projectService serviceImplementation="io.gitpod.jetbrains.remote.latest.GitpodPortForwardingService" preload="true" client="guest"/>
<applicationService serviceInterface="io.gitpod.jetbrains.remote.GitpodCLIHelper" serviceImplementation="io.gitpod.jetbrains.remote.latest.GitpodCLIHelperImpl" preload="true"/>
<projectService serviceImplementation="io.gitpod.jetbrains.remote.GitpodClientProjectSessionTracker" client="controller" preload="true"/>
<projectService serviceImplementation="io.gitpod.jetbrains.remote.GitpodTerminalService" client="controller" preload="true"/>
<projectService serviceImplementation="io.gitpod.jetbrains.remote.latest.GitpodPortForwardingService" preload="true" client="controller"/>
</extensions>
</idea-plugin>
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,8 @@
<idea-plugin>
<extensions defaultExtensionNs="com.intellij">
<applicationService serviceInterface="io.gitpod.jetbrains.remote.GitpodIgnoredPortsForNotificationService" serviceImplementation="io.gitpod.jetbrains.remote.stable.GitpodIgnoredPortsForNotificationServiceImpl" preload="true"/>
<applicationService serviceInterface="io.gitpod.jetbrains.remote.GitpodCLIHelper" serviceImplementation="io.gitpod.jetbrains.remote.stable.GitpodCLIHelperImpl" preload="true"/>
<projectService serviceImplementation="io.gitpod.jetbrains.remote.GitpodClientProjectSessionTracker" client="guest" preload="true"/>
<projectService serviceImplementation="io.gitpod.jetbrains.remote.GitpodTerminalService" client="guest" preload="true"/>
</extensions>
</idea-plugin>
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,7 @@
<applicationService serviceImplementation="io.gitpod.jetbrains.remote.GitpodPortsService" preload="true"/>
<notificationGroup id="Gitpod Notifications" displayType="BALLOON" isLogByDefault="false"/>
<httpRequestHandler implementation="io.gitpod.jetbrains.remote.GitpodCLIService"/>
<projectService serviceImplementation="io.gitpod.jetbrains.remote.GitpodClientProjectSessionTracker"
client="guest" preload="true"/>
<projectService serviceImplementation="io.gitpod.jetbrains.remote.GitpodProjectManager" preload="true"/>
<projectService serviceImplementation="io.gitpod.jetbrains.remote.GitpodTerminalService" client="guest"
preload="true"/>
<gateway.customization.name
implementation="io.gitpod.jetbrains.remote.GitpodGatewayClientCustomizationProvider"/>
<gateway.customization.performance id="gitpodMetricsControl" order="before cpuControl"
Expand Down

0 comments on commit 75d4a98

Please sign in to comment.