コード例 #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));
  }
コード例 #2
0
  private KotlinEnvironment(@NotNull IJavaProject javaProject) {
    this.javaProject = javaProject;

    applicationEnvironment = createJavaCoreApplicationEnvironment();

    projectEnvironment = new JavaCoreProjectEnvironment(DISPOSABLE, applicationEnvironment);

    project = projectEnvironment.getProject();

    CoreExternalAnnotationsManager annotationsManager =
        new CoreExternalAnnotationsManager(project.getComponent(PsiManager.class));
    project.registerService(ExternalAnnotationsManager.class, annotationsManager);
    project.registerService(
        CoreJavaFileManager.class,
        (CoreJavaFileManager) ServiceManager.getService(project, JavaFileManager.class));

    CliLightClassGenerationSupport cliLightClassGenerationSupport =
        new CliLightClassGenerationSupport();
    project.registerService(LightClassGenerationSupport.class, cliLightClassGenerationSupport);
    project.registerService(CliLightClassGenerationSupport.class, cliLightClassGenerationSupport);
    project.registerService(
        KotlinLightClassForPackage.FileStubCache.class,
        new KotlinLightClassForPackage.FileStubCache(project));

    VirtualFile ktJDKAnnotations =
        PathUtil.jarFileOrDirectoryToVirtualFile(new File(KT_JDK_ANNOTATIONS_PATH));
    annotationsManager.addExternalAnnotationsRoot(ktJDKAnnotations);

    addJreClasspath();
    addSourcesToClasspath();
    addLibsToClasspath();

    project.registerService(
        VirtualFileFinderFactory.class, new EclipseVirtualFileFinder(classPath));

    CoreApplicationEnvironment.registerExtensionPoint(
        Extensions.getRootArea(),
        ClsCustomNavigationPolicy.EP_NAME,
        ClsCustomNavigationPolicy.class);
    CoreApplicationEnvironment.registerExtensionPoint(
        Extensions.getRootArea(),
        ClassFileDecompilers.EP_NAME,
        ClassFileDecompilers.Decompiler.class);

    cachedEnvironment.put(javaProject, this);
  }
コード例 #3
0
 public <T> void registerProjectComponent(
     @NotNull Class<T> interfaceClass, @NotNull T implementation) {
   CoreApplicationEnvironment.registerComponentInstance(
       myProject.getPicoContainer(), interfaceClass, implementation);
 }