// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.codeInspection.ex;

import com.intellij.codeInspection.ProjectDescriptionUtilKt;
import com.intellij.openapi.project.Project;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;

public class StaticAnalysisReportConverter extends JsonInspectionsReportConverter {
  @Override
  public String getFormatName() {
    return "sa";
  }

  @Override
  public void projectData(@NotNull Project project, @Nullable String outputPath) throws ConversionException {
    if (outputPath == null) return;
    ProjectDescriptionUtilKt.writeProjectDescription(Paths.get(outputPath).resolve("projectStructure.json"), project);
    writeInspectionsMeta(Paths.get(outputPath).resolve("inspectionsMeta.json"));
  }

  private static void writeInspectionsMeta(Path target) throws ConversionException {
    Path meta = Paths.get("inspectionsMeta.json");
    if (Files.notExists(meta)) return;
    try {
      Files.copy(meta, target);
    }
    catch (IOException e) {
      throw new ConversionException(e);
    }
  }
}

@@ -1087,52 +1087,139 @@
     
-Path meta = Paths.get(%22inspectionsMeta.json%22
+String path = System.getProperty(%22inspection.external.metafile.path%22);%0A    if (path == null) return;%0A    Path meta = Paths.get(path
 );%0A 

add external metainfo to inspections reporter