Search in sources :

Example 1 with JavaBlazeRules

use of com.google.idea.blaze.java.JavaBlazeRules in project intellij by bazelbuild.

the class KotlinSyncAugmenterTest method initTest.

@Override
protected void initTest(@NotNull Container applicationServices, @NotNull Container projectServices) {
    super.initTest(applicationServices, projectServices);
    ExtensionPointImpl<BlazeSyncPlugin> syncPlugins = registerExtensionPoint(BlazeSyncPlugin.EP_NAME, BlazeSyncPlugin.class);
    syncPlugins.registerExtension(new BlazeJavaSyncPlugin());
    syncPlugins.registerExtension(new BlazeKotlinSyncPlugin());
    BlazeContext context = BlazeContext.create();
    context.addOutputSink(IssueOutput.class, errorCollector);
    ExtensionPointImpl<Kind.Provider> ep = registerExtensionPoint(Kind.Provider.EP_NAME, Kind.Provider.class);
    ep.registerExtension(new JavaBlazeRules());
    ep.registerExtension(new KotlinBlazeRules());
    applicationServices.register(Kind.ApplicationState.class, new Kind.ApplicationState());
    MockExperimentService experimentService = new MockExperimentService();
    applicationServices.register(ExperimentService.class, experimentService);
    augmenters = registerExtensionPoint(BlazeJavaSyncAugmenter.EP_NAME, BlazeJavaSyncAugmenter.class);
    augmenters.registerExtension(new KotlinSyncAugmenter());
}
Also used : JavaBlazeRules(com.google.idea.blaze.java.JavaBlazeRules) MockExperimentService(com.google.idea.common.experiments.MockExperimentService) KotlinBlazeRules(com.google.idea.blaze.kotlin.KotlinBlazeRules) BlazeKotlinSyncPlugin(com.google.idea.blaze.kotlin.sync.BlazeKotlinSyncPlugin) BlazeJavaSyncPlugin(com.google.idea.blaze.java.sync.BlazeJavaSyncPlugin) BlazeContext(com.google.idea.blaze.base.scope.BlazeContext) BlazeJavaSyncAugmenter(com.google.idea.blaze.java.sync.BlazeJavaSyncAugmenter) Kind(com.google.idea.blaze.base.model.primitives.Kind) BlazeSyncPlugin(com.google.idea.blaze.base.sync.BlazeSyncPlugin)

Example 2 with JavaBlazeRules

use of com.google.idea.blaze.java.JavaBlazeRules in project intellij by bazelbuild.

the class BlazeAndroidWorkspaceImporterTest method initTest.

