use of com.google.idea.blaze.base.model.BlazeProjectData in project intellij by bazelbuild.
the class AddSourceToProjectHelper method getContext.
/**
* Returns the location context related to a source file to be added to the project.
*/
@Nullable
static LocationContext getContext(Project project, File file) {
BlazeProjectData syncData = BlazeProjectDataManager.getInstance(project).getBlazeProjectData();
if (syncData == null) {
return null;
}
WorkspacePath workspacePath = getWorkspacePath(project, file);
if (workspacePath == null || isBuildSystemOutputArtifact(project, workspacePath)) {
return null;
}
ProjectViewSet projectViewSet = ProjectViewManager.getInstance(project).getProjectViewSet();
if (projectViewSet == null) {
return null;
}
WorkspacePath parent = workspacePath.getParent();
if (parent == null) {
return null;
}
WorkspacePath blazePackage = findBlazePackagePath(project, parent);
return blazePackage != null ? new LocationContext(project, syncData, projectViewSet, file, workspacePath, blazePackage) : null;
}
use of com.google.idea.blaze.base.model.BlazeProjectData in project intellij by bazelbuild.
the class AdditionalLanguagesHelper method createNotificationPanel.
@Nullable
@Override
public EditorNotificationPanel createNotificationPanel(VirtualFile file, FileEditor fileEditor) {
String ext = file.getExtension();
if (ext == null) {
return null;
}
LanguageClass language = LanguageClass.fromExtension(ext);
if (language == null || notifiedLanguages.contains(language)) {
return null;
}
BlazeProjectData projectData = BlazeProjectDataManager.getInstance(project).getBlazeProjectData();
if (projectData == null) {
return null;
}
WorkspaceLanguageSettings settings = projectData.workspaceLanguageSettings;
if (settings.isLanguageActive(language)) {
return null;
}
if (!LanguageSupport.supportedLanguagesForWorkspaceType(settings.getWorkspaceType()).contains(language)) {
return null;
}
String langName = language.getName();
String message = String.format("Do you want to enable %s plugin %s support?", Blaze.buildSystemName(project), langName);
EditorNotificationPanel panel = new EditorNotificationPanel();
panel.setText(message);
panel.createActionLabel(String.format("Enable %s support", langName), () -> {
enableLanguageSupport(project, ImmutableList.of(language));
suppressNotifications(language);
});
panel.createActionLabel("Don't show again", () -> suppressNotifications(language));
return panel;
}
use of com.google.idea.blaze.base.model.BlazeProjectData in project intellij by bazelbuild.
the class OpenBlazeWorkspaceFileAction method actionPerformedInBlazeProject.
@Override
protected void actionPerformedInBlazeProject(Project project, AnActionEvent e) {
BlazeProjectData blazeProjectData = BlazeProjectDataManager.getInstance(project).getBlazeProjectData();
if (blazeProjectData == null) {
return;
}
new OpenBlazeWorkspaceFileActionDialog(project, blazeProjectData.workspacePathResolver).show();
}
use of com.google.idea.blaze.base.model.BlazeProjectData in project intellij by bazelbuild.
the class PrefetchProjectInitializer method prefetchProjectFiles.
private static void prefetchProjectFiles(Project project) {
if (!Blaze.isBlazeProject(project)) {
return;
}
BlazeProjectData projectData = getBlazeProjectData(project);
ProjectViewSet projectViewSet = getProjectViewSet(project);
if (projectViewSet == null) {
return;
}
PrefetchIndexingTask.submitPrefetchingTask(project, PrefetchService.getInstance().prefetchProjectFiles(project, projectViewSet, projectData), "Initial Prefetching");
}
use of com.google.idea.blaze.base.model.BlazeProjectData in project intellij by bazelbuild.
the class BlazeBuildFileRunConfigurationProducer method doIsConfigFromContext.
@Override
protected boolean doIsConfigFromContext(BlazeCommandRunConfiguration configuration, ConfigurationContext context) {
BuildTarget target = getBuildTarget(context);
if (target == null) {
return false;
}
if (!Objects.equals(configuration.getTarget(), target.label)) {
return false;
}
// We don't know any details about how the various factories set up configurations from here.
// Simply returning true at this point would be overly broad
// (all configs with a matching target would be identified).
// A complete equality check, meanwhile, would be too restrictive
// (things like config name and user flags shouldn't count)
// - not to mention we lack the equals() implementations needed to perform such a check!
// So we compromise: if the target, suggested name, and command name match,
// we consider it close enough. The suggested name is checked because it tends
// to cover what the handler considers important,
// and ignores changes the user may have made to the name.
BlazeProjectData blazeProjectData = BlazeProjectDataManager.getInstance(configuration.getProject()).getBlazeProjectData();
if (blazeProjectData == null) {
return false;
}
BlazeCommandRunConfiguration generatedConfiguration = new BlazeCommandRunConfiguration(configuration.getProject(), configuration.getFactory(), configuration.getName());
setupConfiguration(configuration.getProject(), blazeProjectData, generatedConfiguration, target);
// ignore filtered test configs, produced by other configuration producers.
BlazeCommandRunConfigurationCommonState handlerState = configuration.getHandlerStateIfType(BlazeCommandRunConfigurationCommonState.class);
if (handlerState != null && handlerState.getTestFilterFlag() != null) {
return false;
}
return Objects.equals(configuration.suggestedName(), generatedConfiguration.suggestedName()) && Objects.equals(configuration.getHandler().getCommandName(), generatedConfiguration.getHandler().getCommandName());
}
Aggregations