mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-02 07:28:24 +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
25 lines
777 B
Java
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);
|
|
}
|
|
} |