本文整理汇总了Java中com.intellij.openapi.roots.LibraryOrderEntry类的典型用法代码示例。如果您正苦于以下问题:Java LibraryOrderEntry类的具体用法?Java LibraryOrderEntry怎么用?Java LibraryOrderEntry使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
LibraryOrderEntry类属于com.intellij.openapi.roots包,在下文中一共展示了LibraryOrderEntry类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getDirectClassPaths
import com.intellij.openapi.roots.LibraryOrderEntry; //导入依赖的package包/类
private static List<String> getDirectClassPaths( Module ijModule )
{
final ModuleRootManager rootManager = ModuleRootManager.getInstance( ijModule );
final List<OrderEntry> orderEntries = Arrays.asList( rootManager.getOrderEntries() );
List<String> paths = new ArrayList<>();
for( OrderEntry entry : orderEntries.stream().filter( (LibraryOrderEntry.class)::isInstance ).collect( Collectors.toList() ) )
{
final Library lib = ((LibraryOrderEntry)entry).getLibrary();
if( lib != null )
{
for( VirtualFile virtualFile : lib.getFiles( OrderRootType.CLASSES ) )
{
final File file = new File( stripExtraCharacters( virtualFile.getPath() ) );
if( file.exists() )
{
paths.add( file.getAbsolutePath() );
}
}
}
}
return paths;
}
示例2: actionPerformed
import com.intellij.openapi.roots.LibraryOrderEntry; //导入依赖的package包/类
@Override
public void actionPerformed(AnActionEvent event) {
final OrderEntry entry = myPanel.getSelectedEntry();
if (!(entry instanceof LibraryOrderEntry)) return;
LibraryOrderEntry libraryEntry = (LibraryOrderEntry)entry;
final LibraryEx library = (LibraryEx)libraryEntry.getLibrary();
if (library == null) return;
final Library copied = doCopy(library);
if (copied == null) return;
if (!isConvertingToModuleLibrary()) {
OrderEntryUtil.replaceLibrary(myPanel.getRootModel(), library, copied);
}
else {
OrderEntryUtil.replaceLibraryEntryByAdded(myPanel.getRootModel(), libraryEntry);
}
}
示例3: collectChildren
import com.intellij.openapi.roots.LibraryOrderEntry; //导入依赖的package包/类
protected void collectChildren(Object element, final List<Object> result) {
if (element instanceof Application) {
Collections.addAll(result, ProjectManager.getInstance().getOpenProjects());
final LibraryTablesRegistrar instance = LibraryTablesRegistrar.getInstance();
result.add(instance.getLibraryTable()); //1
result.addAll(instance.getCustomLibraryTables()); //2
}
else if (element instanceof Project) {
Collections.addAll(result, ModuleManager.getInstance((Project)element).getModules());
result.add(LibraryTablesRegistrar.getInstance().getLibraryTable((Project)element));
}
else if (element instanceof LibraryTable) {
Collections.addAll(result, ((LibraryTable)element).getLibraries());
}
else if (element instanceof Module) {
for (OrderEntry entry : ModuleRootManager.getInstance((Module)element).getOrderEntries()) {
if (entry instanceof LibraryOrderEntry) {
final LibraryOrderEntry libraryOrderEntry = (LibraryOrderEntry)entry;
if (LibraryTableImplUtil.MODULE_LEVEL.equals(libraryOrderEntry.getLibraryLevel())) {
final Library library = libraryOrderEntry.getLibrary();
result.add(library);
}
}
}
}
}
示例4: findLibrary
import com.intellij.openapi.roots.LibraryOrderEntry; //导入依赖的package包/类
@Nullable
public Library findLibrary(@NotNull PackagingElementResolvingContext context) {
if (myModuleName == null) {
return context.findLibrary(myLevel, myLibraryName);
}
final ModulesProvider modulesProvider = context.getModulesProvider();
final Module module = modulesProvider.getModule(myModuleName);
if (module != null) {
for (OrderEntry entry : modulesProvider.getRootModel(module).getOrderEntries()) {
if (entry instanceof LibraryOrderEntry) {
final LibraryOrderEntry libraryEntry = (LibraryOrderEntry)entry;
if (libraryEntry.isModuleLevel()) {
final String libraryName = libraryEntry.getLibraryName();
if (libraryName != null && libraryName.equals(myLibraryName)) {
return libraryEntry.getLibrary();
}
}
}
}
}
return null;
}
示例5: removeLibrary
import com.intellij.openapi.roots.LibraryOrderEntry; //导入依赖的package包/类
@Override
public void removeLibrary(@NotNull Library library) {
final Iterator<OrderEntry> orderIterator = myRootModel.getOrderIterator();
while (orderIterator.hasNext()) {
OrderEntry orderEntry = orderIterator.next();
if (orderEntry instanceof LibraryOrderEntry) {
final LibraryOrderEntry libraryOrderEntry = (LibraryOrderEntry) orderEntry;
if (libraryOrderEntry.isModuleLevel()) {
if (library.equals(libraryOrderEntry.getLibrary())) {
myRootModel.removeOrderEntry(orderEntry);
//Disposer.dispose(library);
return;
}
}
}
}
}
示例6: importMissing
import com.intellij.openapi.roots.LibraryOrderEntry; //导入依赖的package包/类
private void importMissing(@NotNull IdeModifiableModelsProvider modelsProvider,
@NotNull Set<LibraryDependencyData> toImport,
@NotNull ModifiableRootModel moduleRootModel,
@NotNull LibraryTable moduleLibraryTable,
@NotNull Module module) {
for (final LibraryDependencyData dependencyData : toImport) {
final LibraryData libraryData = dependencyData.getTarget();
final String libraryName = libraryData.getInternalName();
switch (dependencyData.getLevel()) {
case MODULE:
final Library moduleLib = moduleLibraryTable.createLibrary(libraryName);
syncExistingLibraryDependency(modelsProvider, dependencyData, moduleLib, moduleRootModel, module);
break;
case PROJECT:
final Library projectLib = modelsProvider.getLibraryByName(libraryName);
if (projectLib == null) {
syncExistingLibraryDependency(modelsProvider, dependencyData, moduleLibraryTable.createLibrary(libraryName), moduleRootModel,
module);
break;
}
LibraryOrderEntry orderEntry = moduleRootModel.addLibraryEntry(projectLib);
setLibraryScope(orderEntry, projectLib, module, dependencyData);
}
}
}
示例7: isMavenAarDependency
import com.intellij.openapi.roots.LibraryOrderEntry; //导入依赖的package包/类
public static boolean isMavenAarDependency(@NotNull Module module, @NotNull OrderEntry entry) {
if (ApplicationManager.getApplication().isUnitTestMode() && entry.getPresentableName().equals("maven_aar_dependency")) {
return true;
}
if (!(entry instanceof LibraryOrderEntry) || !isMavenizedModule(module)) {
return false;
}
final Library library = ((LibraryOrderEntry)entry).getLibrary();
if (library == null) {
return false;
}
final MavenProject mavenProject = MavenProjectsManager.getInstance(module.getProject()).findProject(module);
if (mavenProject == null) {
return false;
}
final MavenArtifact artifact = MavenRootModelAdapter.findArtifact(mavenProject, library);
return artifact != null && AAR_DEPENDENCY_AND_PACKAGING_TYPE.equals(artifact.getType());
}
示例8: removeUnusedProjectLibraries
import com.intellij.openapi.roots.LibraryOrderEntry; //导入依赖的package包/类
private boolean removeUnusedProjectLibraries() {
Set<Library> unusedLibraries = new HashSet<Library>();
Collections.addAll(unusedLibraries, myModelsProvider.getAllLibraries());
for (ModuleRootModel eachModel : collectModuleModels()) {
for (OrderEntry eachEntry : eachModel.getOrderEntries()) {
if (eachEntry instanceof LibraryOrderEntry) {
unusedLibraries.remove(((LibraryOrderEntry)eachEntry).getLibrary());
}
}
}
boolean removed = false;
for (Library each : unusedLibraries) {
if (!isDisposed(each) && MavenRootModelAdapter.isMavenLibrary(each) && !MavenRootModelAdapter.isChangedByUser(each)) {
myModelsProvider.removeLibrary(each);
removed = true;
}
}
return removed;
}
示例9: perform
import com.intellij.openapi.roots.LibraryOrderEntry; //导入依赖的package包/类
@Override
public ActionCallback perform(List<LibraryOrderEntry> orderEntriesContainingFile) {
ApplicationManager.getApplication().assertIsDispatchThread();
ActionCallback callback = new ActionCallback();
callback.setDone();
if (!mySrcFile.isValid()) return callback;
if (myLibrary != getLibraryFromOrderEntriesList(orderEntriesContainingFile)) return callback;
AccessToken accessToken = WriteAction.start();
try {
addSourceFile(mySrcFile, myLibrary);
}
finally {
accessToken.finish();
}
return callback;
}
示例10: assertScalaLibrary
import com.intellij.openapi.roots.LibraryOrderEntry; //导入依赖的package包/类
protected void assertScalaLibrary(String moduleName) throws Exception {
// This is to match scala-platform used in pants repo across different releases,
// so we expect at least one of the versions should be found here.
ArrayList<String> expectedLibs =
Lists.newArrayList(
"Pants: org.scala-lang:scala-library:2.10.4",
"Pants: org.scala-lang:scala-library:2.10.6",
"Pants: org.scala-lang:scala-library:2.11.8",
"Pants: org.scala-lang:scala-library:2.11.11"
);
for (String libName : expectedLibs) {
LibraryOrderEntry libX = ContainerUtil.getFirstItem(this.getModuleLibDeps(moduleName, libName));
if (libX != null) {
assertModuleLibDep(moduleName, libName);
return;
}
}
fail(String.format("None of %s is found for module %s.", expectedLibs, moduleName));
}
示例11: removeUnusedProjectLibraries
import com.intellij.openapi.roots.LibraryOrderEntry; //导入依赖的package包/类
private boolean removeUnusedProjectLibraries() {
Set<Library> allLibraries = new THashSet<Library>();
Collections.addAll(allLibraries, myModelsProvider.getAllLibraries());
Set<Library> usedLibraries = new THashSet<Library>();
for (ModuleRootModel eachModel : collectModuleModels()) {
for (OrderEntry eachEntry : eachModel.getOrderEntries()) {
if (eachEntry instanceof LibraryOrderEntry) {
Library lib = ((LibraryOrderEntry)eachEntry).getLibrary();
if (MavenRootModelAdapter.isMavenLibrary(lib)) usedLibraries.add(lib);
}
}
}
Set<Library> unusedLibraries = new THashSet<Library>(allLibraries);
unusedLibraries.removeAll(usedLibraries);
boolean removed = false;
for (Library each : unusedLibraries) {
if (!isDisposed(each) && MavenRootModelAdapter.isMavenLibrary(each) && !MavenRootModelAdapter.isChangedByUser(each)) {
myModelsProvider.removeLibrary(each);
removed = true;
}
}
return removed;
}
示例12: removeLibrary
import com.intellij.openapi.roots.LibraryOrderEntry; //导入依赖的package包/类
@Override
public void removeLibrary(@Nonnull Library library) {
final Iterator<OrderEntry> orderIterator = myRootLayer.getOrderIterator();
while (orderIterator.hasNext()) {
OrderEntry orderEntry = orderIterator.next();
if (orderEntry instanceof LibraryOrderEntry) {
final LibraryOrderEntry libraryOrderEntry = (LibraryOrderEntry) orderEntry;
if (libraryOrderEntry.isModuleLevel()) {
if (library.equals(libraryOrderEntry.getLibrary())) {
myRootLayer.removeOrderEntry(orderEntry);
//Disposer.dispose(library);
return;
}
}
}
}
}
示例13: findLibrary
import com.intellij.openapi.roots.LibraryOrderEntry; //导入依赖的package包/类
@Nullable
public Library findLibrary(@Nonnull PackagingElementResolvingContext context) {
if (myModuleName == null) {
return context.findLibrary(myLevel, myLibraryName);
}
final ModulesProvider modulesProvider = context.getModulesProvider();
final Module module = modulesProvider.getModule(myModuleName);
if (module != null) {
for (OrderEntry entry : modulesProvider.getRootModel(module).getOrderEntries()) {
if (entry instanceof LibraryOrderEntry) {
final LibraryOrderEntry libraryEntry = (LibraryOrderEntry)entry;
if (libraryEntry.isModuleLevel()) {
final String libraryName = libraryEntry.getLibraryName();
if (libraryName != null && libraryName.equals(myLibraryName)) {
return libraryEntry.getLibrary();
}
}
}
}
}
return null;
}
示例14: addLibraryOrderEntry
import com.intellij.openapi.roots.LibraryOrderEntry; //导入依赖的package包/类
public void addLibraryOrderEntry(final Module module, final Library library) {
Component parent = WindowManager.getInstance().suggestParentWindow(module.getProject());
final ModuleEditor moduleEditor = myContext.myModulesConfigurator.getModuleEditor(module);
LOG.assertTrue(moduleEditor != null, "Current module editor was not initialized");
final ModifiableRootModel modelProxy = moduleEditor.getModifiableRootModelProxy();
final OrderEntry[] entries = modelProxy.getOrderEntries();
for (OrderEntry entry : entries) {
if (entry instanceof LibraryOrderEntry && Comparing.strEqual(entry.getPresentableName(), library.getName())) {
if (Messages.showYesNoDialog(parent,
ProjectBundle.message("project.roots.replace.library.entry.message", entry.getPresentableName()),
ProjectBundle.message("project.roots.replace.library.entry.title"),
Messages.getInformationIcon()) == Messages.YES) {
modelProxy.removeOrderEntry(entry);
break;
}
}
}
modelProxy.addLibraryEntry(library);
myContext.getDaemonAnalyzer().queueUpdate(new ModuleProjectStructureElement(myContext, module));
myTree.repaint();
}
示例15: findLibraryEntriesForFile
import com.intellij.openapi.roots.LibraryOrderEntry; //导入依赖的package包/类
@Nullable
private List<LibraryOrderEntry> findLibraryEntriesForFile(VirtualFile file)
{
List<LibraryOrderEntry> entries = null;
ProjectFileIndex index = ProjectFileIndex.SERVICE.getInstance(myProject);
for(OrderEntry entry : index.getOrderEntriesForFile(file))
{
if(entry instanceof LibraryOrderEntry)
{
if(entries == null)
{
entries = ContainerUtil.newSmartList();
}
entries.add((LibraryOrderEntry) entry);
}
}
return entries;
}