@NotNull
  private List<Pair<PsiClass, VirtualFile>> doFindClasses(
      @NotNull String qName, @NotNull final GlobalSearchScope scope) {
    final Collection<PsiClass> classes =
        JavaFullClassNameIndex.getInstance().get(qName.hashCode(), myManager.getProject(), scope);
    if (classes.isEmpty()) return Collections.emptyList();
    List<Pair<PsiClass, VirtualFile>> result = new ArrayList<>(classes.size());
    for (PsiClass aClass : classes) {
      final String qualifiedName = aClass.getQualifiedName();
      if (qualifiedName == null || !qualifiedName.equals(qName)) continue;

      PsiFile file = aClass.getContainingFile();
      if (file == null) {
        throw new AssertionError("No file for class: " + aClass + " of " + aClass.getClass());
      }
      final boolean valid = file.isValid();
      VirtualFile vFile = file.getVirtualFile();
      if (!valid) {
        LOG.error(
            "Invalid file "
                + file
                + "; virtualFile:"
                + vFile
                + (vFile != null && !vFile.isValid() ? " (invalid)" : "")
                + "; id="
                + (vFile == null ? 0 : ((VirtualFileWithId) vFile).getId()),
            new PsiInvalidElementAccessException(aClass));
        continue;
      }
      if (!hasAcceptablePackage(vFile)) continue;

      result.add(Pair.create(aClass, vFile));
    }

    return result;
  }
  @Override
  public List<AbstractStepDefinition> loadStepsFor(
      @Nullable PsiFile featureFile, @NotNull Module module) {
    final GlobalSearchScope dependenciesScope =
        module.getModuleWithDependenciesAndLibrariesScope(true);

    Collection<PsiClass> stepDefAnnotationCandidates =
        JavaFullClassNameIndex.getInstance()
            .get(
                CUCUMBER_RUNTIME_JAVA_STEP_DEF_ANNOTATION.hashCode(),
                module.getProject(),
                dependenciesScope);

    PsiClass stepDefAnnotationClass = null;
    for (PsiClass candidate : stepDefAnnotationCandidates) {
      if (CUCUMBER_RUNTIME_JAVA_STEP_DEF_ANNOTATION.equals(candidate.getQualifiedName())) {
        stepDefAnnotationClass = candidate;
        break;
      }
    }
    if (stepDefAnnotationClass == null) {
      return Collections.emptyList();
    }

    final List<AbstractStepDefinition> result = new ArrayList<AbstractStepDefinition>();
    final Query<PsiClass> stepDefAnnotations =
        AnnotatedElementsSearch.searchPsiClasses(stepDefAnnotationClass, dependenciesScope);
    for (PsiClass annotationClass : stepDefAnnotations) {
      final Query<PsiMethod> javaStepDefinitions =
          AnnotatedElementsSearch.searchPsiMethods(annotationClass, dependenciesScope);
      for (PsiMethod stepDefMethod : javaStepDefinitions) {
        result.add(new JavaStepDefinition(stepDefMethod));
      }
    }
    return result;
  }
  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;
  }