public void fetch(@NotNull final String location) throws DownloadException {
    if (!location.equals(resourceManager.getResourceLocation(location, myProject))) {
      return;
    }

    myProgress.setText(XPathBundle.message("progress.text.downloading", location));

    File file = null;
    try {
      file = HttpRequests.request(location).connect(new HttpRequests.RequestProcessor<>() {
        @Override
        public File process(@NotNull HttpRequests.Request request) throws IOException {
          String name = Integer.toHexString(System.identityHashCode(this)) + "_" +
                        Integer.toHexString(location.hashCode()) + "_" +
                        location.substring(location.lastIndexOf('/') + 1);
          return request.saveToFile(new File(myResourcePath, name.lastIndexOf('.') == -1 ? name + ".xml" : name), myProgress);
        }
      });

      try {
        //noinspection unchecked
        final Set<String>[] resourceDependencies = new Set[1];
        final VirtualFile vf = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(file);
        if (vf != null) {
          PsiFile psiFile = PsiManager.getInstance(myProject).findFile(vf);
          if (psiFile != null && isAccepted(psiFile)) {
            resourceDependencies[0] = getResourceDependencies(psiFile);
            resourceManager.addResource(location, file.getAbsolutePath());
          }
          else {
            ApplicationManager.getApplication().invokeLater(
              () -> Messages.showErrorDialog(myProject,
                                             XPathBundle.message("dialog.message.not.valid.file", vf.getPresentableUrl()),
                                             XPathBundle.message("dialog.title.download.problem")), myProject.getDisposed());
          }
        }

        if (resourceDependencies[0] != null) {
          for (String s : resourceDependencies[0]) {
            myProgress.checkCanceled();
            myProgress.setFraction(0);
            fetch(s);
          }
        }
      }
      catch (Error err) {
        Throwable e = err.getCause();
        if (e instanceof InvocationTargetException) {
          Throwable targetException = ((InvocationTargetException)e).getTargetException();
          ExceptionUtil.rethrowUnchecked(targetException);
          if (targetException instanceof IOException) {
            throw (IOException)targetException;
          }
          if (!(targetException instanceof InterruptedException)) {
            Logger.getInstance(getClass().getName()).error(e);
          }
        }
        else if (!(e instanceof InterruptedException)) {
          throw err;
        }
      }
    }
    catch (IOException e) {
      throw new DownloadException(location, e);
    }
    finally {
      if (file != null && location.equals(resourceManager.getResourceLocation(location, myProject))) {
        // something went wrong. get rid of the file
        FileUtil.delete(file);
      }
    }
  }
public void fetch(@NotNull final String location)