コード例 #1
0
 private GlobalSearchScope getScope() {
   final GlobalSearchScope scope = myJavaClassReferenceSet.getProvider().getScope();
   if (scope == null) {
     final Module module = ModuleUtil.findModuleForPsiElement(getElement());
     if (module != null) {
       return module.getModuleWithDependenciesAndLibrariesScope(true);
     }
     return GlobalSearchScope.allScope(getElement().getProject());
   }
   return scope;
 }
コード例 #2
0
 public JavaClassReference(
     final JavaClassReferenceSet referenceSet,
     TextRange range,
     int index,
     String text,
     final boolean staticImport) {
   super(referenceSet.getProvider());
   myInStaticImport = staticImport;
   LOG.assertTrue(range.getEndOffset() <= referenceSet.getElement().getTextLength());
   myIndex = index;
   myRange = range;
   myText = text;
   myJavaClassReferenceSet = referenceSet;
 }
コード例 #3
0
  @NotNull
  private Object[] getSubclassVariants(
      @NotNull PsiPackage context, @NotNull String[] extendClasses) {
    HashSet<Object> lookups = new HashSet<Object>();
    GlobalSearchScope packageScope = PackageScope.packageScope(context, true);
    GlobalSearchScope scope = myJavaClassReferenceSet.getProvider().getScope();
    if (scope != null) {
      packageScope = packageScope.intersectWith(scope);
    }
    final GlobalSearchScope allScope = ProjectScope.getAllScope(context.getProject());
    final boolean instantiatable =
        JavaClassReferenceProvider.INSTANTIATABLE.getBooleanValue(getOptions());
    final boolean notInterface =
        JavaClassReferenceProvider.NOT_INTERFACE.getBooleanValue(getOptions());
    final boolean notEnum = JavaClassReferenceProvider.NOT_ENUM.getBooleanValue(getOptions());
    final boolean concrete = JavaClassReferenceProvider.CONCRETE.getBooleanValue(getOptions());

    final ClassKind classKind = getClassKind();

    for (String extendClassName : extendClasses) {
      final PsiClass extendClass =
          JavaPsiFacade.getInstance(context.getProject()).findClass(extendClassName, allScope);
      if (extendClass != null) {
        // add itself
        if (packageScope.contains(extendClass.getContainingFile().getVirtualFile())) {
          if (isClassAccepted(
              extendClass, classKind, instantiatable, concrete, notInterface, notEnum)) {
            ContainerUtil.addIfNotNull(createSubclassLookupValue(context, extendClass), lookups);
          }
        }
        for (final PsiClass clazz : ClassInheritorsSearch.search(extendClass, packageScope, true)) {
          if (isClassAccepted(clazz, classKind, instantiatable, concrete, notInterface, notEnum)) {
            ContainerUtil.addIfNotNull(createSubclassLookupValue(context, clazz), lookups);
          }
        }
      }
    }
    return lookups.toArray();
  }