• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java PsiPackageManager类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中consulo.psi.PsiPackageManager的典型用法代码示例。如果您正苦于以下问题:Java PsiPackageManager类的具体用法?Java PsiPackageManager怎么用?Java PsiPackageManager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



PsiPackageManager类属于consulo.psi包,在下文中一共展示了PsiPackageManager类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: findPackage

import consulo.psi.PsiPackageManager; //导入依赖的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: getChildDirectoryIcon

import consulo.psi.PsiPackageManager; //导入依赖的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


示例3: addSubtreeToUpdateByElement

import consulo.psi.PsiPackageManager; //导入依赖的package包/类
@Override
public boolean addSubtreeToUpdateByElement(Object element) {
  // should convert PsiDirectories into PackageElements
  if (element instanceof PsiDirectory) {
    PsiDirectory dir = (PsiDirectory)element;
    final PsiPackage aPackage = PsiPackageManager.getInstance(dir.getProject()).findAnyPackage(dir);
    if (ProjectView.getInstance(myProject).isShowModules(getId())) {
      Module[] modules = getModulesFor(dir);
      boolean rv = false;
      for (Module module : modules) {
        rv |= addPackageElementToUpdate(aPackage, module);
      }
      return rv;
    }
    else {
      return addPackageElementToUpdate(aPackage, null);
    }
  }

  return super.addSubtreeToUpdateByElement(element);
}
 
开发者ID:consulo,项目名称:consulo,代码行数:22,代码来源:PackageViewPane.java


示例4: getSubpackages

import consulo.psi.PsiPackageManager; //导入依赖的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


示例5: createPackage

import consulo.psi.PsiPackageManager; //导入依赖的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


示例6: NonClasspathClassFinder

