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

Java AllClassesSearch类代码示例

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

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



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

示例1: processAllClassesInGlobalScope

import com.intellij.psi.search.searches.AllClassesSearch; //导入依赖的package包/类
private static boolean processAllClassesInGlobalScope(@NotNull final GlobalSearchScope scope,
                                                      @NotNull final AllClassesSearch.SearchParameters parameters,
                                                      @NotNull Processor<PsiClass> processor) {
  final Set<String> names = new THashSet<String>(10000);
  processClassNames(parameters.getProject(), scope, new Consumer<String>() {
    @Override
    public void consume(String s) {
      if (parameters.nameMatches(s)) {
        names.add(s);
      }
    }
  });

  List<String> sorted = new ArrayList<String>(names);
  Collections.sort(sorted, String.CASE_INSENSITIVE_ORDER);

  return processClassesByNames(parameters.getProject(), scope, sorted, processor);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:AllClassesSearchExecutor.java


示例2: execute

import com.intellij.psi.search.searches.AllClassesSearch; //导入依赖的package包/类
@Override
public boolean execute(@NotNull final AllClassesSearch.SearchParameters queryParameters, @NotNull final Processor<PsiClass> consumer)
{
	SearchScope scope = queryParameters.getScope();

	if(scope instanceof GlobalSearchScope)
	{
		return processAllClassesInGlobalScope((GlobalSearchScope) scope, queryParameters, consumer);
	}

	PsiElement[] scopeRoots = ((LocalSearchScope) scope).getScope();
	for(final PsiElement scopeRoot : scopeRoots)
	{
		if(!processScopeRootForAllClasses(scopeRoot, consumer))
		{
			return false;
		}
	}
	return true;
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:21,代码来源:AllClassesSearchExecutor.java


示例3: processAllClassesInGlobalScope

import com.intellij.psi.search.searches.AllClassesSearch; //导入依赖的package包/类
private static boolean processAllClassesInGlobalScope(@NotNull final GlobalSearchScope scope, @NotNull final AllClassesSearch.SearchParameters parameters, @NotNull Processor<PsiClass> processor)
{
	final Set<String> names = new THashSet<String>(10000);
	processClassNames(parameters.getProject(), scope, new Consumer<String>()
	{
		@Override
		public void consume(String s)
		{
			if(parameters.nameMatches(s))
			{
				names.add(s);
			}
		}
	});

	List<String> sorted = new ArrayList<String>(names);
	Collections.sort(sorted, String.CASE_INSENSITIVE_ORDER);

	return processClassesByNames(parameters.getProject(), scope, sorted, processor);
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:21,代码来源:AllClassesSearchExecutor.java


示例4: refreshSketchSelector

import com.intellij.psi.search.searches.AllClassesSearch; //导入依赖的package包/类
private void refreshSketchSelector(Module [] moduleSearchScope) {
    ApplicationManager.getApplication().runWriteAction(() -> {
        Query<PsiClass> classQuery =
                AllClassesSearch.search(ProcessingPluginUtil.INSTANCE.sketchesInModuleScope(moduleSearchScope), project);
        Collection<PsiClass> classesInModule = classQuery.findAll();

        for (PsiClass classInModule : classesInModule) {
            if (SketchClassFilter.isSketchClass(classInModule)) {
                sketchSelector.addItem(new SketchSelectorComboItem(classInModule));
            }
        }
    });
}
 
开发者ID:mistodev,项目名称:processing-idea,代码行数:14,代码来源:ProcessingRunConfigurationEditor.java


示例5: execute

import com.intellij.psi.search.searches.AllClassesSearch; //导入依赖的package包/类
@Override
public boolean execute(@NotNull final AllClassesSearch.SearchParameters queryParameters, @NotNull final Processor<PsiClass> consumer) {
  SearchScope scope = queryParameters.getScope();

  if (scope instanceof GlobalSearchScope) {
    return processAllClassesInGlobalScope((GlobalSearchScope)scope, queryParameters, consumer);
  }

  PsiElement[] scopeRoots = ((LocalSearchScope)scope).getScope();
  for (final PsiElement scopeRoot : scopeRoots) {
    if (!processScopeRootForAllClasses(scopeRoot, consumer)) return false;
  }
  return true;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:15,代码来源:AllClassesSearchExecutor.java


示例6: getAllTestClasses

import com.intellij.psi.search.searches.AllClassesSearch; //导入依赖的package包/类
@Nullable
public static PsiClass[] getAllTestClasses(final TestClassFilter filter, boolean sync) {
  final PsiClass[][] holder = new PsiClass[1][];
  final Runnable process = new Runnable() {
    public void run() {
      final ProgressIndicator indicator = ProgressManager.getInstance().getProgressIndicator();

      final Collection<PsiClass> set = new LinkedHashSet<PsiClass>();
      final PsiManager manager = PsiManager.getInstance(filter.getProject());
      final GlobalSearchScope projectScope = GlobalSearchScope.projectScope(manager.getProject());
      final GlobalSearchScope scope = projectScope.intersectWith(filter.getScope());
      ApplicationManager.getApplication().runReadAction(new Runnable() {
        public void run() {
          for (final PsiClass psiClass : AllClassesSearch.search(scope, manager.getProject())) {
            if (filter.isAccepted(psiClass)) {
              if (indicator != null) {
                indicator.setText2("Found test class " + psiClass.getQualifiedName());
              }
              set.add(psiClass);
            }
          }
        }
      });
      holder[0] = set.toArray(new PsiClass[set.size()]);
    }
  };
  if (sync) {
     ProgressManager.getInstance().runProcessWithProgressSynchronously(process, "Searching For Tests...", true, filter.getProject());
  }
  else {
     process.run();
  }
  return holder[0];
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:35,代码来源:TestNGUtil.java


示例7: extractDagger2ModulesPsiClasses

import com.intellij.psi.search.searches.AllClassesSearch; //导入依赖的package包/类
@NotNull
private List<PsiClass> extractDagger2ModulesPsiClasses(AnActionEvent e) {
    DaggerModuleClassFilter filter = new DaggerModuleClassFilter();
    final Module module = LangDataKeys.MODULE.getData(e.getDataContext());
    SearchScope scope = GlobalSearchScope.moduleScope(module);
    Query<PsiClass> search = AllClassesSearch.search(scope, e.getProject());
    List<PsiClass> modulesClasses = new ArrayList<>();
    for (PsiClass psiClass : search.findAll()) {
        if (filter.isAccepted(psiClass)) {
            modulesClasses.add(psiClass);
        }
    }
    return modulesClasses;
}
 
开发者ID:phajduk,项目名称:dagger2-intellij-plugin,代码行数:15,代码来源:GenerateComponentAction.java


示例8: getVariants

import com.intellij.psi.search.searches.AllClassesSearch; //导入依赖的package包/类
@NotNull
@Override
public Object[] getVariants() {
  // all classes of current platform with same type closure are eligible
  final Project project = getElement().getProject();
  final DefracFacet facet = DefracFacet.getInstance(getElement());

  if(facet == null) {
    return NO_VARIANTS;
  }

  final GlobalSearchScope scope = facet.getMultiPlatformClassSearchScope(platform);
  final PsiJavaFile file = (PsiJavaFile)getElement().getContainingFile();

  if(file == null) {
    return NO_VARIANTS;
  }

  final PsiClass enclosingClass =
      getParentOfType(getElement(), PsiClass.class, false);

  if(enclosingClass == null) {
    return NO_VARIANTS;
  }

  final Query<PsiClass> query = AllClassesSearch.search(scope, project);
  return variantsViaQuery(query, enclosingClass);
}
 
开发者ID:defrac,项目名称:defrac-plugin-intellij,代码行数:29,代码来源:InjectorClassReference.java


示例9: getAllTestClasses

import com.intellij.psi.search.searches.AllClassesSearch; //导入依赖的package包/类
@Nullable
public static PsiClass[] getAllTestClasses(final TestClassFilter filter, boolean sync) {
  final PsiClass[][] holder = new PsiClass[1][];
  final Runnable process = new Runnable() {
    public void run() {
      final ProgressIndicator indicator = ProgressManager.getInstance().getProgressIndicator();

      final Collection<PsiClass> set = new HashSet<PsiClass>();
      PsiManager manager = PsiManager.getInstance(filter.getProject());
      GlobalSearchScope scope = filter.getScope();
      GlobalSearchScope projectScope = GlobalSearchScope.projectScope(manager.getProject());
      scope = projectScope.intersectWith(scope);
      for (final PsiClass psiClass : AllClassesSearch.search(scope, manager.getProject())) {
        ApplicationManager.getApplication().runReadAction(new Runnable() {
          public void run() {
            if (filter.isAccepted(psiClass)) {
              indicator.setText2("Found test class " + psiClass.getQualifiedName());
              set.add(psiClass);
            }
          }
        });
      }
      holder[0] = set.toArray(new PsiClass[set.size()]);
    }
  };
  if (sync) {
     ProgressManager.getInstance().runProcessWithProgressSynchronously(process, "Searching For Tests...", true, filter.getProject());
  }
  else {
     process.run();
  }
  return holder[0];
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:34,代码来源:TestNGUtil.java


示例10: buildEntryPoints

import com.intellij.psi.search.searches.AllClassesSearch; //导入依赖的package包/类
@NotNull
public static PsiElement[] buildEntryPoints(@NotNull Module module)
{
	Query<PsiClass> search = AllClassesSearch.search(GlobalSearchScope.moduleScope(module), module.getProject());

	final List<PsiElement> list = new ArrayList<PsiElement>();
	search.forEach(psiClass -> {
		if(PsiMethodUtil.hasMainMethod(psiClass))
		{
			list.add(new IkvmJavaClassAsDotNetTypeElement(psiClass));
		}
		return true;
	});
	return ContainerUtil.toArray(list, PsiElement.ARRAY_FACTORY);
}
 
开发者ID:consulo,项目名称:consulo-ikvm,代码行数:16,代码来源:IkvmModuleExtensionUtil.java


示例11: processInheritors

import com.intellij.psi.search.searches.AllClassesSearch; //导入依赖的package包/类
private static void processInheritors(@NotNull final Processor<PsiClass> consumer,
                                         @NotNull final PsiClass baseClass,
                                         @NotNull final SearchScope searchScope,
                                         @NotNull final ClassInheritorsSearch.SearchParameters parameters) {
  if (baseClass instanceof PsiAnonymousClass || isFinal(baseClass)) return;

  Project project = PsiUtilCore.getProjectInReadAction(baseClass);
  if (isJavaLangObject(baseClass)) {
    AllClassesSearch.search(searchScope, project, parameters.getNameCondition()).forEach(new Processor<PsiClass>() {
      @Override
      public boolean process(final PsiClass aClass) {
        ProgressManager.checkCanceled();
        return isJavaLangObject(aClass) || consumer.process(aClass);
      }
    });
    return;
  }

  final Ref<PsiClass> currentBase = Ref.create(null);
  final Stack<PsiAnchor> stack = new Stack<PsiAnchor>();
  final Set<PsiAnchor> processed = ContainerUtil.newTroveSet();

  final Processor<PsiClass> processor = new ReadActionProcessor<PsiClass>() {
    @Override
    public boolean processInReadAction(PsiClass candidate) {
      ProgressManager.checkCanceled();

      if (parameters.isCheckInheritance() || parameters.isCheckDeep() && !(candidate instanceof PsiAnonymousClass)) {
        if (!candidate.isInheritor(currentBase.get(), false)) {
          return true;
        }
      }

      if (PsiSearchScopeUtil.isInScope(searchScope, candidate)) {
        if (candidate instanceof PsiAnonymousClass) {
          return consumer.process(candidate);
        }
        
        final String name = candidate.getName();
        if (name != null && parameters.getNameCondition().value(name) && !consumer.process(candidate)) {
          return false;
        }
      }

      if (parameters.isCheckDeep() && !(candidate instanceof PsiAnonymousClass) && !isFinal(candidate)) {
        stack.push(PsiAnchor.create(candidate));
      }
      return true;
    }
  };
  
  ApplicationManager.getApplication().runReadAction(new Runnable() {
    @Override
    public void run() {
      stack.push(PsiAnchor.create(baseClass));
    }
  });
  final GlobalSearchScope projectScope = GlobalSearchScope.allScope(project);
  
  while (!stack.isEmpty()) {
    ProgressManager.checkCanceled();

    final PsiAnchor anchor = stack.pop();
    if (!processed.add(anchor)) continue;

    PsiClass psiClass = ApplicationManager.getApplication().runReadAction(new Computable<PsiClass>() {
        @Override
        public PsiClass compute() {
          return (PsiClass)anchor.retrieve();
        }
      });
    if (psiClass == null) continue;

    currentBase.set(psiClass);
    if (!DirectClassInheritorsSearch.search(psiClass, projectScope, parameters.isIncludeAnonymous(), false).forEach(processor)) return;
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:78,代码来源:JavaClassInheritorsSearcher.java


示例12: getVariants

import com.intellij.psi.search.searches.AllClassesSearch; //导入依赖的package包/类
@NotNull
@Override
public Object[] getVariants() {
  // all classes of current platform with same type closure are eligible
  final Project project = getElement().getProject();
  final DefracFacet facet = DefracFacet.getInstance(getElement());

  if(facet == null) {
    return NO_VARIANTS;
  }

  final GlobalSearchScope scope = facet.getMultiPlatformClassSearchScope(platform);
  final PsiJavaFile file = (PsiJavaFile)getElement().getContainingFile();

  if(file == null) {
    return NO_VARIANTS;
  }

  final PsiClass enclosingClass =
      getParentOfType(getElement(), PsiClass.class, false);

  if(enclosingClass == null) {
    return NO_VARIANTS;
  }

  final PsiClassType[] extendsTypes = enclosingClass.getExtendsListTypes();
  final PsiClassType[] implementsTypes = enclosingClass.getImplementsListTypes();
  final PsiClassType[] baseTypes = ArrayUtil.mergeArrays(extendsTypes, implementsTypes);

  final Query<PsiClass> query;

  if(baseTypes.length == 0) {
    // There is no filter (no bases or interfaces the injection must implement)
    // so we offer the user everything we got.
    query = AllClassesSearch.search(scope, project);
  } else {
    PsiClass base = null;

    for(final PsiClassType baseType : baseTypes) {
      final PsiClass resolved = baseType.resolve();
      if(resolved != null) {
        base = resolved;
        break;
      }
    }

    if(base == null) {
      return NO_VARIANTS;
    }

    query = ClassInheritorsSearch.search(base, scope, true, true);
  }

  return variantsViaQuery(query, enclosingClass,
      extendsTypes.length    == 0 ? null : extendsTypes,
      implementsTypes.length == 0 ? null : implementsTypes);
}
 
开发者ID:defrac,项目名称:defrac-plugin-intellij,代码行数:58,代码来源:InjectionClassReference.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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