Search in sources :

Example 1 with LibraryInfo

use of com.intellij.facet.ui.libraries.LibraryInfo in project intellij-community by JetBrains.

the class RequiredLibrariesInfo method checkLibraries.

@Nullable
public RequiredClassesNotFoundInfo checkLibraries(List<VirtualFile> libraryFiles) {
    List<LibraryInfo> infos = new ArrayList<>();
    List<String> classes = new ArrayList<>();
    for (LibraryInfo info : myLibraryInfos) {
        boolean notFound;
        final String md5 = info.getMd5();
        if (!StringUtil.isEmptyOrSpaces(md5)) {
            notFound = true;
            for (VirtualFile libraryFile : libraryFiles) {
                final VirtualFile jarFile = JarFileSystem.getInstance().getVirtualFileForJar(libraryFile);
                if (md5.equals(md5(jarFile))) {
                    notFound = false;
                    break;
                }
            }
        } else {
            notFound = false;
            for (String className : info.getRequiredClasses()) {
                if (!LibraryUtil.isClassAvailableInLibrary(libraryFiles, className)) {
                    classes.add(className);
                    notFound = true;
                }
            }
        }
        if (notFound) {
            infos.add(info);
        }
    }
    if (infos.isEmpty()) {
        return null;
    }
    return new RequiredClassesNotFoundInfo(ArrayUtil.toStringArray(classes), infos.toArray(new LibraryInfo[infos.size()]));
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) LibraryInfo(com.intellij.facet.ui.libraries.LibraryInfo) ArrayList(java.util.ArrayList) Nullable(org.jetbrains.annotations.Nullable)

Example 2 with LibraryInfo

use of com.intellij.facet.ui.libraries.LibraryInfo in project intellij-community by JetBrains.

the class FacetLibrariesValidatorImpl method check.

@NotNull
public ValidationResult check() {
    if (myRequiredLibraries == null) {
        return ValidationResult.OK;
    }
    List<VirtualFile> roots = collectRoots(myContext.getRootModel());
    RequiredLibrariesInfo.RequiredClassesNotFoundInfo info = myRequiredLibraries.checkLibraries(VfsUtil.toVirtualFileArray(roots));
    if (info == null) {
        return ValidationResult.OK;
    }
    String missingJars = IdeBundle.message("label.missed.libraries.prefix") + " " + info.getMissingJarsText();
    LibraryInfo[] missingLibraries = info.getLibraryInfos();
    CustomLibraryDescription description = new OldCustomLibraryDescription(missingLibraries, myDescription.getDefaultLibraryName());
    return new ValidationResult(missingJars, new LibrariesQuickFix(description));
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) LibraryInfo(com.intellij.facet.ui.libraries.LibraryInfo) OldCustomLibraryDescription(com.intellij.ide.util.frameworkSupport.OldCustomLibraryDescription) ValidationResult(com.intellij.facet.ui.ValidationResult) CustomLibraryDescription(com.intellij.openapi.roots.ui.configuration.libraries.CustomLibraryDescription) OldCustomLibraryDescription(com.intellij.ide.util.frameworkSupport.OldCustomLibraryDescription) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

LibraryInfo (com.intellij.facet.ui.libraries.LibraryInfo)2 VirtualFile (com.intellij.openapi.vfs.VirtualFile)2 ValidationResult (com.intellij.facet.ui.ValidationResult)1 OldCustomLibraryDescription (com.intellij.ide.util.frameworkSupport.OldCustomLibraryDescription)1 CustomLibraryDescription (com.intellij.openapi.roots.ui.configuration.libraries.CustomLibraryDescription)1 ArrayList (java.util.ArrayList)1 NotNull (org.jetbrains.annotations.NotNull)1 Nullable (org.jetbrains.annotations.Nullable)1