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 24, 2022
1 parent 9fd3e3b commit a8cc430
Show file tree
Hide file tree
Showing 19 changed files with 268 additions and 62 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
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
)
}
}
Loading

0 comments on commit a8cc430

Please sign in to comment.