当前位置: 首页>>代码示例>>Java>>正文


Java LibraryUtil.isClassAvailableInLibrary方法代码示例

本文整理汇总了Java中com.intellij.openapi.roots.libraries.LibraryUtil.isClassAvailableInLibrary方法的典型用法代码示例。如果您正苦于以下问题:Java LibraryUtil.isClassAvailableInLibrary方法的具体用法?Java LibraryUtil.isClassAvailableInLibrary怎么用?Java LibraryUtil.isClassAvailableInLibrary使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.intellij.openapi.roots.libraries.LibraryUtil的用法示例。


在下文中一共展示了LibraryUtil.isClassAvailableInLibrary方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: checkLibraries

import com.intellij.openapi.roots.libraries.LibraryUtil; //导入方法依赖的package包/类
@Nullable
public RequiredClassesNotFoundInfo checkLibraries(List<VirtualFile> libraryFiles) {
  List<LibraryInfo> infos = new ArrayList<LibraryInfo>();
  List<String> classes = new ArrayList<String>();

  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()]));
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:37,代码来源:RequiredLibrariesInfo.java

示例2: getDefaultDependencyScope

import com.intellij.openapi.roots.libraries.LibraryUtil; //导入方法依赖的package包/类
@Nullable
@Override
public DependencyScope getDefaultDependencyScope(@NotNull Library library) {
  VirtualFile[] files = library.getFiles(OrderRootType.CLASSES);
  if (files.length == 1 && LibraryUtil.isClassAvailableInLibrary(files, "org.testng.annotations.Test")) {
    return DependencyScope.TEST;
  }
  return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:10,代码来源:TestNGDependencyScopeSuggester.java

示例3: isTestJarRoot

import com.intellij.openapi.roots.libraries.LibraryUtil; //导入方法依赖的package包/类
private static boolean isTestJarRoot(VirtualFile file) {
  for (String marker : JUNIT_JAR_MARKERS) {
    if (LibraryUtil.isClassAvailableInLibrary(Collections.singletonList(file), marker)) {
      return true;
    }
  }
  return false;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:9,代码来源:JUnitDependencyScopeSuggester.java

示例4: addGroovyAndAntJars

import com.intellij.openapi.roots.libraries.LibraryUtil; //导入方法依赖的package包/类
private static void addGroovyAndAntJars(JavaParameters params, Module module, String gantHome) {
  final File[] groovyJars = GroovyConfigUtils.getGroovyAllJars(gantHome + "/lib/");
  if (groovyJars.length > 0) {
    params.getClassPath().add(groovyJars[0].getAbsolutePath());
  }

  if (module == null) {
    return;
  }

  final String groovyHome = LibrariesUtil.getGroovyHomePath(module);
  if (groovyHome != null) {
    File[] libJars = GroovyUtils.getFilesInDirectoryByPattern(groovyHome + "/lib/", ".*\\.jar");
    if (libJars.length > 0) {
      params.getClassPath().addAllFiles(libJars);
    }
  }

  List<VirtualFile> classpath = params.getClassPath().getRootDirs();

  String[] characteristicClasses = ContainerUtil.ar(
    LibrariesUtil.SOME_GROOVY_CLASS, "org.apache.tools.ant.BuildException", "org.apache.tools.ant.launch.AntMain",
    "org.apache.commons.cli.ParseException");
  for (String someClass : characteristicClasses) {
    if (!LibraryUtil.isClassAvailableInLibrary(classpath, someClass)) {
      VirtualFile jar = LibrariesUtil.findJarWithClass(module, someClass);
      if (jar != null) {
        params.getClassPath().add(jar);
      }
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:33,代码来源:GantRunner.java

示例5: detectVersion

import com.intellij.openapi.roots.libraries.LibraryUtil; //导入方法依赖的package包/类
@Nullable
private static LibraryVersionProperties detectVersion(List<VirtualFile> classesRoots, String detectionClass) {
  if (!LibraryUtil.isClassAvailableInLibrary(classesRoots, detectionClass)) {
    return null;
  }
  final String version = JarVersionDetectionUtil.detectJarVersion(detectionClass, classesRoots);
  return new LibraryVersionProperties(version);
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:9,代码来源:DownloadableLibraryTypeBase.java

示例6: removeAsmJarFromClasspath

import com.intellij.openapi.roots.libraries.LibraryUtil; //导入方法依赖的package包/类
private static void removeAsmJarFromClasspath(PathsList classPath) {
  List<String> toRemove = new ArrayList<String>();
  for (String filePath : classPath.getPathList()) {
    if (filePath.endsWith(".jar")) {
      final VirtualFile root =
        JarFileSystem.getInstance().findFileByPath(FileUtil.toSystemIndependentName(filePath) + JarFileSystem.JAR_SEPARATOR);
      if (root != null && LibraryUtil.isClassAvailableInLibrary(new VirtualFile[]{root}, "org.objectweb.asm.ClassReader")) {
        toRemove.add(filePath);
      }
    }
  }
  for (String path : toRemove) {
    classPath.remove(path);
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:16,代码来源:EnhancerCompilerInstance.java

示例7: getDefaultDependencyScope

import com.intellij.openapi.roots.libraries.LibraryUtil; //导入方法依赖的package包/类
@Nullable
@Override
public DependencyScope getDefaultDependencyScope(@NotNull Library library) {
  VirtualFile[] files = library.getFiles(OrderRootType.CLASSES);
  if (files.length == 1 && (LibraryUtil.isClassAvailableInLibrary(files, "junit.framework.TestCase")
                            || LibraryUtil.isClassAvailableInLibrary(library, "org.junit.Test"))) {
    return DependencyScope.TEST;
  }
  return null;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:11,代码来源:JUnitDependencyScopeSuggester.java

示例8: addGroovyAndAntJars

import com.intellij.openapi.roots.libraries.LibraryUtil; //导入方法依赖的package包/类
private static void addGroovyAndAntJars(JavaParameters params, Module module, String gantHome) {
  final File[] groovyJars = GroovyConfigUtils.getGroovyAllJars(gantHome + "/lib/");
  if (groovyJars.length > 0) {
    params.getClassPath().add(groovyJars[0].getAbsolutePath());
  }

  if (module == null) {
    return;
  }

  final String groovyHome = LibrariesUtil.getGroovyHomePath(module);
  if (groovyHome != null) {
    File[] libJars = GroovyUtils.getFilesInDirectoryByPattern(groovyHome + "/lib/", ".*\\.jar");
    if (libJars.length > 0) {
      params.getClassPath().addAllFiles(libJars);
    }
  }

  List<VirtualFile> classpath = params.getClassPath().getRootDirs();

  String[] characteristicClasses = ar(
    LibrariesUtil.SOME_GROOVY_CLASS, "org.apache.tools.ant.BuildException", "org.apache.tools.ant.launch.AntMain",
    "org.apache.commons.cli.ParseException");
  for (String someClass : characteristicClasses) {
    if (!LibraryUtil.isClassAvailableInLibrary(classpath, someClass)) {
      VirtualFile jar = LibrariesUtil.findJarWithClass(module, someClass);
      if (jar != null) {
        params.getClassPath().add(jar);
      }
    }
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:33,代码来源:GantRunner.java


注:本文中的com.intellij.openapi.roots.libraries.LibraryUtil.isClassAvailableInLibrary方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。