@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; } }
@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); }
@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); } }
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(); }