Java Code Examples for com.intellij.openapi.extensions.ExtensionPoint#registerExtension()

The following examples show how to use com.intellij.openapi.extensions.ExtensionPoint#registerExtension() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BlazeSyncManagerTest.java    From intellij with Apache License 2.0 6 votes vote down vote up
@Override
protected void initTest(Container applicationServices, Container projectServices) {
  super.initTest(applicationServices, projectServices);
  manager = new BlazeSyncManager(project);
  MockitoAnnotations.initMocks(this);
  applicationServices.register(BlazeUserSettings.class, new BlazeUserSettings());
  applicationServices.register(ExperimentService.class, new MockExperimentService());

  projectServices.register(
      BlazeImportSettingsManager.class, new BlazeImportSettingsManager(project));
  projectServices.register(ProjectViewManager.class, new MockProjectViewManager());
  ExtensionPoint<BuildSystemProvider> ep =
      registerExtensionPoint(BuildSystemProvider.EP_NAME, BuildSystemProvider.class);
  ep.registerExtension(new BazelBuildSystemProvider());

  doNothing().when(manager).requestProjectSync(any());
  projectServices.register(BlazeSyncManager.class, manager);
  assertThat(BlazeSyncManager.getInstance(project)).isSameAs(manager);
}
 
Example 2
Source File: BlazeCompilerSettingsTest.java    From intellij with Apache License 2.0 6 votes vote down vote up
@Override
protected void initTest(Container applicationServices, Container projectServices) {
  ExtensionPoint<BuildSystemProvider> extensionPoint =
      registerExtensionPoint(BuildSystemProvider.EP_NAME, BuildSystemProvider.class);
  extensionPoint.registerExtension(new BazelBuildSystemProvider());

  ExtensionPointImpl<BlazeCompilerFlagsProcessor.Provider> ep =
      registerExtensionPoint(
          BlazeCompilerFlagsProcessor.EP_NAME, BlazeCompilerFlagsProcessor.Provider.class);
  ep.registerExtension(new IncludeRootFlagsProcessor.Provider());
  ep.registerExtension(new SysrootFlagsProcessor.Provider());

  BlazeImportSettingsManager importSettingsManager = new BlazeImportSettingsManager(project);
  BlazeImportSettings importSettings =
      new BlazeImportSettings("/root", "", "", "", BuildSystem.Bazel);
  importSettingsManager.setImportSettings(importSettings);
  projectServices.register(BlazeImportSettingsManager.class, importSettingsManager);

  workspaceRoot = WorkspaceRoot.fromImportSettings(importSettings);
  blazeProjectData = MockBlazeProjectDataBuilder.builder(workspaceRoot).build();
  projectServices.register(
      BlazeProjectDataManager.class, new MockBlazeProjectDataManager(blazeProjectData));
}
 
Example 3
Source File: ScalaSourceDirectoryCalculatorTest.java    From intellij with Apache License 2.0 6 votes vote down vote up
@Override
protected void initTest(Container applicationServices, Container projectServices) {
  super.initTest(applicationServices, projectServices);

  mockInputStreamProvider = new MockInputStreamProvider();
  applicationServices.register(InputStreamProvider.class, mockInputStreamProvider);
  applicationServices.register(JavaSourcePackageReader.class, new JavaSourcePackageReader());
  applicationServices.register(PackageManifestReader.class, new PackageManifestReader());
  applicationServices.register(PrefetchService.class, new MockPrefetchService());
  applicationServices.register(FileOperationProvider.class, new FileOperationProvider());
  applicationServices.register(
      RemoteArtifactPrefetcher.class, new MockRemoteArtifactPrefetcher());

  ExtensionPoint<JavaLikeLanguage> javaLikeLanguages =
      registerExtensionPoint(JavaLikeLanguage.EP_NAME, JavaLikeLanguage.class);
  javaLikeLanguages.registerExtension(new JavaLikeLanguage.Java());
  javaLikeLanguages.registerExtension(new ScalaJavaLikeLanguage());

  context.addOutputSink(IssueOutput.class, issues);
  sourceDirectoryCalculator = new SourceDirectoryCalculator();
}
 
