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


Java LocalFileSystem.refreshAndFindFileByPath方法代码示例

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


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

示例1: getExternalConfig

import com.intellij.openapi.vfs.LocalFileSystem; //导入方法依赖的package包/类
@Nullable
protected VirtualFile getExternalConfig(@NotNull ExternalConfigPathAware data, ProjectSystemId externalSystemId) {
  String path = data.getLinkedExternalProjectPath();
  LocalFileSystem fileSystem = LocalFileSystem.getInstance();
  VirtualFile externalSystemConfigPath = fileSystem.refreshAndFindFileByPath(path);
  if (externalSystemConfigPath == null) {
    return null;
  }

  VirtualFile toOpen = externalSystemConfigPath;
  for (ExternalSystemConfigLocator locator : ExternalSystemConfigLocator.EP_NAME.getExtensions()) {
    if (externalSystemId.equals(locator.getTargetExternalSystemId())) {
      toOpen = locator.adjust(toOpen);
      if (toOpen == null) {
        return null;
      }
      break;
    }
  }
  return toOpen.isDirectory() ? null : toOpen;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:ExternalSystemNodeAction.java

示例2: getChosenFiles

import com.intellij.openapi.vfs.LocalFileSystem; //导入方法依赖的package包/类
@NotNull
private static List<VirtualFile> getChosenFiles(final List<String> paths) {
  if (ContainerUtil.isEmpty(paths)) {
    return Collections.emptyList();
  }

  final LocalFileSystem fs = LocalFileSystem.getInstance();
  final List<VirtualFile> files = ContainerUtil.newArrayListWithCapacity(paths.size());
  for (String path : paths) {
    final String vfsPath = FileUtil.toSystemIndependentName(path);
    final VirtualFile file = fs.refreshAndFindFileByPath(vfsPath);
    if (file != null && file.isValid()) {
      files.add(file);
    }
  }

  return files;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:MacFileChooserDialogImpl.java

示例3: convertToLocalVirtualFile

import com.intellij.openapi.vfs.LocalFileSystem; //导入方法依赖的package包/类
/**
 * Convert {@link VcsVirtualFile} to the {@link LocalFileSystem local} Virtual File.
 *
 * TODO
 * It is a workaround for the following problem: VcsVirtualFiles returned from the {@link FileHistoryPanelImpl} contain the current path
 * of the file, not the path that was in certain revision. This has to be fixed by making {@link HgFileRevision} implement
 * {@link VcsFileRevisionEx}.
 */
@Nullable
public static VirtualFile convertToLocalVirtualFile(@Nullable VirtualFile file) {
  if (!(file instanceof AbstractVcsVirtualFile)) {
    return file;
  }
  LocalFileSystem lfs = LocalFileSystem.getInstance();
  VirtualFile resultFile = lfs.findFileByPath(file.getPath());
  if (resultFile == null) {
    resultFile = lfs.refreshAndFindFileByPath(file.getPath());
  }
  return resultFile;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:21,代码来源:HgUtil.java

示例4: setupRootModel

import com.intellij.openapi.vfs.LocalFileSystem; //导入方法依赖的package包/类
private static void setupRootModel(
        ProjectDescriptor projectDescriptor,
        final ModuleDescriptor descriptor,
        final ModifiableRootModel rootModel,
        final Map<LibraryDescriptor, Library> projectLibs) {
    final CompilerModuleExtension compilerModuleExtension =
            rootModel.getModuleExtension(CompilerModuleExtension.class);
    compilerModuleExtension.setExcludeOutput(true);
    rootModel.inheritSdk();

    //Module root model seems to store .iml files root dependencies. (src, test, lib)
    logger.info("Starting setupRootModel in ProjectFromSourcesBuilderImplModified");
    final Set<File> contentRoots = descriptor.getContentRoots();
    for (File contentRoot : contentRoots) {
        final LocalFileSystem lfs = LocalFileSystem.getInstance();
        VirtualFile moduleContentRoot =
                lfs.refreshAndFindFileByPath(
                        FileUtil.toSystemIndependentName(contentRoot.getPath()));
        if (moduleContentRoot != null) {
            final ContentEntry contentEntry = rootModel.addContentEntry(moduleContentRoot);
            final Collection<DetectedSourceRoot> sourceRoots =
                    descriptor.getSourceRoots(contentRoot);
            for (DetectedSourceRoot srcRoot : sourceRoots) {
                final String srcpath =
                        FileUtil.toSystemIndependentName(srcRoot.getDirectory().getPath());
                final VirtualFile sourceRoot = lfs.refreshAndFindFileByPath(srcpath);
                if (sourceRoot != null) {
                    contentEntry.addSourceFolder(
                            sourceRoot,
                            shouldBeTestRoot(srcRoot.getDirectory()),
                            getPackagePrefix(srcRoot));
                }
            }
        }
    }
    logger.info("Inherits compiler output path from project");
    compilerModuleExtension.inheritCompilerOutputPath(true);

    logger.info("Starting to create module level libraries");
    final LibraryTable moduleLibraryTable = rootModel.getModuleLibraryTable();
    for (LibraryDescriptor libDescriptor :
            ModuleInsight.getLibraryDependencies(
                    descriptor, projectDescriptor.getLibraries())) {
        final Library projectLib = projectLibs.get(libDescriptor);
        if (projectLib != null) {
            rootModel.addLibraryEntry(projectLib);
        } else {
            // add as module library
            final Collection<File> jars = libDescriptor.getJars();
            for (File file : jars) {
                Library library = moduleLibraryTable.createLibrary();
                Library.ModifiableModel modifiableModel = library.getModifiableModel();
                modifiableModel.addRoot(
                        VfsUtil.getUrlForLibraryRoot(file), OrderRootType.CLASSES);
                modifiableModel.commit();
            }
        }
    }
    logger.info("Ending setupRootModel in ProjectFromSourcesBuilderImplModified");
}
 
开发者ID:testmycode,项目名称:tmc-intellij,代码行数:61,代码来源:ProjectFromSourcesBuilderImplModified.java

示例5: setupRootModel

import com.intellij.openapi.vfs.LocalFileSystem; //导入方法依赖的package包/类
private static void setupRootModel(ProjectDescriptor projectDescriptor, final ModuleDescriptor descriptor,
                                   final ModifiableRootModel rootModel, final Map<LibraryDescriptor, Library> projectLibs) {
  final CompilerModuleExtension compilerModuleExtension = rootModel.getModuleExtension(CompilerModuleExtension.class);
  compilerModuleExtension.setExcludeOutput(true);
  rootModel.inheritSdk();

  final Set<File> contentRoots = descriptor.getContentRoots();
  for (File contentRoot : contentRoots) {
    final LocalFileSystem lfs = LocalFileSystem.getInstance();
    VirtualFile moduleContentRoot = lfs.refreshAndFindFileByPath(FileUtil.toSystemIndependentName(contentRoot.getPath()));
    if (moduleContentRoot != null) {
      final ContentEntry contentEntry = rootModel.addContentEntry(moduleContentRoot);
      final Collection<DetectedSourceRoot> sourceRoots = descriptor.getSourceRoots(contentRoot);
      for (DetectedSourceRoot srcRoot : sourceRoots) {
        final String srcpath = FileUtil.toSystemIndependentName(srcRoot.getDirectory().getPath());
        final VirtualFile sourceRoot = lfs.refreshAndFindFileByPath(srcpath);
        if (sourceRoot != null) {
          contentEntry.addSourceFolder(sourceRoot, shouldBeTestRoot(srcRoot.getDirectory()), getPackagePrefix(srcRoot));
        }
      }
    }
  }
  compilerModuleExtension.inheritCompilerOutputPath(true);
  final LibraryTable moduleLibraryTable = rootModel.getModuleLibraryTable();
  for (LibraryDescriptor libDescriptor : ModuleInsight.getLibraryDependencies(descriptor, projectDescriptor.getLibraries())) {
    final Library projectLib = projectLibs.get(libDescriptor);
    if (projectLib != null) {
      rootModel.addLibraryEntry(projectLib);
    }
    else {
      // add as module library
      final Collection<File> jars = libDescriptor.getJars();
      for (File file : jars) {
        Library library = moduleLibraryTable.createLibrary();
        Library.ModifiableModel modifiableModel = library.getModifiableModel();
        modifiableModel.addRoot(VfsUtil.getUrlForLibraryRoot(file), OrderRootType.CLASSES);
        modifiableModel.commit();
      }
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:42,代码来源:ProjectFromSourcesBuilderImpl.java


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