コード例 #1
0
  @Override
  public void annotateExternally(
      @NotNull final PsiModifierListOwner listOwner,
      @NotNull final String annotationFQName,
      @NotNull final PsiFile fromFile,
      @Nullable final PsiNameValuePair[] value) {
    final Project project = myPsiManager.getProject();
    final PsiFile containingFile = listOwner.getContainingFile();
    if (!(containingFile instanceof PsiJavaFile)) {
      notifyAfterAnnotationChanging(listOwner, annotationFQName, false);
      return;
    }
    final String packageName = ((PsiJavaFile) containingFile).getPackageName();
    final VirtualFile containingVirtualFile = containingFile.getVirtualFile();
    LOG.assertTrue(containingVirtualFile != null);
    final List<OrderEntry> entries =
        ProjectRootManager.getInstance(project)
            .getFileIndex()
            .getOrderEntriesForFile(containingVirtualFile);
    if (entries.isEmpty()) {
      notifyAfterAnnotationChanging(listOwner, annotationFQName, false);
      return;
    }
    for (final OrderEntry entry : entries) {
      if (entry instanceof ModuleOrderEntry) continue;
      VirtualFile[] roots = AnnotationOrderRootType.getFiles(entry);
      roots = filterByReadOnliness(roots);

      if (roots.length > 0) {
        chooseRootAndAnnotateExternally(
            listOwner, annotationFQName, fromFile, project, packageName, roots, value);
      } else {
        if (ApplicationManager.getApplication().isUnitTestMode()
            || ApplicationManager.getApplication().isHeadlessEnvironment()) {
          notifyAfterAnnotationChanging(listOwner, annotationFQName, false);
          return;
        }
        SwingUtilities.invokeLater(
            new Runnable() {
              @Override
              public void run() {
                setupRootAndAnnotateExternally(
                    entry, project, listOwner, annotationFQName, fromFile, packageName, value);
              }
            });
      }
      break;
    }
  }
コード例 #2
0
 public void actionPerformed(AnActionEvent e) {
   DependenciesToolWindow.getInstance(myProject).closeContent(myContent);
   mySettings.copyToApplicationDependencySettings();
   SwingUtilities.invokeLater(
       new Runnable() {
         public void run() {
           final List<AnalysisScope> scopes = new ArrayList<AnalysisScope>();
           for (DependenciesBuilder builder : myBuilders) {
             final AnalysisScope scope = builder.getScope();
             scope.invalidate();
             scopes.add(scope);
           }
           if (!myForward) {
             new BackwardDependenciesHandler(myProject, scopes, myScopeOfInterest, myExcluded)
                 .analyze();
           } else {
             new AnalyzeDependenciesHandler(myProject, scopes, myTransitiveBorder, myExcluded)
                 .analyze();
           }
         }
       });
 }