ApplicationManager.getApplication().executeOnPooledThread(() -> { try { String buildNumber = ApplicationInfo.getInstance().getBuild().asString(); IdeaPluginDescriptor plugin = getPlugin(); String pluginVersion = plugin.getVersion();
@Nullable public static String getDownloadVersions() { String userAgent = String.format("%s / %s / Symfony Plugin %s", ApplicationInfo.getInstance().getVersionName(), ApplicationInfo.getInstance().getBuild(), PluginManager.getPlugin(PluginId.getId("fr.adrienbrault.idea.symfony2plugin")).getVersion() ); try { // @TODO: PhpStorm9: // simple replacement for: com.intellij.util.io.HttpRequests URL url = new URL("https://symfony.com/versions.json"); URLConnection conn = url.openConnection(); conn.setRequestProperty("User-Agent", userAgent); conn.connect(); BufferedReader in = new BufferedReader(new InputStreamReader(conn.getInputStream())); String content = ""; String line; while ((line = in.readLine()) != null) { content += line; } in.close(); return content; } catch (IOException e) { return null; } }
protected String getIdeVersion() { return ApplicationInfo.getInstance().getFullVersion(); }
@NotNull @Override public Response handle(@NotNull RequestMatcher requestMatcher) { InfoDic info = new InfoDic(); info.fullVersion = ApplicationInfo.getInstance().getFullVersion(); info.apiVersion = ApplicationInfo.getInstance().getApiVersion(); info.versionName = ApplicationInfo.getInstance().getVersionName(); info.projects = ProjectIndexHttpAction.getProjects(); info.routes = ContainerUtil.map(RemoteUtil.getRoutes(), route -> new HashMap<String, String>() {{ put("path", route.getPath()); put("method", route.getMethod()); }}); for (IdeaPluginDescriptor descriptor : PluginManager.getPlugins()) { Map<String, String> map = new TreeMap<>(); map.put("name", descriptor.getName()); map.put("version", descriptor.getVersion()); map.put("pluginId", descriptor.getPluginId().getIdString()); info.plugins.add(map); } return new JsonResponse(info); } }
@Override public void initComponent() { applicationInfo = ApplicationInfo.getInstance(); AnalyticsListener.init(); ga = new CustomGoogleAnalytics(TRACKING_ID); ga.getConfig().setValidate(GraphConstants.IS_DEVELOPMENT); sessionStart(); ApplicationManager.getApplication().addApplicationListener(new ApplicationAdapter() { @Override public void applicationExiting() { sessionEnd(); } }); }
private void enrich(GoogleAnalyticsRequest request) { request.clientId(SettingsComponent.getInstance().getUserId()); request.dataSource("plugin"); request.customDimension(1, applicationInfo.getBuild().getProductCode()); // jetbrainsProductCode request.customDimension(2, applicationInfo.getBuild().asStringWithoutProductCode()); // jetbrainsBuildNumber request.customDimension(3, applicationInfo.getFullVersion()); // jetbrainsProductVersion request.customDimension(4, String.valueOf(PluginUtil.isEnabled())); // pluginEnabled request.customDimension(5, PluginUtil.getVersion()); // pluginVersion request.customDimension(6, String.valueOf(GraphConstants.IS_DEVELOPMENT)); // pluginDevelopmentMode }
/** * Constructs a usage tracker configured with analytics and plugin name configured from its * environment. */ public GoogleUsageTrackerService() { analyticsId = UsageTrackingManagementService.getInstance().getAnalyticsProperty(); PluginInfoService pluginInfo = ServiceManager.getService(PluginInfoService.class); externalPluginName = pluginInfo.getExternalPluginName(); userAgent = pluginInfo.getUserAgent(); String intellijPlatformName = PlatformUtils.getPlatformPrefix(); String intellijPlatformVersion = ApplicationInfo.getInstance().getStrictVersion(); String cloudToolsPluginVersion = pluginInfo.getPluginVersion(); Map<String, String> systemMetadataMap = ImmutableMap.of( PLATFORM_NAME_KEY, METADATA_ESCAPER.escape(intellijPlatformName), PLATFORM_VERSION_KEY, METADATA_ESCAPER.escape(intellijPlatformVersion), JDK_VERSION_KEY, METADATA_ESCAPER.escape(JDK_VERSION_VALUE), OPERATING_SYSTEM_KEY, METADATA_ESCAPER.escape(OPERATING_SYSTEM_VALUE), PLUGIN_VERSION_KEY, METADATA_ESCAPER.escape(cloudToolsPluginVersion)); systemMetadataKeyValues = METADATA_JOINER.join(systemMetadataMap); }
@Before public void prepare() { when(powerModeCheck.getAsBoolean()).thenReturn(false); when(type.isBinary()).thenReturn(false); when(testFile.getParent()).thenReturn(mock(VirtualFile.class)); when(testFile.getFileType()).thenReturn(type); when(testFile.isInLocalFileSystem()).thenReturn(true); when(testFile.isValid()).thenReturn(true); when(info.getVersionName()).thenReturn("Intellij IDEA"); super.register(module, ModuleRootManager.class, moduleRootManager); }
private void initializeApplication(Application application) { DefaultPicoContainer pico = new DefaultPicoContainer(); when(application.getPicoContainer()).thenReturn(pico); MessageBus bus = new SingleThreadedMessageBus(null); when(application.getMessageBus()).thenReturn(bus); // Service setup. See ServiceManager pico.registerComponent(service(PasswordSafe.class, new MockPasswordSafe())); pico.registerComponent(service(VcsContextFactory.class, new MockVcsContextFactory())); VirtualFileManager vfm = mock(VirtualFileManager.class); when(application.getComponent(VirtualFileManager.class)).thenReturn(vfm); AccessToken readToken = mock(AccessToken.class); when(application.acquireReadActionLock()).thenReturn(readToken); ApplicationInfo appInfo = mock(ApplicationInfo.class); when(appInfo.getApiVersion()).thenReturn("IC-182.1.1"); registerApplicationService(ApplicationInfo.class, appInfo); }
error.getMessage() == null ? "" : error.getMessage(), error.getDescription() == null ? "" : error.getDescription(), ApplicationInfo.getInstance().getFullVersion(), successCallback, errorCallback);
errorBean, ApplicationManager.getApplication(), (ApplicationInfoEx) ApplicationInfo.getInstance(), ApplicationNamesInfo.getInstance(), super.getPluginDescriptor()
public Result canAnalyze(VirtualFile file, @Nullable Module module) { FileType fileType = file.getFileType(); if (module == null) { return Result.excluded("file is not part of any module in IntelliJ's project structure"); } if (module.isDisposed() || module.getProject().isDisposed()) { return Result.excluded("module is disposed"); } if (!file.isInLocalFileSystem() || fileType.isBinary() || !file.isValid() || ".idea".equals(file.getParent().getName())) { return Result.excluded("file's type or location are not supported"); } // In PHPStorm the same PHP file is analyzed twice (once as PHP file and once as HTML file) String ijFlavor = applicationInfo.getVersionName().toLowerCase(Locale.US); if (ijFlavor.contains("phpstorm") && "html".equalsIgnoreCase(fileType.getName())) { return Result.excluded(null); } return Result.notExcluded(); }
protected String getIdeType() { return ApplicationInfo.getInstance().getBuild().getProductCode(); }
.getKeyValuePairs(bean, ApplicationManager.getApplication(), (ApplicationInfoEx) ApplicationInfo.getInstance(), ApplicationNamesInfo.getInstance());
@NotNull @VisibleForTesting String getCurrentPlatformVersion() { return ApplicationInfo.getInstance().getBuild().asString(); } }
private String getPlatformVersion() { return ApplicationInfo.getInstance().getBuild().asString(); }
static Icon load(String svg, String png) { boolean useSvg = ApplicationInfo.getInstance().getBuild().getBaselineVersion() >= 172; return IconLoader.getIcon(useSvg ? svg : png); } }
public static Icon getToolWindow() { // IntelliJ 2018.2+ has monochrome icons for tool windows so let's use one too if (ApplicationInfo.getInstance().getBuild().getBaselineVersion() >= 182) { return IconLoader.getIcon("/icons/org/antlr/intellij/plugin/toolWindowAntlr.svg"); } return IconLoader.getIcon("/icons/org/antlr/intellij/plugin/antlr.png"); } }
@Override public void run(@NotNull ProgressIndicator indicator) { indicator.setText("Submitting BashSupport error report..."); indicator.setIndeterminate(true); LoggingEventSubmitter submitter = new TextStreamLoggingEventSubmitter(serverUrl); submitter.setPluginId(properties.getProperty(PLUGIN_ID_PROPERTY_KEY)); submitter.setPluginName(properties.getProperty(PLUGIN_NAME_PROPERTY_KEY)); submitter.setPluginVersion(properties.getProperty(PLUGIN_VERSION_PROPERTY_KEY)); submitter.setIdeaBuild(ApplicationInfo.getInstance().getBuild().asString()); submitter.setEmailTo(splitByBlanks(properties.getProperty(EMAIL_TO_PROPERTY_KEY))); submitter.setEmailCc(splitByBlanks(properties.getProperty(EMAIL_CC_PROPERTY_KEY))); try { submitter.submit(stacktrace, description, user); successConsumer.consume(new SubmittedReportInfo(SubmittedReportInfo.SubmissionStatus.NEW_ISSUE)); } catch (LoggingEventSubmitter.SubmitException e) { //ignore } } };
@Override protected void doSingleTest(String fileSuffix, String testDataPath) { enableInspectionTools(inspectionsClasses); try { super.doSingleTest(fileSuffix, testDataPath); } catch (AssertionFailedError e) { // ignore in 163.x // for unknown reasons 163.x sets the file to read-only before executing the test case // this seems like a bug if (ApplicationInfo.getInstance().getBuild().getBaselineVersion() != 163) { throw e; } } }