void (PsiFile file, final String ... expectedUnresolved) { final List<String> actualUnresolved = new ArrayList<>(); final StringBuilder sb = new StringBuilder(); final String text = file.getText(); final Ref<Integer> lastUnresolvedRef = Ref.create(0); file.acceptChildren(new PsiRecursiveElementVisitor() { @Override public void visitElement(@NotNull PsiElement element) { if (element instanceof GrReferenceExpression psiReference) { GrExpression qualifier = psiReference.getQualifierExpression(); if (qualifier instanceof GrReferenceExpression) { if (((GrReferenceExpression)qualifier).resolve() == null) { super.visitElement(element); return; } } if (psiReference.resolve() == null) { CollectConsumer<PomTarget> consumer = new CollectConsumer<>(); for (PomDeclarationSearcher searcher : PomDeclarationSearcher.EP_NAME.getExtensions()) { searcher.findDeclarationsAt(psiReference, 0, consumer); if (consumer.getResult().size() > 0) break; } if (consumer.getResult().isEmpty()) { PsiElement nameElement = psiReference.getReferenceNameElement(); assert nameElement != null; String name = nameElement.getText(); assert name.equals(psiReference.getReferenceName()); int last = lastUnresolvedRef.get(); sb.append(text, last, nameElement.getTextOffset()); sb.append('!').append(name).append('!'); lastUnresolvedRef.set(nameElement.getTextOffset() + nameElement.getTextLength()); actualUnresolved.add(name); return; } } } super.visitElement(element); } @Override public void visitFile(@NotNull PsiFile file) { } }); sb.append("\n\n"); Assert.assertEquals(sb.toString(), Arrays.asList(expectedUnresolved), actualUnresolved); }