@Override
protected void initTest(Container applicationServices, Container projectServices) {
    experimentService = new MockExperimentService();
    applicationServices.register(ExperimentService.class, experimentService);
    BlazeExecutor blazeExecutor = new MockBlazeExecutor();
    applicationServices.register(BlazeExecutor.class, blazeExecutor);
    projectServices.register(BlazeImportSettingsManager.class, new BlazeImportSettingsManager(project));
    BlazeImportSettingsManager.getInstance(getProject()).setImportSettings(DUMMY_IMPORT_SETTINGS);
    MockFileOperationProvider mockFileOperationProvider = new MockFileOperationProvider();
    applicationServices.register(FileOperationProvider.class, mockFileOperationProvider);
    ExtensionPointImpl<Provider> targetKindEp = registerExtensionPoint(Provider.EP_NAME, Provider.class);
    targetKindEp.registerExtension(new AndroidBlazeRules());
    targetKindEp.registerExtension(new JavaBlazeRules());
    targetKindEp.registerExtension(new GenericBlazeRules());
    applicationServices.register(Kind.ApplicationState.class, new Kind.ApplicationState());
    retentionFilterEp = registerExtensionPoint(GeneratedResourceRetentionFilter.EP_NAME, GeneratedResourceRetentionFilter.class);
    context = BlazeContext.create();
    context.addOutputSink(IssueOutput.class, errorCollector);
    registerExtensionPoint(BlazeJavaSyncAugmenter.EP_NAME, BlazeJavaSyncAugmenter.class);
    registerExtensionPoint(EmptyLibraryFilterSettings.EP_NAME, EmptyLibraryFilterSettings.class);
    // For importJavaWorkspace.
    applicationServices.register(JavaSourcePackageReader.class, new JavaSourcePackageReader() {

        @Nullable
        @Override
        public String getDeclaredPackageOfJavaFile(BlazeContext context, ArtifactLocationDecoder artifactLocationDecoder, SourceArtifact sourceArtifact) {
            return null;
        }
    });
    applicationServices.register(PackageManifestReader.class, new PackageManifestReader());
    applicationServices.register(PrefetchService.class, new MockPrefetchService());
    registerExtensionPoint(JavaLikeLanguage.EP_NAME, JavaLikeLanguage.class).registerExtension(new JavaLikeLanguage.Java());
    applicationServices.register(RemoteArtifactPrefetcher.class, new MockRemoteArtifactPrefetcher());
}
Also used : MockExperimentService(com.google.idea.common.experiments.MockExperimentService) JavaBlazeRules(com.google.idea.blaze.java.JavaBlazeRules) GeneratedResourceRetentionFilter(com.google.idea.blaze.android.sync.importer.problems.GeneratedResourceRetentionFilter) MockBlazeExecutor(com.google.idea.blaze.base.async.executor.MockBlazeExecutor) BlazeContext(com.google.idea.blaze.base.scope.BlazeContext) MockPrefetchService(com.google.idea.blaze.base.prefetch.MockPrefetchService) MockBlazeExecutor(com.google.idea.blaze.base.async.executor.MockBlazeExecutor) BlazeExecutor(com.google.idea.blaze.base.async.executor.BlazeExecutor) Kind(com.google.idea.blaze.base.model.primitives.Kind) MockArtifactLocationDecoder(com.google.idea.blaze.base.sync.workspace.MockArtifactLocationDecoder) ArtifactLocationDecoder(com.google.idea.blaze.base.sync.workspace.ArtifactLocationDecoder) JavaSourcePackageReader(com.google.idea.blaze.java.sync.source.JavaSourcePackageReader) BlazeImportSettingsManager(com.google.idea.blaze.base.settings.BlazeImportSettingsManager) JavaLikeLanguage(com.google.idea.blaze.java.sync.source.JavaLikeLanguage) PackageManifestReader(com.google.idea.blaze.java.sync.source.PackageManifestReader) GenericBlazeRules(com.google.idea.blaze.base.model.primitives.GenericBlazeRules) MockRemoteArtifactPrefetcher(com.google.idea.blaze.base.sync.MockRemoteArtifactPrefetcher) SourceArtifact(com.google.idea.blaze.java.sync.source.SourceArtifact) BuildSystemProvider(com.google.idea.blaze.base.bazel.BuildSystemProvider) FileOperationProvider(com.google.idea.blaze.base.io.FileOperationProvider) Provider(com.google.idea.blaze.base.model.primitives.Kind.Provider) BazelBuildSystemProvider(com.google.idea.blaze.base.bazel.BazelBuildSystemProvider) AndroidBlazeRules(com.google.idea.blaze.java.AndroidBlazeRules) Nullable(javax.annotation.Nullable)

Example 3 with JavaBlazeRules

use of com.google.idea.blaze.java.JavaBlazeRules in project intellij by bazelbuild.

the class BlazeJavaRunProfileStateTest method initTest.

