void (@NotNull AnActionEvent e) { final Project project = e.getProject(); if (project == null) { return; } final MultiMap<String, PsiExpression> calls = new MultiMap<>(); final JavaPsiFacade psiFacade = JavaPsiFacade.getInstance(project); Processor<PsiReference> consumer = new Processor<>() { @Override public boolean process(PsiReference reference) { PsiCallExpression call = PsiTreeUtil.getParentOfType(reference.getElement(), PsiCallExpression.class, false); if (call == null) return true; if (call.getArgumentList() == null) return true; PsiFile file = reference.getElement().getContainingFile(); if ("AllIcons.java".equals(file.getName())) return true; PsiClass container = PsiUtil.getTopLevelClass(reference.getElement()); if (container != null && container.getQualifiedName().startsWith("icons.")) { return true; } for (PsiExpression arg : call.getArgumentList().getExpressions()) { Object value; if (arg instanceof PsiLiteralExpression) { value = ((PsiLiteralExpression)arg).getValue(); } else { value = psiFacade.getConstantEvaluationHelper().computeConstantExpression(arg, false); } processValue(value, call, file); } return true; } private void processValue(Object value, PsiCallExpression call, PsiFile file) { if (value instanceof String) { String str = StringUtil.unquoteString((String)value, '\"'); if (!str.startsWith("/")) { if (file instanceof PsiClassOwner) { str = "/" + ((PsiClassOwner)file).getPackageName().replace('.', '/') + "/" + str; } } calls.putValue(str, call); } } }; GlobalSearchScope allScope = GlobalSearchScope.allScope(project); PsiClass iconLoader = psiFacade.findClass("com.intellij.openapi.util.IconLoader", allScope); PsiMethod getIconMethod = iconLoader.findMethodsByName("getIcon", false)[0]; PsiMethod findIconMethod = iconLoader.findMethodsByName("findIcon", false)[0]; MethodReferencesSearch.search(getIconMethod, false).forEach(consumer); MethodReferencesSearch.search(findIconMethod, false).forEach(consumer); final ProjectFileIndex index = ProjectRootManager.getInstance(project).getFileIndex(); PsiClass javaeeIcons = psiFacade.findClass("com.intellij.javaee.JavaeeIcons", allScope); MethodReferencesSearch.search(javaeeIcons.findMethodsByName("getIcon", false)[0], false).forEach(consumer); MethodReferencesSearch.search(findIconMethod, false).forEach(consumer); final List<XmlAttribute> xmlAttributes = new ArrayList<>(); PsiSearchHelper.getInstance(project).processAllFilesWithWordInText( "icon", new DelegatingGlobalSearchScope(GlobalSearchScope.projectScope(project)) { @Override public boolean contains(@NotNull VirtualFile file) { return super.contains(file) && FileTypeRegistry.getInstance().isFileOfType(file, XmlFileType.INSTANCE) && index.isInSource(file); } }, new Processor<>() { @Override public boolean process(PsiFile file) { file.accept(new XmlRecursiveElementVisitor() { @Override public void visitXmlTag(@NotNull XmlTag tag) { super.visitXmlTag(tag); String icon = tag.getAttributeValue("icon"); if (icon != null) { xmlAttributes.add(tag.getAttribute("icon")); } } }); return true; } }, true ); PsiClass presentation = psiFacade.findClass("com.intellij.ide.presentation.Presentation", allScope); final MultiMap<String, PsiAnnotation> annotations = new MultiMap<>(); AnnotationTargetsSearch.search(presentation).forEach(owner -> { PsiAnnotation annotation = owner.getModifierList().findAnnotation("com.intellij.ide.presentation.Presentation"); PsiAnnotationMemberValue icon = annotation.findAttributeValue("icon"); if (icon instanceof PsiLiteralExpression) { Object value = ((PsiLiteralExpression)icon).getValue(); if (value instanceof String) { annotations.putValue((String)value, annotation); } } return true; }); doReplacements(project, calls, xmlAttributes, annotations, psiFacade.findClass("com.intellij.icons.AllIcons", allScope)); for (PsiClass iconClass : psiFacade.findPackage("icons").getClasses(allScope)) { if (iconClass.getName().endsWith("Icons")) { doReplacements(project, calls, xmlAttributes, annotations, iconClass); } } }