本文整理汇总了Java中com.intellij.openapi.vfs.LocalFileSystem.getInstance方法的典型用法代码示例。如果您正苦于以下问题:Java LocalFileSystem.getInstance方法的具体用法?Java LocalFileSystem.getInstance怎么用?Java LocalFileSystem.getInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.openapi.vfs.LocalFileSystem
的用法示例。
在下文中一共展示了LocalFileSystem.getInstance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: findProject
import com.intellij.openapi.vfs.LocalFileSystem; //导入方法依赖的package包/类
@Nullable
private Project findProject(String file) {
LocalFileSystem localFileSystem = LocalFileSystem.getInstance();
ProjectLocator projectLocator = ProjectLocator.getInstance();
AtomicReference<Project> ret = new AtomicReference<>();
FileUtil.processFilesRecursively(
new File(file),
(f) -> {
VirtualFile vf = localFileSystem.findFileByIoFile(f);
if (vf != null) {
ret.set(projectLocator.guessProjectForFile(vf));
return false;
}
return true;
});
return ret.get();
}
示例2: removeAllFiles
import com.intellij.openapi.vfs.LocalFileSystem; //导入方法依赖的package包/类
@Override
public void removeAllFiles(@NotNull final Collection<File> files) throws IOException {
Validate.notNull(files);
if (files.isEmpty()) {
return;
}
final LocalFileSystem localFileSystem = LocalFileSystem.getInstance();
for (File file : files) {
final VirtualFile virtualFile = localFileSystem.findFileByIoFile(file);
if (null != virtualFile) {
ApplicationManager.getApplication().runWriteAction(new RemoveFileComputable(virtualFile));
} else {
FileUtil.delete(file);
}
}
}
开发者ID:AlexanderBartash,项目名称:hybris-integration-intellij-idea-plugin,代码行数:21,代码来源:DefaultVirtualFileSystemService.java
示例3: createFromTempFile
import com.intellij.openapi.vfs.LocalFileSystem; //导入方法依赖的package包/类
public static FileContent createFromTempFile(Project project, String name, String ext, @NotNull byte[] content) throws IOException {
File tempFile = FileUtil.createTempFile(name, "." + ext);
if (content.length != 0) {
FileUtil.writeToFile(tempFile, content);
}
tempFile.deleteOnExit();
final LocalFileSystem lfs = LocalFileSystem.getInstance();
VirtualFile file = lfs.findFileByIoFile(tempFile);
if (file == null) {
file = lfs.refreshAndFindFileByIoFile(tempFile);
}
if (file != null) {
return new FileContent(project, file);
}
throw new IOException("Can not create temp file for revision content");
}
示例4: fillMapping
import com.intellij.openapi.vfs.LocalFileSystem; //导入方法依赖的package包/类
private void fillMapping(final SvnMapping mapping, final List<SvnCopyRootSimple> list) {
final LocalFileSystem lfs = LocalFileSystem.getInstance();
for (SvnCopyRootSimple simple : list) {
final VirtualFile copyRoot = lfs.findFileByIoFile(new File(simple.myCopyRoot));
final VirtualFile vcsRoot = lfs.findFileByIoFile(new File(simple.myVcsRoot));
if (copyRoot == null || vcsRoot == null) continue;
final SvnVcs vcs = SvnVcs.getInstance(myProject);
final Info svnInfo = vcs.getInfo(copyRoot);
if ((svnInfo == null) || (svnInfo.getRepositoryRootURL() == null)) continue;
Node node = new Node(copyRoot, svnInfo.getURL(), svnInfo.getRepositoryRootURL());
final RootUrlInfo info = new RootUrlInfo(node, SvnFormatSelector.findRootAndGetFormat(svnInfo.getFile()), vcsRoot);
mapping.add(info);
}
}
示例5: 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;
}
示例6: run
import com.intellij.openapi.vfs.LocalFileSystem; //导入方法依赖的package包/类
public void run() {
final LocalFileSystem lfs = LocalFileSystem.getInstance();
final FileGroup conflictedGroup = myUpdatedFiles.getGroupById(FileGroup.MERGED_WITH_TREE_CONFLICT);
final Collection<String> conflictedFiles = conflictedGroup.getFiles();
final Collection<VirtualFile> parents = new ArrayList<VirtualFile>();
if ((conflictedFiles != null) && (! conflictedFiles.isEmpty())) {
for (final String conflictedFile : conflictedFiles) {
final File file = new File(conflictedFile);
final VirtualFile vfFile = lfs.refreshAndFindFileByIoFile(file);
if (vfFile != null) {
parents.add(vfFile);
continue;
}
final File parent = file.getParentFile();
VirtualFile vf = lfs.findFileByIoFile(parent);
if (vf == null) {
vf = lfs.refreshAndFindFileByIoFile(parent);
}
if (vf != null) {
parents.add(vf);
}
}
}
if (! parents.isEmpty()) {
RefreshQueue.getInstance().refresh(true, true, new Runnable() {
public void run() {
myDirtyScopeManager.filesDirty(null, parents);
}
}, parents);
}
}
示例7: RemoteRevisionsNumbersCache
import com.intellij.openapi.vfs.LocalFileSystem; //导入方法依赖的package包/类
RemoteRevisionsNumbersCache(final Project project) {
myProject = project;
myLock = new Object();
myData = new HashMap<String, Pair<VcsRoot, VcsRevisionNumber>>();
myRefreshingQueues = Collections.synchronizedMap(new HashMap<VcsRoot, LazyRefreshingSelfQueue<String>>());
myLatestRevisionsMap = new HashMap<String, VcsRevisionNumber>();
myLfs = LocalFileSystem.getInstance();
myVcsManager = ProjectLevelVcsManager.getInstance(project);
myVcsConfiguration = VcsConfiguration.getInstance(project);
}
示例8: testExternalCommitInExternals
import com.intellij.openapi.vfs.LocalFileSystem; //导入方法依赖的package包/类
@Test
public void testExternalCommitInExternals() throws Exception {
prepareExternal();
final File sourceDir = new File(myWorkingCopyDir.getPath(), "source");
final File externalDir = new File(myWorkingCopyDir.getPath(), "source/external");
final File file = new File(externalDir, "t11.txt");
final VirtualFile vf = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(file);
final File mainFile = new File(myWorkingCopyDir.getPath(), "source/s1.txt");
final VirtualFile vfMain = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(mainFile);
renameFileInCommand(vf, "tt11.txt");
renameFileInCommand(vfMain, "ss11.txt");
myVcsDirtyScopeManager.markEverythingDirty();
clManager.ensureUpToDate(false);
Assert.assertEquals(2, clManager.getChangesIn(myWorkingCopyDir).size());
TimeoutUtil.sleep(100);
runInAndVerifyIgnoreOutput("ci", "-m", "test", sourceDir.getPath());
runInAndVerifyIgnoreOutput("ci", "-m", "test", externalDir.getPath());
myWorkingCopyDir.refresh(false, true);
final LocalFileSystem lfs = LocalFileSystem.getInstance();
imitateEvent(lfs.refreshAndFindFileByIoFile(sourceDir));
imitateEvent(lfs.refreshAndFindFileByIoFile(externalDir));
// no dirty scope externally provided! just VFS refresh
clManager.ensureUpToDate(false);
Assert.assertEquals(0, clManager.getChangesIn(myWorkingCopyDir).size());
}
示例9: appendNestedVcsRootsToDirt
import com.intellij.openapi.vfs.LocalFileSystem; //导入方法依赖的package包/类
public static void appendNestedVcsRootsToDirt(final VcsDirtyScope dirtyScope, GitVcs vcs, final ProjectLevelVcsManager vcsManager) {
final Set<FilePath> recursivelyDirtyDirectories = dirtyScope.getRecursivelyDirtyDirectories();
if (recursivelyDirtyDirectories.isEmpty()) {
return;
}
final LocalFileSystem lfs = LocalFileSystem.getInstance();
final Set<VirtualFile> rootsUnderGit = new HashSet<VirtualFile>(Arrays.asList(vcsManager.getRootsUnderVcs(vcs)));
final Set<VirtualFile> inputColl = new HashSet<VirtualFile>(rootsUnderGit);
final Set<VirtualFile> existingInScope = new HashSet<VirtualFile>();
for (FilePath dir : recursivelyDirtyDirectories) {
VirtualFile vf = dir.getVirtualFile();
if (vf == null) {
vf = lfs.findFileByIoFile(dir.getIOFile());
}
if (vf == null) {
vf = lfs.refreshAndFindFileByIoFile(dir.getIOFile());
}
if (vf != null) {
existingInScope.add(vf);
}
}
inputColl.addAll(existingInScope);
FileUtil.removeAncestors(inputColl, new Convertor<VirtualFile, String>() {
@Override
public String convert(VirtualFile o) {
return o.getPath();
}
}, new PairProcessor<VirtualFile, VirtualFile>() {
@Override
public boolean process(VirtualFile parent, VirtualFile child) {
if (! existingInScope.contains(child) && existingInScope.contains(parent)) {
debug("adding git root for check: " + child.getPath());
((VcsModifiableDirtyScope)dirtyScope).addDirtyDirRecursively(VcsUtil.getFilePath(child));
}
return true;
}
}
);
}
示例10: 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;
}
示例11: FileGroupingProjectNode
import com.intellij.openapi.vfs.LocalFileSystem; //导入方法依赖的package包/类
public FileGroupingProjectNode(Project project, File file, ViewSettings viewSettings) {
super(project, file, viewSettings);
final LocalFileSystem lfs = LocalFileSystem.getInstance();
myVirtualFile = lfs.findFileByIoFile(file);
if (myVirtualFile == null) {
myVirtualFile = lfs.refreshAndFindFileByIoFile(file);
}
}
示例12: findFirstValidVirtualParent
import com.intellij.openapi.vfs.LocalFileSystem; //导入方法依赖的package包/类
@Nullable
private static VirtualFile findFirstValidVirtualParent(@Nullable File file) {
LocalFileSystem lfs = LocalFileSystem.getInstance();
VirtualFile vf = null;
while (file != null && (vf == null || !vf.isValid())) {
vf = lfs.findFileByIoFile(file);
file = file.getParentFile();
}
return vf == null || !vf.isValid() ? null : vf;
}
示例13: NewMappings
import com.intellij.openapi.vfs.LocalFileSystem; //导入方法依赖的package包/类
public NewMappings(final Project project, final MessageBus messageBus, final ProjectLevelVcsManagerImpl vcsManager,
FileStatusManager fileStatusManager) {
myProject = project;
myMessageBus = messageBus;
myVcsManager = vcsManager;
myFileStatusManager = fileStatusManager;
myLock = new Object();
myVcsToPaths = new HashMap<String, List<VcsDirectoryMapping>>();
myFileWatchRequestsManager = new FileWatchRequestsManager(myProject, this, LocalFileSystem.getInstance());
myDefaultVcsRootPolicy = DefaultVcsRootPolicy.getInstance(project);
myActiveVcses = new AbstractVcs[0];
if (!myProject.isDefault()) {
final ArrayList<VcsDirectoryMapping> listStr = new ArrayList<VcsDirectoryMapping>();
final VcsDirectoryMapping mapping = new VcsDirectoryMapping("", "");
listStr.add(mapping);
myVcsToPaths.put("", listStr);
mySortedMappings = new VcsDirectoryMapping[]{mapping};
}
else {
mySortedMappings = VcsDirectoryMapping.EMPTY_ARRAY;
}
myActivated = false;
vcsManager.addInitializationRequest(VcsInitObject.MAPPINGS, new DumbAwareRunnable() {
public void run() {
if (!myProject.isDisposed()) {
activateActiveVcses();
}
}
});
}
示例14: putAdministrative17UnderVfsListener
import com.intellij.openapi.vfs.LocalFileSystem; //导入方法依赖的package包/类
/**
* TODO: Currently could not find exact case when "file status is not correctly refreshed after external commit" that is covered by this
* TODO: code. So for now, checks for formats greater than 1.7 are not added here.
*/
private static void putAdministrative17UnderVfsListener(Set<NestedCopyInfo> pointInfos) {
if (! SvnVcs.ourListenToWcDb) return;
final LocalFileSystem lfs = LocalFileSystem.getInstance();
for (NestedCopyInfo info : pointInfos) {
if (WorkingCopyFormat.ONE_DOT_SEVEN.equals(info.getFormat()) && ! NestedCopyType.switched.equals(info.getType())) {
final VirtualFile root = info.getFile();
lfs.refreshIoFiles(Collections.singletonList(SvnUtil.getWcDb(new File(root.getPath()))), true, false, null);
}
}
}
示例15: 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");
}