Search in sources :

Example 1 with WorkspaceType

use of com.google.idea.blaze.base.model.primitives.WorkspaceType in project intellij by bazelbuild.

the class ProjectViewVerifierTest method initTest.

@Override
protected void initTest(@NotNull Container applicationServices, @NotNull Container projectServices) {
    super.initTest(applicationServices, projectServices);
    ExtensionPointImpl<BlazeSyncPlugin> ep = registerExtensionPoint(BlazeSyncPlugin.EP_NAME, BlazeSyncPlugin.class);
    ep.registerExtension(new BlazeSyncPlugin() {

        @Override
        public ImmutableList<WorkspaceType> getSupportedWorkspaceTypes() {
            return ImmutableList.of(WorkspaceType.JAVA);
        }

        @Override
        public Set<LanguageClass> getSupportedLanguagesInWorkspace(WorkspaceType workspaceType) {
            return ImmutableSet.of(LanguageClass.JAVA);
        }
    });
    fileOperationProvider = new MockFileOperationProvider(workspaceRoot);
    applicationServices.register(FileOperationProvider.class, fileOperationProvider);
    context = new BlazeContext();
    context.addOutputSink(IssueOutput.class, errorCollector);
}
Also used : BlazeContext(com.google.idea.blaze.base.scope.BlazeContext) WorkspaceType(com.google.idea.blaze.base.model.primitives.WorkspaceType) ImmutableSet(com.google.common.collect.ImmutableSet) Set(java.util.Set) ImmutableList(com.google.common.collect.ImmutableList) BlazeSyncPlugin(com.google.idea.blaze.base.sync.BlazeSyncPlugin)

Example 2 with WorkspaceType

use of com.google.idea.blaze.base.model.primitives.WorkspaceType in project intellij by bazelbuild.

the class LanguageSupportTest method testFailWithUnsupportedLanguageType.

@Test
public void testFailWithUnsupportedLanguageType() {
    syncPlugins.registerExtension(new BlazeSyncPlugin() {

        @Override
        public Set<LanguageClass> getSupportedLanguagesInWorkspace(WorkspaceType workspaceType) {
            return ImmutableSet.of(LanguageClass.C);
        }

        @Override
        public ImmutableList<WorkspaceType> getSupportedWorkspaceTypes() {
            return ImmutableList.of(WorkspaceType.C);
        }

        @Override
        public WorkspaceType getDefaultWorkspaceType() {
            return WorkspaceType.C;
        }
    });
    ProjectViewSet projectViewSet = ProjectViewSet.builder().add(ProjectView.builder().add(ScalarSection.builder(WorkspaceTypeSection.KEY).set(WorkspaceType.C)).add(ListSection.builder(AdditionalLanguagesSection.KEY).add(LanguageClass.PYTHON)).build()).build();
    WorkspaceLanguageSettings settings = LanguageSupport.createWorkspaceLanguageSettings(projectViewSet);
    LanguageSupport.validateLanguageSettings(context, settings);
    errorCollector.assertIssues("Language 'python' is not supported by this plugin");
}
Also used : ProjectViewSet(com.google.idea.blaze.base.projectview.ProjectViewSet) WorkspaceType(com.google.idea.blaze.base.model.primitives.WorkspaceType) ImmutableSet(com.google.common.collect.ImmutableSet) Set(java.util.Set) ProjectViewSet(com.google.idea.blaze.base.projectview.ProjectViewSet) ImmutableList(com.google.common.collect.ImmutableList) WorkspaceLanguageSettings(com.google.idea.blaze.base.sync.projectview.WorkspaceLanguageSettings) Test(org.junit.Test)

Example 3 with WorkspaceType

use of com.google.idea.blaze.base.model.primitives.WorkspaceType in project intellij by bazelbuild.

the class BlazeAndroidLiteSyncPluginTest method initTest.

@Override
protected void initTest(@NotNull Container applicationServices, @NotNull Container projectServices) {
    super.initTest(applicationServices, projectServices);
    ExtensionPointImpl<BlazeSyncPlugin> ep = registerExtensionPoint(BlazeSyncPlugin.EP_NAME, BlazeSyncPlugin.class);
    ep.registerExtension(new BlazeAndroidLiteSyncPlugin());
    // add java, because we need at least one WorkspaceType available.
    ep.registerExtension(new BlazeSyncPlugin() {

        @Override
        public ImmutableList<WorkspaceType> getSupportedWorkspaceTypes() {
            return ImmutableList.of(WorkspaceType.JAVA);
        }

        @Override
        public Set<LanguageClass> getSupportedLanguagesInWorkspace(WorkspaceType workspaceType) {
            return ImmutableSet.of(LanguageClass.JAVA);
        }

        @Override
        public WorkspaceType getDefaultWorkspaceType() {
            return WorkspaceType.JAVA;
        }
    });
    context = new BlazeContext();
    context.addOutputSink(IssueOutput.class, errorCollector);
}
Also used : BlazeContext(com.google.idea.blaze.base.scope.BlazeContext) WorkspaceType(com.google.idea.blaze.base.model.primitives.WorkspaceType) ImmutableSet(com.google.common.collect.ImmutableSet) Set(java.util.Set) ProjectViewSet(com.google.idea.blaze.base.projectview.ProjectViewSet) ImmutableList(com.google.common.collect.ImmutableList) BlazeSyncPlugin(com.google.idea.blaze.base.sync.BlazeSyncPlugin)

