use of com.google.idea.blaze.base.model.primitives.LanguageClass in project intellij by bazelbuild.
the class AdditionalLanguagesHelper method enableLanguageSupport.
/**
* Adds the specified languages to the project view's 'additional_languages' section, and
* installs/enables any other required plugins.
*/
public static void enableLanguageSupport(Project project, List<LanguageClass> languages) {
ProjectViewEdit edit = ProjectViewEdit.editLocalProjectView(project, builder -> {
ListSection<LanguageClass> existingSection = builder.getLast(AdditionalLanguagesSection.KEY);
builder.replace(existingSection, ListSection.update(AdditionalLanguagesSection.KEY, existingSection).addAll(languages));
return true;
});
if (edit == null) {
Messages.showErrorDialog("Could not modify project view. Check for errors in your project view and try again", "Error");
return;
}
edit.apply();
ImmutableSet<String> requiredPlugins = Arrays.stream(BlazeSyncPlugin.EP_NAME.getExtensions()).map(syncPlugin -> syncPlugin.getRequiredExternalPluginIds(languages)).flatMap(Collection::stream).collect(toImmutableSet());
PluginUtils.installOrEnablePlugins(requiredPlugins);
BlazeSyncManager.getInstance(project).requestProjectSync(new BlazeSyncParams.Builder("Sync", BlazeSyncParams.SyncMode.INCREMENTAL).addProjectViewTargets(true).addWorkingSet(BlazeUserSettings.getInstance().getExpandSyncToWorkingSet()).build());
}
use of com.google.idea.blaze.base.model.primitives.LanguageClass in project intellij by bazelbuild.
the class LanguageSupport method supportedLanguagesForWorkspaceType.
/**
* @return The set of {@link LanguageClass}'s supported for this {@link WorkspaceType}s.
*/
public static Set<LanguageClass> supportedLanguagesForWorkspaceType(WorkspaceType type) {
Set<LanguageClass> supportedLanguages = EnumSet.noneOf(LanguageClass.class);
for (BlazeSyncPlugin syncPlugin : BlazeSyncPlugin.EP_NAME.getExtensions()) {
supportedLanguages.addAll(syncPlugin.getSupportedLanguagesInWorkspace(type));
supportedLanguages.addAll(syncPlugin.getAlwaysActiveLanguages());
}
supportedLanguages.add(LanguageClass.GENERIC);
return supportedLanguages;
}
use of com.google.idea.blaze.base.model.primitives.LanguageClass in project intellij by bazelbuild.
the class LanguageSupport method validateLanguageSettings.
public static boolean validateLanguageSettings(BlazeContext context, WorkspaceLanguageSettings languageSettings) {
Set<WorkspaceType> supportedTypes = supportedWorkspaceTypes();
WorkspaceType workspaceType = languageSettings.getWorkspaceType();
if (!supportedTypes.contains(languageSettings.getWorkspaceType())) {
IssueOutput.error(String.format("Workspace type '%s' is not supported by this plugin", languageSettings.getWorkspaceType().getName())).submit(context);
return false;
}
Set<LanguageClass> supportedLanguages = supportedLanguagesForWorkspaceType(workspaceType);
Set<LanguageClass> availableLanguages = EnumSet.noneOf(LanguageClass.class);
for (WorkspaceType type : supportedTypes) {
availableLanguages.addAll(supportedLanguagesForWorkspaceType(type));
}
for (LanguageClass languageClass : languageSettings.activeLanguages) {
if (!availableLanguages.contains(languageClass)) {
IssueOutput.error(String.format("Language '%s' is not supported by this plugin", languageClass.getName())).submit(context);
return false;
}
if (!supportedLanguages.contains(languageClass)) {
IssueOutput.error(String.format("Language '%s' is not supported for this plugin with workspace type: '%s'", languageClass.getName(), workspaceType.getName())).submit(context);
return false;
}
}
return true;
}
Aggregations