Search in sources :

Example 51 with PluginId

use of com.intellij.openapi.extensions.PluginId in project google-cloud-intellij by GoogleCloudPlatform.

the class GoogleFeedbackErrorReporter method configureErrorFromEvent.

private static void configureErrorFromEvent(IdeaLoggingEvent event, ErrorBean error) {
    Throwable throwable = event.getThrowable();
    if (throwable != null) {
        PluginId pluginId = IdeErrorsDialog.findPluginId(throwable);
        if (pluginId != null) {
            IdeaPluginDescriptor ideaPluginDescriptor = PluginManager.getPlugin(pluginId);
            if (ideaPluginDescriptor != null && !ideaPluginDescriptor.isBundled()) {
                error.setPluginName(ideaPluginDescriptor.getName());
                error.setPluginVersion(ideaPluginDescriptor.getVersion());
            }
        }
    }
    Object data = event.getData();
    if (data instanceof AbstractMessage) {
        error.setAttachments(((AbstractMessage) data).getIncludedAttachments());
    }
}
Also used : AbstractMessage(com.intellij.diagnostic.AbstractMessage) IdeaPluginDescriptor(com.intellij.ide.plugins.IdeaPluginDescriptor) PluginId(com.intellij.openapi.extensions.PluginId)

Example 52 with PluginId

use of com.intellij.openapi.extensions.PluginId in project phpinspectionsea by kalessil.

the class UnknownInspectionInspector method collectKnownInspections.

private static Set<String> collectKnownInspections() {
    final Set<String> names = new HashSet<>();
    final PluginId phpSupport = PluginId.getId("com.jetbrains.php");
    for (IdeaPluginDescriptor plugin : PluginManager.getPlugins()) {
        /* check plugins' dependencies and extensions */
        /* we have to rely on impl-class, see  */
        final MultiMap<String, Element> extensions = ((IdeaPluginDescriptorImpl) plugin).getExtensions();
        final boolean isPhpPlugin = plugin.getPluginId().equals(phpSupport);
        if (null == extensions || (!ArrayUtils.contains(plugin.getDependentPluginIds(), phpSupport)) && !isPhpPlugin) {
            continue;
        }
        /* extract inspections; short names */
        for (Element node : extensions.values()) {
            final String nodeName = node.getName();
            if (null == nodeName || !nodeName.equals("localInspection")) {
                continue;
            }
            final Attribute name = node.getAttribute("shortName");
            final String shortName = null == name ? null : name.getValue();
            if (null != shortName && shortName.length() > 0) {
                names.add(shortName);
            }
        }
    }
    return names;
}
Also used : Attribute(org.jdom.Attribute) PsiElement(com.intellij.psi.PsiElement) Element(org.jdom.Element) IdeaPluginDescriptor(com.intellij.ide.plugins.IdeaPluginDescriptor) PluginId(com.intellij.openapi.extensions.PluginId) HashSet(java.util.HashSet) IdeaPluginDescriptorImpl(com.intellij.ide.plugins.IdeaPluginDescriptorImpl)

Example 53 with PluginId

use of com.intellij.openapi.extensions.PluginId in project psiviewer by cmf.

the class YouTrackBugReporter method submit.

