From 63f65b97d39dd7b391a0dc6fedcc24d85588cffa Mon Sep 17 00:00:00 2001 From: Daniel Brauner Date: Thu, 19 Sep 2024 15:35:40 +0200 Subject: [PATCH] fixed notification show for files in a different project model --- .../blaze/clwb/CLionNotificationProvider.java | 51 ++++++++++--------- 1 file changed, 26 insertions(+), 25 deletions(-) diff --git a/clwb/sdkcompat/v242/com/google/idea/blaze/clwb/CLionNotificationProvider.java b/clwb/sdkcompat/v242/com/google/idea/blaze/clwb/CLionNotificationProvider.java index 5a33328033e..51d8aba078c 100644 --- a/clwb/sdkcompat/v242/com/google/idea/blaze/clwb/CLionNotificationProvider.java +++ b/clwb/sdkcompat/v242/com/google/idea/blaze/clwb/CLionNotificationProvider.java @@ -15,6 +15,7 @@ */ package com.google.idea.blaze.clwb; +import A.d.Vi; import com.google.idea.blaze.base.lang.buildfile.language.BuildFileType; import com.google.idea.blaze.base.settings.Blaze; import com.google.idea.blaze.base.wizard2.BazelImportCurrentProjectAction; @@ -25,6 +26,7 @@ import com.intellij.openapi.project.Project; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.ui.EditorNotificationProvider; +import com.jetbrains.cidr.lang.daemon.OCFileScopeProvider; import com.jetbrains.cidr.project.ui.ProjectStatusHelperKt; import com.jetbrains.cidr.project.ui.notifications.EditorNotificationWarningProvider; import com.jetbrains.cidr.project.ui.notifications.ProjectNotification; @@ -75,26 +77,38 @@ public static void register(Project project) { registered = true; } - @NotNull - @Override - public List collectFixes(@NotNull Project project, @Nullable VirtualFile file, - @NotNull DataContext dataContext) { - if (file == null) { - return List.of(); - } - + private static Boolean isBazelAwareFile(Project project, VirtualFile file) { if (Blaze.isBlazeProject(project)) { - return List.of(); + return false; } if (!isProjectAwareFile(file, project) && file.getFileType() != BuildFileType.INSTANCE) { - return List.of(); + return false; } + + if (OCFileScopeProvider.Companion.getProjectSourceLocationKind(project, file).isInProject()) { + return false; + } + if (!BazelImportCurrentProjectAction.projectCouldBeImported(project)) { + return false; + } + + if (project.getBasePath() == null) { + return false; + } + + return true; + } + + @NotNull + @Override + public List collectFixes(@NotNull Project project, @Nullable VirtualFile file, @NotNull DataContext dataContext) { + if (file == null || !isBazelAwareFile(project, file)) { return List.of(); } - String root = project.getBasePath(); + final var root = project.getBasePath(); if (root == null) { return List.of(); } @@ -127,24 +141,11 @@ public ProjectNotification getProjectNotification(@NotNull Project project, @Nullable @Override public WidgetStatus getWidgetStatus(@NotNull Project project, @Nullable VirtualFile file) { - if (Blaze.isBlazeProject(project)) { return new DefaultWidgetStatus(Status.OK, Scope.Project, "Project is configured"); } - if (file == null) { - return null; - } - - if (!isProjectAwareFile(file, project) && file.getFileType() != BuildFileType.INSTANCE) { - return null; - } - if (!BazelImportCurrentProjectAction.projectCouldBeImported(project)) { - return null; - } - - String root = project.getBasePath(); - if (root == null) { + if (file == null || !isBazelAwareFile(project, file)) { return null; }