本文整理汇总了Java中consulo.psi.PsiPackage类的典型用法代码示例。如果您正苦于以下问题:Java PsiPackage类的具体用法?Java PsiPackage怎么用?Java PsiPackage使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PsiPackage类属于consulo.psi包,在下文中一共展示了PsiPackage类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: findPackage
import consulo.psi.PsiPackage; //导入依赖的package包/类
@Nullable
@Override
@RequiredReadAction
public PsiJavaPackage findPackage(@NotNull String qualifiedName)
{
if(qualifiedName.equals("cli"))
{
return new PsiPackageImpl(myPsiManager, myPsiPackageManager, JavaModuleExtension.class, qualifiedName);
}
if(qualifiedName.startsWith("cli."))
{
PsiPackage aPackage = PsiPackageManager.getInstance(myProject).findPackage(qualifiedName.substring(4, qualifiedName.length()),
JavaModuleExtension.class);
if(aPackage != null)
{
return new PsiPackageImpl(myPsiManager, myPsiPackageManager, JavaModuleExtension.class, qualifiedName);
}
}
return super.findPackage(qualifiedName);
}
开发者ID:consulo,项目名称:consulo-ikvm,代码行数:22,代码来源:IkvmPsiElementFinder.java
示例2: buildResourceName
import consulo.psi.PsiPackage; //导入依赖的package包/类
@Nullable
public static String buildResourceName(final PsiFile file)
{
PsiDirectory directory = file.getContainingDirectory();
if(directory != null)
{
PsiPackage pkg = JavaDirectoryService.getInstance().getPackage(directory);
String packageName = pkg != null ? pkg.getQualifiedName() : "";
if(packageName.length() == 0)
{
return file.getName();
}
return packageName.replace('.', '/') + '/' + file.getName();
}
return null;
}
开发者ID:consulo,项目名称:consulo-ui-designer,代码行数:17,代码来源:FormEditingUtil.java
示例3: isSideEffectFreeConstructor
import consulo.psi.PsiPackage; //导入依赖的package包/类
static boolean isSideEffectFreeConstructor(PsiNewExpression newExpression) {
PsiJavaCodeReferenceElement classReference = newExpression.getClassReference();
PsiClass aClass = classReference == null ? null : (PsiClass)classReference.resolve();
String qualifiedName = aClass == null ? null : aClass.getQualifiedName();
if (qualifiedName == null) return false;
if (ourSideEffectFreeClasses.contains(qualifiedName)) return true;
PsiFile file = aClass.getContainingFile();
PsiDirectory directory = file.getContainingDirectory();
PsiPackage classPackage = JavaDirectoryService.getInstance().getPackage(directory);
String packageName = classPackage == null ? null : classPackage.getQualifiedName();
// all Throwable descendants from java.lang are side effects free
if ("java.lang".equals(packageName) || "java.io".equals(packageName)) {
PsiClass throwableClass = JavaPsiFacade.getInstance(aClass.getProject()).findClass("java.lang.Throwable", aClass.getResolveScope());
if (throwableClass != null && InheritanceUtil.isInheritorOrSelf(aClass, throwableClass, true)) {
return true;
}
}
return false;
}
开发者ID:consulo,项目名称:consulo-java,代码行数:22,代码来源:RemoveUnusedVariableUtil.java
示例4: getChildDirectoryIcon
import consulo.psi.PsiPackage; //导入依赖的package包/类
/**
* Return child directory icon
* If psiDirectory is null it require force package support if this provider is supported it
* @param psiDirectory child directory
* @return icon of child directory
*/
@Nullable
@RequiredReadAction
public final Icon getChildDirectoryIcon(@Nullable PsiDirectory psiDirectory) {
Icon packageIcon = getChildPackageIcon();
if(packageIcon == null) {
return getChildDirectoryIcon();
}
if(psiDirectory != null) {
PsiPackage anyPackage = PsiPackageManager.getInstance(psiDirectory.getProject()).findAnyPackage(psiDirectory);
if(anyPackage != null) {
return packageIcon;
}
else {
return getChildDirectoryIcon();
}
}
else {
//
return packageIcon;
}
}
开发者ID:consulo,项目名称:consulo,代码行数:29,代码来源:ContentFolderTypeProvider.java
示例5: findPackage
import consulo.psi.PsiPackage; //导入依赖的package包/类
@RequiredReadAction
@Nullable
@Override
public PsiPackage findPackage(@Nonnull String qualifiedName, @Nonnull Class<? extends ModuleExtension> extensionClass) {
ConcurrentMap<String, Object> map = myPackageCache.get(extensionClass);
if (map != null) {
final Object value = map.get(qualifiedName);
// if we processed - but not found package
if (value == ObjectUtil.NULL) {
return null;
}
else if (value != null) {
return (PsiPackage)value;
}
}
PsiPackage newPackage = createPackage(qualifiedName, extensionClass);
Object valueForInsert = ObjectUtil.notNull(newPackage, ObjectUtil.NULL);
myPackageCache.computeIfAbsent(extensionClass, aClass -> ContainerUtil.newConcurrentMap()).putIfAbsent(qualifiedName, valueForInsert);
return newPackage;
}
开发者ID:consulo,项目名称:consulo,代码行数:25,代码来源:PsiPackageManagerImpl.java
示例6: createPackage
import consulo.psi.PsiPackage; //导入依赖的package包/类
@Nullable
private PsiPackage createPackage(@Nonnull String qualifiedName, @Nonnull Class<? extends ModuleExtension> extensionClass) {
Query<VirtualFile> dirs = myDirectoryIndex.getDirectoriesByPackageName(qualifiedName, true);
if (dirs.findFirst() == null) {
return null;
}
for (VirtualFile directory : dirs) {
PsiPackage packageFromProviders = createPackageFromProviders(directory, extensionClass, qualifiedName);
if (packageFromProviders != null) {
return packageFromProviders;
}
PsiPackage packageFromLibrary = createPackageFromLibrary(directory, extensionClass, qualifiedName);
if (packageFromLibrary != null) {
return packageFromLibrary;
}
}
return null;
}
开发者ID:consulo,项目名称:consulo,代码行数:21,代码来源:PsiPackageManagerImpl.java
示例7: createPackageFromProviders
import consulo.psi.PsiPackage; //导入依赖的package包/类
@Nullable
private PsiPackage createPackageFromProviders(@Nonnull VirtualFile virtualFile,
@Nonnull Class<? extends ModuleExtension> extensionClass,
@Nonnull String qualifiedName) {
final Module moduleForFile = ModuleUtil.findModuleForFile(virtualFile, myProject);
if (moduleForFile == null) {
return null;
}
ModuleRootManager moduleRootManager = ModuleRootManager.getInstance(moduleForFile);
final ModuleExtension extension = moduleRootManager.getExtension(extensionClass);
if (extension == null) {
return null;
}
PsiManager psiManager = PsiManager.getInstance(myProject);
for (PsiPackageSupportProvider p : PsiPackageSupportProvider.EP_NAME.getExtensions()) {
if (p.isSupported(extension) && p.acceptVirtualFile(moduleForFile, virtualFile)) {
return p.createPackage(psiManager, this, extensionClass, qualifiedName);
}
}
return null;
}
开发者ID:consulo,项目名称:consulo,代码行数:25,代码来源:PsiPackageManagerImpl.java
示例8: createPackageFromLibrary
import consulo.psi.PsiPackage; //导入依赖的package包/类
private PsiPackage createPackageFromLibrary(@Nonnull VirtualFile virtualFile,
@Nonnull Class<? extends ModuleExtension> extensionClass,
@Nonnull String qualifiedName) {
ProjectFileIndex fileIndexFacade = ProjectFileIndex.getInstance(myProject);
PsiManager psiManager = PsiManager.getInstance(myProject);
if (fileIndexFacade.isInLibraryClasses(virtualFile)) {
List<OrderEntry> orderEntriesForFile = fileIndexFacade.getOrderEntriesForFile(virtualFile);
for (OrderEntry orderEntry : orderEntriesForFile) {
Module ownerModule = orderEntry.getOwnerModule();
ModuleExtension extension = ModuleUtilCore.getExtension(ownerModule, extensionClass);
if (extension != null) {
for (PsiPackageSupportProvider p : PsiPackageSupportProvider.EP_NAME.getExtensions()) {
if (p.isSupported(extension)) {
return p.createPackage(psiManager, this, extensionClass, qualifiedName);
}
}
}
}
}
return null;
}
开发者ID:consulo,项目名称:consulo,代码行数:22,代码来源:PsiPackageManagerImpl.java
示例9: findAnyPackage
import consulo.psi.PsiPackage; //导入依赖的package包/类
@RequiredReadAction
@Override
public PsiPackage findAnyPackage(@Nonnull String packageName) {
Query<VirtualFile> dirs = myDirectoryIndex.getDirectoriesByPackageName(packageName, true);
if (dirs.findFirst() == null) {
return null;
}
PsiPackage packageFromCache = findAnyPackageFromCache(packageName);
if (packageFromCache != null) {
return packageFromCache;
}
for (VirtualFile dir : dirs) {
PsiPackage psiPackage = findAnyPackage(dir);
if (psiPackage != null) {
return psiPackage;
}
}
return null;
}
开发者ID:consulo,项目名称:consulo,代码行数:22,代码来源:PsiPackageManagerImpl.java
示例10: getPackageName
import consulo.psi.PsiPackage; //导入依赖的package包/类
public static String getPackageName(PsiDirectory directory, boolean includeRootDir)
{
PsiPackage aPackage = JavaDirectoryService.getInstance().getPackage(directory);
if(aPackage == null)
{
return directory.getVirtualFile().getPresentableUrl();
}
else
{
String packageName = getPackageName(aPackage);
if(includeRootDir)
{
String rootDir = getRootDirectoryForPackage(directory);
if(rootDir != null)
{
return UsageViewBundle.message("usage.target.package.in.directory", packageName, rootDir);
}
}
return packageName;
}
}
开发者ID:consulo,项目名称:consulo-java,代码行数:22,代码来源:JavaFindUsagesProvider.java
示例11: getSubPackages
import consulo.psi.PsiPackage; //导入依赖的package包/类
@Nonnull
public PsiPackage[] getSubPackages(@Nonnull PsiPackage psiPackage, @Nonnull GlobalSearchScope scope) {
final Map<String, PsiPackage> packagesMap = new HashMap<String, PsiPackage>();
final String qualifiedName = psiPackage.getQualifiedName();
for (PsiDirectory dir : psiPackage.getDirectories(scope)) {
PsiDirectory[] subDirs = dir.getSubdirectories();
for (PsiDirectory subDir : subDirs) {
final PsiPackage aPackage = myPackageManager.findPackage(subDir, myExtensionClass);
if (aPackage != null) {
final String subQualifiedName = aPackage.getQualifiedName();
if (subQualifiedName.startsWith(qualifiedName) && !packagesMap.containsKey(subQualifiedName)) {
packagesMap.put(aPackage.getQualifiedName(), aPackage);
}
}
}
}
packagesMap.remove(qualifiedName); // avoid SOE caused by returning a package as a subpackage of itself
return ContainerUtil.toArray(packagesMap.values(), getPackageArrayFactory());
}
开发者ID:consulo,项目名称:consulo,代码行数:21,代码来源:PsiPackageBase.java
示例12: getUniqueId
import consulo.psi.PsiPackage; //导入依赖的package包/类
@Nullable
private Object getUniqueId()
{
if(myElement instanceof PsiClass)
{
String qName = ((PsiClass) myElement).getQualifiedName();
return qName == null ? ((PsiClass) myElement).getName() : qName;
}
if(myElement instanceof PsiPackage)
{
return ((PsiPackage) myElement).getQualifiedName();
}
if(myElement instanceof PsiMethod)
{
return Pair.create(((PsiMethod) myElement).getSignature(mySubstitutor), myQualifierText);
}
if(myElement instanceof PsiVariable)
{
return "#" + ((PsiVariable) myElement).getName();
}
return null;
}
开发者ID:consulo,项目名称:consulo-java,代码行数:24,代码来源:CompletionElement.java
示例13: addPackageAsChild
import consulo.psi.PsiPackage; //导入依赖的package包/类
public static void addPackageAsChild(@Nonnull Collection<AbstractTreeNode> children,
@Nonnull PsiPackage aPackage,
@Nullable Module module,
@Nonnull ViewSettings settings,
final boolean inLibrary) {
final boolean shouldSkipPackage = settings.isHideEmptyMiddlePackages() && isPackageEmpty(aPackage, module, !settings.isFlattenPackages(), inLibrary);
final Project project = aPackage.getProject();
if (!shouldSkipPackage) {
children.add(new PackageElementNode(project, new PackageElement(module, aPackage, inLibrary), settings));
}
if (settings.isFlattenPackages() || shouldSkipPackage) {
final PsiPackage[] subpackages = getSubpackages(aPackage, module, project, inLibrary);
for (PsiPackage subpackage : subpackages) {
addPackageAsChild(children, subpackage, module, settings, inLibrary);
}
}
}
开发者ID:consulo,项目名称:consulo,代码行数:18,代码来源:PackageNodeUtil.java
示例14: getSubpackages
import consulo.psi.PsiPackage; //导入依赖的package包/类
@Nonnull
public static PsiPackage[] getSubpackages(@Nonnull PsiPackage aPackage,
@Nullable Module module,
@Nonnull Project project,
final boolean searchInLibraries) {
final PsiDirectory[] dirs = getDirectories(aPackage, project, module, searchInLibraries);
final Set<PsiPackage> subpackages = new HashSet<PsiPackage>();
for (PsiDirectory dir : dirs) {
final PsiDirectory[] subdirectories = dir.getSubdirectories();
for (PsiDirectory subdirectory : subdirectories) {
final PsiPackage psiPackage = PsiPackageManager.getInstance(project).findAnyPackage(subdirectory);
if (psiPackage != null) {
final String name = psiPackage.getName();
// skip "default" subpackages as they should be attributed to other modules
// this is the case when contents of one module is nested into contents of another
if (name != null && !name.isEmpty()) {
subpackages.add(psiPackage);
}
}
}
}
return subpackages.toArray(new PsiPackage[subpackages.size()]);
}
开发者ID:consulo,项目名称:consulo,代码行数:24,代码来源:PackageNodeUtil.java
示例15: getChildren
import consulo.psi.PsiPackage; //导入依赖的package包/类
@Override
@Nonnull
public Collection<AbstractTreeNode> getChildren() {
final PackageElement value = getValue();
if (value == null) return Collections.emptyList();
final List<AbstractTreeNode> children = new ArrayList<AbstractTreeNode>();
final Module module = value.getModule();
final PsiPackage aPackage = value.getPackage();
if (!getSettings().isFlattenPackages()) {
final PsiPackage[] subpackages = PackageNodeUtil.getSubpackages(aPackage, module, myProject, isLibraryElement());
for (PsiPackage subpackage : subpackages) {
PackageNodeUtil.addPackageAsChild(children, subpackage, module, getSettings(), isLibraryElement());
}
}
// process only files in package's directories
final PsiDirectory[] dirs = PackageNodeUtil.getDirectories(aPackage, myProject, module, isLibraryElement());
for (final PsiDirectory dir : dirs) {
children.addAll(BaseProjectViewDirectoryHelper.getDirectoryChildren(dir, getSettings(), false));
}
return children;
}
开发者ID:consulo,项目名称:consulo,代码行数:24,代码来源:PackageElementNode.java
示例16: createPackage
import consulo.psi.PsiPackage; //导入依赖的package包/类
@Nonnull
@Override
public PsiPackage createPackage(@Nonnull PsiManager psiManager,
@Nonnull PsiPackageManager packageManager,
@Nonnull Class<? extends ModuleExtension> extensionClass,
@Nonnull String packageName) {
return new PsiPackageBase(psiManager, packageManager, extensionClass, packageName) {
@Override
protected ArrayFactory<? extends PsiPackage> getPackageArrayFactory() {
return PsiPackage.ARRAY_FACTORY;
}
@RequiredReadAction
@Nonnull
@Override
public Language getLanguage() {
return SandLanguage.INSTANCE;
}
};
}
开发者ID:consulo,项目名称:consulo,代码行数:21,代码来源:Sand2PackageProvider.java
示例17: isToSearchForTextOccurrences
import consulo.psi.PsiPackage; //导入依赖的package包/类
@Override
public boolean isToSearchForTextOccurrences(PsiElement element) {
if (element instanceof PsiClass) {
return JavaRefactoringSettings.getInstance().RENAME_SEARCH_FOR_TEXT_FOR_CLASS;
}
else if (element instanceof PsiMethod) {
return JavaRefactoringSettings.getInstance().RENAME_SEARCH_FOR_TEXT_FOR_METHOD;
}
else if (element instanceof PsiVariable) {
return JavaRefactoringSettings.getInstance().RENAME_SEARCH_FOR_TEXT_FOR_VARIABLE;
}
else if (element instanceof PsiPackage) {
return JavaRefactoringSettings.getInstance().RENAME_SEARCH_FOR_TEXT_FOR_PACKAGE;
}
return false;
}
开发者ID:consulo,项目名称:consulo-java,代码行数:17,代码来源:JavaSafeDeleteProcessor.java
示例18: processImplicitlyImportedPackages
import consulo.psi.PsiPackage; //导入依赖的package包/类
public static boolean processImplicitlyImportedPackages(final PsiScopeProcessor processor, final ResolveState state, final PsiElement place, PsiManager manager)
{
PsiPackage defaultPackage = JavaPsiFacade.getInstance(manager.getProject()).findPackage("");
if(defaultPackage != null)
{
if(!defaultPackage.processDeclarations(processor, state, null, place))
{
return false;
}
}
PsiPackage langPackage = JavaPsiFacade.getInstance(manager.getProject()).findPackage(CommonClassNames.DEFAULT_PACKAGE);
if(langPackage != null)
{
if(!langPackage.processDeclarations(processor, state, null, place))
{
return false;
}
}
return true;
}
开发者ID:consulo,项目名称:consulo-java,代码行数:23,代码来源:JavaResolveUtil.java
示例19: resolveToPackage
import consulo.psi.PsiPackage; //导入依赖的package包/类
@NotNull
private JavaResolveResult[] resolveToPackage(@NotNull PsiFile containingFile)
{
final String packageName = getCachedNormalizedText();
Project project = containingFile.getProject();
JavaPsiFacade psiFacade = JavaPsiFacade.getInstance(project);
final PsiPackage aPackage = psiFacade.findPackage(packageName);
if(aPackage == null)
{
return psiFacade.isPartOfPackagePrefix(packageName) ? CandidateInfo.RESOLVE_RESULT_FOR_PACKAGE_PREFIX_PACKAGE : JavaResolveResult.EMPTY_ARRAY;
}
// check that all qualifiers must resolve to package parts, to prevent local vars shadowing corresponding package case
PsiExpression qualifier = getQualifierExpression();
if(qualifier instanceof PsiReferenceExpression && !(((PsiReferenceExpression) qualifier).resolve() instanceof PsiPackage))
{
return JavaResolveResult.EMPTY_ARRAY;
}
return new JavaResolveResult[]{new CandidateInfo(aPackage, PsiSubstitutor.EMPTY)};
}
开发者ID:consulo,项目名称:consulo-java,代码行数:20,代码来源:PsiReferenceExpressionImpl.java
示例20: checkClassReferenceAfterQualifier
import consulo.psi.PsiPackage; //导入依赖的package包/类
@Nullable
static HighlightInfo checkClassReferenceAfterQualifier(@NotNull final PsiReferenceExpression expression, final PsiElement resolved)
{
if(!(resolved instanceof PsiClass))
{
return null;
}
final PsiExpression qualifier = expression.getQualifierExpression();
if(qualifier == null)
{
return null;
}
if(qualifier instanceof PsiReferenceExpression)
{
PsiElement qualifierResolved = ((PsiReferenceExpression) qualifier).resolve();
if(qualifierResolved instanceof PsiClass || qualifierResolved instanceof PsiPackage)
{
return null;
}
}
String description = JavaErrorMessages.message("expected.class.or.package");
HighlightInfo info = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(qualifier).descriptionAndTooltip(description).create();
QuickFixAction.registerQuickFixAction(info, QUICK_FIX_FACTORY.createRemoveQualifierFix(qualifier, expression, (PsiClass) resolved));
return info;
}
开发者ID:consulo,项目名称:consulo-java,代码行数:26,代码来源:HighlightUtil.java
注:本文中的consulo.psi.PsiPackage类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论