private SubmittedReportInfo submit(IdeaLoggingEvent[] ideaLoggingEvents, String description, String user, Component component) {
    this.description = ideaLoggingEvents[0].getThrowableText().substring(0, Math.min(Math.max(80, ideaLoggingEvents[0].getThrowableText().length()), 80));
    this.email = user;
    @NonNls StringBuilder descBuilder = new StringBuilder();
    String platformBuild = ApplicationInfo.getInstance().getBuild().asString();
    descBuilder.append("Platform Version: ").append(platformBuild).append('\n');
    Throwable t = ideaLoggingEvents[0].getThrowable();
    if (t != null) {
        final PluginId pluginId = IdeErrorsDialog.findPluginId(t);
        if (pluginId != null) {
            final IdeaPluginDescriptor ideaPluginDescriptor = PluginManager.getPlugin(pluginId);
            if (ideaPluginDescriptor != null && !ideaPluginDescriptor.isBundled()) {
                descBuilder.append("Plugin ").append(ideaPluginDescriptor.getName()).append(" version: ").append(ideaPluginDescriptor.getVersion()).append("\n");
                this.affectedVersion = ideaPluginDescriptor.getVersion();
            }
        }
    }
    if (user == null)
        user = "<none>";
    if (description == null)
        description = "<none>";
    descBuilder.append("\n\nDescription: ").append(description).append("\n\nUser: ").append(user);
    for (IdeaLoggingEvent e : ideaLoggingEvents) descBuilder.append("\n\n").append(e.toString());
    this.extraInformation = descBuilder.toString();
    String result = submit();
    log.info("Error submitted, response: " + result);
    if (result == null)
        return new SubmittedReportInfo(SERVER_ISSUE_URL, "", FAILED);
    String ResultString = null;
    try {
        Pattern regex = Pattern.compile("id=\"([^\"]+)\"", Pattern.DOTALL | Pattern.MULTILINE);
        Matcher regexMatcher = regex.matcher(result);
        if (regexMatcher.find()) {
            ResultString = regexMatcher.group(1);
        }
    } catch (PatternSyntaxException ex) {
    // Syntax error in the regular expression
    }
    SubmittedReportInfo.SubmissionStatus status = NEW_ISSUE;
    if (ResultString == null)
        return new SubmittedReportInfo(SERVER_ISSUE_URL, "", FAILED);
    return new SubmittedReportInfo(SERVER_URL + "issue/" + ResultString, ResultString, status);
}
Also used : NonNls(org.jetbrains.annotations.NonNls) Pattern(java.util.regex.Pattern) Matcher(java.util.regex.Matcher) IdeaPluginDescriptor(com.intellij.ide.plugins.IdeaPluginDescriptor) PluginId(com.intellij.openapi.extensions.PluginId) IdeaLoggingEvent(com.intellij.openapi.diagnostic.IdeaLoggingEvent) SubmittedReportInfo(com.intellij.openapi.diagnostic.SubmittedReportInfo) PatternSyntaxException(java.util.regex.PatternSyntaxException)

Example 54 with PluginId

use of com.intellij.openapi.extensions.PluginId in project intellij-plugins by StepicOrg.

the class PluginUtils method getVersion.

@NotNull
public static String getVersion() {
    PluginId pluginId = PluginId.getId(PLUGIN_ID);
    IdeaPluginDescriptor plugin = PluginManager.getPlugin(pluginId);
    return plugin != null ? plugin.getVersion() : DEFAULT_PLUGIN_VERSION;
}
Also used : IdeaPluginDescriptor(com.intellij.ide.plugins.IdeaPluginDescriptor) PluginId(com.intellij.openapi.extensions.PluginId) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

PluginId (com.intellij.openapi.extensions.PluginId)54 IdeaPluginDescriptor (com.intellij.ide.plugins.IdeaPluginDescriptor)25 NotNull (org.jetbrains.annotations.NotNull)10 IOException (java.io.IOException)8 IdeaLoggingEvent (com.intellij.openapi.diagnostic.IdeaLoggingEvent)6 Project (com.intellij.openapi.project.Project)6 Nullable (org.jetbrains.annotations.Nullable)6 SubmittedReportInfo (com.intellij.openapi.diagnostic.SubmittedReportInfo)5 PluginException (com.intellij.diagnostic.PluginException)4 DataContext (com.intellij.openapi.actionSystem.DataContext)4 NonNls (org.jetbrains.annotations.NonNls)4 ErrorBean (com.intellij.errorreport.bean.ErrorBean)3 EmptyProgressIndicator (com.intellij.openapi.progress.EmptyProgressIndicator)3 PluginDownloader (com.intellij.openapi.updateSettings.impl.PluginDownloader)3 VirtualFile (com.intellij.openapi.vfs.VirtualFile)3 File (java.io.File)3 AbstractMessage (com.intellij.diagnostic.AbstractMessage)2 LogMessageEx (com.intellij.diagnostic.LogMessageEx)2 CantRunException (com.intellij.execution.CantRunException)2 DataManager (com.intellij.ide.DataManager)2