@Override
protected void initTest(Container applicationServices, Container projectServices) {
    projectServices.register(BlazeImportSettingsManager.class, new BlazeImportSettingsManager(project));
    BlazeImportSettingsManager.getInstance(getProject()).setImportSettings(DUMMY_IMPORT_SETTINGS);
    ExperimentService experimentService = new MockExperimentService();
    applicationServices.register(ExperimentService.class, experimentService);
    applicationServices.register(BlazeUserSettings.class, new BlazeUserSettings());
    applicationServices.register(TempDirectoryProvider.class, new TempDirectoryProviderImpl());
    applicationServices.register(FileOperationProvider.class, new FakeFileOperationProvider());
    ExtensionPointImpl<Kind.Provider> kindProviderEp = registerExtensionPoint(Kind.Provider.EP_NAME, Kind.Provider.class);
    kindProviderEp.registerExtension(new GenericBlazeRules(), testDisposable);
    kindProviderEp.registerExtension(new JavaBlazeRules(), testDisposable);
    applicationServices.register(Kind.ApplicationState.class, new Kind.ApplicationState());
    projectServices.register(FastBuildService.class, new DisabledFastBuildService());
    projectServices.register(ProjectViewManager.class, new MockProjectViewManager());
    ExtensionPointImpl<TargetFinder> targetFinderEp = registerExtensionPoint(TargetFinder.EP_NAME, TargetFinder.class);
    targetFinderEp.registerExtension(new MockTargetFinder(), testDisposable);
    ExtensionPointImpl<JavaLikeLanguage> javaLikeEp = registerExtensionPoint(JavaLikeLanguage.EP_NAME, JavaLikeLanguage.class);
    javaLikeEp.registerExtension(new JavaLikeLanguage.Java(), testDisposable);
    registerExtensionPoint(BuildFlagsProvider.EP_NAME, BuildFlagsProvider.class);
    ExtensionPointImpl<BlazeCommandRunConfigurationHandlerProvider> handlerProviderEp = registerExtensionPoint(BlazeCommandRunConfigurationHandlerProvider.EP_NAME, BlazeCommandRunConfigurationHandlerProvider.class);
    handlerProviderEp.registerExtension(new BlazeJavaRunConfigurationHandlerProvider(), testDisposable);
    handlerProviderEp.registerExtension(new BlazeCommandGenericRunConfigurationHandlerProvider(), testDisposable);
    registerExtensionPoint(HotSwapCommandBuilder.EP_NAME, HotSwapCommandBuilder.class);
    configuration = new BlazeCommandRunConfigurationType().getFactory().createTemplateConfiguration(project);
}
Also used : MockExperimentService(com.google.idea.common.experiments.MockExperimentService) JavaBlazeRules(com.google.idea.blaze.java.JavaBlazeRules) BlazeCommandRunConfigurationType(com.google.idea.blaze.base.run.BlazeCommandRunConfigurationType) Kind(com.google.idea.blaze.base.model.primitives.Kind) TempDirectoryProviderImpl(com.google.idea.blaze.base.io.TempDirectoryProviderImpl) BlazeImportSettingsManager(com.google.idea.blaze.base.settings.BlazeImportSettingsManager) JavaLikeLanguage(com.google.idea.blaze.java.sync.source.JavaLikeLanguage) BlazeCommandRunConfigurationHandlerProvider(com.google.idea.blaze.base.run.confighandler.BlazeCommandRunConfigurationHandlerProvider) GenericBlazeRules(com.google.idea.blaze.base.model.primitives.GenericBlazeRules) BuildFlagsProvider(com.google.idea.blaze.base.command.BuildFlagsProvider) BuildSystemProvider(com.google.idea.blaze.base.bazel.BuildSystemProvider) FileOperationProvider(com.google.idea.blaze.base.io.FileOperationProvider) FakeBuildSystemProvider(com.google.idea.blaze.base.bazel.FakeBuildSystemProvider) TempDirectoryProvider(com.google.idea.blaze.base.io.TempDirectoryProvider) BlazeCommandRunConfigurationHandlerProvider(com.google.idea.blaze.base.run.confighandler.BlazeCommandRunConfigurationHandlerProvider) BlazeCommandGenericRunConfigurationHandlerProvider(com.google.idea.blaze.base.run.confighandler.BlazeCommandGenericRunConfigurationHandlerProvider) BlazeCommandGenericRunConfigurationHandlerProvider(com.google.idea.blaze.base.run.confighandler.BlazeCommandGenericRunConfigurationHandlerProvider) TargetFinder(com.google.idea.blaze.base.run.targetfinder.TargetFinder) BlazeUserSettings(com.google.idea.blaze.base.settings.BlazeUserSettings) ExperimentService(com.google.idea.common.experiments.ExperimentService) MockExperimentService(com.google.idea.common.experiments.MockExperimentService)

