Exemplo n.º 1
0
  public static KeysManager instance() {

    if (sInstance == null) {
      sInstance = ServiceManager.getService(KeysManager.class);

      ProjectManager.getInstance()
          .addProjectManagerListener(
              new ProjectManagerListener() {
                @Override
                public void projectOpened(Project project) {

                  CompilerManager.getInstance(project).addCompilationStatusListener(sInstance);
                }

                @Override
                public boolean canCloseProject(Project project) {
                  return true;
                }

                @Override
                public void projectClosed(Project project) {}

                @Override
                public void projectClosing(Project project) {

                  CompilerManager.getInstance(project).removeCompilationStatusListener(sInstance);
                }
              });

      CompilerManager.getInstance(ProjectManager.getInstance().getOpenProjects()[0])
          .addCompilationStatusListener(sInstance);
    }

    return sInstance;
  }
 @Override
 public WorkspaceConfig get() {
   SimpleWorkspaceConfig _xblockexpression = null;
   {
     ProjectManager _instance = ProjectManager.getInstance();
     Project[] _openProjects = _instance.getOpenProjects();
     final Project project =
         IterableExtensions.<Project>head(
             ((Iterable<Project>) Conversions.doWrapArray(_openProjects)));
     String _basePath = project.getBasePath();
     final SimpleWorkspaceConfig result = new SimpleWorkspaceConfig(_basePath);
     ModuleManager _instance_1 = ModuleManager.getInstance(project);
     Module[] _modules = _instance_1.getModules();
     final Procedure1<Module> _function =
         new Procedure1<Module>() {
           @Override
           public void apply(final Module m) {
             IdeaModuleConfig _ideaModuleConfig =
                 new IdeaModuleConfig(m, IdeaWorkspaceConfigProvider.this.outputConfigurations);
             result.addProjectConfig(_ideaModuleConfig);
           }
         };
     IterableExtensions.<Module>forEach(
         ((Iterable<Module>) Conversions.doWrapArray(_modules)), _function);
     _xblockexpression = result;
   }
   return _xblockexpression;
 }
Exemplo n.º 3
0
  @Override
  public void compilationFinished(
      boolean aborted, int errors, int warnings, CompileContext compileContext) {

    if (errors < 1) {

      // get the current time
      lastCompileTime = Calendar.getInstance();

      StatusBar statusBar =
          WindowManager.getInstance()
              .getStatusBar(ProjectManager.getInstance().getOpenProjects()[0]);

      JBPopupFactory.getInstance()
          .createHtmlTextBalloonBuilder(
              "Build ready to be sent to TestFlight, <a href='open'>Click Here</a> to open TestFlightUploader and send it.",
              MessageType.INFO,
              new HyperlinkListener() {
                @Override
                public void hyperlinkUpdate(HyperlinkEvent e) {

                  if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
                    ToolWindowManager.getInstance(ProjectManager.getInstance().getOpenProjects()[0])
                        .getToolWindow("TF Uploader")
                        .show(null);
                  }
                }
              })
          .setFadeoutTime(4000)
          .createBalloon()
          .show(RelativePoint.getNorthEastOf(statusBar.getComponent()), Balloon.Position.atRight);
    }
  }
Exemplo n.º 4
0
 @Nullable
 public static Sdk getNewProjectJdk(WizardContext context) {
   if (context.getProjectJdk() != null) {
     return context.getProjectJdk();
   }
   final Project project =
       context.getProject() == null
           ? ProjectManager.getInstance().getDefaultProject()
           : context.getProject();
   final Sdk projectJdk = ProjectRootManager.getInstance(project).getProjectSdk();
   if (projectJdk != null) {
     return projectJdk;
   }
   if (context.getProject() == null) {
     @Nullable final ProjectBuilder projectBuilder = context.getProjectBuilder();
     return ProjectJdkTable.getInstance()
         .findMostRecentSdk(
             new Condition<Sdk>() {
               public boolean value(Sdk sdk) {
                 return projectBuilder == null || projectBuilder.isSuitableSdk(sdk);
               }
             });
   }
   return null;
 }
