Search in sources :

Example 16 with LibraryEx

use of com.intellij.openapi.roots.impl.libraries.LibraryEx in project google-cloud-intellij by GoogleCloudPlatform.

the class AppEngineStandardSupportProviderTest method testAppEngine_defaultManagedLibrariesSelected.

public void testAppEngine_defaultManagedLibrariesSelected() {
    AppEngineStandardLibraryPanel libraryPanel = new AppEngineStandardLibraryPanel(true);
    LibraryEx library = mock(LibraryEx.class);
    when(library.getTable()).thenReturn(ProjectLibraryTable.getInstance(myModule.getProject()));
    when(library.getExcludedRoots()).thenReturn(new VirtualFile[0]);
    when(library.getName()).thenReturn("javax.servlet:servlet-api:2.5");
    setupAppEngine(libraryPanel, library);
    addSupport();
    assertNull(FacetManager.getInstance(myModule).getFacetByType(WebFacet.ID));
    final String moduleName = myModule.getName();
    ArtifactsTestUtil.assertLayout(myProject, moduleName, "<root>\n" + " WEB-INF/\n" + "  classes/\n" + "   module:" + moduleName + "\n" + "  lib/\n" + "   lib:javax.servlet:servlet-api:2.5(project)\n");
}
Also used : AppEngineStandardLibraryPanel(com.google.cloud.tools.intellij.appengine.facet.standard.AppEngineStandardLibraryPanel) LibraryEx(com.intellij.openapi.roots.impl.libraries.LibraryEx)

Example 17 with LibraryEx

use of com.intellij.openapi.roots.impl.libraries.LibraryEx in project go-lang-idea-plugin by go-lang-plugin-org.

the class GoModuleLibrariesInitializer method attachLibraries.

private void attachLibraries(@NotNull Collection<VirtualFile> libraryRoots, Set<VirtualFile> exclusions) {
    ApplicationManager.getApplication().assertIsDispatchThread();
    if (!libraryRoots.isEmpty()) {
        ApplicationManager.getApplication().runWriteAction(() -> {
            ModuleRootManager model = ModuleRootManager.getInstance(myModule);
            LibraryOrderEntry goLibraryEntry = OrderEntryUtil.findLibraryOrderEntry(model, getLibraryName());
            if (goLibraryEntry != null && goLibraryEntry.isValid()) {
                Library library = goLibraryEntry.getLibrary();
                if (library != null && !((LibraryEx) library).isDisposed()) {
                    fillLibrary(library, libraryRoots, exclusions);
                }
            } else {
                LibraryTable libraryTable = LibraryTablesRegistrar.getInstance().getLibraryTable(myModule.getProject());
                Library library = libraryTable.createLibrary(getLibraryName());
                fillLibrary(library, libraryRoots, exclusions);
                ModuleRootModificationUtil.addDependency(myModule, library);
            }
        });
        showNotification(myModule.getProject());
    } else {
        removeLibraryIfNeeded();
    }
}
Also used : LibraryTable(com.intellij.openapi.roots.libraries.LibraryTable) LibraryEx(com.intellij.openapi.roots.impl.libraries.LibraryEx) Library(com.intellij.openapi.roots.libraries.Library)

Example 18 with LibraryEx

use of com.intellij.openapi.roots.impl.libraries.LibraryEx in project go-lang-idea-plugin by go-lang-plugin-org.

the class GoPathLibraryTest method assertLibrary.

private void assertLibrary(@NotNull Collection<String> libUrls, String... exclusionUrls) {
    UIUtil.dispatchAllInvocationEvents();
    GoModuleLibrariesInitializer initializer = myModule.getComponent(GoModuleLibrariesInitializer.class);
    ModuleRootManager model = ModuleRootManager.getInstance(myModule);
    LibraryOrderEntry libraryOrderEntry = OrderEntryUtil.findLibraryOrderEntry(model, initializer.getLibraryName());
    if (libUrls.isEmpty()) {
        assertNull(libraryOrderEntry);
        return;
    }
    LibraryEx library = (LibraryEx) libraryOrderEntry.getLibrary();
    assertNotNull(library);
    assertSameElements(Arrays.asList(library.getUrls(OrderRootType.CLASSES)), libUrls);
    assertSameElements(library.getExcludedRootUrls(), exclusionUrls);
}
Also used : GoModuleLibrariesInitializer(com.goide.project.GoModuleLibrariesInitializer) LibraryEx(com.intellij.openapi.roots.impl.libraries.LibraryEx)

Example 19 with LibraryEx

use of com.intellij.openapi.roots.impl.libraries.LibraryEx in project intellij-plugins by JetBrains.

the class DartUrlResolverImpl method initPackagesMapFromLib.

