Skip to content
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

Support 2024.2 platform #20

Closed
wants to merge 5 commits into from
Closed
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
2 changes: 1 addition & 1 deletion .github/workflows/build-plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
strategy:
fail-fast: true
matrix:
platform-version: [ 241 ]
platform-version: [ 241, 242 ]
env:
ORG_GRADLE_PROJECT_buildNumber: ${{ needs.generate-build-number.outputs.build_number }}
ORG_GRADLE_PROJECT_platformVersion: ${{ matrix.platform-version }}
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
.idea
.intellijPlatform
.kotlin
.fleet
*.iml
.gradle
Expand Down
2 changes: 1 addition & 1 deletion .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,8 @@ allprojects {

compileOnly(kotlin("stdlib-jdk8"))
implementation("junit:junit:4.13.2") // used in kotlin/org/rust/openapiext/Testmark.kt
// https://plugins.jetbrains.com/docs/intellij/tools-intellij-platform-gradle-plugin-faq.html#missing-opentest4j-dependency-in-test-framework
testImplementation("org.opentest4j:opentest4j:1.3.0")
testOutput(sourceSets.getByName("test").output.classesDirs)
}

Expand Down
19 changes: 19 additions & 0 deletions gradle-242.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Existent IDE versions can be found in the following repos:
# https://www.jetbrains.com/intellij-repository/releases/
# https://www.jetbrains.com/intellij-repository/snapshots/
ideaVersion=2024.2

# https://plugins.jetbrains.com/plugin/8195-toml/versions
tomlPlugin=org.toml.lang:242.20224.155
# https://plugins.jetbrains.com/plugin/12775-native-debugging-support/versions
nativeDebugPlugin=com.intellij.nativeDebug:242.20224.155
# https://plugins.jetbrains.com/plugin/12175-grazie-lite/versions
graziePlugin=tanvd.grazi:242.20224.155
# https://plugins.jetbrains.com/plugin/227-psiviewer/versions
psiViewerPlugin=PsiViewer:242.4697
# https://plugins.jetbrains.com/plugin/13114-copyright/versions
copyrightPlugin=com.intellij.copyright:242.20224.237

# please see https://www.jetbrains.org/intellij/sdk/docs/basics/getting_started/build_number_ranges.html for description
sinceBuild=242
untilBuild=242.*
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
propertiesPluginEnvironmentNameProperty=platformVersion
# Supported platforms: 241
platformVersion=241
# Supported platforms: 241, 242
platformVersion=242
# Supported IDEs: IU
baseIDE=IU
ideToRun=
Expand Down
9 changes: 9 additions & 0 deletions src/241/test/kotlin/org/rust/TestCompat.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,17 @@
package org.rust

import com.intellij.execution.process.ProcessOutputType
import com.intellij.ide.navbar.tests.contextNavBarPathStrings
import com.intellij.ide.util.treeView.smartTree.Sorter
import com.intellij.openapi.actionSystem.DataContext
import com.intellij.openapi.util.Key

// BACKCOMPAT 2023.2: move to the RsAnsiEscapeDecoderTest companion
val Key<*>.escapeSequence: String
get() = (this as? ProcessOutputType)?.escapeSequence ?: toString()

val alphaSorterId = Sorter.ALPHA_SORTER_ID

fun contextNavBarPathStringsCompat(ctx: DataContext): List<String> {
return contextNavBarPathStrings(ctx)
}
11 changes: 11 additions & 0 deletions src/242/main/kotlin/org/rust/ide/debugger/runconfig/comparUtils.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/*
* Use of this source code is governed by the MIT license that can be
* found in the LICENSE file.
*/

package org.rust.ide.debugger.runconfig

import com.intellij.ide.plugins.IdeaPluginDescriptor
import com.intellij.ide.plugins.PluginManagerCore

fun PluginManagerCore.getLoadedPlugins(): List<IdeaPluginDescriptor> = loadedPlugins
24 changes: 24 additions & 0 deletions src/242/test/kotlin/org/rust/DumbModeTestUtil.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
* Use of this source code is governed by the MIT license that can be
* found in the LICENSE file.
*/

