void (@NotNull List<String> args) { final int size = args.size(); if (size != 2) { LOG.error("Usage: %s <output directory>".formatted(getCommandName())); System.exit(-1); } ApplicationInfo appInfo = ApplicationInfo.getInstance(); String IDE_CODE = appInfo.getBuild().getProductCode().toLowerCase(Locale.getDefault()); String IDE_NAME = appInfo.getVersionName(); String IDE_VERSION = appInfo.getShortVersion(); String ASSET_FILENAME = IDE_CODE + "-inspections."; final String outputDirectory = args.get(1); final Path rootOutputPath = Path.of(outputDirectory).toAbsolutePath(); final Path outputPath = rootOutputPath.resolve(IDE_CODE); try { Files.createDirectories(outputPath); } catch (IOException e) { LOG.error("Output directory does not exist and could not be created"); System.exit(-1); } if (!Files.exists(outputPath) || !Files.isDirectory(outputPath) || !Files.isWritable(outputPath)) { LOG.error("Output path is invalid"); System.exit(-1); } try { final Project project = ProjectManager.getInstance().getDefaultProject(); LOG.info("Using project " + project.getName() + ", default: " + project.isDefault()); final InspectionProjectProfileManager inspectionManager = InspectionProjectProfileManager.getInstance(project); final List<ScopeToolState> scopeToolStates = inspectionManager.getCurrentProfile().getAllTools(); final Map<String, Plugin> availablePlugins = Arrays.stream(PluginManager.getPlugins()).map( pluginDescriptor -> new Plugin(pluginDescriptor.getPluginId().getIdString(), pluginDescriptor.getName(), pluginDescriptor.getVersion())).distinct() .collect(Collectors.toMap(Plugin::getId, plugin -> plugin)); availablePlugins.put(IDE_NAME, new Plugin(IDE_NAME, IDE_NAME, IDE_VERSION)); for (final ScopeToolState scopeToolState : scopeToolStates) { final InspectionToolWrapper<?, ?> wrapper = scopeToolState.getTool(); final InspectionEP extension = wrapper.getExtension(); final String pluginId = extension == null ? IDE_NAME : extension.getPluginDescriptor().getPluginId().getIdString(); final String originalDescription = wrapper.loadDescription(); final String[] description = originalDescription == null ? new String[]{""} : originalDescription.split("<!-- tooltip end -->"); List<OptionsPanelInfo> panelInfo = null; try { InspectionProfileEntry tool = wrapper.getTool(); final OptPane panel = tool.getOptionsPane(); if (!panel.equals(OptPane.EMPTY)) { LOG.info("Saving options panel for " + wrapper.getShortName()); panelInfo = retrievePanelStructure(panel, tool.getOptionController()); } } catch (Throwable t) { LOG.info("Cannot create options panel " + wrapper.getShortName(), t); } final String language = wrapper.getLanguage(); final String briefDescription = HtmlUtils.cleanupHtml(description[0], language); final String extendedDescription = description.length > 1 ? HtmlUtils.cleanupHtml(description[1], language) : null; final Inspection inspection = new Inspection(wrapper.getShortName(), wrapper.getDisplayName(), wrapper.getDefaultLevel().getName(), language, briefDescription, extendedDescription, Arrays.asList(wrapper.getGroupPath()), wrapper.applyToDialects(), wrapper.isCleanupTool(), wrapper.isEnabledByDefault(), panelInfo); availablePlugins.get(pluginId).addInspection(inspection); } var sortedPlugins = availablePlugins.values().stream() .sorted(Comparator.comparing(Plugin::getId)) .peek(plugin -> { plugin.inspections.sort(null); }).toList(); final Plugins pluginsData = new Plugins(sortedPlugins, IDE_CODE, IDE_NAME, IDE_VERSION); for (final String ext : ASSETS.keySet()) { String data = ""; try { data = ASSETS.get(ext).writeValueAsString(pluginsData); } catch (JsonProcessingException e) { LOG.error("Cannot serialize " + ext.toUpperCase(Locale.getDefault()), e); System.exit(-1); } final Path outPath = outputPath.resolve(ASSET_FILENAME + ext); try { Files.writeString(outPath, data); } catch (IOException e) { LOG.error("Cannot write " + outPath, e); System.exit(-1); } LOG.info("Inspections info saved in " + outPath); } } catch (Exception e) { LOG.error(e.getMessage(), e); System.exit(-1); } System.exit(0); }