本文整理汇总了Java中consulo.vfs.util.ArchiveVfsUtil.getArchiveRootForLocalFile方法的典型用法代码示例。如果您正苦于以下问题:Java ArchiveVfsUtil.getArchiveRootForLocalFile方法的具体用法?Java ArchiveVfsUtil.getArchiveRootForLocalFile怎么用?Java ArchiveVfsUtil.getArchiveRootForLocalFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类consulo.vfs.util.ArchiveVfsUtil
的用法示例。
在下文中一共展示了ArchiveVfsUtil.getArchiveRootForLocalFile方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createSdk
import consulo.vfs.util.ArchiveVfsUtil; //导入方法依赖的package包/类
@Override
protected Sdk createSdk(VirtualFile virtualFile)
{
SdkImpl sdk = new SdkImpl("Mono IKVM.NET", IkvmBundleType.getInstance());
VirtualFile mainMonoPath = virtualFile.getParent().getParent().getParent();
sdk.setHomePath(mainMonoPath.getPath());
sdk.setPredefined(true);
sdk.setVersionString(IkvmBundleType.getInstance().getVersionString(sdk));
SdkModificator sdkModificator = sdk.getSdkModificator();
for(String library : IkvmBundleType.ourLibraries)
{
VirtualFile libraryFile = mainMonoPath.findFileByRelativePath("lib/mono/ikvm/" + library);
if(libraryFile != null)
{
VirtualFile archiveLibraryFile = ArchiveVfsUtil.getArchiveRootForLocalFile(libraryFile);
if(archiveLibraryFile != null)
{
sdkModificator.addRoot(archiveLibraryFile, BinariesOrderRootType.getInstance());
}
}
}
sdkModificator.commitChanges();
return sdk;
}
示例2: loadProperties
import consulo.vfs.util.ArchiveVfsUtil; //导入方法依赖的package包/类
public static Properties loadProperties(File antJar) throws IOException
{
Properties properties = new Properties();
VirtualFile fileByIoFile = LocalFileSystem.getInstance().findFileByIoFile(antJar);
if(fileByIoFile == null)
{
return properties;
}
VirtualFile archiveRootForLocalFile = ArchiveVfsUtil.getArchiveRootForLocalFile(fileByIoFile);
if(archiveRootForLocalFile == null)
{
return properties;
}
VirtualFile fileByRelativePath = archiveRootForLocalFile.findFileByRelativePath(VERSION_RESOURCE);
if(fileByRelativePath == null)
{
return null;
}
properties.load(fileByRelativePath.getInputStream());
return properties;
}
示例3: setupSdkPaths
import consulo.vfs.util.ArchiveVfsUtil; //导入方法依赖的package包/类
@Override
public void setupSdkPaths(Sdk sdk)
{
SdkModificator sdkModificator = sdk.getSdkModificator();
VirtualFile homeDirectory = sdk.getHomeDirectory();
VirtualFile lib = homeDirectory.findChild("lib");
if(lib != null)
{
for(VirtualFile virtualFile : lib.getChildren())
{
VirtualFile archiveRootForLocalFile = ArchiveVfsUtil.getArchiveRootForLocalFile(virtualFile);
if(archiveRootForLocalFile != null)
{
sdkModificator.addRoot(archiveRootForLocalFile, BinariesOrderRootType.getInstance());
}
}
}
sdkModificator.commitChanges();
}
示例4: testFindRootShouldNotBeFooledByRelativePath
import consulo.vfs.util.ArchiveVfsUtil; //导入方法依赖的package包/类
public void testFindRootShouldNotBeFooledByRelativePath() throws IOException {
File tmp = createTempDirectory();
File x = new File(tmp, "x.jar");
x.createNewFile();
LocalFileSystem lfs = LocalFileSystem.getInstance();
VirtualFile vx = lfs.refreshAndFindFileByIoFile(x);
assertNotNull(vx);
ArchiveFileSystem jfs = (ArchiveFileSystem)StandardFileSystems.jar();
VirtualFile root = ArchiveVfsUtil.getArchiveRootForLocalFile(vx);
PersistentFS fs = PersistentFS.getInstance();
String path = vx.getPath() + "/../" + vx.getName() + ArchiveFileSystem.ARCHIVE_SEPARATOR;
NewVirtualFile root1 = fs.findRoot(path, (NewVirtualFileSystem)jfs);
assertSame(root1, root);
}
示例5: isAccepted
import consulo.vfs.util.ArchiveVfsUtil; //导入方法依赖的package包/类
@Override
public boolean isAccepted(@Nonnull VirtualFile rootCandidate, @Nonnull final ProgressIndicator progressIndicator) {
if (isJarDirectory()) {
if (!rootCandidate.isDirectory() || !rootCandidate.isInLocalFileSystem()) {
return false;
}
for (VirtualFile child : rootCandidate.getChildren()) {
if (!child.isDirectory() && child.getFileType() instanceof ArchiveFileType) {
final VirtualFile archiveRoot = ArchiveVfsUtil.getArchiveRootForLocalFile(child);
if (archiveRoot != null && containsFileOfType(archiveRoot, progressIndicator)) {
return true;
}
}
}
return false;
}
else {
return containsFileOfType(rootCandidate, progressIndicator);
}
}
示例6: attachJdkAnnotations
import consulo.vfs.util.ArchiveVfsUtil; //导入方法依赖的package包/类
public static boolean attachJdkAnnotations(@NotNull SdkModificator modificator)
{
File pluginPath = PluginManager.getPluginPath(JavaSdkImpl.class);
File file = new File(pluginPath, "jdk-annotations.jar");
VirtualFile localFile = LocalFileSystem.getInstance().findFileByIoFile(file);
if(localFile == null)
{
LOG.error("jdk annotations not found in: " + file);
return false;
}
VirtualFile jarFile = ArchiveVfsUtil.getArchiveRootForLocalFile(localFile);
if(jarFile == null)
{
LOG.error("jdk annotations is not archive: " + file);
return false;
}
OrderRootType annoType = AnnotationOrderRootType.getInstance();
modificator.removeRoot(jarFile, annoType);
modificator.addRoot(jarFile, annoType);
return true;
}
示例7: findFile
import consulo.vfs.util.ArchiveVfsUtil; //导入方法依赖的package包/类
@Override
public VirtualFile findFile() {
final VirtualFile jarFile = super.findFile();
if (jarFile == null) return null;
final VirtualFile archiveRoot = ArchiveVfsUtil.getArchiveRootForLocalFile(jarFile);
if ("/".equals(myPathInJar)) return archiveRoot;
return archiveRoot != null ? archiveRoot.findFileByRelativePath(myPathInJar) : null;
}
示例8: testDoNotRegisterChangesNotInLocalFS
import consulo.vfs.util.ArchiveVfsUtil; //导入方法依赖的package包/类
public void testDoNotRegisterChangesNotInLocalFS() throws Exception {
File f = new File(myRoot.getPath(), "f.jar");
JarOutputStream jar = new JarOutputStream(new FileOutputStream(f));
jar.putNextEntry(new JarEntry("file.txt"));
jar.write(1);
jar.closeEntry();
jar.close();
VirtualFile vfile = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(f);
assertNotNull(vfile);
VirtualFile jarRoot = ArchiveVfsUtil.getArchiveRootForLocalFile(vfile);
assertEquals(1, jarRoot.findChild("file.txt").contentsToByteArray()[0]);
assertEquals(2, getRevisionsFor(myRoot).size());
jar = new JarOutputStream(new FileOutputStream(f));
JarEntry e = new JarEntry("file.txt");
e.setTime(f.lastModified() + 10000);
jar.putNextEntry(e);
jar.write(2);
jar.closeEntry();
jar.close();
f.setLastModified(f.lastModified() + 10000);
LocalFileSystem.getInstance().refreshWithoutFileWatcher(false);
StandardFileSystems.jar().refresh(false);
jarRoot = ArchiveVfsUtil.getArchiveRootForLocalFile(vfile);
assertEquals(2, jarRoot.findChild("file.txt").contentsToByteArray()[0]);
assertEquals(2, getRevisionsFor(myRoot).size());
assertEquals(1, getRevisionsFor(jarRoot).size());
}
示例9: registerPaths
import consulo.vfs.util.ArchiveVfsUtil; //导入方法依赖的package包/类
@SuppressWarnings("MethodMayBeStatic")
public void registerPaths(@Nonnull final Map<OrderRootType, Collection<File>> libraryFiles,
@Nonnull Library.ModifiableModel model,
@Nonnull String libraryName)
{
for (Map.Entry<OrderRootType, Collection<File>> entry : libraryFiles.entrySet()) {
for (File file : entry.getValue()) {
VirtualFile virtualFile = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(file);
if (virtualFile == null) {
if (ExternalSystemConstants.VERBOSE_PROCESSING && entry.getKey() == BinariesOrderRootType.getInstance()) {
LOG.warn(
String.format("Can't find %s of the library '%s' at path '%s'", entry.getKey(), libraryName, file.getAbsolutePath())
);
}
String url = VfsUtil.getUrlForLibraryRoot(file);
model.addRoot(url, entry.getKey());
continue;
}
if (virtualFile.isDirectory()) {
model.addRoot(virtualFile, entry.getKey());
}
else {
VirtualFile archiveRoot = ArchiveVfsUtil.getArchiveRootForLocalFile(virtualFile);
if (archiveRoot == null) {
LOG.warn(String.format(
"Can't parse contents of the jar file at path '%s' for the library '%s''", file.getAbsolutePath(), libraryName
));
continue;
}
model.addRoot(archiveRoot, entry.getKey());
}
}
}
}
示例10: createDiffElement
import consulo.vfs.util.ArchiveVfsUtil; //导入方法依赖的package包/类
@Override
public DiffElement createDiffElement(Object obj) {
if (obj instanceof VirtualFile) {
final VirtualFile file = (VirtualFile)obj;
VirtualFile archiveRootForLocalFile = ArchiveVfsUtil.getArchiveRootForLocalFile(file);
return archiveRootForLocalFile != null ? new ArchiveFileDiffElement(archiveRootForLocalFile) : new VirtualFileDiffElement(file);
}
return null;
}
示例11: addJavaFxSources
import consulo.vfs.util.ArchiveVfsUtil; //导入方法依赖的package包/类
private static void addJavaFxSources(File file, SdkModificator sdkModificator)
{
VirtualFile fileByIoFile = LocalFileSystem.getInstance().findFileByIoFile(new File(file, "javafx-src.zip"));
if(fileByIoFile == null)
{
return;
}
VirtualFile archiveRootForLocalFile = ArchiveVfsUtil.getArchiveRootForLocalFile(fileByIoFile);
if(archiveRootForLocalFile == null)
{
return;
}
sdkModificator.addRoot(archiveRootForLocalFile, SourcesOrderRootType.getInstance());
}
示例12: findInJar
import consulo.vfs.util.ArchiveVfsUtil; //导入方法依赖的package包/类
@Nullable
private static VirtualFile findInJar(File jarFile, String relativePath)
{
VirtualFile fileByIoFile = LocalFileSystem.getInstance().findFileByIoFile(jarFile);
if(fileByIoFile == null)
{
return null;
}
VirtualFile archiveRootForLocalFile = ArchiveVfsUtil.getArchiveRootForLocalFile(fileByIoFile);
return archiveRootForLocalFile == null ? null : archiveRootForLocalFile.findFileByRelativePath(relativePath);
}
示例13: isClassAvailable
import consulo.vfs.util.ArchiveVfsUtil; //导入方法依赖的package包/类
@Override
public boolean isClassAvailable(final String[] urls, String fqn)
{
for(String url : urls)
{
VirtualFile file = VirtualFileManager.getInstance().findFileByUrl(url);
if(file == null)
{
continue;
}
VirtualFile root = null;
if(file.isDirectory())
{
root = file;
}
else
{
root = ArchiveVfsUtil.getArchiveRootForLocalFile(file);
}
if(root == null)
{
continue;
}
if(findInFile(root, fqn))
{
return true;
}
}
return false;
}
示例14: isAllowedAssembly
import consulo.vfs.util.ArchiveVfsUtil; //导入方法依赖的package包/类
@RequiredReadAction
@Override
public boolean isAllowedAssembly(@NotNull String assemblyName)
{
VirtualFile archiveRootForLocalFile = ArchiveVfsUtil.getArchiveRootForLocalFile(myModuleFile);
if(archiveRootForLocalFile == null)
{
return false;
}
VirtualFile assemblyFile = archiveRootForLocalFile.findChild("AssemblyInfo.msil");
if(assemblyFile == null)
{
return false;
}
PsiFileImpl file = (PsiFileImpl) PsiManager.getInstance(myProject).findFile(assemblyFile);
if(!(file instanceof MsilFile))
{
return false;
}
for(PsiElement psiElement : ((MsilFile) file).getMembers())
{
if(psiElement instanceof MsilAssemblyEntry)
{
MsilAssemblyEntry assemblyEntry = (MsilAssemblyEntry) psiElement;
MsilCustomAttribute[] attributes = assemblyEntry.getAttributes();
for(MsilCustomAttribute attribute : attributes)
{
if(DotNetTypeRefUtil.isVmQNameEqual(attribute.toTypeRef(), attribute, DotNetTypes2.System.Runtime.CompilerServices.InternalsVisibleToAttribute))
{
MsilCustomAttributeArgumentList argumentList = MsilCustomAttributeStubber.build(attribute);
List<MsiCustomAttributeValue> constructorArguments = argumentList.getConstructorArguments();
if(constructorArguments.size() != 1)
{
continue;
}
MsiCustomAttributeValue msiCustomAttributeValue = constructorArguments.get(0);
if(msiCustomAttributeValue.getTypeSignature() == TypeSignature.STRING && Comparing.equal(msiCustomAttributeValue.getValue(), assemblyName))
{
return true;
}
}
}
}
}
return false;
}
示例15: resolveHolderImpl
import consulo.vfs.util.ArchiveVfsUtil; //导入方法依赖的package包/类
@NotNull
private ExternalAttributeHolder resolveHolderImpl(@NotNull VirtualFile virtualFile, @NotNull VirtualFile localFile)
{
VirtualFile archiveFile = ArchiveVfsUtil.getArchiveRootForLocalFile(localFile);
if(archiveFile == null)
{
return ExternalAttributeHolder.EMPTY;
}
List<OrderEntry> orderEntriesForFile = ProjectFileIndex.getInstance(myProject).getOrderEntriesForFile(virtualFile);
List<VirtualFile> externalAttributeFiles = new SmartList<VirtualFile>();
for(OrderEntry orderEntry : orderEntriesForFile)
{
if(ArrayUtil.contains(archiveFile, orderEntry.getFiles(BinariesOrderRootType.getInstance())))
{
VirtualFile[] files = orderEntry.getFiles(ExternalAttributesRootOrderType.getInstance());
if(files.length != 0)
{
Collections.addAll(externalAttributeFiles, files);
}
}
}
if(externalAttributeFiles.isEmpty())
{
return ExternalAttributeHolder.EMPTY;
}
else if(externalAttributeFiles.size() == 1)
{
return SingleExternalAttributeHolder.load(externalAttributeFiles.get(0));
}
else
{
List<ExternalAttributeHolder> list = new SmartList<ExternalAttributeHolder>();
for(VirtualFile externalAttributeFile : externalAttributeFiles)
{
list.add(SingleExternalAttributeHolder.load(externalAttributeFile));
}
return new CompositeExternalAttributeHolder(list);
}
}