예제 #1
0
 public GitVcs(
     @NotNull Project project,
     @NotNull Git git,
     @NotNull final ProjectLevelVcsManager gitVcsManager,
     @NotNull final GitAnnotationProvider gitAnnotationProvider,
     @NotNull final GitDiffProvider gitDiffProvider,
     @NotNull final GitHistoryProvider gitHistoryProvider,
     @NotNull final GitRollbackEnvironment gitRollbackEnvironment,
     @NotNull final GitVcsApplicationSettings gitSettings,
     @NotNull final GitVcsSettings gitProjectSettings,
     @NotNull GitSharedSettings sharedSettings) {
   super(project, NAME);
   myGit = git;
   myVcsManager = gitVcsManager;
   myAppSettings = gitSettings;
   myChangeProvider =
       project.isDefault() ? null : ServiceManager.getService(project, GitChangeProvider.class);
   myCheckinEnvironment =
       project.isDefault()
           ? null
           : ServiceManager.getService(project, GitCheckinEnvironment.class);
   myAnnotationProvider = gitAnnotationProvider;
   myDiffProvider = gitDiffProvider;
   myHistoryProvider = gitHistoryProvider;
   myRollbackEnvironment = gitRollbackEnvironment;
   myRevSelector = new GitRevisionSelector();
   myConfigurable = new GitVcsConfigurable(myProject, gitProjectSettings, sharedSettings);
   myUpdateEnvironment = new GitUpdateEnvironment(myProject, gitProjectSettings);
   myCommittedChangeListProvider = new GitCommittedChangeListProvider(myProject);
   myOutgoingChangesProvider = new GitOutgoingChangesProvider(myProject);
   myTreeDiffProvider = new GitTreeDiffProvider(myProject);
   myCommitAndPushExecutor = new GitCommitAndPushExecutor(myCheckinEnvironment);
   myExecutableValidator = new GitExecutableValidator(myProject);
 }
 @Nullable
 public List<Module> addModule(Component parent, boolean anImport) {
   if (myProject.isDefault()) return null;
   final ProjectBuilder builder = runModuleWizard(parent, anImport);
   if (builder != null) {
     final List<Module> modules = new ArrayList<Module>();
     final List<Module> commitedModules;
     if (builder instanceof ProjectImportBuilder<?>) {
       final ModifiableArtifactModel artifactModel =
           ProjectStructureConfigurable.getInstance(myProject)
               .getArtifactsStructureConfigurable()
               .getModifiableArtifactModel();
       commitedModules =
           ((ProjectImportBuilder<?>) builder)
               .commit(myProject, myModuleModel, this, artifactModel);
     } else {
       commitedModules = builder.commit(myProject, myModuleModel, this);
     }
     if (commitedModules != null) {
       modules.addAll(commitedModules);
     }
     ApplicationManager.getApplication()
         .runWriteAction(
             new Runnable() {
               @Override
               public void run() {
                 for (Module module : modules) {
                   getOrCreateModuleEditor(module);
                 }
               }
             });
     return modules;
   }
   return null;
 }
