UsageGroup (@NotNull Usage usage, UsageTarget @NotNull [] targets) { if (!(usage instanceof PsiElementUsage elementUsage)) { return null; } PsiElement element = elementUsage.getElement(); VirtualFile virtualFile = PsiUtilCore.getVirtualFile(element); if (virtualFile == null) { return null; } Project project = element.getProject(); ProjectFileIndex fileIndex = ProjectRootManager.getInstance(project).getFileIndex(); boolean isInLib = fileIndex.isInLibrary(virtualFile); if (isInLib) return LIBRARY; return TestSourcesFilter.isTestSources(virtualFile, project) ? TEST : PRODUCTION; }