Example 4 with JavaBlazeRules

use of com.google.idea.blaze.java.JavaBlazeRules in project intellij by bazelbuild.

the class BlazeJavaWorkspaceImporterTest method initTest.

@Override
// False positive on getDeclaredPackageOfJavaFile.
@SuppressWarnings("FunctionalInterfaceClash")
protected void initTest(Container applicationServices, Container projectServices) {
    fileOperationProvider = new MockFileOperationProvider();
    applicationServices.register(FileOperationProvider.class, fileOperationProvider);
    experimentService = new MockExperimentService();
    applicationServices.register(ExperimentService.class, experimentService);
    MockRemoteArtifactPrefetcher remoteArtifactPrefetcher = new MockRemoteArtifactPrefetcher();
    applicationServices.register(RemoteArtifactPrefetcher.class, remoteArtifactPrefetcher);
    ExtensionPointImpl<Kind.Provider> ep = registerExtensionPoint(Kind.Provider.EP_NAME, Kind.Provider.class);
    ep.registerExtension(new JavaBlazeRules());
    ep.registerExtension(new AndroidBlazeRules());
    ep.registerExtension(new GenericBlazeRules());
    applicationServices.register(Kind.ApplicationState.class, new Kind.ApplicationState());
    BlazeExecutor blazeExecutor = new MockBlazeExecutor();
    applicationServices.register(BlazeExecutor.class, blazeExecutor);
    projectServices.register(BlazeImportSettingsManager.class, new BlazeImportSettingsManager(project));
    BlazeImportSettingsManager.getInstance(getProject()).setImportSettings(DUMMY_IMPORT_SETTINGS);
    // will silently fall back to FilePathJavaPackageReader
    applicationServices.register(JavaSourcePackageReader.class, new JavaSourcePackageReader() {

        @Nullable
        @Override
        public String getDeclaredPackageOfJavaFile(BlazeContext context, ArtifactLocationDecoder artifactLocationDecoder, SourceArtifact sourceArtifact) {
            return null;
        }
    });
    applicationServices.register(PackageManifestReader.class, new PackageManifestReader());
    applicationServices.register(PrefetchService.class, new MockPrefetchService());
    context = BlazeContext.create();
    context.addOutputSink(IssueOutput.class, errorCollector);
    augmenters = registerExtensionPoint(BlazeJavaSyncAugmenter.EP_NAME, BlazeJavaSyncAugmenter.class);
    registerExtensionPoint(EmptyLibraryFilterSettings.EP_NAME, EmptyLibraryFilterSettings.class);
    registerExtensionPoint(JavaLikeLanguage.EP_NAME, JavaLikeLanguage.class).registerExtension(new JavaLikeLanguage.Java());
    projectServices.register(JarCache.class, new MockJarCache(project));
}
Also used : MockExperimentService(com.google.idea.common.experiments.MockExperimentService) JavaBlazeRules(com.google.idea.blaze.java.JavaBlazeRules) MockBlazeExecutor(com.google.idea.blaze.base.async.executor.MockBlazeExecutor) BlazeContext(com.google.idea.blaze.base.scope.BlazeContext) MockPrefetchService(com.google.idea.blaze.base.prefetch.MockPrefetchService) MockBlazeExecutor(com.google.idea.blaze.base.async.executor.MockBlazeExecutor) BlazeExecutor(com.google.idea.blaze.base.async.executor.BlazeExecutor) Kind(com.google.idea.blaze.base.model.primitives.Kind) MockArtifactLocationDecoder(com.google.idea.blaze.base.sync.workspace.MockArtifactLocationDecoder) ArtifactLocationDecoder(com.google.idea.blaze.base.sync.workspace.ArtifactLocationDecoder) JavaSourcePackageReader(com.google.idea.blaze.java.sync.source.JavaSourcePackageReader) BlazeImportSettingsManager(com.google.idea.blaze.base.settings.BlazeImportSettingsManager) JavaLikeLanguage(com.google.idea.blaze.java.sync.source.JavaLikeLanguage) PackageManifestReader(com.google.idea.blaze.java.sync.source.PackageManifestReader) GenericBlazeRules(com.google.idea.blaze.base.model.primitives.GenericBlazeRules) MockRemoteArtifactPrefetcher(com.google.idea.blaze.base.sync.MockRemoteArtifactPrefetcher) SourceArtifact(com.google.idea.blaze.java.sync.source.SourceArtifact) BuildSystemProvider(com.google.idea.blaze.base.bazel.BuildSystemProvider) FileOperationProvider(com.google.idea.blaze.base.io.FileOperationProvider) BazelBuildSystemProvider(com.google.idea.blaze.base.bazel.BazelBuildSystemProvider) AndroidBlazeRules(com.google.idea.blaze.java.AndroidBlazeRules) BlazeJavaSyncAugmenter(com.google.idea.blaze.java.sync.BlazeJavaSyncAugmenter) Nullable(javax.annotation.Nullable)