예제 #3
0
 @Override
 public void initComponent() {
   if (myProject.isDefault()) {
     return;
   }
   super.initComponent();
 }
  @SuppressWarnings("unchecked")
  private void executeAndRestoreDefaultProjectSettings(
      @NotNull Project project, @NotNull Runnable task) {
    if (!project.isDefault()) {
      task.run();
      return;
    }

    AbstractExternalSystemSettings systemSettings =
        ExternalSystemApiUtil.getSettings(project, myExternalSystemId);
    Object systemStateToRestore = null;
    if (systemSettings instanceof PersistentStateComponent) {
      systemStateToRestore = ((PersistentStateComponent) systemSettings).getState();
    }
    systemSettings.copyFrom(myControl.getSystemSettings());
    Collection projectSettingsToRestore = systemSettings.getLinkedProjectsSettings();
    systemSettings.setLinkedProjectsSettings(
        Collections.singleton(getCurrentExternalProjectSettings()));
    try {
      task.run();
    } finally {
      if (systemStateToRestore != null) {
        ((PersistentStateComponent) systemSettings).loadState(systemStateToRestore);
      } else {
        systemSettings.setLinkedProjectsSettings(projectSettingsToRestore);
      }
    }
  }
 public static void notifyMessages(
     Project project,
     @Nullable String title,
     @Nullable String description,
     NotificationType type,
     boolean important,
     @Nullable Collection<String> messages) {
   if (title == null) {
     title = "";
   }
   String desc = (description != null ? description.replace("\n", "<br/>") : "");
   if (messages != null && !messages.isEmpty()) {
     desc += "<hr/>" + StringUtil.join(messages, "<br/>");
   }
   if (StringUtil.isEmptyOrSpaces(desc)) {
     desc =
         StringUtil.isEmptyOrSpaces(title)
             ? "Error"
             : title; // description is not allowed to be empty, title is => moving title text to
                      // description
     title = "";
   }
   NotificationGroup group =
       important ? GitVcs.IMPORTANT_ERROR_NOTIFICATION : GitVcs.NOTIFICATION_GROUP_ID;
   group.createNotification(title, desc, type, null).notify(project.isDefault() ? null : project);
 }
 public ReadonlyStatusHandlerImpl(Project project) {
   myProject = project;
   myAccessProviders =
       project.isDefault()
           ? new WritingAccessProvider[0]
           : Extensions.getExtensions(WritingAccessProvider.EP_NAME, project);
 }
 @Nullable
 public CvsTabbedWindow openTabbedWindow(final CvsHandler output) {
   if (ApplicationManager.getApplication().isUnitTestMode()) return null;
   if (myProject != null && myProject.isDefault()) return null;
   if (myProject != null) {
     if (myConfiguration != null && myConfiguration.SHOW_OUTPUT && !myIsQuietOperation) {
       if (ApplicationManager.getApplication().isDispatchThread()) {
         connectToOutput(output);
       } else {
         ApplicationManager.getApplication()
             .invokeAndWait(
                 new Runnable() {
                   public void run() {
                     connectToOutput(output);
                   }
                 },
                 ModalityState.defaultModalityState());
       }
     }
     if (!myProject.isDisposed()) {
       return CvsTabbedWindow.getInstance(myProject);
     }
   }
   return null;
 }
예제 #8
0
  public SvnVcs(
      final Project project,
      MessageBus bus,
      SvnConfiguration svnConfiguration,
      final SvnLoadedBrachesStorage storage) {
    super(project, VCS_NAME);
    myLoadedBranchesStorage = storage;
    LOG.debug("ct");
    myRootsToWorkingCopies = new RootsToWorkingCopies(this);
    myConfiguration = svnConfiguration;
    myAuthNotifier = new SvnAuthenticationNotifier(this);

    dumpFileStatus(FileStatus.ADDED);
    dumpFileStatus(FileStatus.DELETED);
    dumpFileStatus(FileStatus.MERGE);
    dumpFileStatus(FileStatus.MODIFIED);
    dumpFileStatus(FileStatus.NOT_CHANGED);
    dumpFileStatus(FileStatus.UNKNOWN);

    dumpFileStatus(SvnFileStatus.REPLACED);
    dumpFileStatus(SvnFileStatus.EXTERNAL);
    dumpFileStatus(SvnFileStatus.OBSTRUCTED);

    final ProjectLevelVcsManager vcsManager = ProjectLevelVcsManager.getInstance(project);
    myAddConfirmation =
        vcsManager.getStandardConfirmation(VcsConfiguration.StandardConfirmation.ADD, this);
    myDeleteConfirmation =
        vcsManager.getStandardConfirmation(VcsConfiguration.StandardConfirmation.REMOVE, this);
    myCheckoutOptions =
        vcsManager.getStandardOption(VcsConfiguration.StandardOption.CHECKOUT, this);

    if (myProject.isDefault()) {
      myChangeListListener = null;
      myEntriesFileListener = null;
    } else {
      myEntriesFileListener = new SvnEntriesFileListener(project);
      upgradeIfNeeded(bus);

      myChangeListListener = new SvnChangelistListener(myProject, this);

      myVcsListener =
          new VcsListener() {
            @Override
            public void directoryMappingChanged() {
              invokeRefreshSvnRoots(true);
            }
          };
    }

    myFrameStateListener =
        project.isDefault()
            ? null
            : new MyFrameStateListener(
                ChangeListManager.getInstance(project), VcsDirtyScopeManager.getInstance(project));
    myWorkingCopiesContent = new WorkingCopiesContent(this);

    // remove used some time before old notification group ids
    correctNotificationIds();
    myChecker = new SvnExecutableChecker(myProject);
  }
