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;
}
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());
}
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();
}
use of com.intellij.openapi.vfs.LocalFileSystem in project intellij-community by JetBrains.
the class CompilerUtil method refreshOutputRoots.
/**
* A lightweight procedure which ensures that given roots exist in the VFS.
* No actual refresh is performed.
*/
public static void refreshOutputRoots(@NotNull Collection<String> outputRoots) {
LocalFileSystem fs = LocalFileSystem.getInstance();
Collection<VirtualFile> toRefresh = ContainerUtil.newHashSet();
for (String outputRoot : outputRoots) {
FileAttributes attributes = FileSystemUtil.getAttributes(FileUtil.toSystemDependentName(outputRoot));
VirtualFile vFile = fs.findFileByPath(outputRoot);
if (attributes != null && vFile == null) {
VirtualFile parent = fs.refreshAndFindFileByPath(PathUtil.getParentPath(outputRoot));
if (parent != null && toRefresh.add(parent)) {
parent.getChildren();
}
} else if (attributes == null && vFile != null || attributes != null && attributes.isDirectory() != vFile.isDirectory()) {
toRefresh.add(vFile);
}
}
if (!toRefresh.isEmpty()) {
RefreshQueue.getInstance().refresh(false, false, null, toRefresh);
}
}
use of com.intellij.openapi.vfs.LocalFileSystem in project intellij-community by JetBrains.
the class ExternalSystemNodeAction method getExternalConfig.
@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;
}
Aggregations