コード例 #1
0
 public BaseAnalysisActionDialog(
     @NotNull String title,
     @NotNull String analysisNoon,
     @NotNull Project project,
     @NotNull final AnalysisScope scope,
     final String moduleName,
     final boolean rememberScope,
     @NotNull AnalysisUIOptions analysisUIOptions,
     @Nullable PsiElement context) {
   super(true);
   Disposer.register(myDisposable, myScopeCombo);
   myAnalysisOptions = analysisUIOptions;
   myContext = context;
   if (!analysisUIOptions.ANALYZE_TEST_SOURCES) {
     myAnalysisOptions.ANALYZE_TEST_SOURCES = scope.isAnalyzeTestsByDefault();
   }
   myProject = project;
   myFileName =
       scope.getScopeType() == AnalysisScope.PROJECT
               || scope.getScopeType() == AnalysisScope.MODULE
           ? null
           : scope.getShortenName();
   myModuleName = moduleName;
   myRememberScope = rememberScope;
   myAnalysisNoon = analysisNoon;
   init();
   setTitle(title);
   onScopeRadioButtonPressed();
 }
コード例 #2
0
  @NotNull
  public AnalysisScope getScope(
      @NotNull AnalysisUIOptions uiOptions,
      @NotNull AnalysisScope defaultScope,
      @NotNull Project project,
      Module module) {
    AnalysisScope scope;
    if (isProjectScopeSelected()) {
      scope = new AnalysisScope(project);
      uiOptions.SCOPE_TYPE = AnalysisScope.PROJECT;
    } else {
      final SearchScope customScope = getCustomScope();
      if (customScope != null) {
        scope = new AnalysisScope(customScope, project);
        uiOptions.SCOPE_TYPE = AnalysisScope.CUSTOM;
        uiOptions.CUSTOM_SCOPE_NAME = customScope.getDisplayName();
      } else if (isModuleScopeSelected()) {
        scope = new AnalysisScope(module);
        uiOptions.SCOPE_TYPE = AnalysisScope.MODULE;
      } else if (isUncommitedFilesSelected()) {
        final ChangeListManager changeListManager = ChangeListManager.getInstance(project);
        List<VirtualFile> files;
        if (myChangeLists.getSelectedItem() == ALL) {
          files = changeListManager.getAffectedFiles();
        } else {
          files = new ArrayList<VirtualFile>();
          for (ChangeList list : changeListManager.getChangeListsCopy()) {
            if (!Comparing.strEqual(list.getName(), (String) myChangeLists.getSelectedItem()))
              continue;
            final Collection<Change> changes = list.getChanges();
            for (Change change : changes) {
              final ContentRevision afterRevision = change.getAfterRevision();
              if (afterRevision != null) {
                final VirtualFile vFile = afterRevision.getFile().getVirtualFile();
                if (vFile != null) {
                  files.add(vFile);
                }
              }
            }
          }
        }
        scope = new AnalysisScope(project, new HashSet<VirtualFile>(files));
        uiOptions.SCOPE_TYPE = AnalysisScope.UNCOMMITTED_FILES;
      } else {
        scope = defaultScope;
        uiOptions.SCOPE_TYPE = defaultScope.getScopeType(); // just not project scope
      }
    }
    uiOptions.ANALYZE_TEST_SOURCES = isInspectTestSources();
    scope.setIncludeTestSource(isInspectTestSources());
    scope.setScope(getCustomScope());

    FindSettings.getInstance().setDefaultScopeName(scope.getDisplayName());
    return scope;
  }