예제 #9
0
  private static String getPresentableName(final Project project) {
    if (project.isDefault()) {
      return project.getName();
    }

    String location = project.getLocation();
    if (location == null) return null;
    String projectName = FileUtil.toSystemIndependentName(location);
    if (projectName.endsWith("/")) {
      projectName = projectName.substring(0, projectName.length() - 1);
    }

    final int lastSlash = projectName.lastIndexOf('/');
    if (lastSlash >= 0 && lastSlash + 1 < projectName.length()) {
      projectName = projectName.substring(lastSlash + 1);
    }

    if (StringUtil.endsWithIgnoreCase(projectName, ProjectFileType.DOT_DEFAULT_EXTENSION)) {
      projectName =
          projectName.substring(
              0, projectName.length() - ProjectFileType.DOT_DEFAULT_EXTENSION.length());
    }

    projectName = projectName.toLowerCase(Locale.US);
    return projectName;
  }
  public void commitSynchronously(
      @NotNull Document document, @NotNull Project project, PsiFile excludeFile) {
    assert !isDisposed;

    if (!project.isInitialized() && !project.isDefault()) {
      @NonNls
      String s = project + "; Disposed: " + project.isDisposed() + "; Open: " + project.isOpen();
      s += "; SA Passed: ";
      try {
        s += ((StartupManagerImpl) StartupManager.getInstance(project)).startupActivityPassed();
      } catch (Exception e) {
        s += e;
      }
      throw new RuntimeException(s);
    }

    ApplicationManager.getApplication().assertWriteAccessAllowed();
    synchronized (documentsToCommit) {
      setCommitStage(document, CommitStage.ABOUT_TO_BE_SYNC_COMMITTED, true);
      removeCommitFromQueue(document);
    }

    ProgressIndicatorBase indicator = new ProgressIndicatorBase();
    indicator.start();
    log("About to commit sync", document, true, indicator);
    Runnable finish = commit(document, project, excludeFile, indicator, true, "Sync commit");
    log("Committed sync", document, true, finish, indicator);

    assert finish != null;
    finish.run();
  }
