void () { String barStr = "class Bar {}"; PsiFile file = addFileToProject("Foo.java", "class Foo {{" + "}}"); JBIterable<PsiClass> barQuery = SyntaxTraverser.psiTraverser(file).filter(PsiClass.class).filter(o -> "Bar".equals(o.getName())); assertNull(barQuery.first()); Document document = PsiDocumentManager.getInstance(getProject()).getDocument(file); int index = document.getText().indexOf("}