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);
}
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");
}
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);
}
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());
}
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)));
}
Aggregations