Java Code Examples for com.intellij.psi.PsiDirectory#getFiles()
The following examples show how to use
com.intellij.psi.PsiDirectory#getFiles() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ContextTagResolver.java From weex-language-support with MIT License | 6 votes |
public static List<WeexTag> resolve(PsiElement any) { List<WeexTag> result = new ArrayList<WeexTag>(); PsiFile file = any.getContainingFile(); PsiDirectory directory = file.getOriginalFile().getContainingDirectory(); if (directory == null) { directory = file.getOriginalFile().getParent(); } if (directory == null) { return result; } PsiFile[] files = directory.getFiles(); for (PsiFile p : files) { if (!p.getName().equals(any.getContainingFile().getName())) { WeexTag common = DirectiveLint.getCommonTag(); if (common != null) { WeexTag fake = new WeexTag(); fake.tag = p.getName().replace(".we", ""); fake.attrs = new CopyOnWriteArrayList<Attribute>(common.attrs); fake.declare = p; result.add(fake); } } } return result; }
Example 2
Source File: ModulesUtil.java From svgtoandroid with MIT License | 6 votes |
private boolean isModule(PsiDirectory directory) { boolean hasGradle = false; boolean hasSrc = false; PsiFile[] files = directory.getFiles(); PsiDirectory[] dirs = directory.getSubdirectories(); for (PsiFile file : files) { if (file.getName().equals("build.gradle")) { hasGradle = true; break; } } for (PsiDirectory dir : dirs) { if (dir.getName().equals("src")) { hasSrc = true; break; } } return hasGradle && hasSrc; }
Example 3
Source File: PantsPythonTestRunConfigurationProducer.java From intellij-pants-plugin with Apache License 2.0 | 6 votes |
private boolean isOrContainsPyTests(PsiElement element) { if (new PyTestFinder().isTest(element)) { return true; } if (element instanceof PyFile) { PyFile pyFile = (PyFile) element; for (PyClass pyClass : pyFile.getTopLevelClasses()) { if (PythonUnitTestUtil.isTestClass(pyClass, ThreeState.YES, null)) { return true; } } } else if (element instanceof PsiDirectory) { PsiDirectory directory = (PsiDirectory) element; for (PsiFile file : directory.getFiles()) { if (isOrContainsPyTests(file)) { return true; } } } return false; }
Example 4
Source File: HaxePackageModel.java From intellij-haxe with Apache License 2.0 | 6 votes |
@Override public List<HaxeModel> getExposedMembers() { PsiDirectory directory = root.access(path); if (directory != null) { PsiFile[] files = directory.getFiles(); return Arrays.stream(files) .filter(file -> file instanceof HaxeFile) .map(file -> { HaxeFileModel fileModel = HaxeFileModel.fromElement(file); return fileModel != null ? fileModel.getMainClassModel() : null; }) .filter(Objects::nonNull) .collect(Collectors.toList()); } return Collections.emptyList(); }
Example 5
Source File: BundleClassGeneratorUtil.java From idea-php-symfony2-plugin with MIT License | 6 votes |
@Nullable public static PhpClass getBundleClassInDirectory(@NotNull PsiDirectory bundleDirContext) { for (PsiFile psiFile : bundleDirContext.getFiles()) { if(!(psiFile instanceof PhpFile)) { continue; } PhpClass aClass = PhpPsiUtil.findClass((PhpFile) psiFile, phpClass -> PhpElementsUtil.isInstanceOf(phpClass, "\\Symfony\\Component\\HttpKernel\\Bundle\\BundleInterface") ); if(aClass != null) { return aClass; } } return null; }
Example 6
Source File: AbstractFileProcessor.java From consulo with Apache License 2.0 | 6 votes |
private static void findFiles(List<PsiFile> files, PsiDirectory directory, boolean subdirs) { final Project project = directory.getProject(); PsiFile[] locals = directory.getFiles(); for (PsiFile local : locals) { CopyrightProfile opts = CopyrightManager.getInstance(project).getCopyrightOptions(local); if (opts != null && CopyrightUpdaters.hasExtension(local)) { files.add(local); } } if (subdirs) { PsiDirectory[] dirs = directory.getSubdirectories(); for (PsiDirectory dir : dirs) { findFiles(files, dir, subdirs); } } }
Example 7
Source File: TypeStateCheckingTest.java From IntelliJDeodorant with MIT License | 5 votes |
private void checkDirectoriesAreEqual(PsiDirectory result, PsiDirectory expected) { for (PsiDirectory directory : result.getSubdirectories()) { if (directory.getName().equals("expected")) { continue; } checkDirectoriesAreEqual(directory, expected.findSubdirectory(directory.getName())); } for (PsiFile file : result.getFiles()) { checkFilesAreEqual(file, expected.findFile(file.getName())); } }
Example 8
Source File: GodClassTest.java From IntelliJDeodorant with MIT License | 5 votes |
private void checkDirectoriesAreEqual(PsiDirectory result, PsiDirectory expected) { for (PsiDirectory directory : result.getSubdirectories()) { if (directory.getName().equals("expected")) { continue; } checkDirectoriesAreEqual(directory, expected.findSubdirectory(directory.getName())); } for (PsiFile file : result.getFiles()) { checkFilesAreEqual(file, expected.findFile(file.getName())); } }
Example 9
Source File: ComposerUtil.java From intellij-neos with GNU General Public License v3.0 | 5 votes |
@Nullable public static JsonFile getComposerManifestInDirectory(@NotNull PsiDirectory packageDirContext) { for (PsiFile psiFile : packageDirContext.getFiles()) { if (psiFile instanceof JsonFile && psiFile.getName().equals("composer.json")) { return (JsonFile) psiFile; } } return null; }
Example 10
Source File: ModulesUtil.java From svgtoandroid with MIT License | 5 votes |
private boolean isAndroidProject(PsiDirectory directory) { PsiFile[] files = directory.getFiles(); for (PsiFile file : files) { if (file.getName().equals("build.gradle")) { isAndroidProject = true; return true; } } isAndroidProject = false; return false; }
Example 11
Source File: PrintManager.java From consulo with Apache License 2.0 | 5 votes |
private static void addToPsiFileList(PsiDirectory psiDirectory, List<Pair<PsiFile, Editor>> filesList, boolean isRecursive) { PsiFile[] files = psiDirectory.getFiles(); for (PsiFile file : files) { filesList.add(Pair.create(file, PsiUtilBase.findEditor(file))); } if (isRecursive) { for (PsiDirectory directory : psiDirectory.getSubdirectories()) { if (!Project.DIRECTORY_STORE_FOLDER.equals(directory.getName())) { addToPsiFileList(directory, filesList, isRecursive); } } } }
Example 12
Source File: BlazePackage.java From intellij with Apache License 2.0 | 4 votes |
private static void processDirectory(Processor<PsiFile> processor, PsiDirectory directory) { for (PsiFile file : directory.getFiles()) { processor.process(file); } }
Example 13
Source File: GenerateAction.java From svgtoandroid with MIT License | 4 votes |
@Override public void actionPerformed(AnActionEvent e) { Project project = e.getProject(); Logger.init("SVG2VectorDrawable", Logger.INFO); ModulesUtil util = new ModulesUtil(project); if (!util.isAndroidProject()) { CommonUtil.showTopic( project, "SVG to VectorDrawable", "Please make sure the current file is in android module", NotificationType.ERROR); return; } String sourceDir = Configuration.getSvgDir(); if (TextUtils.isEmpty(sourceDir)) { CommonUtil.showTopic( project, "SVG to VectorDrawable", "SVG source directory not set, please setting it first", NotificationType.ERROR); return; } String currentModule = util.getCurrentModule(); VirtualFile vf = LocalFileSystem.getInstance().refreshAndFindFileByPath(sourceDir); PsiDirectory svgDir = PsiDirectoryFactory.getInstance(project).createDirectory(vf); final List<String> files = new ArrayList<String>(); for (PsiFile svg : svgDir.getFiles()) { if (svg != null && !svg.isDirectory() && svg.getName().toLowerCase().endsWith(".svg")) { final Transformer transformer = new Transformer.Builder() .setProject(project) .setSVG((XmlFile) svg) .setDpi("nodpi") .setModule(currentModule) .setXmlName(CommonUtil.getValidName(svg.getName().split("\\.")[0]) + ".xml") .create(); Transformer.CallBack callBack = new Transformer.CallBack() { @Override public void onComplete(XmlFile dist) { transformer.writeXmlToDir(dist, false); files.add(dist.getName()); } }; transformer.transforming(callBack); } } String msg = ""; for (String s : files) { msg = msg + s + "<br>"; } CommonUtil.showTopic(project, "SVG to VectorDrawable", "Generating completed.<br>" + msg, NotificationType.INFORMATION); }