Exemplo n.º 5
0
  public WelcomeFrame() {
    JRootPane rootPane = getRootPane();
    final WelcomeScreen screen = createScreen(rootPane);

    final IdeGlassPaneImpl glassPane = new IdeGlassPaneImpl(rootPane);
    setGlassPane(glassPane);
    glassPane.setVisible(false);
    setContentPane(screen.getWelcomePanel());
    setTitle(ApplicationNamesInfo.getInstance().getFullProductName());
    AppUIUtil.updateWindowIcon(this);

    ProjectManager.getInstance()
        .addProjectManagerListener(
            new ProjectManagerAdapter() {
              @Override
              public void projectOpened(Project project) {
                dispose();
              }
            });

    myBalloonLayout = new BalloonLayoutImpl(rootPane.getLayeredPane(), new Insets(8, 8, 8, 8));

    myScreen = screen;
    setupCloseAction();
    new MnemonicHelper().register(this);
    myScreen.setupFrame(this);
  }
  @NotNull
  private static Document setupFileEditorAndDocument(
      @NotNull String fileName, @NotNull String fileText) throws IOException {
    EncodingProjectManager.getInstance(getProject()).setEncoding(null, CharsetToolkit.UTF8_CHARSET);
    EncodingProjectManager.getInstance(ProjectManager.getInstance().getDefaultProject())
        .setEncoding(null, CharsetToolkit.UTF8_CHARSET);
    PostprocessReformattingAspect.getInstance(ourProject).doPostponedFormatting();
    deleteVFile();
    myVFile = getSourceRoot().createChildData(null, fileName);
    VfsUtil.saveText(myVFile, fileText);
    final FileDocumentManager manager = FileDocumentManager.getInstance();
    final Document document = manager.getDocument(myVFile);
    assertNotNull("Can't create document for '" + fileName + "'", document);
    manager.reloadFromDisk(document);
    document.insertString(0, " ");
    document.deleteString(0, 1);
    myFile = getPsiManager().findFile(myVFile);
    assertNotNull(
        "Can't create PsiFile for '" + fileName + "'. Unknown file type most probably.", myFile);
    assertTrue(myFile.isPhysical());
    myEditor = createEditor(myVFile);
    myVFile.setCharset(CharsetToolkit.UTF8_CHARSET);

    PsiDocumentManager.getInstance(getProject()).commitAllDocuments();
    return document;
  }
  @NotNull
  @Override
  protected JBPopup createPopup(@NotNull AnActionEvent e) {
    Project project = e.getProject();
    if (project == null) project = ProjectManager.getInstance().getDefaultProject();

    Ref<JBPopup> popup = new Ref<JBPopup>();
    ChangesBrowser cb = new MyChangesBrowser(project, getChanges(), getCurrentSelection(), popup);

    popup.set(
        JBPopupFactory.getInstance()
            .createComponentPopupBuilder(cb, cb.getPreferredFocusedComponent())
            .setResizable(true)
            .setModalContext(false)
            .setFocusable(true)
            .setRequestFocus(true)
            .setCancelOnWindowDeactivation(true)
            .setCancelOnOtherWindowOpen(true)
            .setMovable(true)
            .setCancelKeyEnabled(true)
            .setCancelOnClickOutside(true)
            .setDimensionServiceKey(project, "Diff.GoToChangePopup", false)
            .createPopup());

    return popup.get();
  }
 private CloseListener(Content content, ContentManager contentManager, Project project) {
   myContent = content;
   myContentManager = contentManager;
   myProject = project;
   contentManager.addContentManagerListener(this);
   ProjectManager.getInstance().addProjectManagerListener(myProject, this);
 }
 @Nullable
 public static Sdk findOrCreateSdk(
     @Nullable Comparator<Sdk> comparator, final SdkType... sdkTypes) {
   final Project defaultProject = ProjectManager.getInstance().getDefaultProject();
   final Sdk sdk = ProjectRootManager.getInstance(defaultProject).getProjectSdk();
   if (sdk != null) {
     for (SdkType type : sdkTypes) {
       if (sdk.getSdkType() == type) {
         return sdk;
       }
     }
   }
   for (SdkType type : sdkTypes) {
     List<Sdk> sdks = ProjectJdkTable.getInstance().getSdksOfType(type);
     if (!sdks.isEmpty()) {
       if (comparator != null) {
         Collections.sort(sdks, comparator);
       }
       return sdks.get(0);
     }
   }
   for (SdkType sdkType : sdkTypes) {
     final String suggestedHomePath = sdkType.suggestHomePath();
     if (suggestedHomePath != null && sdkType.isValidSdkHome(suggestedHomePath)) {
       Sdk an_sdk = createAndAddSDK(suggestedHomePath, sdkType);
       if (an_sdk != null) return an_sdk;
     }
   }
   return null;
 }
