1 // Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
2 package com.intellij.psi;
4 import com.intellij.lang.jvm.JvmPackage;
5 import com.intellij.navigation.NavigationItem;
6 import com.intellij.openapi.vfs.VirtualFile;
7 import com.intellij.psi.search.GlobalSearchScope;
8 import org.jetbrains.annotations.NotNull;
9 import org.jetbrains.annotations.Nullable;
12 * Represents a Java package.
14 public interface PsiPackage extends PsiCheckedRenameElement, NavigationItem, PsiJvmModifiersOwner,
15 PsiDirectoryContainer, PsiQualifiedNamedElement, JvmPackage {
17 String PACKAGE_INFO_CLASS = "package-info";
18 String PACKAGE_INFO_FILE = PACKAGE_INFO_CLASS + ".java";
19 String PACKAGE_INFO_CLS_FILE = PACKAGE_INFO_CLASS + ".class";
21 PsiPackage[] EMPTY_ARRAY = new PsiPackage[0];
24 * Returns the full-qualified name of the package.
26 * @return the full-qualified name, or an empty string for the default package.
30 String getQualifiedName();
33 * Returns the parent of the package.
35 * @return the parent package, or null for the default package.
39 PsiPackage getParentPackage();
42 * Returns the list of subpackages of this package under all source roots of the project.
44 * @return the array of subpackages.
47 PsiPackage[] getSubPackages();
50 * Returns the list of subpackages of this package in the specified search scope.
52 * @param scope the scope in which packages are searched.
53 * @return the array of subpackages.
56 PsiPackage[] getSubPackages(@NotNull GlobalSearchScope scope);
59 * Returns the list of classes in all directories corresponding to the package.
61 * @return the array of classes.
64 PsiClass[] getClasses();
67 * Returns the list of classes in directories corresponding to the package in the specified
70 * @param scope the scope in which directories are searched.
71 * @return the array of classes.
74 PsiClass[] getClasses(@NotNull GlobalSearchScope scope);
77 * Returns the list of all files in the package, restricted by the specified scope. (This is
78 * normally the list of all files in all directories corresponding to the package, but it can
79 * be modified by custom language plugins which have a different notion of packages.)
82 PsiFile[] getFiles(@NotNull GlobalSearchScope scope);
85 * Returns the list of package-level annotations for the package.
87 * @return the list of annotations, or null if the package does not have any package-level annotations.
90 PsiModifierList getAnnotationList();
93 * This method must be invoked on the package after all directories corresponding
94 * to it have been renamed/moved accordingly to qualified name change.
96 * @param newQualifiedName the new qualified name of the package.
98 void handleQualifiedNameChange(@NotNull String newQualifiedName);
101 * Returns source roots that this package occurs in package prefixes of.
103 * @return the array of virtual files for the source roots.
106 VirtualFile[] occursInPackagePrefixes();
109 @Nullable("default package")
112 boolean containsClassNamed(@NotNull String name);
115 PsiClass[] findClassByShortName(@NotNull String name, @NotNull GlobalSearchScope scope);