mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-10-01 21:01:48 +07:00
The inspection must not suggest replacing service retrieving calls with a `getInstance` call if a `getInstance` method has a nullable return type. GitOrigin-RevId: cd8a36698f0c1efb4c6af27962554ae36ba7266a
26 lines
747 B
Kotlin
26 lines
747 B
Kotlin
@file:Suppress("NO_REFLECTION_IN_CLASS_PATH")
|
|
|
|
import com.intellij.openapi.application.ApplicationManager
|
|
import com.intellij.openapi.components.Service
|
|
import com.intellij.openapi.project.Project
|
|
|
|
@Service
|
|
class MyAppService {
|
|
companion object {
|
|
@JvmStatic
|
|
fun getInstance(): MyAppService? = ApplicationManager.getApplication().getService(MyAppService::class.java)
|
|
}
|
|
}
|
|
|
|
@Service(Service.Level.PROJECT)
|
|
class MyProjectService {
|
|
companion object {
|
|
@JvmStatic
|
|
fun getInstance(project: Project): MyProjectService? = project.getService(MyProjectService::class.java)
|
|
}
|
|
}
|
|
|
|
fun test(project: Project) {
|
|
ApplicationManager.getApplication().getService(MyAppService::class.java)
|
|
project.getService(MyProjectService::class.java)
|
|
} |