Example 4
Source File: BlazeRenderErrorContributorTest.java    From intellij with Apache License 2.0 5 votes vote down vote up
@Override
protected void initTest(Container applicationServices, Container projectServices) {
  super.initTest(applicationServices, projectServices);
  applicationServices.register(FileTypeManager.class, new MockFileTypeManager());

  projectServices.register(ProjectFileIndex.class, mock(ProjectFileIndex.class));
  projectServices.register(BuildReferenceManager.class, new MockBuildReferenceManager(project));
  projectServices.register(TransitiveDependencyMap.class, new TransitiveDependencyMap(project));
  projectServices.register(ProjectScopeBuilder.class, new ProjectScopeBuilderImpl(project));
  projectServices.register(
      AndroidResourceModuleRegistry.class, new AndroidResourceModuleRegistry());

  ExtensionPointImpl<Provider> kindProvider =
      registerExtensionPoint(Kind.Provider.EP_NAME, Kind.Provider.class);
  kindProvider.registerExtension(new AndroidBlazeRules());
  applicationServices.register(Kind.ApplicationState.class, new Kind.ApplicationState());

  BlazeImportSettingsManager importSettingsManager = new BlazeImportSettingsManager(project);
  BlazeImportSettings settings = new BlazeImportSettings("", "", "", "", BuildSystem.Blaze);
  importSettingsManager.setImportSettings(settings);
  projectServices.register(BlazeImportSettingsManager.class, importSettingsManager);

  projectServices.register(JvmPsiConversionHelper.class, new JvmPsiConversionHelperImpl());
  createPsiClassesAndSourceToTargetMap(projectServices);

  projectDataManager = new MockBlazeProjectDataManager();
  projectServices.register(BlazeProjectDataManager.class, projectDataManager);

  ExtensionPoint<RenderErrorContributor.Provider> extensionPoint =
      registerExtensionPoint(
          ExtensionPointName.create("com.android.rendering.renderErrorContributor"),
          RenderErrorContributor.Provider.class);
  extensionPoint.registerExtension(new RenderErrorContributor.Provider());
  extensionPoint.registerExtension(new BlazeRenderErrorContributor.BlazeProvider());

  module = new MockModule(project, () -> {});

  // For the isApplicable tests.
  provider = new BlazeRenderErrorContributor.BlazeProvider();
}
 
Example 5
Source File: BuildTargetFinderTest.java    From intellij with Apache License 2.0 5 votes vote down vote up
@Override
protected void initTest(Container applicationServices, Container projectServices) {
  super.initTest(applicationServices, projectServices);

  applicationServices.register(FileOperationProvider.class, fileOperationProvider);
  applicationServices.register(ExperimentService.class, new MockExperimentService());
  projectServices.register(
      BlazeImportSettingsManager.class, mock(BlazeImportSettingsManager.class));
  ExtensionPoint<BuildSystemProvider> extensionPoint =
      registerExtensionPoint(BuildSystemProvider.EP_NAME, BuildSystemProvider.class);
  extensionPoint.registerExtension(new BazelBuildSystemProvider());
}
 
Example 6
Source File: ExecutionRootPathResolverTest.java    From intellij with Apache License 2.0 5 votes vote down vote up
@Override
protected void initTest(Container applicationServices, Container projectServices) {
  ExtensionPoint<BuildSystemProvider> extensionPoint =
      registerExtensionPoint(BuildSystemProvider.EP_NAME, BuildSystemProvider.class);
  extensionPoint.registerExtension(new BazelBuildSystemProvider());

  pathResolver =
      new ExecutionRootPathResolver(
          BuildSystem.Bazel,
          WORKSPACE_ROOT,
          new File(EXECUTION_ROOT),
          new WorkspacePathResolverImpl(WORKSPACE_ROOT));
}
 
Example 7
Source File: CMakeNotificationFilter.java    From intellij with Apache License 2.0 5 votes vote down vote up
public static void overrideProjectExtension(Project project) {
  ExtensionPoint<EditorNotifications.Provider> ep =
      Extensions.getArea(project).getExtensionPoint(EDITOR_NOTIFICATIONS_EPNAME);
  for (EditorNotifications.Provider<?> editorNotificationsProvider : ep.getExtensions()) {
    if (editorNotificationsProvider instanceof CMakeNotificationProvider) {
      ep.unregisterExtension(editorNotificationsProvider);
    }
  }
  ep.registerExtension(new CMakeNotificationFilter(project));
}
 
Example 8
Source File: PyDynamicImportResolverInitializer.java    From intellij with Apache License 2.0 5 votes vote down vote up
private static void registerImportCandidateProviders() {
  ExtensionPoint<PyImportCandidateProvider> ep =
      Extensions.getRootArea().getExtensionPoint(PyImportCandidateProvider.EP_NAME);

  for (PyImportResolverStrategy provider : PyImportResolverStrategy.EP_NAME.getExtensions()) {
    ep.registerExtension(
        (reference, name, quickFix) -> {
          if (!providerEnabled(reference.getElement().getProject(), provider)) {
            return;
          }
          provider.addImportCandidates(reference, name, quickFix);
        });
  }
}
 
Example 9
Source File: ServiceHelper.java    From intellij with Apache License 2.0 4 votes vote down vote up
public static <T> void registerExtension(
    ExtensionPointName<T> name, T instance, Disposable parentDisposable) {
  ExtensionPoint<T> ep = Extensions.getRootArea().getExtensionPoint(name);
  ep.registerExtension(instance);
  Disposer.register(parentDisposable, () -> ep.unregisterExtension(instance));
}