Skip to content

Commit d1bdf08

Browse files
committed
Add support for 2022.3 JetBrains IDEs
1 parent 65f4fc5 commit d1bdf08

File tree

6 files changed

+63
-40
lines changed

6 files changed

+63
-40
lines changed

components/ide/jetbrains/backend-plugin/build.gradle.kts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,11 @@ dependencies {
6767
// Read more: https://github.com/JetBrains/gradle-intellij-plugin
6868
intellij {
6969
pluginName.set(properties("pluginName"))
70-
version.set(properties("platformVersion"))
70+
if (properties("platformVersion") != "null") {
71+
version.set(properties("platformVersion"))
72+
} else {
73+
localPath.set(properties("localPath"))
74+
}
7175
type.set(properties("platformType"))
7276
instrumentCode.set(false)
7377
downloadSources.set(properties("platformDownloadSources").toBoolean())
@@ -115,6 +119,7 @@ tasks {
115119
}
116120

117121
runPluginVerifier {
122+
enabled = false // TODO: Re-enable it when there's a 2022.3 ide version released.
118123
ideVersions.set(properties("pluginVerifierIdeVersions").split(',').map(String::trim).filter(String::isNotEmpty))
119124
}
120125
}
Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
# See https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html
22
# for insight into build numbers and IntelliJ Platform versions.
3-
pluginSinceBuild=222
4-
pluginUntilBuild=222.*
3+
pluginSinceBuild=223
4+
pluginUntilBuild=223.*
55
# Plugin Verifier integration -> https://github.com/JetBrains/gradle-intellij-plugin#plugin-verifier-dsl
66
# See https://jb.gg/intellij-platform-builds-list for available build versions.
7-
pluginVerifierIdeVersions=2022.2
7+
pluginVerifierIdeVersions=2022.3
88
# Version from "com.jetbrains.intellij.idea" which can be found at https://www.jetbrains.com/intellij-repository/snapshots
9-
platformVersion=222.3739-EAP-CANDIDATE-SNAPSHOT
9+
platformVersion=223.1192-EAP-CANDIDATE-SNAPSHOT
10+
# If you want to try, during development, a snapshot that you need to download because it's not available at https://www.jetbrains.com/intellij-repository/snapshots, run the following command:
11+
# (cd /workspace && wget https://download-cdn.jetbrains.com/idea/gateway/idea_tmp/ideaIU-223.2931.tar.gz && tar -xvf ideaIU-223.2931.tar.gz && rm ideaIU-223.2931.tar.gz && mv idea-IU-223.2931 ide-backend)
12+
# And then comment out the line above ("platformVersion").
13+
localPath=/workspace/ide-backend

components/ide/jetbrains/backend-plugin/src/main/kotlin/io/gitpod/jetbrains/remote/GitpodCLIService.kt

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,17 @@ import io.netty.channel.ChannelHandlerContext
2525
import io.netty.handler.codec.http.FullHttpRequest
2626
import io.netty.handler.codec.http.QueryStringDecoder
2727
import io.prometheus.client.exporter.common.TextFormat
28+
import kotlinx.coroutines.Dispatchers
29+
import kotlinx.coroutines.GlobalScope
30+
import kotlinx.coroutines.launch
31+
import kotlinx.coroutines.withContext
2832
import org.jetbrains.ide.RestService
2933
import org.jetbrains.io.response
3034
import java.io.OutputStreamWriter
3135
import java.nio.file.InvalidPathException
3236
import java.nio.file.Path
3337

34-
@Suppress("UnstableApiUsage")
38+
@Suppress("UnstableApiUsage", "OPT_IN_USAGE")
3539
class GitpodCLIService : RestService() {
3640

3741
private val manager = service<GitpodManager>()
@@ -65,7 +69,11 @@ class GitpodCLIService : RestService() {
6569
val file = parseFilePath(fileStr) ?: return "invalid file"
6670
val shouldWait = getBooleanParameter("wait", urlDecoder)
6771
return withClient(request, context) {
68-
CommandLineProcessor.doOpenFileOrProject(file, shouldWait).future.get()
72+
GlobalScope.launch {
73+
withContext(Dispatchers.IO) {
74+
CommandLineProcessor.doOpenFileOrProject(file, shouldWait).future.get()
75+
}
76+
}
6977
}
7078
}
7179
if (operation == "preview") {

components/ide/jetbrains/backend-plugin/src/main/kotlin/io/gitpod/jetbrains/remote/GitpodClientProjectSessionTracker.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ package io.gitpod.jetbrains.remote
66

77
import com.intellij.codeWithMe.ClientId
88
import com.intellij.ide.BrowserUtil
9-
import com.intellij.idea.StartupUtil
9+
import com.intellij.idea.getServerFutureAsync
1010
import com.intellij.notification.NotificationAction
1111
import com.intellij.notification.NotificationType
1212
import com.intellij.openapi.Disposable
@@ -120,7 +120,7 @@ class GitpodClientProjectSessionTracker(
120120

121121
// Ignore ports that aren't actually used by the user (e.g. ports used internally by JetBrains IDEs)
122122
val backendPort = BuiltInServerManager.getInstance().waitForStart().port
123-
val serverPort = StartupUtil.getServerFuture().await().port
123+
val serverPort = getServerFutureAsync().await()?.port
124124
val ignorePorts = listOf(backendPort, serverPort, 5990)
125125
val portsStatus = hashMapOf<Int, PortsStatus>()
126126

components/ide/jetbrains/backend-plugin/src/main/kotlin/io/gitpod/jetbrains/remote/latest/GitpodPortForwardingService.kt

Lines changed: 36 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,11 @@ import com.intellij.openapi.diagnostic.thisLogger
99
import com.intellij.openapi.project.Project
1010
import com.intellij.remoteDev.util.onTerminationOrNow
1111
import com.intellij.util.application
12-
import com.jetbrains.codeWithMe.model.RdPortType
12+
import com.jetbrains.rd.platform.codeWithMe.portForwarding.PortType
1313
import com.jetbrains.rd.platform.util.lifetime
1414
import com.jetbrains.rd.util.lifetime.LifetimeStatus
15-
import com.jetbrains.rdserver.portForwarding.ForwardedPortInfo
16-
import com.jetbrains.rdserver.portForwarding.PortForwardingManager
17-
import com.jetbrains.rdserver.portForwarding.remoteDev.PortEventsProcessor
15+
import com.jetbrains.rdserver.portForwarding.*
16+
import com.jetbrains.rdserver.portForwarding.remoteDev.ControllerPortsInformationProvider
1817
import io.gitpod.jetbrains.remote.GitpodManager
1918
import io.gitpod.jetbrains.remote.GitpodPortsService
2019
import io.gitpod.supervisor.api.Status
@@ -32,6 +31,7 @@ class GitpodPortForwardingService(private val project: Project) {
3231
}
3332

3433
private val portsService = service<GitpodPortsService>()
34+
private val controllerPortsInformationProvider = service<ControllerPortsInformationProvider>()
3535

3636
init { start() }
3737

@@ -85,42 +85,48 @@ class GitpodPortForwardingService(private val project: Project) {
8585
}
8686

8787
private fun updateForwardedPortsList(response: Status.PortsStatusResponse) {
88-
val portForwardingManager = PortForwardingManager.getInstance(project)
89-
val forwardedPortsList = portForwardingManager.getForwardedPortsWithLabel(FORWARDED_PORT_LABEL)
88+
val portForwardingManager = PortForwardingManager.getInstance()
89+
val forwardedPorts = portForwardingManager.getPortsWithLabel(FORWARDED_PORT_LABEL)
9090

9191
for (port in response.portsList) {
9292
val hostPort = port.localPort
9393
val isServed = port.served
94-
95-
if (isServed && !forwardedPortsList.containsKey(hostPort)) {
96-
val portEventsProcessor = object : PortEventsProcessor {
97-
override fun onPortForwarded(hostPort: Int, clientPort: Int) {
98-
portsService.setForwardedPort(hostPort, clientPort)
99-
thisLogger().info("gitpod: Forwarded port $hostPort to client's port $clientPort.")
94+
val existingForwardedPort = forwardedPorts.find { it.hostPortNumber == hostPort }
95+
96+
if (isServed && existingForwardedPort == null) {
97+
thisLogger().warn("hostPort $hostPort started being served.")
98+
// portForwardingManager.addPort(Port.ExposedPort(
99+
// hostPort,
100+
// PortIdentity.MutableNameAndDescription(port.name, port.description),
101+
// setOf(FORWARDED_PORT_LABEL),
102+
// Property(port.exposed.url),
103+
// Property(PortVisibility.PrivatePort("Private Gitpod Port"))
104+
// ))
105+
106+
portForwardingManager.addPort(Port.ForwardedPort(
107+
hostPort,
108+
PortType.HTTP,
109+
PortIdentity.MutableNameAndDescription(port.name, port.description),
110+
setOf(FORWARDED_PORT_LABEL)
111+
))
112+
113+
when (val clientPortState = controllerPortsInformationProvider.getForwardedClientPortState(hostPort)) {
114+
is ClientPortState.Assigned -> {
115+
thisLogger().info("gitpod: Started forwarding host port $hostPort to client port ${clientPortState.clientPort}.")
116+
portsService.setForwardedPort(hostPort, clientPortState.clientPort)
100117
}
101-
102-
override fun onPortForwardingEnded(hostPort: Int) {
103-
thisLogger().info("gitpod: Finished forwarding port $hostPort.")
118+
is ClientPortState.FailedToAssign -> {
119+
thisLogger().info("gitpod: Detected that host port $hostPort failed to be assigned to a client port.")
104120
}
105-
106-
override fun onPortForwardingFailed(hostPort: Int, reason: String) {
107-
thisLogger().error("gitpod: Failed to forward port $hostPort: $reason")
121+
else -> {
122+
thisLogger().info("gitpod: Detected that host port $hostPort is not assigned to any client port.")
108123
}
109124
}
110-
111-
val portInfo = ForwardedPortInfo(
112-
hostPort,
113-
RdPortType.HTTP,
114-
FORWARDED_PORT_LABEL,
115-
emptyList(),
116-
portEventsProcessor
117-
)
118-
119-
portForwardingManager.forwardPort(portInfo)
120125
}
121126

122-
if (!isServed && forwardedPortsList.containsKey(hostPort)) {
123-
portForwardingManager.removePort(hostPort)
127+
if (!isServed && existingForwardedPort != null) {
128+
thisLogger().warn("hostPort $hostPort stopped being")
129+
portForwardingManager.removePort(existingForwardedPort)
124130
portsService.removeForwardedPort(hostPort)
125131
thisLogger().info("gitpod: Stopped forwarding port $hostPort.")
126132
}

components/ide/jetbrains/image/BUILD.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ packages:
5050
metadata:
5151
helm-component: workspace.desktopIdeImages.intellijLatest
5252
buildArgs:
53-
JETBRAINS_BACKEND_URL: "https://download.jetbrains.com/product?type=release,rc,eap&distribution=linux&code=IIU"
53+
JETBRAINS_BACKEND_URL: "https://download-cdn.jetbrains.com/idea/gateway/idea_tmp/ideaIU-223.2931.tar.gz"
5454
SUPERVISOR_IDE_CONFIG: supervisor-ide-config_intellij.json
5555
JETBRAINS_BACKEND_QUALIFIER: latest
5656
image:

0 commit comments

Comments
 (0)