本文整理汇总了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()]));
}
示例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;
}
示例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;
}
示例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);
}
}
}
}
示例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);
}
示例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);
}
}
示例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;
}
示例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);
}
}
}
}