void () { addJavaFile("x/MyTest.java", """ package x; public class MyTest { String foo; {System.out.println(foo);}}"""); ServiceContainerUtil.registerExtension(ApplicationManager.getApplication(), ImplicitUsageProvider.EP_NAME, new ImplicitUsageProvider() { @Override public boolean isImplicitUsage(@NotNull PsiElement element) { return false; } @Override public boolean isImplicitRead(@NotNull PsiElement element) { return false; } @Override public boolean isImplicitWrite(@NotNull PsiElement element) { return element instanceof PsiField && "foo".equals(((PsiField)element).getName()); } }, getTestRootDisposable()); myFixture.configureByFiles("x/MyTest.java"); myFixture.checkHighlighting(); }