void () { myFixture.addClass("public class MainClass { }"); Project project = getProject(); PsiElement context = JavaPsiFacade.getInstance(project).findPackage(""); JavaCodeFragment fragment = JavaCodeFragmentFactory.getInstance(project).createReferenceCodeFragment("MainClass", context, true, true); Document document = PsiDocumentManager.getInstance(project).getDocument(fragment); Editor editor = EditorFactory.getInstance().createViewer(document, project); Disposer.register(myFixture.getTestRootDisposable(), () -> EditorFactory.getInstance().releaseEditor(editor)); List<HighlightInfo> highlights = CodeInsightTestFixtureImpl.instantiateAndRun(fragment, editor, ArrayUtilRt.EMPTY_INT_ARRAY, false); List<HighlightInfo> problems = DaemonAnalyzerTestCase.filter(highlights, HighlightSeverity.WARNING); assertThat(problems).isEmpty(); }