Search in sources :

Example 1 with LibraryProperties

use of com.intellij.openapi.roots.libraries.LibraryProperties in project intellij-community by JetBrains.

the class RepositoryLibraryDependencyScopeSuggester method getDefaultDependencyScope.

@Nullable
@Override
public DependencyScope getDefaultDependencyScope(@NotNull Library library) {
    if (!(library instanceof LibraryEx)) {
        return null;
    }
    LibraryEx libraryEx = (LibraryEx) library;
    LibraryProperties libraryProperties = libraryEx.getProperties();
    if (libraryProperties == null || !(libraryProperties instanceof RepositoryLibraryProperties)) {
        return null;
    }
    RepositoryLibraryProperties repositoryLibraryProperties = (RepositoryLibraryProperties) libraryProperties;
    RepositoryLibraryDescription libraryDescription = RepositoryLibraryDescription.findDescription(repositoryLibraryProperties);
    return libraryDescription.getSuggestedScope();
}
Also used : LibraryProperties(com.intellij.openapi.roots.libraries.LibraryProperties) LibraryEx(com.intellij.openapi.roots.impl.libraries.LibraryEx) Nullable(org.jetbrains.annotations.Nullable)

Example 2 with LibraryProperties

use of com.intellij.openapi.roots.libraries.LibraryProperties in project intellij-community by JetBrains.

the class RepositoryLibrarySupport method isLibraryEqualsToSelected.

private boolean isLibraryEqualsToSelected(Library library) {
    if (!(library instanceof LibraryEx)) {
        return false;
    }
    LibraryEx libraryEx = (LibraryEx) library;
    if (!RepositoryLibraryType.REPOSITORY_LIBRARY_KIND.equals(libraryEx.getKind())) {
        return false;
    }
    LibraryProperties libraryProperties = libraryEx.getProperties();
    if (libraryProperties == null || !(libraryProperties instanceof RepositoryLibraryProperties)) {
        return false;
    }
    RepositoryLibraryProperties repositoryLibraryProperties = (RepositoryLibraryProperties) libraryProperties;
    RepositoryLibraryDescription description = RepositoryLibraryDescription.findDescription(repositoryLibraryProperties);
    if (!description.equals(libraryDescription)) {
        return false;
    }
    return Comparing.equal(repositoryLibraryProperties.getVersion(), model.getVersion());
}
Also used : LibraryProperties(com.intellij.openapi.roots.libraries.LibraryProperties) LibraryEx(com.intellij.openapi.roots.impl.libraries.LibraryEx)

Example 3 with LibraryProperties

use of com.intellij.openapi.roots.libraries.LibraryProperties 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)

Aggregations

LibraryEx (com.intellij.openapi.roots.impl.libraries.LibraryEx)3 LibraryProperties (com.intellij.openapi.roots.libraries.LibraryProperties)3 Module (com.intellij.openapi.module.Module)1 LibraryOrderEntry (com.intellij.openapi.roots.LibraryOrderEntry)1 OrderEntry (com.intellij.openapi.roots.OrderEntry)1 DartPackagesLibraryProperties (com.jetbrains.lang.dart.sdk.DartPackagesLibraryProperties)1 THashMap (gnu.trove.THashMap)1 List (java.util.List)1 Map (java.util.Map)1 Nullable (org.jetbrains.annotations.Nullable)1