@Nullable
  @Override
  public String getEncoding(@NotNull File file) {
    if (isXmlFile(file)) {
      try {
        String encoding = XmlCharsetDetector.extractXmlEncodingFromProlog(FileUtil.loadFileBytes(file));
        if (encoding != null) {
          return encoding;
        }
      }
      catch (IOException e) {
        LOG.info("Cannot detect encoding for xml file " + file.getAbsolutePath(), e);
      }
    }

    if (!myUrlToEncoding.isEmpty()) {

      File current = file;
      while (current != null) {
        String encoding = myUrlToEncoding.get(JpsPathUtil.pathToUrl(FileUtilRt.toSystemIndependentName(current.getPath())));

        if (encoding != null) {
          return encoding;
        }

        current = FileUtilRt.getParentFile(current);
      }
    }

    if (myProjectEncoding != null) {
      return myProjectEncoding;
    }

    final JpsModel model = getModel();
    assert model != null;
    return JpsEncodingConfigurationService.getInstance().getGlobalEncoding(model.getGlobal());
  }
@Nullable
  @Override
  public String getEncoding(@NotNull File file)