Example 5 with JavaBlazeRules

use of com.google.idea.blaze.java.JavaBlazeRules in project intellij by bazelbuild.

the class BlazeScalaWorkspaceImporterTest method initTest.

@Override
// False positive on getDeclaredPackageOfJavaFile.
@SuppressWarnings("FunctionalInterfaceClash")
protected void initTest(@NotNull Container applicationServices, @NotNull Container projectServices) {
    super.initTest(applicationServices, projectServices);
    context = BlazeContext.create();
    context.addOutputSink(IssueOutput.class, errorCollector);
    ExtensionPointImpl<Provider> ep = registerExtensionPoint(Kind.Provider.EP_NAME, Kind.Provider.class);
    ep.registerExtension(new JavaBlazeRules());
    ep.registerExtension(new ScalaBlazeRules());
    ep.registerExtension(new GenericBlazeRules());
    applicationServices.register(Kind.ApplicationState.class, new Kind.ApplicationState());
    registerExtensionPoint(BlazeJavaSyncAugmenter.EP_NAME, BlazeJavaSyncAugmenter.class);
    registerExtensionPoint(EmptyLibraryFilterSettings.EP_NAME, EmptyLibraryFilterSettings.class);
    BlazeImportSettingsManager importSettingsManager = new BlazeImportSettingsManager(project);
    importSettingsManager.setImportSettings(new BlazeImportSettings("", "", "", "", BuildSystemName.Blaze));
    projectServices.register(BlazeImportSettingsManager.class, importSettingsManager);
    applicationServices.register(PrefetchService.class, new MockPrefetchService());
    applicationServices.register(PackageManifestReader.class, new PackageManifestReader());
    applicationServices.register(ExperimentService.class, new MockExperimentService());
    applicationServices.register(FileOperationProvider.class, new FileOperationProvider() {

        @Override
        public long getFileSize(File file) {
            // Make JARs appear nonempty so that they aren't filtered out
            return file.getName().endsWith("jar") ? 500L : super.getFileSize(file);
        }
    });
    // will silently fall back to FilePathJavaPackageReader
    applicationServices.register(JavaSourcePackageReader.class, new JavaSourcePackageReader() {

        @Nullable
        @Override
        public String getDeclaredPackageOfJavaFile(BlazeContext context, ArtifactLocationDecoder artifactLocationDecoder, SourceArtifact sourceArtifact) {
            return null;
        }
    });
    applicationServices.register(RemoteArtifactPrefetcher.class, new MockRemoteArtifactPrefetcher());
    ExtensionPoint<JavaLikeLanguage> javaLikeLanguages = registerExtensionPoint(JavaLikeLanguage.EP_NAME, JavaLikeLanguage.class);
    javaLikeLanguages.registerExtension(new JavaLikeLanguage.Java());
    javaLikeLanguages.registerExtension(new ScalaJavaLikeLanguage());
}
Also used : JavaBlazeRules(com.google.idea.blaze.java.JavaBlazeRules) MockExperimentService(com.google.idea.common.experiments.MockExperimentService) BlazeImportSettings(com.google.idea.blaze.base.settings.BlazeImportSettings) ScalaBlazeRules(com.google.idea.blaze.scala.ScalaBlazeRules) MockPrefetchService(com.google.idea.blaze.base.prefetch.MockPrefetchService) BlazeContext(com.google.idea.blaze.base.scope.BlazeContext) Kind(com.google.idea.blaze.base.model.primitives.Kind) FileOperationProvider(com.google.idea.blaze.base.io.FileOperationProvider) MockArtifactLocationDecoder(com.google.idea.blaze.base.sync.workspace.MockArtifactLocationDecoder) ArtifactLocationDecoder(com.google.idea.blaze.base.sync.workspace.ArtifactLocationDecoder) JavaSourcePackageReader(com.google.idea.blaze.java.sync.source.JavaSourcePackageReader) BlazeImportSettingsManager(com.google.idea.blaze.base.settings.BlazeImportSettingsManager) JavaLikeLanguage(com.google.idea.blaze.java.sync.source.JavaLikeLanguage) ScalaJavaLikeLanguage(com.google.idea.blaze.scala.ScalaJavaLikeLanguage) PackageManifestReader(com.google.idea.blaze.java.sync.source.PackageManifestReader) GenericBlazeRules(com.google.idea.blaze.base.model.primitives.GenericBlazeRules) ScalaJavaLikeLanguage(com.google.idea.blaze.scala.ScalaJavaLikeLanguage) MockRemoteArtifactPrefetcher(com.google.idea.blaze.base.sync.MockRemoteArtifactPrefetcher) SourceArtifact(com.google.idea.blaze.java.sync.source.SourceArtifact) FileOperationProvider(com.google.idea.blaze.base.io.FileOperationProvider) Provider(com.google.idea.blaze.base.model.primitives.Kind.Provider) File(java.io.File) Nullable(javax.annotation.Nullable)

