Search in sources :

Example 1 with LocalFileSystem

use of com.intellij.openapi.vfs.LocalFileSystem in project intellij-community by JetBrains.

the class AntTasksProvider method getAntObjects.

private static Map<String, Class> getAntObjects(final GroovyFile groovyFile) {
    final Project project = groovyFile.getProject();
    final Module module = ModuleUtilCore.findModuleForPsiElement(groovyFile);
    Set<VirtualFile> jars = new HashSet<>();
    if (module != null) {
        ContainerUtil.addAll(jars, OrderEnumerator.orderEntries(module).getAllLibrariesAndSdkClassesRoots());
    }
    if (groovyFile.isScript() && GroovyScriptUtil.getScriptType(groovyFile) instanceof GantScriptType) {
        jars.addAll(GantScriptType.additionalScopeFiles(groovyFile));
    }
    final ArrayList<URL> urls = new ArrayList<>();
    for (VirtualFile jar : jars) {
        VirtualFile localFile = PathUtil.getLocalFile(jar);
        if (localFile.getFileSystem() instanceof LocalFileSystem) {
            urls.add(VfsUtilCore.convertToURL(localFile.getUrl()));
        }
    }
    AntClassLoader loader;
    synchronized (ourLock) {
        final Map<List<URL>, AntClassLoader> map = CachedValuesManager.getManager(project).getParameterizedCachedValue(project, KEY, PROVIDER, false, project);
        loader = map.get(urls);
        if (loader == null) {
            map.put(urls, loader = new AntClassLoader(urls));
        }
    }
    return loader.getAntObjects();
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) URL(java.net.URL) Project(com.intellij.openapi.project.Project) ReflectedProject(com.intellij.lang.ant.ReflectedProject) LocalFileSystem(com.intellij.openapi.vfs.LocalFileSystem) Module(com.intellij.openapi.module.Module)

Example 2 with LocalFileSystem

use of com.intellij.openapi.vfs.LocalFileSystem in project intellij-community by JetBrains.

the class MavenProject method getExistingModuleFiles.

@NotNull
public List<VirtualFile> getExistingModuleFiles() {
    LocalFileSystem fs = LocalFileSystem.getInstance();
    List<VirtualFile> result = new ArrayList<>();
    Set<String> pathsInStack = getModulePaths();
    for (String each : pathsInStack) {
        VirtualFile f = fs.findFileByPath(each);
        if (f != null)
            result.add(f);
    }
    return result;
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) LocalFileSystem(com.intellij.openapi.vfs.LocalFileSystem) NotNull(org.jetbrains.annotations.NotNull)

Example 3 with LocalFileSystem

use of com.intellij.openapi.vfs.LocalFileSystem in project intellij-community by JetBrains.

the class SvnExternalCommitNoticedTest method testExternalCommitInExternals.

@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());
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) LocalFileSystem(com.intellij.openapi.vfs.LocalFileSystem) VirtualFile(com.intellij.openapi.vfs.VirtualFile) File(java.io.File) Test(org.junit.Test)

Example 4 with LocalFileSystem

use of com.intellij.openapi.vfs.LocalFileSystem in project intellij-community by JetBrains.

the class SvnChangeProvider method putAdministrative17UnderVfsListener.

/**
   * 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(virtualToIoFile(root))), true, false, null);
        }
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) LocalFileSystem(com.intellij.openapi.vfs.LocalFileSystem)

Example 5 with LocalFileSystem

use of com.intellij.openapi.vfs.LocalFileSystem in project intellij-community by JetBrains.

the class SvnFileUrlMappingImpl method fillMapping.

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);
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) LocalFileSystem(com.intellij.openapi.vfs.LocalFileSystem) Info(org.jetbrains.idea.svn.info.Info) VirtualFile(com.intellij.openapi.vfs.VirtualFile) File(java.io.File)

Aggregations

LocalFileSystem (com.intellij.openapi.vfs.LocalFileSystem)70 VirtualFile (com.intellij.openapi.vfs.VirtualFile)62 File (java.io.File)32 Nullable (org.jetbrains.annotations.Nullable)10 NotNull (org.jetbrains.annotations.NotNull)8 IOException (java.io.IOException)7 Project (com.intellij.openapi.project.Project)5 Change (com.intellij.openapi.vcs.changes.Change)5 Test (org.junit.Test)5 Module (com.intellij.openapi.module.Module)4 Library (com.intellij.openapi.roots.libraries.Library)4 LibraryTable (com.intellij.openapi.roots.libraries.LibraryTable)4 PsiFile (com.intellij.psi.PsiFile)4 Application (com.intellij.openapi.application.Application)3 VfsUtilCore.virtualToIoFile (com.intellij.openapi.vfs.VfsUtilCore.virtualToIoFile)3 Notification (com.intellij.notification.Notification)2 ModuleManager (com.intellij.openapi.module.ModuleManager)2 ModifiableRootModel (com.intellij.openapi.roots.ModifiableRootModel)2 StringUtil (com.intellij.openapi.util.text.StringUtil)2 FileAnnotation (com.intellij.openapi.vcs.annotate.FileAnnotation)2