Skip to content

Commit

Permalink
[kotlin] Add k1 invalidateCaches
Browse files Browse the repository at this point in the history
#KTIJ-5644

GitOrigin-RevId: ba69c563cf00f2a00511948ed2a7d167fcb3506a
  • Loading branch information
vladimirdolzhenko authored and intellij-monorepo-bot committed Jan 9, 2025
1 parent d2aec39 commit 7f09309
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,21 @@ import com.intellij.testFramework.common.runAll
import com.intellij.testFramework.runInEdtAndWait
import org.jetbrains.kotlin.idea.KotlinLanguage
import org.jetbrains.kotlin.idea.base.test.InTextDirectivesUtils
import org.jetbrains.kotlin.idea.caches.trackers.KotlinCodeBlockModificationListener
import org.jetbrains.kotlin.idea.caches.trackers.KotlinModuleOutOfCodeBlockModificationTracker
import org.jetbrains.kotlin.idea.formatter.kotlinCustomSettings
import org.jetbrains.kotlin.idea.test.KotlinLightCodeInsightFixtureTestCase
import org.jetbrains.kotlin.idea.test.KotlinTestUtils
import org.jetbrains.kotlin.idea.test.configureCodeStyleAndRun
import org.jetbrains.kotlin.idea.util.application.executeWriteCommand
import org.jetbrains.kotlin.psi.KtFile
import org.jetbrains.kotlin.scripting.definitions.ScriptConfigurationsProvider
import org.jetbrains.kotlin.test.util.invalidateCaches
import java.io.File

abstract class AbstractFormatterTest : KotlinLightCodeInsightFixtureTestCase() {

override fun tearDown() {
runAll(
{ runInEdtAndWait {
KotlinCodeBlockModificationListener.getInstance(project).incModificationCount()
KotlinModuleOutOfCodeBlockModificationTracker.incrementModificationCountForAllModules(project)
} },
{ runInEdtAndWait { project.invalidateCaches() } },
{ super.tearDown() },
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ package org.jetbrains.kotlin.idea.inspections
import com.intellij.codeInspection.ex.EntryPointsManagerBase
import com.intellij.openapi.application.runWriteAction
import com.intellij.openapi.fileTypes.FileTypeManager
import com.intellij.openapi.roots.ProjectRootManager
import com.intellij.openapi.util.io.FileUtil
import com.intellij.psi.PsiFile
import com.intellij.testFramework.TestLoggerFactory
Expand All @@ -14,11 +13,10 @@ import org.jdom.Document
import org.jdom.input.SAXBuilder
import org.jetbrains.kotlin.formatter.FormatSettingsUtil
import org.jetbrains.kotlin.idea.base.test.InTextDirectivesUtils
import org.jetbrains.kotlin.idea.caches.trackers.KotlinCodeBlockModificationListener
import org.jetbrains.kotlin.idea.caches.trackers.KotlinModuleOutOfCodeBlockModificationTracker
import org.jetbrains.kotlin.idea.compiler.configuration.KotlinPluginLayout
import org.jetbrains.kotlin.idea.test.*
import org.jetbrains.kotlin.idea.util.application.executeWriteCommand
import org.jetbrains.kotlin.test.util.invalidateCaches
import org.jetbrains.plugins.groovy.GroovyFileType
import org.junit.runner.Description
import java.io.File
Expand Down Expand Up @@ -49,11 +47,7 @@ abstract class AbstractInspectionTest : KotlinLightCodeInsightFixtureTestCase()
{
EntryPointsManagerBase.getInstance(project).ADDITIONAL_ANNOTATIONS.remove(ENTRY_POINT_ANNOTATION)
}, {
runInEdtAndWait {
KotlinCodeBlockModificationListener.getInstance(project).incModificationCount()
KotlinModuleOutOfCodeBlockModificationTracker.incrementModificationCountForAllModules(project)
ProjectRootManager.getInstance(project).incModificationCount()
}
runInEdtAndWait { project.invalidateCaches() }
},
{ super.tearDown() }
)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package org.jetbrains.kotlin.test.util

import com.intellij.openapi.application.runWriteAction
import com.intellij.openapi.project.Project
import org.jetbrains.kotlin.idea.caches.trackers.KotlinCodeBlockModificationListener
import org.jetbrains.kotlin.idea.caches.trackers.KotlinModuleOutOfCodeBlockModificationTracker

fun Project.invalidateCaches() {
runWriteAction {
// see Fe10KotlinGlobalModificationService
KotlinCodeBlockModificationListener.getInstance(this).incModificationCount()
KotlinModuleOutOfCodeBlockModificationTracker.incrementModificationCountForAllModules(this)
}
}

0 comments on commit 7f09309

Please sign in to comment.