Aggregations

Kind (com.google.idea.blaze.base.model.primitives.Kind)5 JavaBlazeRules (com.google.idea.blaze.java.JavaBlazeRules)5 MockExperimentService (com.google.idea.common.experiments.MockExperimentService)5 FileOperationProvider (com.google.idea.blaze.base.io.FileOperationProvider)4 GenericBlazeRules (com.google.idea.blaze.base.model.primitives.GenericBlazeRules)4 BlazeContext (com.google.idea.blaze.base.scope.BlazeContext)4 BlazeImportSettingsManager (com.google.idea.blaze.base.settings.BlazeImportSettingsManager)4 JavaLikeLanguage (com.google.idea.blaze.java.sync.source.JavaLikeLanguage)4 BuildSystemProvider (com.google.idea.blaze.base.bazel.BuildSystemProvider)3 MockPrefetchService (com.google.idea.blaze.base.prefetch.MockPrefetchService)3 MockRemoteArtifactPrefetcher (com.google.idea.blaze.base.sync.MockRemoteArtifactPrefetcher)3 ArtifactLocationDecoder (com.google.idea.blaze.base.sync.workspace.ArtifactLocationDecoder)3 MockArtifactLocationDecoder (com.google.idea.blaze.base.sync.workspace.MockArtifactLocationDecoder)3 JavaSourcePackageReader (com.google.idea.blaze.java.sync.source.JavaSourcePackageReader)3 PackageManifestReader (com.google.idea.blaze.java.sync.source.PackageManifestReader)3 SourceArtifact (com.google.idea.blaze.java.sync.source.SourceArtifact)3 Nullable (javax.annotation.Nullable)3 BlazeExecutor (com.google.idea.blaze.base.async.executor.BlazeExecutor)2 MockBlazeExecutor (com.google.idea.blaze.base.async.executor.MockBlazeExecutor)2 BazelBuildSystemProvider (com.google.idea.blaze.base.bazel.BazelBuildSystemProvider)2