package org.rust

import com.intellij.openapi.project.Project
import com.intellij.testFramework.DumbModeTestUtils

object DumbModeTestUtil {
fun startEternalDumbModeTask(project: Project): Token {
return Token(project, DumbModeTestUtils.startEternalDumbModeTask(project))
}

class Token(
private val project: Project,
private val token: DumbModeTestUtils.EternalTaskShutdownToken
) : AutoCloseable {
override fun close() {
DumbModeTestUtils.endEternalDumbModeTaskAndWaitForSmartMode(project, token)
}
}
}
45 changes: 45 additions & 0 deletions src/242/test/kotlin/org/rust/TestCompat.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
* Use of this source code is governed by the MIT license that can be
* found in the LICENSE file.
*/

package org.rust

import com.intellij.execution.process.ProcessOutputType
import com.intellij.ide.util.treeView.smartTree.Sorter
import com.intellij.openapi.actionSystem.DataContext
import com.intellij.openapi.util.Key
import com.intellij.platform.navbar.NavBarItemPresentationData
import com.intellij.platform.navbar.backend.NavBarItem
import com.intellij.platform.navbar.backend.impl.pathToItem
import com.intellij.util.concurrency.annotations.RequiresReadLock
import org.jetbrains.annotations.TestOnly

// BACKCOMPAT 2023.2: move to the RsAnsiEscapeDecoderTest companion
val Key<*>.escapeSequence: String
get() = (this as? ProcessOutputType)?.escapeSequence ?: toString()

val alphaSorterId = Sorter.getAlphaSorterId()

@Suppress("UnstableApiUsage")
@TestOnly
@RequiresReadLock
fun contextNavBarPathStrings(ctx: DataContext): List<String> {
// Navigation bar implementation was split into several modules, which made `navbar.testFramework` test scope only.
//
// See https://youtrack.jetbrains.com/issue/IJPL-850/Split-navigation-bar-implementation-into-several-modules,
// https://github.com/JetBrains/intellij-community/commit/a9e1406257b330d17d2a3f78f47b2d2113eca97c and
// https://github.com/JetBrains/intellij-community/commit/bfa6619891699658f86a7bf8bdf7726a67bc6efd

// Code copied from [platform/navbar/testFramework/src/testFramework.kt](https://github.com/JetBrains/intellij-community/blob/d161fd043392998e10c4551df92634dbda5a06b5/platform/navbar/testFramework/src/testFramework.kt#L34).
val contextItem = NavBarItem.NAVBAR_ITEM_KEY.getData(ctx)
?.dereference()
?: return emptyList()
return contextItem.pathToItem().map {
(it.presentation() as NavBarItemPresentationData).text
}
}

fun contextNavBarPathStringsCompat(ctx: DataContext): List<String> {
return contextNavBarPathStrings(ctx)
}
39 changes: 39 additions & 0 deletions src/242/test/kotlin/org/rust/ide/MockBrowserLauncher.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* Use of this source code is governed by the MIT license that can be
* found in the LICENSE file.
*/

package org.rust.ide

import com.intellij.ide.browsers.BrowserLauncher
import com.intellij.ide.browsers.WebBrowser
import com.intellij.openapi.Disposable
import com.intellij.openapi.application.ApplicationManager
import com.intellij.openapi.project.Project
import com.intellij.testFramework.replaceService
import java.io.File
import java.nio.file.Path

