|
7 | 7 |
|
8 | 8 | import com.intellij.ide.fileTemplates.FileTemplate;
|
9 | 9 | import com.intellij.ide.fileTemplates.FileTemplateManager;
|
| 10 | +import com.intellij.ide.plugins.IdeaPluginDescriptor; |
| 11 | +import com.intellij.ide.plugins.PluginManagerCore; |
| 12 | +import com.intellij.openapi.application.ApplicationInfo; |
| 13 | +import com.intellij.openapi.extensions.PluginId; |
10 | 14 | import com.intellij.openapi.project.Project;
|
| 15 | +import com.intellij.openapi.util.SystemInfo; |
11 | 16 | import java.io.IOException;
|
12 | 17 | import java.net.URLDecoder;
|
13 | 18 | import java.net.URLEncoder;
|
@@ -76,6 +81,9 @@ private static String buildTemplate(
|
76 | 81 | final Properties properties = new Properties();
|
77 | 82 | properties.setProperty("BUG_DESCRIPTION", bugDescription);
|
78 | 83 | properties.setProperty("STACK_TRACE", stackTrace);
|
| 84 | + properties.setProperty("OS_VERSION", getOsVersion()); |
| 85 | + properties.setProperty("INTELLIJ_VERSION", getIntellijVersion()); |
| 86 | + properties.setProperty("PLUGIN_VERSION", getPluginVersion()); |
79 | 87 |
|
80 | 88 | try {
|
81 | 89 | return errorReportTemplate.getText(properties);
|
@@ -124,4 +132,34 @@ private static String encode(final @NotNull String value) {
|
124 | 132 | private static String decode(final @NotNull String value) {
|
125 | 133 | return URLDecoder.decode(value, StandardCharsets.UTF_8);
|
126 | 134 | }
|
| 135 | + |
| 136 | + /** |
| 137 | + * Get OS version. |
| 138 | + * |
| 139 | + * @return String |
| 140 | + */ |
| 141 | + private static String getOsVersion() { |
| 142 | + return SystemInfo.OS_NAME + " " + SystemInfo.OS_VERSION; |
| 143 | + } |
| 144 | + |
| 145 | + /** |
| 146 | + * Get Intellij Idea version. |
| 147 | + * |
| 148 | + * @return String |
| 149 | + */ |
| 150 | + private static String getIntellijVersion() { |
| 151 | + return ApplicationInfo.getInstance().getFullVersion(); |
| 152 | + } |
| 153 | + |
| 154 | + /** |
| 155 | + * Get plugin version. |
| 156 | + * |
| 157 | + * @return String |
| 158 | + */ |
| 159 | + private static String getPluginVersion() { |
| 160 | + final IdeaPluginDescriptor magento2pluginDescriptor = |
| 161 | + PluginManagerCore.getPlugin(PluginId.getId("com.magento.idea.magento2plugin")); |
| 162 | + |
| 163 | + return magento2pluginDescriptor == null ? null : magento2pluginDescriptor.getVersion(); |
| 164 | + } |
127 | 165 | }
|
0 commit comments