Skip to content
This repository was archived by the owner on Mar 26, 2024. It is now read-only.
Open
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
1 change: 1 addition & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ subprojects {
mavenCentral()
maven("https://jitpack.io")
maven("https://www.jetbrains.com/intellij-repository/releases")
maven("https://www.jetbrains.com/intellij-repository/snapshots")
maven("https://cache-redirector.jetbrains.com/intellij-dependencies")
}

Expand Down
13 changes: 12 additions & 1 deletion buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,28 @@
* Please contact JetBrains, Na Hrebenech II 1718/10, Prague, 14000, Czech Republic
* if you need additional information or have any questions.
*/

import java.util.*

plugins {
`kotlin-dsl`
}

repositories {
mavenCentral()
maven("https://www.jetbrains.com/intellij-repository/releases")
maven("https://www.jetbrains.com/intellij-repository/snapshots")
maven("https://cache-redirector.jetbrains.com/intellij-dependencies")
}

val intellijPlatformVersion: String by project
val gradleProperties = Properties()
val gradlePropertiesFile = project.file("../gradle.properties")
if (gradlePropertiesFile.canRead()) {
gradleProperties.load(gradlePropertiesFile.inputStream())
}

val intellijPlatformVersion: String by gradleProperties

val serializationVersion: String by project

