public static UsageInfo @NotNull [] removeDuplicatedUsages(UsageInfo @NotNull [] usages) {
    Set<UsageInfo> set = new LinkedHashSet<>(Arrays.asList(usages));

    // Replace duplicates of move rename usage infos in injections from non code usages of master files
    String newTextInNonCodeUsage =
      Arrays.stream(usages)
            .filter(usage -> usage instanceof NonCodeUsageInfo)
            .map(usage -> ((NonCodeUsageInfo)usage).newText)
            .findFirst().orElse(null);

    if (newTextInNonCodeUsage != null) {
      for(UsageInfo usage:usages) {
        if (!(usage instanceof MoveRenameUsageInfo)) continue;
        PsiFile file = usage.getFile();

        if (file != null) {
          PsiElement context = InjectedLanguageManager.getInstance(file.getProject()).getInjectionHost(file);
          if (context != null) {

            PsiElement usageElement = usage.getElement();
            if (usageElement == null) continue;

            PsiReference psiReference = usage.getReference();
            if (psiReference == null) continue;

            int injectionOffsetInMasterFile = InjectedLanguageManager.getInstance(usageElement.getProject()).injectedToHost(usageElement, usageElement.getTextOffset());
            TextRange rangeInElement = usage.getRangeInElement();
            assert rangeInElement != null : usage;
            TextRange range = rangeInElement.shiftRight(injectionOffsetInMasterFile);
            PsiFile containingFile = context.getContainingFile();
            if (containingFile == null) continue; //move package to another package
            set.remove(
              NonCodeUsageInfo.create(
                containingFile,
                range.getStartOffset(),
                range.getEndOffset(),
                ((MoveRenameUsageInfo)usage).getReferencedElement(),
                newTextInNonCodeUsage
              )
            );
          }
        }
      }
    }
    return set.toArray(UsageInfo.EMPTY_ARRAY);
  }
public static UsageInfo @NotNull [] removeDuplicatedUsages(UsageInfo @NotNull [] usages)