UsageGroup (@NotNull Usage usage, UsageTarget @NotNull [] targets) { if (usage instanceof UsageWithType) { UsageType usageType = ((UsageWithType)usage).getUsageType(); return usageType == null ? null : new UsageTypeGroup(usageType); } if (usage instanceof PsiElementUsage elementUsage) { PsiElement element = elementUsage.getElement(); UsageType usageType = getUsageType(element, targets); if (usageType == null && element instanceof PsiFile && elementUsage instanceof UsageInfo2UsageAdapter) { usageType = ((UsageInfo2UsageAdapter)elementUsage).getUsageType(); } if (usageType != null) return new UsageTypeGroup(usageType); if (usage instanceof ReadWriteAccessUsage u) { if (u.isAccessedForWriting()) return new UsageTypeGroup(UsageType.WRITE); if (u.isAccessedForReading()) return new UsageTypeGroup(UsageType.READ); } return new UsageTypeGroup(UsageType.UNCLASSIFIED); } return null; }