예제 #11
0
 public void focusTable() {
   final Project project = myModel.getProject();
   final IdeFocusManager focusManager =
       project == null || project.isDefault()
           ? IdeFocusManager.getGlobalInstance()
           : IdeFocusManager.getInstance(project);
   focusManager.requestFocus(myTable, true);
 }
 public void update(AnActionEvent e) {
   final Project project = e.getData(CommonDataKeys.PROJECT);
   if (project == null || project.isDefault()) {
     setVisibleEnabled(e, false, false);
     return;
   }
   setVisibleEnabled(e, true, true);
 }
  private RemoteRevisionsCache(final Project project) {
    myProject = project;
    myLock = new Object();

    myRemoteRevisionsNumbersCache = new RemoteRevisionsNumbersCache(myProject);
    myRemoteRevisionsStateCache = new RemoteRevisionsStateCache(myProject);

    myChangeDecorator = new RemoteStatusChangeNodeDecorator(this);

    myVcsManager = ProjectLevelVcsManager.getInstance(project);
    myVcsManager.addVcsListener(this);
    myKinds = new HashMap<String, RemoteDifferenceStrategy>();
    Disposer.register(
        project,
        new Disposable() {
          public void dispose() {
            myVcsManager.removeVcsListener(RemoteRevisionsCache.this);
          }
        });
    final VcsConfiguration vcsConfiguration = VcsConfiguration.getInstance(myProject);
    myControlledCycle =
        new ControlledCycle(
            project,
            new Getter<Boolean>() {
              @Override
              public Boolean get() {
                final boolean shouldBeDone =
                    vcsConfiguration.isChangedOnServerEnabled() && myVcsManager.hasActiveVcss();

                if (shouldBeDone) {
                  boolean somethingChanged = myRemoteRevisionsNumbersCache.updateStep();
                  somethingChanged |= myRemoteRevisionsStateCache.updateStep();
                  if (somethingChanged) {
                    myProject.getMessageBus().syncPublisher(REMOTE_VERSION_CHANGED).run();
                  }
                }
                return shouldBeDone;
              }
            },
            "Finishing \"changed on server\" update",
            DEFAULT_REFRESH_INTERVAL);

    updateRoots();

    if ((!myProject.isDefault()) && vcsConfiguration.isChangedOnServerEnabled()) {
      ((ProjectLevelVcsManagerImpl) myVcsManager)
          .addInitializationRequest(
              VcsInitObject.REMOTE_REVISIONS_CACHE,
              new Runnable() {
                public void run() {
                  // do not start if there're no vcses
                  if (!myVcsManager.hasActiveVcss() || !vcsConfiguration.isChangedOnServerEnabled())
                    return;
                  myControlledCycle.startIfNotStarted(-1);
                }
              });
    }
  }
 /**
  * Get name of the file in the last commit. If file was renamed, returns the previous name.
  *
  * @param project the context project
  * @param path the path to check
  * @return the name of file in the last commit or argument
  */
 public static FilePath getLastCommitName(final Project project, FilePath path) {
   if (project.isDefault()) return path;
   final ChangeListManager changeManager = ChangeListManager.getInstance(project);
   final Change change = changeManager.getChange(path);
   if (change != null && change.getType() == Change.Type.MOVED) {
     // GitContentRevision r = (GitContentRevision)change.getBeforeRevision();
     assert change.getBeforeRevision() != null : "Move change always have beforeRevision";
     path = change.getBeforeRevision().getFile();
   }
   return path;
 }
 public ShelveChangesManager(final Project project, final MessageBus bus) {
   myProject = project;
   myBus = bus;
   if (!project.isDefault()) {
     myFileProcessor = new CompoundShelfFileProcessor("shelf");
   } else {
     myFileProcessor =
         new CompoundShelfFileProcessor(
             new StreamProvider[] {}, PathManager.getConfigPath() + File.separator + "shelf");
   }
 }
 private FileScope(@NotNull Project project, @Nullable VirtualFile virtualFile) {
   super(project);
   myVirtualFile = virtualFile;
   final FileIndexFacade facade = FileIndexFacade.getInstance(project);
   myModule =
       virtualFile == null || project.isDefault() ? null : facade.getModuleForFile(virtualFile);
   mySearchOutsideContent =
       virtualFile != null
           && myModule == null
           && !facade.isInLibraryClasses(virtualFile)
           && !facade.isInLibrarySource(virtualFile);
 }
 private void manageAlarm() {
   final VcsConfiguration vcsConfiguration = VcsConfiguration.getInstance(myProject);
   if ((!myProject.isDefault())
       && myVcsManager.hasActiveVcss()
       && vcsConfiguration.isChangedOnServerEnabled()) {
     // will check whether is already started inside
     // interval is checked further, this is small and constant
     myControlledCycle.startIfNotStarted(-1);
   } else {
     myControlledCycle.stop();
   }
 }
  @Override
  @NotNull
  public ProcessingItem[] getProcessingItems(final CompileContext context) {
    final Project project = context.getProject();
    if (project.isDefault() || !ValidationConfiguration.shouldValidate(this, context)) {
      return ProcessingItem.EMPTY_ARRAY;
    }
    final ExcludesConfiguration excludesConfiguration =
        ValidationConfiguration.getExcludedEntriesConfiguration(project);
    final List<ProcessingItem> items =
        DumbService.getInstance(project)
            .runReadActionInSmartMode(
                new Computable<List<ProcessingItem>>() {
                  @Override
                  public List<ProcessingItem> compute() {
                    final CompileScope compileScope = context.getCompileScope();
                    if (!myValidator.isAvailableOnScope(compileScope)) return null;

                    final ArrayList<ProcessingItem> items = new ArrayList<ProcessingItem>();

                    final Processor<VirtualFile> processor =
                        new Processor<VirtualFile>() {
                          @Override
                          public boolean process(VirtualFile file) {
                            if (!file.isValid()) {
                              return true;
                            }

                            if (myCompilerManager.isExcludedFromCompilation(file)
                                || excludesConfiguration.isExcluded(file)) {
                              return true;
                            }

                            final Module module = context.getModuleByFile(file);
                            if (module != null) {
                              final PsiFile psiFile = myPsiManager.findFile(file);
                              if (psiFile != null) {
                                items.add(new MyValidatorProcessingItem(psiFile));
                              }
                            }
                            return true;
                          }
                        };
                    ContainerUtil.process(
                        myValidator.getFilesToProcess(myPsiManager.getProject(), context),
                        processor);
                    return items;
                  }
                });
    if (items == null) return ProcessingItem.EMPTY_ARRAY;

    return items.toArray(new ProcessingItem[items.size()]);
  }
 @NotNull
 @Override
 public List<DeploymentSource> createArtifactDeploymentSources(
     Project project, ArtifactType... artifactTypes) {
   if (project.isDefault()) return Collections.emptyList();
   Artifact[] artifacts = ArtifactManager.getInstance(project).getArtifacts();
   List<Artifact> supportedArtifacts = new ArrayList<>();
   Set<ArtifactType> typeSet = ContainerUtil.set(artifactTypes);
   for (Artifact artifact : artifacts) {
     if (typeSet.contains(artifact.getArtifactType())) {
       supportedArtifacts.add(artifact);
     }
   }
   return createArtifactDeploymentSources(project, supportedArtifacts);
 }
 private boolean hasFilesOutOfProjectRoots() {
   if (myHasFilesOutOfProjectRoots == null) {
     myHasFilesOutOfProjectRoots = false;
     Project project = getProject();
     if (project != null && !project.isDefault()) {
       for (VirtualFile file : myFiles) {
         if (FileIndexFacade.getInstance(project).getModuleForFile(file) == null) {
           myHasFilesOutOfProjectRoots = true;
           break;
         }
       }
     }
   }
   return myHasFilesOutOfProjectRoots;
 }
 public static boolean isInjectable(@Nullable final PsiType type, final Project project) {
   if (type == null) return false;
   if (type instanceof PsiPrimitiveType) return false;
   if (project.isDefault()) {
     @NonNls final String text = type.getPresentableText();
     if (text == null) return false;
     return text.equals("java.lang.String")
         || text.equals("java.lang.String...")
         || text.equals("java.lang.String[]");
   } else {
     return type.equalsToText("java.lang.String")
         || type.equalsToText("java.lang.String...")
         || type.equalsToText("java.lang.String[]");
   }
 }
 public DebuggerManagerImpl(
     Project project, StartupManager startupManager, EditorColorsManager colorsManager) {
   myProject = project;
   myBreakpointManager = new BreakpointManager(myProject, startupManager, this);
   if (!project.isDefault()) {
     colorsManager.addEditorColorsListener(
         new EditorColorsListener() {
           @Override
           public void globalSchemeChange(EditorColorsScheme scheme) {
             getBreakpointManager().updateBreakpointsUI();
           }
         },
         project);
   }
 }
  public ProjectLevelVcsManagerImpl(
      Project project,
      final FileStatusManager manager,
      MessageBus messageBus,
      final FileIndexFacade excludedFileIndex) {
    myProject = project;
    myMessageBus = messageBus;
    mySerialization = new ProjectLevelVcsManagerSerialization();
    myOptionsAndConfirmations = new OptionsAndConfirmations();

    myDefaultVcsRootPolicy = DefaultVcsRootPolicy.getInstance(project);

    myBackgroundableActionHandlerMap =
        new EnumMap<VcsBackgroundableActions, BackgroundableActionEnabledHandler>(
            VcsBackgroundableActions.class);
    myInitialization = new VcsInitialization(myProject);
    myMappings = new NewMappings(myProject, myMessageBus, this, manager);
    myMappingsToRoots = new MappingsToRoots(myMappings, myProject);

    if (!myProject.isDefault()) {
      myVcsEventListenerManager = new VcsEventsListenerManagerImpl();
    }

    myVcsHistoryCache = new VcsHistoryCache();
    myContentRevisionCache = new ContentRevisionCache();
    myConnect = myMessageBus.connect();
    myVcsFileListenerContextHelper = VcsFileListenerContextHelper.getInstance(myProject);
    VcsListener vcsListener =
        new VcsListener() {
          @Override
          public void directoryMappingChanged() {
            myVcsHistoryCache.clear();
            myVcsFileListenerContextHelper.possiblySwitchActivation(hasActiveVcss());
          }
        };
    myExcludedIndex = excludedFileIndex;
    myConnect.subscribe(ProjectLevelVcsManager.VCS_CONFIGURATION_CHANGED, vcsListener);
    myConnect.subscribe(ProjectLevelVcsManager.VCS_CONFIGURATION_CHANGED_IN_PLUGIN, vcsListener);
    myConnect.subscribe(
        UpdatedFilesListener.UPDATED_FILES,
        new UpdatedFilesListener() {
          @Override
          public void consume(Set<String> strings) {
            myContentRevisionCache.clearCurrent(strings);
          }
        });
    myAnnotationLocalChangesListener = new VcsAnnotationLocalChangesListenerImpl(myProject, this);
  }
 @Override
 public void executeWriteAction(final Editor editor, final DataContext dataContext) {
   final Project project = PlatformDataKeys.PROJECT.getData(dataContext);
   if (project != null && !project.isDefault()) {
     PostprocessReformattingAspect.getInstance(project)
         .disablePostprocessFormattingInside(
             new Runnable() {
               @Override
               public void run() {
                 executeWriteActionInner(editor, dataContext, project);
               }
             });
   } else {
     executeWriteActionInner(editor, dataContext, project);
   }
 }
