void (ImperativeCommand.Environment env) { JavaPsiFacadeEx facade = myFixture.getJavaFacade(); Project project = getProject(); PsiClass psiClass = Objects.requireNonNull(facade.findClass("com.jetbrains.A", GlobalSearchScope.allScope(project))); myFixture.openFileInEditor(psiClass.getContainingFile().getVirtualFile()); MethodBody methodBody = MethodBody.generate(env); PsiClass aClass = WriteCommandAction.runWriteCommandAction(project, (Computable<PsiClass>)() -> recreateClass(facade.getElementFactory(), psiClass)); JavaContext javaContext = JavaContext.create(aClass, facade); WriteCommandAction.runWriteCommandAction(project, () -> methodBody.add(javaContext)); env.logMessage("A class:\n" + aClass.getText()); TaintState taintState = methodBody.taintState(); List<HighlightInfo> infos = myFixture.doHighlighting(HighlightSeverity.WEAK_WARNING); if (infos.size() == 1) { HighlightInfo info = infos.get(0); if (info.getDescription().equals(JvmAnalysisBundle.message("jvm.inspections.source.to.sink.flow.too.complex"))) { return; } } if (taintState == TaintState.SAFE) { assertEmpty(infos); } else { assertSize(1, infos); PsiElement sinkArgument = javaContext.getSinkCallArgument(); HighlightInfo info = infos.get(0); assertEquals(sinkArgument.getTextRange().getStartOffset(), info.getActualStartOffset()); String description = JvmAnalysisBundle.message(taintState == TaintState.TAINTED ? "jvm.inspections.source.to.sink.flow.passed.unsafe" : "jvm.inspections.source.to.sink.flow.passed.unknown"); assertEquals(description, info.getDescription()); } }