Skip to content

Diagnostic improvement #593

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 14, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,12 @@ If applicable, add screenshots to help explain your problem.

**Please complete the following information:** (*)

- OS: [e.g. MacOS or Ubuntu Linux 20.04]
- PhpStorm/Intellij version: [e.g. 2019.3.3]
- Plugin Version: [e.g. 1.0.0]
#set($os = "#if(${OS_VERSION})${OS_VERSION}#else[e.g. MacOS or Ubuntu Linux 20.04]#end")
#set($intellijVersion = "#if(${INTELLIJ_VERSION})${INTELLIJ_VERSION}#else[e.g. 2019.3.3]#end")
#set($pluginVersion = "#if(${PLUGIN_VERSION})${PLUGIN_VERSION}#else[e.g. 1.0.0]#end")
- OS: $os
- PhpStorm/Intellij version: $intellijVersion
- Plugin Version: $pluginVersion

**Additional context**

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,12 @@

import com.intellij.ide.fileTemplates.FileTemplate;
import com.intellij.ide.fileTemplates.FileTemplateManager;
import com.intellij.ide.plugins.IdeaPluginDescriptor;
import com.intellij.ide.plugins.PluginManagerCore;
import com.intellij.openapi.application.ApplicationInfo;
import com.intellij.openapi.extensions.PluginId;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.SystemInfo;
import java.io.IOException;
import java.net.URLDecoder;
import java.net.URLEncoder;
Expand Down Expand Up @@ -76,6 +81,9 @@ private static String buildTemplate(
final Properties properties = new Properties();
properties.setProperty("BUG_DESCRIPTION", bugDescription);
properties.setProperty("STACK_TRACE", stackTrace);
properties.setProperty("OS_VERSION", getOsVersion());
properties.setProperty("INTELLIJ_VERSION", getIntellijVersion());
properties.setProperty("PLUGIN_VERSION", getPluginVersion());

try {
return errorReportTemplate.getText(properties);
Expand Down Expand Up @@ -124,4 +132,34 @@ private static String encode(final @NotNull String value) {
private static String decode(final @NotNull String value) {
return URLDecoder.decode(value, StandardCharsets.UTF_8);
}

/**
* Get OS version.
*
* @return String
*/
private static String getOsVersion() {
return SystemInfo.OS_NAME + " " + SystemInfo.OS_VERSION;
}

/**
* Get Intellij Idea version.
*
* @return String
*/
private static String getIntellijVersion() {
return ApplicationInfo.getInstance().getFullVersion();
}

/**
* Get plugin version.
*
* @return String
*/
private static String getPluginVersion() {
final IdeaPluginDescriptor magento2pluginDescriptor =
PluginManagerCore.getPlugin(PluginId.getId("com.magento.idea.magento2plugin"));

return magento2pluginDescriptor == null ? null : magento2pluginDescriptor.getVersion();
}
}