예제 #25
0
 @Override
 public void disposeComponent() {
   LibraryInitializer.getInstance().removeContributor(this);
   Application application = ApplicationManager.getApplication();
   if (myProject.isDefault()
       || application.isUnitTestMode() && application.isDisposeInProgress()) {
     return;
   }
   // Temporary HACK for MPS 3.1: LibraryInitializer.getInstance().update() moved to
   // MPSProject.disposeComponent()
   //    ModelAccess.instance().runWriteAction(new Runnable() {
   //      @Override
   //      public void run() {
   //        LibraryInitializer.getInstance().update();
   //      }
   //    });
 }
  private void showErrorNotification(boolean hasErrors) {
    NotificationsManager manager = NotificationsManager.getNotificationsManager();
    ErrorsFoundNotification[] notifications =
        manager.getNotificationsOfType(ErrorsFoundNotification.class, myProject);

    if (hasErrors) {
      // do not show notification if it is already shown
      if (notifications.length == 0) {
        new ErrorsFoundNotification(myProject).notify(myProject.isDefault() ? null : myProject);
      }
    } else {
      // expire notification
      for (ErrorsFoundNotification notification : notifications) {
        notification.expire();
      }
    }
  }
예제 #27
0
 @Override
 @NotNull
 public PsiFile[] getFilesWithWord(
     @NotNull final String word,
     final short occurenceMask,
     @NotNull final GlobalSearchScope scope,
     final boolean caseSensitively) {
   if (myProject.isDefault()) {
     return PsiFile.EMPTY_ARRAY;
   }
   CommonProcessors.CollectProcessor<PsiFile> processor =
       new CommonProcessors.CollectProcessor<PsiFile>();
   processFilesWithWord(processor, word, occurenceMask, scope, caseSensitively);
   return processor.getResults().isEmpty()
       ? PsiFile.EMPTY_ARRAY
       : processor.toArray(PsiFile.EMPTY_ARRAY);
 }
