void (ReferenceData @NotNull [] referenceData, PsiJavaCodeReferenceElement @NotNull [] refs, @NotNull Set<? super String> imported) { for (int i = 0; i < refs.length; i++) { PsiJavaCodeReferenceElement reference = refs[i]; if (reference == null || !reference.isValid()) continue; try { PsiManager manager = reference.getManager(); ReferenceData refData = referenceData[i]; ProgressManager.progress2(refData.qClassName); PsiClass refClass = JavaPsiFacade.getInstance(manager.getProject()).findClass(refData.qClassName, reference.getResolveScope()); if (refClass != null) { if (refData.staticMemberName == null) { if (reference instanceof PsiJavaCodeReferenceElementImpl && ((PsiJavaCodeReferenceElementImpl)reference).getKindEnum(reference.getContainingFile()) == PsiJavaCodeReferenceElementImpl.Kind.PACKAGE_NAME_KIND) { // Trying to paste class reference into e.g. package statement continue; } reference.bindToElement(refClass); imported.add(refData.qClassName); } else { LOG.assertTrue(reference instanceof PsiReferenceExpression); ((PsiReferenceExpression)reference).bindToElementViaStaticImport(refClass); imported.add(StringUtil.getQualifiedName(refData.qClassName, refData.staticMemberName)); } } } catch (IncorrectOperationException e) { LOG.error(e); } } }