Files
Andrey Cherkasovandintellij-monorepo-bot 7bef3fb7b8 [devkit] Simplifiable service retrieving: fix false positives
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
2023-11-29 13:31:50 +00:00

25 lines
777 B
Java

import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.components.Service;
import org.jetbrains.annotations.Nullable;
@Service
final class MyAppService {
public static @Nullable MyAppService getInstance() {
return ApplicationManager.getApplication().getService(MyAppService.class);
}
void foo() {
MyAppService service = ApplicationManager.getApplication().getService(MyAppService.class);
}
}
@Service(Service.Level.PROJECT)
final class MyProjectService {
public static @Nullable MyProjectService getInstance() {
return ApplicationManager.getApplication().getService(MyProjectService.class);
}
void foo() {
MyProjectService service = ApplicationManager.getApplication().getService(MyProjectService.class);
}
}