@Override public void setDefaultParameters( @NotNull Project project, @NotNull VirtualFile virtualFile, @NotNull BackgroundTaskByVfsParameters backgroundTaskByVfsParameters) { Sdk sdk = null; Module module = ModuleUtilCore.findModuleForFile(virtualFile, project); if (module != null) { sdk = ModuleUtilCore.getSdk(module, JavaModuleExtension.class); } if (sdk == null) { sdk = SdkTable.getInstance().findPredefinedSdkByType(JavaSdk.getInstance()); } if (sdk == null) { sdk = SdkTable.getInstance().findMostRecentSdkOfType(JavaSdk.getInstance()); } List<String> parameters = new ArrayList<String>(); if (sdk != null) { GeneralCommandLine generalCommandLine = new GeneralCommandLine(); ((JavaSdkType) sdk.getSdkType()).setupCommandLine(generalCommandLine, sdk); backgroundTaskByVfsParameters.setExePath(generalCommandLine.getExePath()); parameters.addAll(generalCommandLine.getParametersList().getList()); } else { backgroundTaskByVfsParameters.setExePath(SystemInfo.isWindows ? "java.exe" : "java"); } PluginClassLoader classLoader = (PluginClassLoader) JFlexBackgroundTaskProvider.class.getClassLoader(); IdeaPluginDescriptor plugin = PluginManager.getPlugin(classLoader.getPluginId()); assert plugin != null; parameters.add("-jar"); parameters.add(new File(plugin.getPath(), "jflex/jflex.jar").getAbsolutePath()); parameters.add("--charat"); parameters.add("--noconstr"); parameters.add("--nobak"); parameters.add("--skel"); parameters.add(new File(plugin.getPath(), "jflex/idea-flex.skeleton").getAbsolutePath()); parameters.add("$FilePath$"); backgroundTaskByVfsParameters.setProgramParameters(StringUtil.join(parameters, " ")); backgroundTaskByVfsParameters.setWorkingDirectory("$FileParentPath$"); backgroundTaskByVfsParameters.setOutPath("$FileParentPath$"); }
@Nullable public static VirtualFile getPluginVirtualDirectory() { IdeaPluginDescriptor descriptor = PluginManager.getPlugin(PluginId.getId("Lua")); if (descriptor != null) { File pluginPath = descriptor.getPath(); String url = VfsUtil.pathToUrl(pluginPath.getAbsolutePath()); return VirtualFileManager.getInstance().findFileByUrl(url); } return null; }
@NotNull protected String[] getSystemLibraryUrlsImpl( @NotNull Sdk sdk, String name, OrderRootType orderRootType) { if (orderRootType == BinariesOrderRootType.getInstance()) { File libraryByAssemblyName = getLibraryByAssemblyName(name, null); if (libraryByAssemblyName == null) { return ArrayUtil.EMPTY_STRING_ARRAY; } return new String[] { VirtualFileManager.constructUrl( DotNetModuleFileType.PROTOCOL, libraryByAssemblyName.getPath()) + ArchiveFileSystem.ARCHIVE_SEPARATOR }; } else if (orderRootType == DocumentationOrderRootType.getInstance()) { String[] systemLibraryUrls = getSystemLibraryUrls(name, BinariesOrderRootType.getInstance()); if (systemLibraryUrls.length != 1) { return ArrayUtil.EMPTY_STRING_ARRAY; } VirtualFile libraryFile = VirtualFileManager.getInstance().findFileByUrl(systemLibraryUrls[0]); if (libraryFile == null) { return ArrayUtil.EMPTY_STRING_ARRAY; } VirtualFile localFile = ArchiveVfsUtil.getVirtualFileForArchive(libraryFile); if (localFile == null) { return ArrayUtil.EMPTY_STRING_ARRAY; } VirtualFile docFile = localFile.getParent().findChild(localFile.getNameWithoutExtension() + ".xml"); if (docFile != null) { return new String[] {docFile.getUrl()}; } return ArrayUtil.EMPTY_STRING_ARRAY; } else if (orderRootType == ExternalAttributesRootOrderType.getInstance()) { try { final Ref<Couple<String>> ref = Ref.create(); File libraryFile = getLibraryByAssemblyName(name, ref); if (libraryFile == null) { return ArrayUtil.EMPTY_STRING_ARRAY; } assert ref.get() != null; PluginClassLoader classLoader = (PluginClassLoader) getClass().getClassLoader(); IdeaPluginDescriptor plugin = PluginManager.getPlugin(classLoader.getPluginId()); assert plugin != null; File dir = new File(plugin.getPath(), "externalAttributes"); val urls = new SmartList<String>(); val requiredFileName = name + ".xml"; FileUtil.visitFiles( dir, new Processor<File>() { @Override public boolean process(File file) { if (file.isDirectory()) { return true; } if (Comparing.equal(requiredFileName, file.getName(), false) && isValidExternalFile(ref.get().getSecond(), file)) { urls.add(VfsUtil.pathToUrl(file.getPath())); } return true; } }); return ArrayUtil.toStringArray(urls); } catch (Exception e) { LOGGER.error(e); } } return ArrayUtil.EMPTY_STRING_ARRAY; }