private void initPackagesMapFromLib(@NotNull final VirtualFile contextFile) {
    final Module module = ModuleUtilCore.findModuleForFile(contextFile, myProject);
    final List<OrderEntry> orderEntries = module != null ? Arrays.asList(ModuleRootManager.getInstance(module).getOrderEntries()) : ProjectRootManager.getInstance(myProject).getFileIndex().getOrderEntriesForFile(contextFile);
    for (OrderEntry orderEntry : orderEntries) {
        if (orderEntry instanceof LibraryOrderEntry && LibraryTablesRegistrar.PROJECT_LEVEL.equals(((LibraryOrderEntry) orderEntry).getLibraryLevel()) && DartPackagesLibraryType.DART_PACKAGES_LIBRARY_NAME.equals(((LibraryOrderEntry) orderEntry).getLibraryName())) {
            final LibraryEx library = (LibraryEx) ((LibraryOrderEntry) orderEntry).getLibrary();
            final LibraryProperties properties = library == null ? null : library.getProperties();
            if (properties instanceof DartPackagesLibraryProperties) {
                for (Map.Entry<String, List<String>> entry : ((DartPackagesLibraryProperties) properties).getPackageNameToDirsMap().entrySet()) {
                    if (entry != null && entry.getKey() != null && entry.getValue() != null) {
                        myPackagesMapFromLib.put(entry.getKey(), entry.getValue());
                    }
                }
                return;
            }
        }
    }
}
Also used : DartPackagesLibraryProperties(com.jetbrains.lang.dart.sdk.DartPackagesLibraryProperties) OrderEntry(com.intellij.openapi.roots.OrderEntry) LibraryOrderEntry(com.intellij.openapi.roots.LibraryOrderEntry) DartPackagesLibraryProperties(com.jetbrains.lang.dart.sdk.DartPackagesLibraryProperties) LibraryProperties(com.intellij.openapi.roots.libraries.LibraryProperties) LibraryEx(com.intellij.openapi.roots.impl.libraries.LibraryEx) List(java.util.List) LibraryOrderEntry(com.intellij.openapi.roots.LibraryOrderEntry) Module(com.intellij.openapi.module.Module) THashMap(gnu.trove.THashMap) Map(java.util.Map)

Example 20 with LibraryEx

use of com.intellij.openapi.roots.impl.libraries.LibraryEx in project intellij-plugins by JetBrains.

the class FlexProjectConfigTest method createModuleLibrary.

private String createModuleLibrary() {
    final ModifiableRootModel modifiableModel = ModuleRootManager.getInstance(myModule).getModifiableModel();
    final LibraryTable.ModifiableModel libraryTable = modifiableModel.getModuleLibraryTable().getModifiableModel();
    LibraryEx library = (LibraryEx) libraryTable.createLibrary("test", FlexLibraryType.FLEX_LIBRARY);
    String libraryId = UUID.randomUUID().toString();
    ((FlexLibraryProperties) library.getProperties()).setId(libraryId);
    ApplicationManager.getApplication().runWriteAction(() -> {
        libraryTable.commit();
        modifiableModel.commit();
    });
    return libraryId;
}
Also used : LibraryTable(com.intellij.openapi.roots.libraries.LibraryTable) FlexLibraryProperties(com.intellij.lang.javascript.flex.library.FlexLibraryProperties) LibraryEx(com.intellij.openapi.roots.impl.libraries.LibraryEx)

Aggregations

LibraryEx (com.intellij.openapi.roots.impl.libraries.LibraryEx)38 Library (com.intellij.openapi.roots.libraries.Library)19 LibraryOrderEntry (com.intellij.openapi.roots.LibraryOrderEntry)8 VirtualFile (com.intellij.openapi.vfs.VirtualFile)8 NotNull (org.jetbrains.annotations.NotNull)8 Nullable (org.jetbrains.annotations.Nullable)8 Module (com.intellij.openapi.module.Module)6 LibraryTable (com.intellij.openapi.roots.libraries.LibraryTable)6 Project (com.intellij.openapi.project.Project)5 FlexLibraryProperties (com.intellij.lang.javascript.flex.library.FlexLibraryProperties)4 Logger (com.intellij.openapi.diagnostic.Logger)4 ContainerUtil (com.intellij.util.containers.ContainerUtil)4 Disposable (com.intellij.openapi.Disposable)3 OrderRootType (com.intellij.openapi.roots.OrderRootType)3 LibraryProperties (com.intellij.openapi.roots.libraries.LibraryProperties)3 StringUtil (com.intellij.openapi.util.text.StringUtil)3 List (java.util.List)3 FlexCommonUtils (com.intellij.flex.FlexCommonUtils)2 BuildConfigurationNature (com.intellij.flex.model.bc.BuildConfigurationNature)2 OutputType (com.intellij.flex.model.bc.OutputType)2