Example 4 with WorkspaceType

use of com.google.idea.blaze.base.model.primitives.WorkspaceType in project intellij by bazelbuild.

the class LanguageSupport method createWorkspaceLanguageSettings.

/**
 * Derives {@link WorkspaceLanguageSettings} from the {@link ProjectViewSet}. Does no validation.
 */
public static WorkspaceLanguageSettings createWorkspaceLanguageSettings(ProjectViewSet projectViewSet) {
    WorkspaceType workspaceType = projectViewSet.getScalarValue(WorkspaceTypeSection.KEY).orElse(getDefaultWorkspaceType());
    ImmutableSet.Builder<LanguageClass> activeLanguages = ImmutableSet.<LanguageClass>builder().addAll(workspaceType.getLanguages()).addAll(projectViewSet.listItems(AdditionalLanguagesSection.KEY)).add(LanguageClass.GENERIC);
    Arrays.stream(BlazeSyncPlugin.EP_NAME.getExtensions()).forEach(plugin -> activeLanguages.addAll(plugin.getAlwaysActiveLanguages()));
    return new WorkspaceLanguageSettings(workspaceType, activeLanguages.build());
}
Also used : WorkspaceType(com.google.idea.blaze.base.model.primitives.WorkspaceType) ImmutableSet(com.google.common.collect.ImmutableSet) LanguageClass(com.google.idea.blaze.base.model.primitives.LanguageClass)

Example 5 with WorkspaceType

use of com.google.idea.blaze.base.model.primitives.WorkspaceType in project intellij by bazelbuild.

the class LanguageSupportTest method testSimpleCase.

@Test
public void testSimpleCase() {
    syncPlugins.registerExtension(new BlazeSyncPlugin() {

        @Override
        public Set<LanguageClass> getSupportedLanguagesInWorkspace(WorkspaceType workspaceType) {
            return ImmutableSet.of(LanguageClass.C);
        }

        @Override
        public ImmutableList<WorkspaceType> getSupportedWorkspaceTypes() {
            return ImmutableList.of(WorkspaceType.C);
        }

        @Override
        public WorkspaceType getDefaultWorkspaceType() {
            return WorkspaceType.C;
        }
    });
    ProjectViewSet projectViewSet = ProjectViewSet.builder().add(ProjectView.builder().add(ScalarSection.builder(WorkspaceTypeSection.KEY).set(WorkspaceType.C)).build()).build();
    WorkspaceLanguageSettings workspaceLanguageSettings = LanguageSupport.createWorkspaceLanguageSettings(projectViewSet);
    errorCollector.assertNoIssues();
    assertThat(workspaceLanguageSettings).isEqualTo(new WorkspaceLanguageSettings(WorkspaceType.C, ImmutableSet.of(LanguageClass.C, LanguageClass.GENERIC)));
}
Also used : ProjectViewSet(com.google.idea.blaze.base.projectview.ProjectViewSet) WorkspaceType(com.google.idea.blaze.base.model.primitives.WorkspaceType) ImmutableSet(com.google.common.collect.ImmutableSet) Set(java.util.Set) ProjectViewSet(com.google.idea.blaze.base.projectview.ProjectViewSet) ImmutableList(com.google.common.collect.ImmutableList) WorkspaceLanguageSettings(com.google.idea.blaze.base.sync.projectview.WorkspaceLanguageSettings) Test(org.junit.Test)

Aggregations

WorkspaceType (com.google.idea.blaze.base.model.primitives.WorkspaceType)13 ImmutableSet (com.google.common.collect.ImmutableSet)9 ImmutableList (com.google.common.collect.ImmutableList)8 ProjectViewSet (com.google.idea.blaze.base.projectview.ProjectViewSet)8 Set (java.util.Set)8 BlazeSyncPlugin (com.google.idea.blaze.base.sync.BlazeSyncPlugin)7 BlazeContext (com.google.idea.blaze.base.scope.BlazeContext)6 WorkspaceLanguageSettings (com.google.idea.blaze.base.sync.projectview.WorkspaceLanguageSettings)4 Test (org.junit.Test)4 LanguageClass (com.google.idea.blaze.base.model.primitives.LanguageClass)2 Nullable (javax.annotation.Nullable)1