private static void retainOnlyJarsAndDirectories(List<VirtualFile> woSdk) { for (Iterator<VirtualFile> iterator = woSdk.iterator(); iterator.hasNext(); ) { VirtualFile file = iterator.next(); final VirtualFile local = ArchiveVfsUtil.getVirtualFileForJar(file); final boolean dir = file.isDirectory(); final String name = file.getName(); if (LOG.isDebugEnabled()) { LOG.debug( "Considering: " + file.getPath() + "; local=" + local + "; dir=" + dir + "; name=" + name); } if (dir || local != null) { continue; } if (name.endsWith(".jar")) { continue; } LOG.debug("Removing"); iterator.remove(); } }
private static void fileChanged(@NotNull final Project project, @NotNull final VirtualFile file) { if (!DotPackagesFileUtil.DOT_PACKAGES.equals(file.getName())) return; if (LocalFileSystem.getInstance() != file.getFileSystem()) return; final VirtualFile parent = file.getParent(); if (parent == null || parent.findChild(PUBSPEC_YAML) == null) return; scheduleDartPackageRootsUpdate(project); }
public static void addAvailableSystemScripts( final Collection<String> result, @NotNull Module module) { VirtualFile scriptRoot = null; GlobalSearchScope searchScope = GlobalSearchScope.moduleWithDependenciesAndLibrariesScope(module, false); for (PsiClass aClass : JavaPsiFacade.getInstance(module.getProject()).findClasses("CreateApp_", searchScope)) { PsiClass superClass = aClass.getSuperClass(); if (superClass != null && GroovyCommonClassNames.GROOVY_LANG_SCRIPT.equals(superClass.getQualifiedName())) { PsiFile psiFile = aClass.getContainingFile(); if (psiFile != null) { VirtualFile file = psiFile.getVirtualFile(); if (file != null && file.getFileSystem() instanceof ArchiveFileSystem) { VirtualFile parent = file.getParent(); if (parent != null && parent.findChild("Console.class") != null) { scriptRoot = parent; break; } } } } } if (scriptRoot == null) return; Pattern scriptPattern = Pattern.compile("([A-Za-z0-9]+)_?\\.class"); for (VirtualFile file : scriptRoot.getChildren()) { Matcher matcher = scriptPattern.matcher(file.getName()); if (matcher.matches()) { result.add(GroovyNamesUtil.camelToSnake(matcher.group(1))); } } }
private static boolean isScriptFile(VirtualFile virtualFile) { return !virtualFile.isDirectory() && isScriptFileName(virtualFile.getName()); }
public String getApplicationName(Module module) { final VirtualFile root = findAppRoot(module); if (root == null) return null; return root.getName(); }
public static void collectAllResources( @NotNull final AndroidFacet facet, final Set<ResourceEntry> resourceSet) { final LocalResourceManager manager = facet.getLocalResourceManager(); for (final String resType : ResourceType.getNames()) { for (final ResourceElement element : manager.getValueResources(resType)) { ApplicationManager.getApplication() .runReadAction( new Runnable() { @Override public void run() { if (!element.isValid() || facet.getModule().isDisposed() || facet.getModule().getProject().isDisposed()) { return; } final String name = element.getName().getValue(); if (name != null) { resourceSet.add(new ResourceEntry(resType, name)); } } }); } } for (final Resources resources : manager.getResourceElements()) { ApplicationManager.getApplication() .runReadAction( new Runnable() { @Override public void run() { if (!resources.isValid() || facet.getModule().isDisposed() || facet.getModule().getProject().isDisposed()) { return; } for (final Attr attr : resources.getAttrs()) { final String name = attr.getName().getValue(); if (name != null) { resourceSet.add(new ResourceEntry(ResourceType.ATTR.getName(), name)); } } for (final DeclareStyleable styleable : resources.getDeclareStyleables()) { final String name = styleable.getName().getValue(); if (name != null) { resourceSet.add( new ResourceEntry(ResourceType.DECLARE_STYLEABLE.getName(), name)); } } } }); } ApplicationManager.getApplication() .runReadAction( new Runnable() { @Override public void run() { if (facet.getModule().isDisposed() || facet.getModule().getProject().isDisposed()) { return; } for (String id : manager.getIds()) { resourceSet.add(new ResourceEntry(ResourceType.ID.getName(), id)); } } }); final HashSet<VirtualFile> visited = new HashSet<VirtualFile>(); for (VirtualFile subdir : manager.getResourceSubdirs(null)) { final HashSet<VirtualFile> resourceFiles = new HashSet<VirtualFile>(); AndroidUtils.collectFiles(subdir, visited, resourceFiles); for (VirtualFile file : resourceFiles) { resourceSet.add(new ResourceEntry(subdir.getName(), file.getName())); } } }