Esempio n. 1
0
  public CoreProjectEnvironment(
      @NotNull Disposable parentDisposable,
      @NotNull CoreApplicationEnvironment applicationEnvironment) {
    myParentDisposable = parentDisposable;
    myEnvironment = applicationEnvironment;
    myProject =
        createProject(myEnvironment.getApplication().getPicoContainer(), myParentDisposable);

    preregisterServices();

    myFileIndexFacade = createFileIndexFacade();
    myMessageBus = MessageBusFactory.newMessageBus("CoreProjectEnvironment");

    PsiModificationTrackerImpl modificationTracker = new PsiModificationTrackerImpl(myProject);
    myProject.registerService(PsiModificationTracker.class, modificationTracker);
    myProject.registerService(FileIndexFacade.class, myFileIndexFacade);
    myProject.registerService(ResolveCache.class, new ResolveCache(myMessageBus));

    registerProjectExtensionPoint(
        PsiTreeChangePreprocessor.EP_NAME, PsiTreeChangePreprocessor.class);
    myPsiManager =
        new PsiManagerImpl(
            myProject, null, null, myFileIndexFacade, myMessageBus, modificationTracker);
    ((FileManagerImpl) myPsiManager.getFileManager()).markInitialized();
    registerProjectComponent(PsiManager.class, myPsiManager);
    myProject.registerService(SmartPointerManager.class, SmartPointerManagerImpl.class);
    registerProjectComponent(
        PsiDocumentManager.class,
        new CorePsiDocumentManager(
            myProject,
            myPsiManager,
            SmartPointerManager.getInstance(myProject),
            myMessageBus,
            new MockDocumentCommitProcessor()));

    myProject.registerService(ResolveScopeManager.class, createResolveScopeManager(myPsiManager));

    myProject.registerService(PsiFileFactory.class, new PsiFileFactoryImpl(myPsiManager));
    myProject.registerService(
        CachedValuesManager.class,
        new CachedValuesManagerImpl(myProject, new PsiCachedValuesFactory(myPsiManager)));
    myProject.registerService(PsiDirectoryFactory.class, new PsiDirectoryFactoryImpl(myPsiManager));
    myProject.registerService(ProjectScopeBuilder.class, createProjectScopeBuilder());
    myProject.registerService(DumbService.class, new MockDumbService(myProject));
  }
 public <T> void registerProjectComponent(
     @NotNull Class<T> interfaceClass, @NotNull T implementation) {
   CoreApplicationEnvironment.registerComponentInstance(
       myProject.getPicoContainer(), interfaceClass, implementation);
 }
 public <T> void registerProjectExtensionPoint(
     @NotNull ExtensionPointName<T> extensionPointName, @NotNull Class<? extends T> aClass) {
   CoreApplicationEnvironment.registerExtensionPoint(
       Extensions.getArea(myProject), extensionPointName, aClass);
 }