Java Code Examples for com.intellij.openapi.roots.impl.libraries.ProjectLibraryTable#getInstance()
The following examples show how to use
com.intellij.openapi.roots.impl.libraries.ProjectLibraryTable#getInstance() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: HaxelibUtil.java From intellij-haxe with Apache License 2.0 | 6 votes |
/** * Get the list of libraries specified on the project. Managed haxelib * (of the form "haxelib|<lib_name>") libraries are included unless * filterManagedLibs is true. * * * @param project to get the classpath for. * @return a (possibly empty) list of the classpaths for all of the libraries * that are specified on the project (in the library pane). */ @NotNull public static HaxeLibraryList getProjectLibraries(@NotNull Project project, boolean filterManagedLibs, boolean filterUnmanagedLibs) { LibraryTable libraryTable = ProjectLibraryTable.getInstance(project); if (null == libraryTable || (filterManagedLibs && filterUnmanagedLibs)) { return new HaxeLibraryList(HaxelibSdkUtils.lookupSdk(project)); } HaxeLibraryList libs = new HaxeLibraryList(HaxelibSdkUtils.lookupSdk(project)); Library[] libraries = libraryTable.getLibraries(); for (Library library : libraries) { String name = library.getName(); if (name == null) continue; boolean isManaged = HaxelibNameUtil.isManagedLibrary(name); if (filterManagedLibs && isManaged) continue; if (filterUnmanagedLibs && !isManaged) continue; libs.add(HaxeLibraryReference.create(project, name)); } return libs; }
Example 2
Source File: LibraryEditor.java From intellij with Apache License 2.0 | 5 votes |
private static void updateLibraryDependency(ModifiableRootModel model, LibraryKey libraryKey) { LibraryTable libraryTable = ProjectLibraryTable.getInstance(model.getProject()); Library library = libraryTable.getLibraryByName(libraryKey.getIntelliJLibraryName()); if (library == null) { logger.error( "Library missing: " + libraryKey.getIntelliJLibraryName() + ". Please resync project to resolve."); return; } model.addLibraryEntry(library); }
Example 3
Source File: LibraryActionHelper.java From intellij with Apache License 2.0 | 5 votes |
@Nullable static Library findLibraryForAction(AnActionEvent e) { Project project = e.getProject(); if (project != null) { NamedLibraryElementNode node = findLibraryNode(e.getDataContext()); if (node != null) { String libraryName = node.getName(); if (StringUtil.isNotEmpty(libraryName)) { LibraryTable libraryTable = ProjectLibraryTable.getInstance(project); return libraryTable.getLibraryByName(libraryName); } } } return null; }
Example 4
Source File: HaxelibClasspathUtils.java From intellij-haxe with Apache License 2.0 | 5 votes |
/** * Gets the libraries specified for the IDEA project; source paths and * class paths for project libraries excepting those named "haxelib|<lib_name>". * * @param project a project to get the class path settings for. * @return a list of class path URLs. */ @NotNull public static HaxeClasspath getUnmanagedProjectLibraryClasspath(@NotNull Project project) { LibraryTable libraryTable = ProjectLibraryTable.getInstance(project); if (null == libraryTable) return HaxeClasspath.EMPTY_CLASSPATH; HaxeClasspath classpath = new HaxeClasspath(); Library[] libraries = libraryTable.getLibraries(); for (Library library : libraries) { // // This is checking that the library name doesn't match "haxelib|lib_name". // That is, if it /is/ a haxelib entry, ignore it; grab the classpaths for // libs that aren't haxelibs. // if (!HaxelibNameUtil.isManagedLibrary(library.getName())) { OrderRootType interestingRootTypes[] = {OrderRootType.SOURCES, OrderRootType.CLASSES}; for (OrderRootType rootType : interestingRootTypes) { for (String url : library.getUrls(rootType)) { if (!classpath.containsUrl(url)) { // The if just keeps us from churning. classpath.add(new HaxeClasspathEntry(library.getName(), url)); } } } } } return classpath; }
Example 5
Source File: HaxelibClasspathUtils.java From intellij-haxe with Apache License 2.0 | 5 votes |
/** * Get the list of library names specified on the project. Managed haxelib * (of the form "haxelib|<lib_name>") libraries are included unless * filterManagedLibs is true. * * @param project to get the libraries for. * @param filterManagedLibs whether to remove managed haxelibs from the list. * @return a (possibly empty) list of libraries that are specified for the * project (in the library pane). */ @NotNull public static List<String> getProjectLibraryNames(@NotNull Project project, boolean filterManagedLibs) { List<String> nameList = new ArrayList<String>(); LibraryTable libraryTable = ProjectLibraryTable.getInstance(project); Library[] libraries = libraryTable.getLibraries(); for (Library library : libraries) { if (filterManagedLibs && HaxelibNameUtil.isManagedLibrary(library.getName())) { continue; } nameList.add(library.getName()); } return nameList; }
Example 6
Source File: LibraryDependencyDataService.java From consulo with Apache License 2.0 | 5 votes |
private void importMissingProjectLibraries(@Nonnull Module module, @Nonnull Collection<DataNode<LibraryDependencyData>> nodesToImport, boolean synchronous) { LibraryTable libraryTable = ProjectLibraryTable.getInstance(module.getProject()); List<DataNode<LibraryData>> librariesToImport = ContainerUtilRt.newArrayList(); for (DataNode<LibraryDependencyData> dataNode : nodesToImport) { final LibraryDependencyData dependencyData = dataNode.getData(); if (dependencyData.getLevel() != LibraryLevel.PROJECT) { continue; } final Library library = libraryTable.getLibraryByName(dependencyData.getInternalName()); if (library == null) { DataNode<ProjectData> projectNode = dataNode.getDataNode(ProjectKeys.PROJECT); if (projectNode != null) { DataNode<LibraryData> libraryNode = ExternalSystemApiUtil.find(projectNode, ProjectKeys.LIBRARY, new BooleanFunction<DataNode<LibraryData>>() { @Override public boolean fun(DataNode<LibraryData> node) { return node.getData().equals(dependencyData.getTarget()); } }); if (libraryNode != null) { librariesToImport.add(libraryNode); } } } } if (!librariesToImport.isEmpty()) { LibraryDataService.getInstance().importData(librariesToImport, module.getProject(), synchronous); } }
Example 7
Source File: ProjectStructureHelper.java From consulo with Apache License 2.0 | 5 votes |
@Nullable public static Library findIdeLibrary(@Nonnull final LibraryData libraryData, @Nonnull Project ideProject) { final LibraryTable libraryTable = ProjectLibraryTable.getInstance(ideProject); for (Library ideLibrary : libraryTable.getLibraries()) { if (ExternalSystemApiUtil.isRelated(ideLibrary, libraryData)) return ideLibrary; } return null; }
Example 8
Source File: ExternalSystemUtil.java From consulo with Apache License 2.0 | 5 votes |
private void processOrphanProjectLibraries() { List<Library> orphanIdeLibraries = ContainerUtilRt.newArrayList(); LibraryTable projectLibraryTable = ProjectLibraryTable.getInstance(myProject); for (Library library : projectLibraryTable.getLibraries()) { if (!ExternalSystemApiUtil.isExternalSystemLibrary(library, myExternalSystemId)) continue; if (ProjectStructureHelper.isOrphanProjectLibrary(library, ModuleManager.getInstance(myProject).getModules())) { orphanIdeLibraries.add(library); } } for (Library orphanIdeLibrary : orphanIdeLibraries) { projectLibraryTable.removeLibrary(orphanIdeLibrary); } }
Example 9
Source File: HaxelibClasspathUtils.java From intellij-haxe with Apache License 2.0 | 3 votes |
/** * Get the classpath for all libraries in the project. This *does not* * filter managed libraries of the form "haxelib|<lib_name>". * * @param project to get the classpath for. * @return a (possibly empty) list of the classpaths for all of the libraries * that are specified on the project (in the library pane). */ @NotNull public static HaxeClasspath getProjectLibraryClasspath(@NotNull Project project) { LibraryTable libraryTable = ProjectLibraryTable.getInstance(project); if (null == libraryTable) return HaxeClasspath.EMPTY_CLASSPATH; return loadClasspathFrom(libraryTable); }