use of com.intellij.openapi.vfs.VirtualFileManager in project intellij-community by JetBrains.
the class ResourceBundleManagerState method removeNonExistentFiles.
public ResourceBundleManagerState removeNonExistentFiles() {
final ResourceBundleManagerState newState = new ResourceBundleManagerState();
final VirtualFileManager virtualFileManager = VirtualFileManager.getInstance();
for (final String dissociatedFileUrl : myDissociatedFiles) {
if (virtualFileManager.findFileByUrl(dissociatedFileUrl) != null) {
newState.myDissociatedFiles.add(dissociatedFileUrl);
}
}
for (CustomResourceBundleState customResourceBundle : myCustomResourceBundles) {
final CustomResourceBundleState updatedCustomResourceBundle = customResourceBundle.removeNonExistentFiles(virtualFileManager);
if (updatedCustomResourceBundle != null) {
newState.myCustomResourceBundles.add(updatedCustomResourceBundle);
}
}
return newState;
}
use of com.intellij.openapi.vfs.VirtualFileManager in project intellij-community by JetBrains.
the class LoaderFactory method createClassLoader.
private static ClassLoader createClassLoader(final String runClasspath, final String moduleName) {
final ArrayList<URL> urls = new ArrayList<>();
final VirtualFileManager manager = VirtualFileManager.getInstance();
final JarFileSystemImpl fileSystem = (JarFileSystemImpl) JarFileSystem.getInstance();
final StringTokenizer tokenizer = new StringTokenizer(runClasspath, File.pathSeparator);
while (tokenizer.hasMoreTokens()) {
final String s = tokenizer.nextToken();
try {
VirtualFile vFile = manager.findFileByUrl(VfsUtil.pathToUrl(s));
final File realFile = fileSystem.getMirroredFile(vFile);
urls.add(realFile != null ? realFile.toURI().toURL() : new File(s).toURI().toURL());
} catch (Exception e) {
// ignore ?
}
}
try {
urls.add(new File(PathUtil.getJarPathForClass(Spacer.class)).toURI().toURL());
} catch (MalformedURLException ignored) {
// ignore
}
final URL[] _urls = urls.toArray(new URL[urls.size()]);
return new DesignTimeClassLoader(Arrays.asList(_urls), LoaderFactory.class.getClassLoader(), moduleName);
}
use of com.intellij.openapi.vfs.VirtualFileManager in project intellij-community by JetBrains.
the class MavenProjectsManager method importProjects.
public List<Module> importProjects(final IdeModifiableModelsProvider modelsProvider) {
final Map<MavenProject, MavenProjectChanges> projectsToImportWithChanges;
final boolean importModuleGroupsRequired;
synchronized (myImportingDataLock) {
projectsToImportWithChanges = new LinkedHashMap<>(myProjectsToImport);
myProjectsToImport.clear();
importModuleGroupsRequired = myImportModuleGroupsRequired;
myImportModuleGroupsRequired = false;
}
final Ref<MavenProjectImporter> importer = new Ref<>();
final Ref<List<MavenProjectsProcessorTask>> postTasks = new Ref<>();
final Runnable r = () -> {
MavenProjectImporter projectImporter = new MavenProjectImporter(myProject, myProjectsTree, getFileToModuleMapping(new MavenModelsProvider() {
@Override
public Module[] getModules() {
return modelsProvider.getModules();
}
@Override
public VirtualFile[] getContentRoots(Module module) {
return modelsProvider.getContentRoots(module);
}
}), projectsToImportWithChanges, importModuleGroupsRequired, modelsProvider, getImportingSettings());
importer.set(projectImporter);
postTasks.set(projectImporter.importProject());
};
// called from wizard or ui
if (ApplicationManager.getApplication().isDispatchThread()) {
r.run();
} else {
MavenUtil.runInBackground(myProject, ProjectBundle.message("maven.project.importing"), false, new MavenTask() {
@Override
public void run(MavenProgressIndicator indicator) throws MavenProcessCanceledException {
r.run();
}
}).waitFor();
}
VirtualFileManager fm = VirtualFileManager.getInstance();
if (isNormalProject()) {
fm.asyncRefresh(null);
} else {
fm.syncRefresh();
}
if (postTasks.get() != null) /*may be null if importing is cancelled*/
{
schedulePostImportTasks(postTasks.get());
}
// do not block user too often
myImportingQueue.restartTimer();
MavenProjectImporter projectImporter = importer.get();
if (projectImporter == null)
return Collections.emptyList();
return projectImporter.getCreatedModules();
}
use of com.intellij.openapi.vfs.VirtualFileManager in project intellij-community by JetBrains.
the class LocalHistoryImpl method initHistory.
protected void initHistory() {
ChangeListStorage storage;
try {
storage = new ChangeListStorageImpl(getStorageDir());
} catch (Throwable e) {
LocalHistoryLog.LOG.warn("cannot create storage, in-memory implementation will be used", e);
storage = new InMemoryChangeListStorage();
}
myChangeList = new ChangeList(storage);
myVcs = new LocalHistoryFacade(myChangeList);
myGateway = new IdeaGateway();
myEventDispatcher = new LocalHistoryEventDispatcher(myVcs, myGateway);
CommandProcessor.getInstance().addCommandListener(myEventDispatcher);
myConnection = myBus.connect();
myConnection.subscribe(VirtualFileManager.VFS_CHANGES, myEventDispatcher);
VirtualFileManager fm = VirtualFileManager.getInstance();
fm.addVirtualFileManagerListener(myEventDispatcher);
}
use of com.intellij.openapi.vfs.VirtualFileManager in project intellij-community by JetBrains.
the class DirectoryUrl method createPath.
@Override
public Object[] createPath(final Project project) {
if (moduleName != null) {
final Module module = ApplicationManager.getApplication().runReadAction(new Computable<Module>() {
@Nullable
@Override
public Module compute() {
return ModuleManager.getInstance(project).findModuleByName(moduleName);
}
});
if (module == null)
return null;
}
final VirtualFileManager virtualFileManager = VirtualFileManager.getInstance();
final VirtualFile file = virtualFileManager.findFileByUrl(url);
if (file == null)
return null;
final PsiDirectory directory = ApplicationManager.getApplication().runReadAction(new Computable<PsiDirectory>() {
@Nullable
@Override
public PsiDirectory compute() {
return PsiManager.getInstance(project).findDirectory(file);
}
});
if (directory == null)
return null;
return new Object[] { directory };
}
Aggregations