コード例 #1
0
 @NotNull
 @Override
 public List<JetFile> allInScope(@NotNull GlobalSearchScope scope) {
   List<JetFile> answer = new ArrayList<JetFile>();
   for (JetFile file : environment.getSourceFiles()) {
     if (scope.contains(file.getVirtualFile())) {
       answer.add(file);
     }
   }
   return answer;
 }
コード例 #2
0
 public static List<PsiDirectory> getWritableDirectoryListDefault(
     @Nullable final PsiPackage context,
     final GlobalSearchScope scope,
     final PsiManager psiManager) {
   if (LOG.isDebugEnabled()) {
     LOG.debug(
         "Getting writable directory list for package '"
             + (context == null ? null : context.getQualifiedName())
             + "', scope="
             + scope);
   }
   final List<PsiDirectory> writableDirectoryList = new ArrayList<PsiDirectory>();
   if (context != null) {
     for (PsiDirectory directory : context.getDirectories()) {
       if (LOG.isDebugEnabled()) {
         LOG.debug("Package directory: " + directory);
       }
       if (directory.isWritable() && scope.contains(directory.getVirtualFile())) {
         writableDirectoryList.add(directory);
       }
     }
   } else {
     for (VirtualFile root :
         ProjectRootManager.getInstance(psiManager.getProject()).getContentSourceRoots()) {
       PsiDirectory directory = psiManager.findDirectory(root);
       if (LOG.isDebugEnabled()) {
         LOG.debug("Root: " + root + ", directory: " + directory);
       }
       if (directory != null
           && directory.isWritable()
           && scope.contains(directory.getVirtualFile())) {
         writableDirectoryList.add(directory);
       }
     }
   }
   if (LOG.isDebugEnabled()) {
     LOG.debug("Result " + writableDirectoryList);
   }
   return writableDirectoryList;
 }
コード例 #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();
  }
コード例 #4
0
 @Override
 public boolean isFileInScope(@NotNull JetFile file, @NotNull GlobalSearchScope scope) {
   return scope.contains(file.getVirtualFile()) && environment.getSourceFiles().contains(file);
 }
コード例 #5
0
  private boolean isInScopeOf(DebugProcessImpl debugProcess, String className) {
    final SourcePosition position = getSourcePosition();
    if (position != null) {
      final VirtualFile breakpointFile = position.getFile().getVirtualFile();
      final ProjectFileIndex fileIndex = ProjectRootManager.getInstance(myProject).getFileIndex();
      if (breakpointFile != null
          && fileIndex.isUnderSourceRootOfType(breakpointFile, JavaModuleSourceRootTypes.SOURCES)) {
        if (debugProcess.getSearchScope().contains(breakpointFile)) {
          return true;
        }
        // apply filtering to breakpoints from content sources only, not for sources attached to
        // libraries
        final Collection<VirtualFile> candidates =
            findClassCandidatesInSourceContent(className, debugProcess.getSearchScope(), fileIndex);
        if (LOG.isDebugEnabled()) {
          LOG.debug(
              "Found "
                  + (candidates == null ? "null" : candidates.size())
                  + " candidate containing files for class "
                  + className);
        }
        if (candidates == null) {
          // If no candidates are found in scope then assume that class is loaded dynamically and
          // allow breakpoint
          return true;
        }

        // breakpointFile is not in scope here and there are some candidates in scope
        // for (VirtualFile classFile : candidates) {
        //  if (LOG.isDebugEnabled()) {
        //    LOG.debug("Breakpoint file: " + breakpointFile.getPath()+ "; candidate file: " +
        // classFile.getPath());
        //  }
        //  if (breakpointFile.equals(classFile)) {
        //    return true;
        //  }
        // }
        if (LOG.isDebugEnabled()) {
          final GlobalSearchScope scope = debugProcess.getSearchScope();
          final boolean contains = scope.contains(breakpointFile);
          final Project project = getProject();
          final List<VirtualFile> files =
              ContainerUtil.map(
                  JavaFullClassNameIndex.getInstance().get(className.hashCode(), project, scope),
                  new Function<PsiClass, VirtualFile>() {
                    @Override
                    public VirtualFile fun(PsiClass aClass) {
                      return aClass.getContainingFile().getVirtualFile();
                    }
                  });
          final List<VirtualFile> allFiles =
              ContainerUtil.map(
                  JavaFullClassNameIndex.getInstance()
                      .get(className.hashCode(), project, new EverythingGlobalScope(project)),
                  new Function<PsiClass, VirtualFile>() {
                    @Override
                    public VirtualFile fun(PsiClass aClass) {
                      return aClass.getContainingFile().getVirtualFile();
                    }
                  });
          final VirtualFile contentRoot = fileIndex.getContentRootForFile(breakpointFile);
          final Module module = fileIndex.getModuleForFile(breakpointFile);

          LOG.debug(
              "Did not find '"
                  + className
                  + "' in "
                  + scope
                  + "; contains="
                  + contains
                  + "; contentRoot="
                  + contentRoot
                  + "; module = "
                  + module
                  + "; all files in index are: "
                  + files
                  + "; all possible files are: "
                  + allFiles);
        }

        return false;
      }
    }
    return true;
  }
コード例 #6
0
ファイル: JavaSourceFilterScope.java プロジェクト: jexp/idea2
 public boolean contains(final VirtualFile file) {
   final FileType fileType = file.getFileType();
   return (myDelegate == null || myDelegate.contains(file))
       && (StdFileTypes.JAVA == fileType && myIndex.isInSourceContent(file)
           || StdFileTypes.CLASS == fileType && myIndex.isInLibraryClasses(file));
 }
コード例 #7
0
 @Override
 public boolean contains(@NotNull VirtualFile file) {
   return myScope1.contains(file) && myScope2.contains(file);
 }