Exemplo n.º 10
0
  private void sendModuleList(HttpExchange exchange) {
    StringBuilder response = new StringBuilder();
    response.append(
        "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">\n");
    response.append("<html>\n");
    response.append("<head>\n");
    response.append("<title>Web View</title>\n");
    response.append("</head>\n");
    response.append("<body>\n");
    response.append("<div>\n");

    Project[] projects = ProjectManager.getInstance().getOpenProjects();
    if (projects.length > 0) {
      response.append("Please, choose the project:<br/>");
      for (Project project : projects) {
        String projectName = project.getName();
        response.append("<a href=\"/project=");
        response.append(projectName);
        response.append("/\">");
        response.append(projectName);
        response.append("</a><br/>");
      }
    } else {
      response.append("There is no open project in Intellij IDEA");
    }

    response.append("</div>\n");
    response.append("</body>\n");
    response.append("</html>\n");
    writeResponse(exchange, response.toString(), 200);
  }
Exemplo n.º 11
0
  private void highlightSearch(final boolean noSmartCase) {
    Project[] projects = ProjectManager.getInstance().getOpenProjects();
    for (Project project : projects) {
      Editor current = FileEditorManager.getInstance(project).getSelectedTextEditor();
      Editor[] editors =
          current == null
              ? null
              : EditorFactory.getInstance().getEditors(current.getDocument(), project);
      if (editors == null) {
        continue;
      }

      for (final Editor editor : editors) {
        String els = EditorData.getLastSearch(editor);
        if (!showSearchHighlight) {
          removeSearchHighlight(editor);

          continue;
        } else if (lastSearch != null && lastSearch.equals(els)) {
          continue;
        } else if (lastSearch == null) {
          continue;
        }

        removeSearchHighlight(editor);
        highlightSearchLines(editor, lastSearch, 0, -1, shouldIgnoreCase(lastSearch, noSmartCase));

        EditorData.setLastSearch(editor, lastSearch);
      }
    }
  }
  private void onProjectClosing() {
    ProjectManager.getInstance()
        .addProjectManagerListener(
            new ProjectManagerListener() {
              @Override
              public void projectOpened(Project project) {}

              @Override
              public boolean canCloseProject(Project project) {
                return true;
              }

              @Override
              public void projectClosed(Project project) {}

              @Override
              public void projectClosing(Project project) {
                if (project != null && project.isInitialized()) {
                  if (persistOnClosing) {
                    doPersistProjectUsages(project);
                  }
                }
              }
            });
  }
Exemplo n.º 13
0
  public void initComponent() {
    log.info("Initializing WakaTime plugin v" + VERSION + " (https://wakatime.com/)");
    // System.out.println("Initializing WakaTime plugin v" + VERSION + " (https://wakatime.com/)");

    // Set runtime constants
    IDE_NAME = PlatformUtils.getPlatformPrefix();
    IDE_VERSION = ApplicationInfo.getInstance().getFullVersion();

    if (!Dependencies.isCLIInstalled()) {
      log.info("Downloading and installing wakatime-cli ...");
      Dependencies.installCLI();
    } else if (Dependencies.isCLIOld()) {
      log.info("Upgrading wakatime-cli ...");
      Dependencies.upgradeCLI();
    }

    if (Dependencies.isPythonInstalled()) {

      WakaTime.DEBUG = WakaTime.isDebugEnabled();
      if (WakaTime.DEBUG) {
        log.setLevel(Level.DEBUG);
        log.debug("Logging level set to DEBUG");
      }

      log.debug("Python location: " + Dependencies.getPythonLocation());
      log.debug("CLI location: " + Dependencies.getCLILocation());

      // prompt for apiKey if it does not already exist
      if (ApiKey.getApiKey().equals("")) {
        Project project = ProjectManager.getInstance().getDefaultProject();
        ApiKey apiKey = new ApiKey(project);
        apiKey.promptForApiKey();
      }
      log.debug("Api Key: " + ApiKey.getApiKey());

      // add WakaTime item to File menu
      ActionManager am = ActionManager.getInstance();
      PluginMenu action = new PluginMenu();
      am.registerAction("WakaTimeApiKey", action);
      DefaultActionGroup fileMenu = (DefaultActionGroup) am.getAction("FileMenu");
      fileMenu.addSeparator();
      fileMenu.add(action);

      // Setup message listeners
      MessageBus bus = ApplicationManager.getApplication().getMessageBus();
      connection = bus.connect();
      connection.subscribe(AppTopics.FILE_DOCUMENT_SYNC, new CustomSaveListener());
      EditorFactory.getInstance()
          .getEventMulticaster()
          .addDocumentListener(new CustomDocumentListener());

      log.debug("Finished initializing WakaTime plugin");

    } else {
      Messages.showErrorDialog(
          "WakaTime requires Python to be installed.\nYou can install it from https://www.python.org/downloads/\nAfter installing Python, restart your IDE.",
          "Error");
    }
  }
 @NotNull
 @Override
 protected LuaSdkChooserPanel compute() {
   return new LuaSdkChooserPanel(
       myContext.getProject() == null
           ? ProjectManager.getInstance().getDefaultProject()
           : myContext.getProject());
 }
Exemplo n.º 15
0
 private static void setStatusBarText(String statusBarText) {
   if (ApplicationManager.getApplication() == null)
     return; // makes this component work in UIDesigner preview.
   final Project[] projects = ProjectManager.getInstance().getOpenProjects();
   for (Project project : projects) {
     StatusBar.Info.set(statusBarText, project);
   }
 }
 /**
  * Allows to get {@link Project} instance to use. Basically, there are two alternatives - {@link
  * WizardContext#getProject() project from the current wizard context} and {@link
  * ProjectManager#getDefaultProject() default project}.
  *
  * @param wizardContext current wizard context
  * @return {@link Project} instance to use
  */
 @NotNull
 public Project getProject(@NotNull WizardContext wizardContext) {
   Project result = wizardContext.getProject();
   if (result == null) {
     result = ProjectManager.getInstance().getDefaultProject();
   }
   return result;
 }
Exemplo n.º 17
0
 public static Project getProjectByProjectName(String projectName) {
   for (Project p : ProjectManager.getInstance().getOpenProjects()) {
     if (p.getName().equals(projectName)) {
       return p;
     }
   }
   return null;
 }
Exemplo n.º 18
0
 public static boolean isGradleAvailable() {
   final Project[] projects = ProjectManager.getInstance().getOpenProjects();
   final Project project;
   if (projects.length == 1) {
     project = projects[0];
   } else {
     project = null;
   }
   return isGradleAvailable(project);
 }
Exemplo n.º 19
0
  public boolean isSaving() {
    if (getStateStore().isSaving()) return true;
    Project[] openProjects = ProjectManager.getInstance().getOpenProjects();
    for (Project openProject : openProjects) {
      ProjectEx project = (ProjectEx) openProject;
      if (project.getStateStore().isSaving()) return true;
    }

    return false;
  }
 public void projectClosed(final Project project) {
   Project[] openProjects = ProjectManager.getInstance().getOpenProjects();
   if (openProjects.length > 0) {
     String path = getProjectPath(openProjects[openProjects.length - 1]);
     if (path != null) {
       markPathRecent(path);
     }
   }
   SystemDock.updateMenu();
 }
 private static void clearAllIdentifierHighlighters() {
   for (Project project : ProjectManager.getInstance().getOpenProjects()) {
     for (FileEditor fileEditor : FileEditorManager.getInstance(project).getAllEditors()) {
       if (fileEditor instanceof TextEditor) {
         Document document = ((TextEditor) fileEditor).getEditor().getDocument();
         IdentifierHighlighterPass.clearMyHighlights(document, project);
       }
     }
   }
 }
 private static void cacheAllSubsAndVarsOfOpenedFiles() {
   Project[] projects = ProjectManager.getInstance().getOpenProjects();
   for (int i = 0; i < projects.length; i++) {
     VirtualFile[] openFiles = FileEditorManager.getInstance(projects[i]).getOpenFiles();
     for (int j = 0; j < openFiles.length; j++) {
       VirtualFile openFile = openFiles[j];
       cacheSingleFile(projects[i], openFile);
     }
   }
 }
 private static void updateModifiedProperty(@NotNull VirtualFile file) {
   for (Project project : ProjectManager.getInstance().getOpenProjects()) {
     FileEditorManager fileEditorManager = FileEditorManager.getInstance(project);
     for (FileEditor editor : fileEditorManager.getAllEditors(file)) {
       if (editor instanceof TextEditorImpl) {
         ((TextEditorImpl) editor).updateModifiedProperty();
       }
     }
   }
 }
  private static void applyChangesToEditors() {
    EditorFactory.getInstance().refreshAllEditors();

    TodoConfiguration.getInstance().colorSettingsChanged();
    Project[] openProjects = ProjectManager.getInstance().getOpenProjects();
    for (Project openProject : openProjects) {
      FileStatusManager.getInstance(openProject).fileStatusesChanged();
      DaemonCodeAnalyzer.getInstance(openProject).restart();
    }
  }
  private static void initScopesDescriptors(
      @NotNull List<EditorSchemeAttributeDescriptor> descriptions, @NotNull MyColorScheme scheme) {
    Set<Pair<NamedScope, NamedScopesHolder>> namedScopes =
        new THashSet<Pair<NamedScope, NamedScopesHolder>>(
            new TObjectHashingStrategy<Pair<NamedScope, NamedScopesHolder>>() {
              @Override
              public int computeHashCode(
                  @NotNull final Pair<NamedScope, NamedScopesHolder> object) {
                return object.getFirst().getName().hashCode();
              }

              @Override
              public boolean equals(
                  @NotNull final Pair<NamedScope, NamedScopesHolder> o1,
                  @NotNull final Pair<NamedScope, NamedScopesHolder> o2) {
                return o1.getFirst().getName().equals(o2.getFirst().getName());
              }
            });
    Project[] projects = ProjectManager.getInstance().getOpenProjects();
    for (Project project : projects) {
      DependencyValidationManagerImpl validationManager =
          (DependencyValidationManagerImpl) DependencyValidationManager.getInstance(project);
      List<Pair<NamedScope, NamedScopesHolder>> cachedScopes =
          validationManager.getScopeBasedHighlightingCachedScopes();
      namedScopes.addAll(cachedScopes);
    }

    List<Pair<NamedScope, NamedScopesHolder>> list =
        new ArrayList<Pair<NamedScope, NamedScopesHolder>>(namedScopes);

    Collections.sort(
        list,
        new Comparator<Pair<NamedScope, NamedScopesHolder>>() {
          @Override
          public int compare(
              @NotNull final Pair<NamedScope, NamedScopesHolder> o1,
              @NotNull final Pair<NamedScope, NamedScopesHolder> o2) {
            return o1.getFirst().getName().compareToIgnoreCase(o2.getFirst().getName());
          }
        });
    for (Pair<NamedScope, NamedScopesHolder> pair : list) {
      NamedScope namedScope = pair.getFirst();
      String name = namedScope.getName();
      TextAttributesKey textAttributesKey = ScopeAttributesUtil.getScopeTextAttributeKey(name);
      if (scheme.getAttributes(textAttributesKey) == null) {
        scheme.setAttributes(textAttributesKey, new TextAttributes());
      }
      NamedScopesHolder holder = pair.getSecond();

      PackageSet value = namedScope.getValue();
      String toolTip = holder.getDisplayName() + (value == null ? "" : ": " + value.getText());
      addSchemedDescription(
          descriptions, name, SCOPES_GROUP, textAttributesKey, scheme, holder.getIcon(), toolTip);
    }
  }
Exemplo n.º 26
0
  @Override
  public void run(@NotNull final ProgressIndicator indicator) {
    myIndicator = indicator;

    final ProjectManager projectManager = ProjectManager.getInstance();
    projectManager.addProjectManagerListener(myProject, myCloseListener = new CloseListener());

    final Semaphore semaphore =
        ((CompilerManagerImpl) CompilerManager.getInstance(myProject)).getCompilationSemaphore();
    boolean acquired = false;
    try {

      try {
        while (!acquired) {
          acquired = semaphore.tryAcquire(300, TimeUnit.MILLISECONDS);
          if (!acquired && !myWaitForPreviousSession) {
            return;
          }
          if (indicator.isCanceled()) {
            // give up obtaining the semaphore,
            // let compile work begin in order to stop gracefuly on cancel event
            break;
          }
        }
      } catch (InterruptedException ignored) {
      }

      if (!isHeadless()) {
        addIndicatorDelegate();
      }
      myCompileWork.run();
    } finally {
      try {
        indicator.stop();
        projectManager.removeProjectManagerListener(myProject, myCloseListener);
      } finally {
        if (acquired) {
          semaphore.release();
        }
      }
    }
  }
  public void testExternalFileModificationWhileProjectClosed() throws Exception {
    VirtualFile root = ProjectRootManager.getInstance(myProject).getContentRoots()[0];

    PsiClass objectClass =
        myJavaFacade.findClass(
            CommonClassNames.JAVA_LANG_OBJECT, GlobalSearchScope.allScope(getProject()));
    assertNotNull(objectClass);
    checkUsages(objectClass, new String[] {});
    FileBasedIndex.getInstance()
        .getContainingFiles(
            TodoIndex.NAME,
            new TodoIndexEntry("todo", true),
            GlobalSearchScope.allScope(getProject()));

    final String projectLocation = myProject.getPresentableUrl();
    assert projectLocation != null : myProject;
    PlatformTestUtil.saveProject(myProject);
    final VirtualFile content = ModuleRootManager.getInstance(getModule()).getContentRoots()[0];
    Project project = myProject;
    ProjectUtil.closeAndDispose(project);
    InjectedLanguageManagerImpl.checkInjectorsAreDisposed(project);

    assertTrue("Project was not disposed", myProject.isDisposed());
    myModule = null;

    final File file = new File(root.getPath(), "1.java");
    assertTrue(file.exists());

    FileUtil.writeToFile(file, "class A{ Object o;}".getBytes(CharsetToolkit.UTF8_CHARSET));
    root.refresh(false, true);

    LocalFileSystem.getInstance().refresh(false);

    myProject = ProjectManager.getInstance().loadAndOpenProject(projectLocation);
    InjectedLanguageManagerImpl.pushInjectors(getProject());

    setUpModule();
    setUpJdk();
    ProjectManagerEx.getInstanceEx().openTestProject(myProject);
    UIUtil.dispatchAllInvocationEvents(); // startup activities

    runStartupActivities();
    PsiTestUtil.addSourceContentToRoots(getModule(), content);

    assertNotNull(myProject);
    myPsiManager = (PsiManagerImpl) PsiManager.getInstance(myProject);
    myJavaFacade = JavaPsiFacadeEx.getInstanceEx(myProject);

    objectClass =
        myJavaFacade.findClass(
            CommonClassNames.JAVA_LANG_OBJECT, GlobalSearchScope.allScope(getProject()));
    assertNotNull(objectClass);
    checkUsages(objectClass, new String[] {"1.java"});
  }
Exemplo n.º 28
0
  public static void doTearDown() throws Exception {
    UsefulTestCase.doPostponedFormatting(ourProject);

    LookupManager.getInstance(ourProject).hideActiveLookup();

    InspectionProfileManager.getInstance().deleteProfile(PROFILE);
    assertNotNull("Application components damaged", ProjectManager.getInstance());

    ApplicationManager.getApplication()
        .runWriteAction(
            new Runnable() {
              public void run() {
                try {
                  final VirtualFile[] children = ourSourceRoot.getChildren();
                  for (VirtualFile child : children) {
                    child.delete(this);
                  }
                } catch (IOException e) {
                  //noinspection CallToPrintStackTrace
                  e.printStackTrace();
                }
                FileDocumentManager manager = FileDocumentManager.getInstance();
                if (manager instanceof FileDocumentManagerImpl) {
                  ((FileDocumentManagerImpl) manager).dropAllUnsavedDocuments();
                }
              }
            });
    //    final Project[] openProjects = ProjectManagerEx.getInstanceEx().getOpenProjects();
    //    assertTrue(Arrays.asList(openProjects).contains(ourProject));
    assertFalse(PsiManager.getInstance(getProject()).isDisposed());
    if (!ourAssertionsInTestDetected) {
      if (IdeaLogger.ourErrorsOccurred != null) {
        throw IdeaLogger.ourErrorsOccurred;
      }
      // assertTrue("Logger errors occurred. ", IdeaLogger.ourErrorsOccurred == null);
    }
    ((PsiDocumentManagerImpl) PsiDocumentManager.getInstance(getProject()))
        .clearUncommitedDocuments();

    ((UndoManagerImpl) UndoManager.getGlobalInstance()).dropHistoryInTests();

    ProjectManagerEx.getInstanceEx().setCurrentTestProject(null);
    ourApplication.setDataProvider(null);
    ourTestCase = null;
    ((PsiManagerImpl) ourPsiManager).cleanupForNextTest();

    final Editor[] allEditors = EditorFactory.getInstance().getAllEditors();
    if (allEditors.length > 0) {
      for (Editor allEditor : allEditors) {
        EditorFactory.getInstance().releaseEditor(allEditor);
      }
      fail("Unreleased editors: " + allEditors.length);
    }
  }
 @Nullable
 private static SvnVcs getVCS(VirtualFile file) {
   Project[] projects = ProjectManager.getInstance().getOpenProjects();
   for (Project project : projects) {
     AbstractVcs vcs = ProjectLevelVcsManager.getInstance(project).getVcsFor(file);
     if (vcs instanceof SvnVcs) {
       return (SvnVcs) vcs;
     }
   }
   return null;
 }
  /**
   * Returns the index of the project that has the given name, the project name is searched in the
   * list of opened projects
   *
   * @param name name of the project
   * @return the index of the project in the list of opened projects, 0 if not found
   */
  public int getProjectIndexWithName(String name) {
    int index = 0;
    Project projects[] = ProjectManager.getInstance().getOpenProjects();

    for (Project project : projects) {
      if (project.getName().equals(name)) {
        return index;
      }
      index++;
    }

    return 0;
  }