class MockBrowserLauncher : BrowserLauncher() {
private var lastFile: File? = null
private var lastPath: Path? = null
var lastUrl: String? = null

override fun browse(file: File) {
lastFile = file
}

override fun browse(file: Path) {
lastPath = file
}

override fun browse(url: String, browser: WebBrowser?, project: Project?) {
lastUrl = url
}

override fun open(url: String) {}

fun replaceService(disposable: Disposable) {
ApplicationManager.getApplication().replaceService(BrowserLauncher::class.java, this, disposable)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,31 +5,20 @@

package org.rust.ide.miscExtensions

import com.intellij.ide.ui.UISettings
import com.intellij.openapi.fileEditor.UniqueVFilePathBuilder
import com.intellij.openapi.fileEditor.impl.UniqueNameEditorTabTitleProvider
import com.intellij.openapi.project.DumbService
import com.intellij.openapi.project.Project
import com.intellij.openapi.vfs.VirtualFile
import org.rust.cargo.CargoConstants
import org.rust.lang.RsConstants
import org.rust.lang.core.psi.isRustFile
import java.io.File

class RsFileTabTitleProvider : UniqueNameEditorTabTitleProvider() {
override fun getEditorTabTitle(project: Project, file: VirtualFile): String? {
if (!((file.isRustFile && file.name in EXPLICIT_FILES) || file.name == CargoConstants.MANIFEST_FILE)) {
return null
}

val uiSettings = UISettings.instanceOrNull
if (uiSettings == null || !uiSettings.showDirectoryForNonUniqueFilenames || DumbService.isDumb(project)) {
return null
}

val uniqueName = UniqueVFilePathBuilder.getInstance().getUniqueVirtualFilePath(project, file)
val tabText = getEditorTabText(uniqueName, File.separator, uiSettings.hideKnownExtensionInTabs)
return tabText.takeUnless { it == file.name }
return super.getEditorTabTitle(project, file)
}

companion object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import com.intellij.psi.util.CachedValue
import com.intellij.psi.util.CachedValueProvider
import com.intellij.psi.util.CachedValuesManager
import com.intellij.psi.util.PsiModificationTracker
import com.intellij.testFramework.IndexingTestUtil
import com.intellij.testFramework.PlatformTestUtil
import com.intellij.util.io.DataOutputStream
import com.intellij.util.io.createDirectories
Expand Down Expand Up @@ -720,7 +721,10 @@ private class MacroExpansionServiceImplInner(

private fun processMacros(taskType: RsTask.TaskType) {
if (!isExpansionModeNew || !enabledInUnitTests) return
if (isUnitTestMode && DumbService.isDumb(project)) return
if (isUnitTestMode) {
IndexingTestUtil.waitUntilIndexesAreReady(project)
if (DumbService.isDumb(project)) return
}

val task = MacroExpansionTask(
project,
Expand All @@ -730,6 +734,7 @@ private class MacroExpansionServiceImplInner(
taskType,
)
submitTask(task)
if (isUnitTestMode) IndexingTestUtil.waitUntilIndexesAreReady(project)
}

private fun isTemplateActiveInAnyEditor(): Boolean {
Expand Down
2 changes: 1 addition & 1 deletion src/main/kotlin/org/rust/lang/core/macros/VfsInternals.kt
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ object VfsInternals {
@Throws(IOException::class)
fun reloadFileIfNeeded(file: VirtualFile) {
if (isMarkedForContentReload(file)) {
file.contentsToByteArray(false)
file.contentsToByteArray(true)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,6 @@ fun RsDocAndAttributeOwner.getQueryAttributes(
stub: RsAttributeOwnerStub? = attributeStub,
outerAttrsOnly: Boolean = false
): QueryAttributes<RsMetaItem> {
testAssert { !DumbService.isDumb(project) }
return if (stub != null) {
QueryAttributes(stub.getQueryAttributes(explicitCrate, outerAttrsOnly).metaItems.map { it.psi })
} else {
Expand Down
3 changes: 3 additions & 0 deletions src/main/kotlin/org/rust/openapiext/utils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ import com.intellij.psi.impl.PsiDocumentManagerBase
import com.intellij.psi.search.GlobalSearchScope
import com.intellij.psi.stubs.StubIndex
import com.intellij.psi.stubs.StubIndexKey
import com.intellij.testFramework.IndexingTestUtil
import com.intellij.util.concurrency.AppExecutorUtil
import com.intellij.util.ui.UIUtil
import org.jdom.Element
Expand Down Expand Up @@ -154,6 +155,7 @@ fun checkIsBackgroundThread() {
}

fun checkIsSmartMode(project: Project) {
if (isUnitTestMode) IndexingTestUtil.waitUntilIndexesAreReady(project)
if (DumbService.getInstance(project).isDumb) throw IndexNotReadyException.create()
}

Expand All @@ -163,6 +165,7 @@ fun checkCommitIsNotInProgress(project: Project) {
if ((PsiDocumentManager.getInstance(project) as PsiDocumentManagerBase).isCommitInProgress) {
error("Accessing indices during PSI event processing can lead to typing performance issues")
}
IndexingTestUtil.waitUntilIndexesAreReady(project)
}
}

Expand Down
2 changes: 2 additions & 0 deletions src/test/kotlin/org/rust/cargo/RsWithToolchainTestBase.kt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import com.intellij.openapi.vcs.ex.ProjectLevelVcsManagerEx
import com.intellij.openapi.vcs.impl.ProjectLevelVcsManagerImpl
import com.intellij.openapi.vfs.VirtualFile
import com.intellij.openapi.vfs.newvfs.impl.VfsRootAccess
import com.intellij.testFramework.IndexingTestUtil
import com.intellij.testFramework.builders.ModuleFixtureBuilder
import com.intellij.testFramework.common.runAll
import com.intellij.testFramework.fixtures.CodeInsightFixtureTestCase
Expand Down Expand Up @@ -58,6 +59,7 @@ abstract class RsWithToolchainTestBase : CodeInsightFixtureTestCase<ModuleFixtur

protected fun refreshWorkspace() {
project.testCargoProjects.discoverAndRefreshSync()
IndexingTestUtil.waitUntilIndexesAreReady(project)
}

override fun runTestRunnable(testRunnable: ThrowableRunnable<Throwable>) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import com.intellij.openapi.actionSystem.PlatformDataKeys
import com.intellij.openapi.util.SystemInfo
import com.intellij.openapi.util.io.FileUtil
import com.intellij.openapi.vfs.VirtualFile
import com.intellij.testFramework.IndexingTestUtil
import com.intellij.testFramework.PlatformTestUtil
import com.intellij.testFramework.fixtures.BuildViewTestFixture
import org.rust.*
Expand Down Expand Up @@ -495,6 +496,7 @@ class SyncToolWindowTest : RsWithToolchainTestBase() {
}

private fun attachCargoProject(cargoProjectRoot: VirtualFile) {
IndexingTestUtil.waitUntilIndexesAreReady(project)
myFixture.launchAnAction("Cargo.AttachCargoProject", PlatformDataKeys.VIRTUAL_FILE to cargoProjectRoot)
}

Expand Down
4 changes: 2 additions & 2 deletions src/test/kotlin/org/rust/ide/structure/RsNavBarTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@

package org.rust.ide.structure

import com.intellij.ide.navbar.tests.contextNavBarPathStrings
import com.intellij.openapi.editor.ex.EditorEx
import org.intellij.lang.annotations.Language
import org.rust.RsTestBase
import org.rust.contextNavBarPathStringsCompat

class RsNavBarTest : RsTestBase() {
fun `test struct`() = doTest("""
Expand Down Expand Up @@ -140,7 +140,7 @@ class RsNavBarTest : RsTestBase() {

val dataContext = (myFixture.editor as EditorEx).dataContext

val actualItems = contextNavBarPathStrings(dataContext)
val actualItems = contextNavBarPathStringsCompat(dataContext)
val expected = listOf("src", "main.rs", *items)
assertEquals(expected, actualItems)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ package org.rust.ide.structure

import com.intellij.ide.util.treeView.smartTree.Sorter
import org.intellij.lang.annotations.Language
import org.rust.alphaSorterId

class RsVisibilitySorterTest : RsStructureViewToggleableActionTest(){
override val actionId: String = RsVisibilitySorter.ID
Expand Down Expand Up @@ -499,6 +500,6 @@ class RsCombinedVisibilityAlphaSorterTest: RsStructureViewTestBase() {
| Zar visibility=private
""") {
setActionActive(RsVisibilitySorter.ID, true)
setActionActive(Sorter.ALPHA_SORTER_ID, true)
setActionActive(alphaSorterId, true)
}
}
Loading