Skip to content

Update Platform Version from JetBrains Backend Plugin #14154

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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=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
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
@@ -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)
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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<GitpodGlobalPortForwardingService>()

init {
start()
Expand Down Expand Up @@ -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(
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
@@ -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<GlobalPortForwardingManager>()

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
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
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.util.application
Expand All @@ -27,7 +27,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 +46,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 +74,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,38 +104,15 @@ 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 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 stateChanged(port: ForwardedPort, newState: ClientPortState) {
when (newState) {
is ClientPortState.Assigned -> {
Expand All @@ -150,10 +127,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}")
Expand Down
Original file line number Diff line number Diff line change
@@ -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")
}
}
}
Loading