dependencies {
Expand Down
1 change: 0 additions & 1 deletion buildSrc/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,4 @@
# if you need additional information or have any questions.
#

intellijPlatformVersion=213.6461.23
serializationVersion=1.3.1
2 changes: 1 addition & 1 deletion buildSrc/src/main/kotlin/runIdeaTaskBase.kt
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ public fun Project.createRunIdeaTask(

println("JDK home dir: $jdkHome")

val ideaPathsSelector = "ProjectorIntelliJIdea"
val prefix = getIdePrefix(ideaPath)
val ideaPathsSelector = "Projector${prefix ?: "Idea"}"

val (classToLaunchProperty, launcherClassName) = getLaunchingSetup(isAgent)

Expand Down
5 changes: 3 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,13 @@
# Please contact JetBrains, Na Hrebenech II 1718/10, Prague, 14000, Czech Republic
# if you need additional information or have any questions.
#
intellijPlatformVersion=213.6461.23
intellijJcefVersion=89.0.12-g2b76680-chromium-89.0.4389.90-api-1.6
intellijPlatformVersion=213.6777.52
intellijPluginVersion=1.3.0
javassistVersion=3.28.0-GA
kotlinVersion=1.6.10
mockitoKotlinVersion=4.0.0
projectorClientVersion=3d0453c9
projectorClientVersion=67b2cd9f
projectorClientGroup=com.github.JetBrains.projector-client
targetJvm=11
jetbrainsMonoVersion=2.242
Expand Down
14 changes: 13 additions & 1 deletion projector-server/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
* if you need additional information or have any questions.
*/

import com.intellij.openapi.util.BuildNumber
import java.net.URL
import java.util.*
import java.util.zip.ZipFile
Expand Down Expand Up @@ -49,18 +50,29 @@ val projectorClientGroup: String by project
val projectorClientVersion: String by project
val mockitoKotlinVersion: String by project
val kotlinVersion: String by project
val intellijJcefVersion: String by project
val intellijPlatformVersion: String by project

val intelliJVersionRemovedSuffix = intellijPlatformVersion.takeWhile { it.isDigit() || it == '.' } // in case of EAP
val intellijPlatformBuildNumber = BuildNumber.fromString(intelliJVersionRemovedSuffix)!!

dependencies {
implementation("$projectorClientGroup:projector-common:$projectorClientVersion")
implementation("$projectorClientGroup:projector-ij-common:$projectorClientVersion")
implementation("$projectorClientGroup:projector-server-core:$projectorClientVersion")
implementation("$projectorClientGroup:projector-util-loading:$projectorClientVersion")
implementation("$projectorClientGroup:projector-util-logging:$projectorClientVersion")
api(project(":projector-awt"))

compileOnly("com.jetbrains.intellij.platform:code-style:$intellijPlatformVersion")
if (intellijPlatformBuildNumber >= BuildNumber.fromString("203.5981.165")!!) {
compileOnly("com.jetbrains.intellij.platform:code-style:$intellijPlatformVersion")
} else {
compileOnly("com.jetbrains.intellij.platform:lang:$intellijPlatformVersion")
}

compileOnly("com.jetbrains.intellij.platform:core-ui:$intellijPlatformVersion")
compileOnly("com.jetbrains.intellij.platform:ide-impl:$intellijPlatformVersion")
compileOnly("org.jetbrains.intellij.deps.jcef:jcef:$intellijJcefVersion")

testImplementation("org.mockito.kotlin:mockito-kotlin:$mockitoKotlinVersion")
testImplementation("org.jetbrains.kotlin:kotlin-test:$kotlinVersion")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/*
* Copyright (c) 2019-2022, JetBrains s.r.o. and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. JetBrains designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact JetBrains, Na Hrebenech II 1718/10, Prague, 14000, Czech Republic
* if you need additional information or have any questions.
*/
@file:Suppress("JAVA_MODULE_DOES_NOT_EXPORT_PACKAGE")

package org.jetbrains.projector.server

import org.jetbrains.projector.awt.peer.PComponentPeer
import org.jetbrains.projector.common.EventSender
import org.jetbrains.projector.common.event.BrowserShowEventPart
import org.jetbrains.projector.common.event.ServerEventPart
import org.jetbrains.projector.common.protocol.toClient.ServerBrowserEvent
import org.jetbrains.projector.common.protocol.toClient.ServerEvent
import org.jetbrains.projector.util.loading.UseProjectorLoader
import sun.awt.AWTAccessor
import java.awt.Component
import java.awt.peer.ComponentPeer
import javax.swing.SwingUtilities

@UseProjectorLoader
class CommonQueueEventSender : EventSender {

override fun sendEvent(event: ServerEvent) {
ProjectorServer.appendToCommonQueue(event)
}

override fun sendEventPart(part: ServerEventPart) {
val serverEvent = when (part) {
is BrowserShowEventPart -> ServerBrowserEvent.ShowEvent(part.browserId, part.show, part.component?.pWindowId)
}

sendEvent(serverEvent)
}

private val Component.pWindowId: Int?
get() = let {
val root = SwingUtilities.getRoot(it) ?: return@let null
val peer = AWTAccessor.getComponentAccessor().getPeer<ComponentPeer>(root) as? PComponentPeer ?: return@let null
peer.pWindow.id
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ import org.jetbrains.projector.common.protocol.data.UserKeymap
import org.jetbrains.projector.common.protocol.handshake.*
import org.jetbrains.projector.common.protocol.toClient.*
import org.jetbrains.projector.common.protocol.toServer.*
import org.jetbrains.projector.ij.jcef.*
import org.jetbrains.projector.server.core.*
import org.jetbrains.projector.server.core.convert.toAwt.*
import org.jetbrains.projector.server.core.convert.toClient.*
Expand Down Expand Up @@ -193,6 +194,7 @@ class ProjectorServer private constructor(
previousWindowEvents = emptySet()
caretInfoUpdater.createCaretInfoEvent()
PanelUpdater.updateAll()
updateCefBrowsersSafely()
}

is ReadyClientSettings -> {
Expand Down Expand Up @@ -501,6 +503,7 @@ class ProjectorServer private constructor(
is ClientWindowsDeactivationEvent -> {
updateWindowsState(message.windowIds, WindowEvent.WINDOW_DEACTIVATED)
}

is ClientNotificationEvent -> {
if (!IdeState.isIdeAttached) return

Expand All @@ -514,6 +517,20 @@ class ProjectorServer private constructor(
val notification = Notification("ProjectorClient", message.title, message.message, intellijNotificationType)
Notifications.Bus.notify(notification)
}

is ClientJcefEvent -> {
val projectorCefBrowser = ProjectorCefBrowser.getInstance(message.browserId) ?: return

val messageRouters = projectorCefBrowser.client.getMessageRouters()
val eventRouter = messageRouters.find {
it.messageRouterConfig?.jsQueryFunction == message.functionName
} ?: return

val handlers = eventRouter.getHandlers()
handlers.forEach {
it.onProjectorQuery(projectorCefBrowser, message.data)
}
}
}
}

Expand Down Expand Up @@ -918,6 +935,10 @@ class ProjectorServer private constructor(
}
}

fun appendToCommonQueue(event: ServerEvent) {
lastStartedServer?.apply { commonQueue += event }
}

@Suppress("MemberVisibilityCanBePrivate") // used in CWM
var lastStartedServer: ProjectorServer? = null
private set
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,12 @@

package org.jetbrains.projector.server.platform

import com.intellij.openapi.application.ApplicationInfo
import com.intellij.openapi.editor.colors.EditorColorsScheme
import com.intellij.openapi.editor.markup.RangeHighlighter
import com.intellij.openapi.editor.markup.TextAttributes
import com.intellij.openapi.util.BuildNumber
import org.jetbrains.projector.common.intellij.buildAtLeast
import org.jetbrains.projector.util.loading.UseProjectorLoader

fun buildAtLeast(version: String): Boolean {
val versionToCheck = BuildNumber.fromString(version) ?: throw IllegalArgumentException("Invalid version string $version")
val currentVersion = ApplicationInfo.getInstance().build

return currentVersion >= versionToCheck
}

private val isColorSchemeRequired: Boolean by lazy { buildAtLeast("202.6397.94") }

@Suppress("DEPRECATION")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#
# Copyright (c) 2019-2022, JetBrains s.r.o. and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 2 only, as
# published by the Free Software Foundation. JetBrains designates this
# particular file as subject to the "Classpath" exception as provided
# by Oracle in the LICENSE file that accompanied this code.
#
# This code is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# version 2 for more details (a copy is included in the LICENSE file that
# accompanied this code).
#
# You should have received a copy of the GNU General Public License version
# 2 along with this work; if not, write to the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Please contact JetBrains, Na Hrebenech II 1718/10, Prague, 14000, Czech Republic
# if you need additional information or have any questions.
#
org.jetbrains.projector.server.CommonQueueEventSender
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need to declare such a file and inject event sender via it? Could we use some easier way of injection, like we do in other places?

9 changes: 5 additions & 4 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,11 @@ val localProperties = Properties().apply {
if (localProperties["useLocalProjectorClient"] == "true") {
includeBuild("../projector-client") {
dependencySubstitution {
substitute(module("$projectorClientGroup:projector-common")).with(project(":projector-common"))
substitute(module("$projectorClientGroup:projector-server-core")).with(project(":projector-server-core"))
substitute(module("$projectorClientGroup:projector-util-loading")).with(project(":projector-util-loading"))
substitute(module("$projectorClientGroup:projector-util-logging")).with(project(":projector-util-logging"))
substitute(module("$projectorClientGroup:projector-common")).using(project(":projector-common"))
substitute(module("$projectorClientGroup:projector-ij-common")).using(project(":projector-ij-common"))
substitute(module("$projectorClientGroup:projector-server-core")).using(project(":projector-server-core"))
substitute(module("$projectorClientGroup:projector-util-loading")).using(project(":projector-util-loading"))
substitute(module("$projectorClientGroup:projector-util-logging")).using(project(":projector-util-logging"))
Comment on lines +52 to +56
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why changing with to using?

}
}
}
Expand Down