예제 #28
0
 private void runAutoMake() {
   if (ApplicationManager.getApplication().isUnitTestMode()) {
     return;
   }
   final Project[] openProjects = myProjectManager.getOpenProjects();
   if (openProjects.length > 0) {
     final List<RequestFuture> futures = new ArrayList<RequestFuture>();
     for (final Project project : openProjects) {
       if (project.isDefault() || project.isDisposed()) {
         continue;
       }
       final CompilerWorkspaceConfiguration config =
           CompilerWorkspaceConfiguration.getInstance(project);
       if (!config.useOutOfProcessBuild() || !config.MAKE_PROJECT_ON_SAVE) {
         continue;
       }
       final List<String> emptyList = Collections.emptyList();
       final RequestFuture future =
           scheduleBuild(
               project,
               false,
               true,
               emptyList,
               emptyList,
               emptyList,
               Collections.<String, String>emptyMap(),
               new AutoMakeMessageHandler(project));
       if (future != null) {
         futures.add(future);
         synchronized (myAutomakeFutures) {
           myAutomakeFutures.put(future, project);
         }
       }
     }
     try {
       for (RequestFuture future : futures) {
         future.waitFor();
       }
     } finally {
       synchronized (myAutomakeFutures) {
         myAutomakeFutures.keySet().removeAll(futures);
       }
     }
   }
 }
 public static CodeStyleSettingsManager getInstance(@Nullable Project project) {
   if (project == null || project.isDefault()) return getInstance();
   ProjectCodeStyleSettingsManager projectSettingsManager =
       ServiceManager.getService(project, ProjectCodeStyleSettingsManager.class);
   if (!projectSettingsManager.isLoaded()) {
     synchronized (projectSettingsManager) {
       if (!projectSettingsManager.isLoaded()) {
         LegacyCodeStyleSettingsManager legacySettingsManager =
             ServiceManager.getService(project, LegacyCodeStyleSettingsManager.class);
         if (legacySettingsManager != null && legacySettingsManager.getState() != null) {
           projectSettingsManager.loadState(legacySettingsManager.getState());
           LOG.info("Imported old project code style settings.");
         }
       }
     }
   }
   return projectSettingsManager;
 }