import consulo.psi.PsiPackageManager; //导入依赖的package包/类
public NonClasspathClassFinder(@NotNull Project project, @NotNull String... fileExtensions)
{
	myProject = project;
	myPackageManager = PsiPackageManager.getInstance(myProject);
	myManager = PsiManager.getInstance(myProject);
	myFileExtensions = ArrayUtil.append(fileExtensions, "class");
	final MessageBusConnection connection = project.getMessageBus().connect(project);
	connection.subscribe(VirtualFileManager.VFS_CHANGES, new BulkFileListener()
	{
		@Override
		public void after(@NotNull List<? extends VFileEvent> events)
		{
			clearCache();
		}
	});
	LowMemoryWatcher.register(this::clearCache, project);
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:18,代码来源:NonClasspathClassFinder.java


示例7: JavaCoreProjectEnvironment

import consulo.psi.PsiPackageManager; //导入依赖的package包/类
public JavaCoreProjectEnvironment(Disposable parentDisposable, CoreApplicationEnvironment applicationEnvironment) {
   super(parentDisposable, applicationEnvironment);

   myProject.registerService(PsiElementFactory.class, new PsiElementFactoryImpl(myPsiManager));
   myProject.registerService(JavaPsiImplementationHelper.class, createJavaPsiImplementationHelper());
   myProject.registerService(PsiResolveHelper.class, new PsiResolveHelperImpl(myPsiManager));
   myProject.registerService(JavaResolveCache.class, new JavaResolveCache(myMessageBus));
   myProject.registerService(JavaCodeStyleSettingsFacade.class, new CoreJavaCodeStyleSettingsFacade());
   myProject.registerService(JavaCodeStyleManager.class, new CoreJavaCodeStyleManager());
   registerProjectExtensionPoint(PsiElementFinder.EP_NAME, PsiElementFinder.class);

/*   myPackageIndex = createCorePackageIndex();
   myProject.registerService(PackageIndex.class, myPackageIndex);     */

   myFileManager = createCoreFileManager();
   myProject.registerService(JavaFileManager.class, myFileManager);

   PsiPackageManager manager = new PsiPackageManagerImpl(getProject(), DirectoryIndex.getInstance(getProject()));

   myProject.registerService(PsiPackageManager.class, manager);

   JavaPsiFacadeImpl javaPsiFacade = new JavaPsiFacadeImpl(myProject, manager);
   registerProjectComponent(JavaPsiFacade.class, javaPsiFacade);
   myProject.registerService(JavaPsiFacade.class, javaPsiFacade);
 }
 
开发者ID:consulo,项目名称:consulo-java,代码行数:26,代码来源:JavaCoreProjectEnvironment.java


示例8: getSubPackages

import consulo.psi.PsiPackageManager; //导入依赖的package包/类
@NotNull
@Override
@RequiredReadAction
public PsiJavaPackage[] getSubPackages(@NotNull PsiJavaPackage psiPackage, @NotNull GlobalSearchScope scope)
{
	String qualifiedName = psiPackage.getQualifiedName();
	if(qualifiedName.startsWith("cli"))
	{
		String substring = qualifiedName.substring(3, qualifiedName.length());
		PsiPackage aPackage = PsiPackageManager.getInstance(myProject).findPackage(substring, DotNetModuleExtension.class);
		if(aPackage == null)
		{
			aPackage = PsiPackageManager.getInstance(myProject).findPackage(substring, JavaModuleExtension.class);
		}
		if(aPackage != null)
		{
			PsiPackage[] subPackages = aPackage.getSubPackages(scope);
			if(subPackages.length == 0)
			{
				return PsiJavaPackage.EMPTY_ARRAY;
			}
			PsiJavaPackage[] packages = new PsiJavaPackage[subPackages.length];
			for(int i = 0; i < subPackages.length; i++)
			{
				PsiPackage subPackage = subPackages[i];
				packages[i] = new PsiPackageImpl(myPsiManager, myPsiPackageManager, JavaModuleExtension.class, subPackage.getQualifiedName());
			}
			return packages;
		}
	}
	return super.getSubPackages(psiPackage, scope);
}
 
开发者ID:consulo,项目名称:consulo-ikvm,代码行数:33,代码来源:IkvmPsiElementFinder.java


示例9: isAvailable

import consulo.psi.PsiPackageManager; //导入依赖的package包/类
@Override
@RequiredDispatchThread
protected boolean isAvailable(DataContext dataContext)
{
	Module module = findModule(dataContext);
	if(module != null)
	{
		DotNetModuleExtension extension = ModuleUtilCore.getExtension(module, DotNetModuleExtension.class);
		if(extension != null && extension.isAllowSourceRoots())
		{
			final IdeView view = dataContext.getData(LangDataKeys.IDE_VIEW);
			if(view == null)
			{
				return false;
			}

			PsiDirectory orChooseDirectory = view.getOrChooseDirectory();
			if(orChooseDirectory == null)
			{
				return false;
			}
			PsiPackage aPackage = PsiPackageManager.getInstance(module.getProject()).findPackage(orChooseDirectory, DotNetModuleExtension.class);

			if(aPackage == null)
			{
				return false;
			}
		}
	}
	return module != null && ModuleUtilCore.getExtension(module, CSharpSimpleModuleExtension.class) != null;
}
 
开发者ID:consulo,项目名称:consulo-csharp,代码行数:32,代码来源:CSharpCreateFileAction.java


示例10: createPackage

import consulo.psi.PsiPackageManager; //导入依赖的package包/类
@NotNull
@Override
public PsiPackage createPackage(@NotNull PsiManager psiManager, @NotNull PsiPackageManager psiPackageManager,
		@NotNull Class<? extends ModuleExtension> aClass, @NotNull String s)
{
	return new HaxePackageImpl(psiManager, psiPackageManager, aClass, s);
}
 
开发者ID:consulo,项目名称:consulo-haxe,代码行数:8,代码来源:HaxePsiPackageSupportProvider.java


示例11: calculateDirtyNamespace

import consulo.psi.PsiPackageManager; //导入依赖的package包/类
@RequiredReadAction
@Nullable
@Override
public String calculateDirtyNamespace(@NotNull PsiDirectory directory)
{
	PsiPackage aPackage = PsiPackageManager.getInstance(directory.getProject()).findPackage(directory, DotNetModuleExtension.class);
	String namespace = null;
	if(aPackage != null)
	{
		namespace = aPackage.getQualifiedName();
	}
	return namespace;
}
 
开发者ID:consulo,项目名称:consulo-dotnet,代码行数:14,代码来源:DotNetNamespaceGeneratePolicy.java


示例12: createPackage

import consulo.psi.PsiPackageManager; //导入依赖的package包/类
@NotNull
@Override
public PsiPackage createPackage(@NotNull PsiManager psiManager, @NotNull PsiPackageManager psiPackageManager, @NotNull Class<? extends
		ModuleExtension> aClass, @NotNull String s)
{
	return new DotNetPackage(psiManager, psiPackageManager, aClass, s);
}
 
开发者ID:consulo,项目名称:consulo-dotnet,代码行数:8,代码来源:DotNetPackageSupportProvider.java


示例13: getGroupForFile

import consulo.psi.PsiPackageManager; //导入依赖的package包/类
protected UsageGroup getGroupForFile(final VirtualFile dir) {
  PsiDirectory psiDirectory = PsiManager.getInstance(myProject).findDirectory(dir);
  if (psiDirectory != null) {
    PsiPackage aPackage = PsiPackageManager.getInstance(myProject).findAnyPackage(psiDirectory);
    if (aPackage != null) {
      return new PackageGroup(aPackage);
    }
  }
  return new DirectoryGroup(dir);
}
 
开发者ID:consulo,项目名称:consulo,代码行数:11,代码来源:DirectoryGroupingRule.java


示例14: getCompilableFiles

import consulo.psi.PsiPackageManager; //导入依赖的package包/类
private static VirtualFile[] getCompilableFiles(Project project, VirtualFile[] files) {
  if (files == null || files.length == 0) {
    return VirtualFile.EMPTY_ARRAY;
  }
  final PsiManager psiManager = PsiManager.getInstance(project);
  final ProjectFileIndex fileIndex = ProjectRootManager.getInstance(project).getFileIndex();
  final CompilerManager compilerManager = CompilerManager.getInstance(project);
  final List<VirtualFile> filesToCompile = new ArrayList<VirtualFile>();
  for (final VirtualFile file : files) {
    if (!fileIndex.isInSourceContent(file)) {
      continue;
    }
    if (!file.isInLocalFileSystem()) {
      continue;
    }
    if (file.isDirectory()) {
      final PsiDirectory directory = psiManager.findDirectory(file);
      if (directory == null || PsiPackageManager.getInstance(project).findAnyPackage(directory) == null) {
        continue;
      }
    }
    else {
      FileType fileType = file.getFileType();
      if (!(compilerManager.isCompilableFileType(fileType) || isCompilableResourceFile(project, file))) {
        continue;
      }
    }
    filesToCompile.add(file);
  }
  return VfsUtil.toVirtualFileArray(filesToCompile);
}
 
开发者ID:consulo,项目名称:consulo,代码行数:32,代码来源:CompileAction.java


示例15: adjustElementToCopy

import consulo.psi.PsiPackageManager; //导入依赖的package包/类
@Nullable
@Override
public PsiElement adjustElementToCopy(PsiElement element) {
  if (element instanceof PsiPackage) {
    return element;
  }
  if (element instanceof PsiDirectory) {
    final PsiPackage psiPackage = PsiPackageManager.getInstance(element.getProject()).findAnyPackage((PsiDirectory)element);
    if (psiPackage != null) {
      return psiPackage;
    }
  }
  return null;
}
 
开发者ID:consulo,项目名称:consulo,代码行数:15,代码来源:DefaultPackageQualifiedNameProvider.java


示例16: getQualifiedName

import consulo.psi.PsiPackageManager; //导入依赖的package包/类
@Nullable
@Override
public String getQualifiedName(PsiElement element) {
  if (element instanceof PsiDirectory) {
    PsiPackage anyPackage = PsiPackageManager.getInstance(element.getProject()).findAnyPackage((PsiDirectory)element);
    if (anyPackage != null) {
      return anyPackage.getQualifiedName();
    }
  }
  else if (element instanceof PsiPackage) {
    return ((PsiPackage)element).getQualifiedName();
  }
  return null;
}
 
开发者ID:consulo,项目名称:consulo,代码行数:15,代码来源:DefaultPackageQualifiedNameProvider.java


示例17: PsiPackageBase

import consulo.psi.PsiPackageManager; //导入依赖的package包/类
public PsiPackageBase(PsiManager manager,
                      PsiPackageManager packageManager,
                      Class<? extends ModuleExtension> extensionClass,
                      String qualifiedName) {
  myManager = manager;
  myPackageManager = packageManager;
  myExtensionClass = extensionClass;
  myQualifiedName = qualifiedName;
}
 
开发者ID:consulo,项目名称:consulo,代码行数:10,代码来源:PsiPackageBase.java


示例18: isEmptyMiddlePackage

import consulo.psi.PsiPackageManager; //导入依赖的package包/类
/**
 * a directory is considered "empty" if it has at least one child and all its children are only directories
 *
 * @param strictlyEmpty if true, the package is considered empty if it has only 1 child and this child  is a directory
 *                      otherwise the package is considered as empty if all direct children that it has are directories
 */
public static boolean isEmptyMiddlePackage(@Nonnull PsiDirectory dir,
                                           @Nullable Class<? extends ModuleExtension> moduleExtensionClass,
                                           boolean strictlyEmpty) {
  final VirtualFile[] files = dir.getVirtualFile().getChildren();
  if (files.length == 0) {
    return false;
  }
  PsiManager manager = dir.getManager();
  int subpackagesCount = 0;
  int directoriesCount = 0;
  for (VirtualFile file : files) {
    if (FileTypeManager.getInstance().isFileIgnored(file)) continue;
    if (!file.isDirectory()) return false;
    PsiDirectory childDir = manager.findDirectory(file);
    if (childDir != null) {
      directoriesCount++;
      if (strictlyEmpty && directoriesCount > 1) return false;

      final PsiPackageManager psiPackageManager = PsiPackageManager.getInstance(dir.getProject());
      PsiPackage tempPackage = moduleExtensionClass == null
                               ? psiPackageManager.findAnyPackage(childDir)
                               : psiPackageManager.findPackage(dir, moduleExtensionClass);
      if (tempPackage != null) {
        subpackagesCount++;
      }
    }
  }
  if (strictlyEmpty) {
    return directoriesCount == subpackagesCount && directoriesCount == 1;
  }
  return directoriesCount == subpackagesCount && directoriesCount > 0;
}
 
开发者ID:consulo,项目名称:consulo,代码行数:39,代码来源:PackageNodeUtil.java


示例19: createPackageViewChildrenOnFiles

import consulo.psi.PsiPackageManager; //导入依赖的package包/类
@Nonnull
public static Collection<AbstractTreeNode> createPackageViewChildrenOnFiles(@Nonnull List<VirtualFile> sourceRoots,
                                                                            @Nonnull Project project,
                                                                            @Nonnull ViewSettings settings,
                                                                            @Nullable Module module,
                                                                            final boolean inLibrary) {
  final PsiManager psiManager = PsiManager.getInstance(project);

  final List<AbstractTreeNode> children = new ArrayList<AbstractTreeNode>();
  final Set<PsiPackage> topLevelPackages = new HashSet<PsiPackage>();

  for (final VirtualFile root : sourceRoots) {
    final PsiDirectory directory = psiManager.findDirectory(root);
    if (directory == null) {
      continue;
    }
    final PsiPackage directoryPackage = PsiPackageManager.getInstance(project).findAnyPackage(directory);
    if (directoryPackage == null || isPackageDefault(directoryPackage)) {
      // add subpackages
      final PsiDirectory[] subdirectories = directory.getSubdirectories();
      for (PsiDirectory subdirectory : subdirectories) {
        final PsiPackage aPackage = PsiPackageManager.getInstance(project).findAnyPackage(subdirectory);
        if (aPackage != null && !isPackageDefault(aPackage)) {
          topLevelPackages.add(aPackage);
        }
      }
      // add non-dir items
      children.addAll(BaseProjectViewDirectoryHelper.getDirectoryChildren(directory, settings, false));
    }
    else {
      topLevelPackages.add(directoryPackage);
    }
  }

  for (final PsiPackage topLevelPackage : topLevelPackages) {
    addPackageAsChild(children, topLevelPackage, module, settings, inLibrary);
  }

  return children;
}
 
开发者ID:consulo,项目名称:consulo,代码行数:41,代码来源:PackageNodeUtil.java


示例20: getLocationString

import consulo.psi.PsiPackageManager; //导入依赖的package包/类
@Nullable
@RequiredReadAction
public static String getLocationString(@Nonnull PsiDirectory psiDirectory) {
  PsiPackage aPackage = PsiPackageManager.getInstance(psiDirectory.getProject()).findAnyPackage(psiDirectory);
  if (ProjectRootsUtil.isSourceRoot(psiDirectory) && aPackage != null) {
    return aPackage.getQualifiedName();
  }

  final VirtualFile directory = psiDirectory.getVirtualFile();
  final VirtualFile contentRootForFile = ProjectRootManager.getInstance(psiDirectory.getProject()).getFileIndex().getContentRootForFile(directory);
  if (Comparing.equal(contentRootForFile, psiDirectory)) {
    return PathUtil.toPresentableUrl(directory.getUrl());
  }
  return null;
}
 
开发者ID:consulo,项目名称:consulo,代码行数:16,代码来源:BaseProjectViewDirectoryHelper.java



注:本文中的consulo.psi.PsiPackageManager类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Array类代码示例发布时间:2022-05-22
下一篇:
Java ProxyBuilder类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap