private SearchScope getSearchScope(@NotNull Project project) throws ExecutionException, InterruptedException {

    if (myAnalyzeChanges) {
      return getSearchScopeFromChangedFiles(project);
    }

    if (myScopePattern != null) {
      try {
        PackageSet packageSet = PackageSetFactory.getInstance().compile(myScopePattern);
        NamedScope namedScope = new NamedScope("commandLineScope", AllIcons.Ide.LocalScope, packageSet);
        return GlobalSearchScopesCore.filterScope(project, namedScope);
      }
      catch (ParsingException e) {
        LOG.error("Error of scope parsing", e);
        gracefulExit();
        throw new IllegalStateException("unreachable");
      }
    }

    if (mySourceDirectory != null) {
      if (!new File(mySourceDirectory).isAbsolute()) {
        mySourceDirectory = new File(myProjectPath, mySourceDirectory).getPath();
      }
      mySourceDirectory = mySourceDirectory.replace(File.separatorChar, '/');

      VirtualFile vfsDir = LocalFileSystem.getInstance().findFileByPath(mySourceDirectory);
      if (vfsDir == null) {
        reportError(InspectionsBundle.message("inspection.application.directory.cannot.be.found", mySourceDirectory));
        printHelpAndExit();
      }
      return GlobalSearchScopesCore.directoriesScope(project, true, Objects.requireNonNull(vfsDir));
    }

    String scopeName = System.getProperty("idea.analyze.scope");
    NamedScope namedScope = scopeName != null ? NamedScopesHolder.getScope(project, scopeName) : null;
    return namedScope != null ? GlobalSearchScopesCore.filterScope(project, namedScope) : GlobalSearchScope.projectScope(project);
  }
private SearchScope getSearchScope(@NotNull Project project)