예제 #30
0
  // IMPORTANT!!!
  // Since implementation of virtualFileProcessor.process() may call indices directly or indirectly,
  // we cannot call it inside FileBasedIndex.processValues() method except in collecting form
  // If we do, deadlocks are possible (IDEADEV-42137). Process the files without not holding
  // indices' read lock.
  private boolean collectVirtualFilesWithWord(
      @NotNull final Processor<VirtualFile> fileProcessor,
      @NotNull final String word,
      final short occurrenceMask,
      @NotNull final GlobalSearchScope scope,
      final boolean caseSensitively) {
    if (myProject.isDefault()) {
      return true;
    }

    try {
      return ApplicationManager.getApplication()
          .runReadAction(
              new Computable<Boolean>() {
                @Override
                public Boolean compute() {
                  return FileBasedIndex.getInstance()
                      .processValues(
                          IdIndex.NAME,
                          new IdIndexEntry(word, caseSensitively),
                          null,
                          new FileBasedIndex.ValueProcessor<Integer>() {
                            final FileIndexFacade index = FileIndexFacade.getInstance(myProject);

                            @Override
                            public boolean process(final VirtualFile file, final Integer value) {
                              ProgressIndicatorProvider.checkCanceled();
                              final int mask = value.intValue();
                              if ((mask & occurrenceMask) != 0
                                  && index.shouldBeFound(scope, file)) {
                                if (!fileProcessor.process(file)) return false;
                              }
                              return true;
                            }
                          },
                          scope);
                }
              });
    } catch (IndexNotReadyException e) {
      throw new ProcessCanceledException();
    }
  }