Skip to content

Commit 1197115

Browse files
Vassiliy kudryashov/693 deprecated api usages in the plugin should be replaced with stable api calls (#982)
Get rid of Module.getModuleFile() Replace deprecated creatNotification() variant call with chain call of setTitle() and setListener()
1 parent 053cdfc commit 1197115

File tree

2 files changed

+5
-9
lines changed

2 files changed

+5
-9
lines changed

utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/ui/Notifications.kt

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -83,13 +83,8 @@ abstract class UrlNotifier : Notifier() {
8383
protected abstract val urlOpeningListener: NotificationListener
8484

8585
override fun notify(info: String, project: Project?, module: Module?) {
86-
notificationGroup
87-
.createNotification(
88-
titleText,
89-
content(project, module, info),
90-
notificationType,
91-
urlOpeningListener,
92-
).notify(project)
86+
notificationGroup.createNotification(content(project, module, info), notificationType)
87+
.setTitle(titleText).setListener(urlOpeningListener).notify(project)
9388
}
9489
}
9590

utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/ui/utils/ModuleUtils.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import com.intellij.openapi.module.Module
1313
import com.intellij.openapi.module.ModuleManager
1414
import com.intellij.openapi.module.ModuleUtilCore
1515
import com.intellij.openapi.project.Project
16+
import com.intellij.openapi.project.guessModuleDir
1617
import com.intellij.openapi.projectRoots.JavaSdk
1718
import com.intellij.openapi.projectRoots.JavaSdkVersion
1819
import com.intellij.openapi.projectRoots.Sdk
@@ -165,8 +166,8 @@ fun Module.addDedicatedTestRoot(testSourceRoots: MutableList<VirtualFile>): Virt
165166
val moduleInstance = ModuleRootManager.getInstance(this)
166167
val testFolder = moduleInstance.contentEntries.flatMap { it.sourceFolders.toList() }
167168
.firstOrNull { it.rootType in testSourceRootTypes }
168-
(testFolder?.let { testFolder.file?.parent } ?: (testFolder?.contentEntry
169-
?: moduleInstance.contentEntries.first()).file ?: moduleFile)?.let {
169+
(testFolder?.let { testFolder.file?.parent }
170+
?: testFolder?.contentEntry?.file ?: this.guessModuleDir())?.let {
170171
val file = FakeVirtualFile(it, dedicatedTestSourceRootName)
171172
testSourceRoots.add(file)
172173
// We return "true" IFF it's case of not yet created fake directory

0 commit comments

Comments
 (0)