void (@NotNull List<String> args) { StringBuilder xml = new StringBuilder(); xml.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n").append("<Keymaps>\n"); KeymapManagerEx keyManager = KeymapManagerEx.getInstanceEx(); Set<String> boundActions = keyManager.getBoundActions(); for (Keymap keymap : keyManager.getAllKeymaps()) { xml.append(LEVELS[0]).append("<Keymap name=\"").append(keymap.getPresentableName()).append("\">\n"); Set<String> alreadyMapped = Sets.newHashSet(keymap.getActionIdList()); alreadyMapped.forEach(id -> { renderAction(id, null, keymap.getShortcuts(id), xml); }); //We need to inject bound actions under their real names in every keymap that doesn't already have them. boundActions.forEach(id -> { final String binding = keyManager.getActionBinding(id); if (binding != null && !alreadyMapped.contains(id)) { renderAction(binding, id, keymap.getShortcuts(binding), xml); } }); xml.append(LEVELS[0]).append("</Keymap>\n"); } xml.append("</Keymaps>"); Path targetFilePath = Paths.get(args.size() > 1 ? args.get(1) : PathManager.getHomePath()) .resolve( "keymap-%s.xml".formatted(ApplicationInfoEx.getInstanceEx().getApiVersionAsNumber().getProductCode().toLowerCase(Locale.ROOT))); try { FileUtil.writeToFile(targetFilePath.toFile(), xml.toString()); LOG.info("Keymaps saved to: " + targetFilePath.toAbsolutePath()); } catch (IOException e) { LOG.error("Cannot save keymaps", e); System.exit(1); } System.exit(0); }