package org.editorconfig;

import com.intellij.openapi.project.Project;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.codeStyle.CodeStyleSettings;
import org.editorconfig.core.EditorConfig.OutPair;
import org.editorconfig.plugincomponents.EditorConfigNotifier;
import org.editorconfig.settings.EditorConfigSettings;

import java.util.List;

public class Utils {
  public static String configValueForKey(List<OutPair> outPairs, String key) {
    for (OutPair outPair : outPairs) {
      if (outPair.getKey().equals(key)) {
        return outPair.getVal();
      }
    }
    return "";
  }

  public static boolean isEnabled(CodeStyleSettings currentSettings) {
    return currentSettings.getCustomSettings(EditorConfigSettings.class).ENABLED;
  }

  public static void invalidConfigMessage(Project project, String configValue, String configKey, String filePath) {
    EditorConfigNotifier.getInstance().error(project, configValue, "\"" + configValue + "\" is not a valid value" + (!configKey.isEmpty() ? " for " + configKey : "") + " for file " + filePath);
  }

  public static String getFilePath(Project project, VirtualFile file) {
    if (!file.isInLocalFileSystem()) {
      return project.getBasePath() + "/" + file.getNameWithoutExtension() + "." + file.getFileType().getDefaultExtension();
    }
    return file.getCanonicalPath();
  }
}

@@ -887,70 +887,80 @@
     
-EditorConfigNotifier.getInstance().error(project, configValue,
+final String message = configValue != null ?%0A                           
  %22%5C%22
@@ -1080,16 +1080,223 @@
 filePath
+ :%0A                            %22Failed to read .editorconfig file%22;%0A    configValue = configValue != null ? configValue : %22ioError%22;%0A    EditorConfigNotifier.getInstance().error(project, configValue, message
 );%0A  %7D%0A%0A

fix NPE in notification on IOError #WEB-14085 fixed