Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Project Status API integration with bazel for CLion #6585

Merged
merged 1 commit into from
Aug 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,13 @@
import com.google.idea.blaze.base.settings.BuildSystemName;
import com.google.idea.blaze.base.sync.workspace.WorkspacePathResolver;
import com.google.idea.blaze.base.sync.workspace.WorkspacePathResolverImpl;
import com.intellij.ide.DataManager;
import com.intellij.ide.util.projectWizard.WizardContext;
import com.intellij.openapi.actionSystem.ActionPlaces;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.actionSystem.ex.ActionUtil;
import com.intellij.openapi.project.Project;
import com.intellij.ui.EditorNotificationPanel;
import java.io.File;
import org.jetbrains.annotations.NotNull;

Expand All @@ -49,7 +48,7 @@ public static boolean projectCouldBeImported(Project project) {
return BazelWorkspaceRootProvider.INSTANCE.isWorkspaceRoot(new File(root));
}

public static Runnable createAction(EditorNotificationPanel panel, String basePath) {
public static Runnable createAction(String basePath) {
File baseFile = new File(basePath);
BazelImportCurrentProjectAction action = new BazelImportCurrentProjectAction(baseFile);

Expand All @@ -58,7 +57,7 @@ public static Runnable createAction(EditorNotificationPanel panel, String basePa
action,
null,
ActionPlaces.UNKNOWN,
DataManager.getInstance().getDataContext(panel)
DataContext.EMPTY_CONTEXT
);

if (ActionUtil.lastUpdateAndCheckDumb(action, event, true)) {
Expand All @@ -69,7 +68,8 @@ public static Runnable createAction(EditorNotificationPanel panel, String basePa

final File workspaceRootFile;

private BazelImportCurrentProjectAction(File workspaceRootFile) {
public BazelImportCurrentProjectAction(File workspaceRootFile) {
super("Import current project");
this.workspaceRootFile = workspaceRootFile;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public class BazelNotificationProvider implements EditorNotificationProvider, Du
@Override
public @Nullable Function<? super FileEditor, ? extends JComponent> collectNotificationData(
@NotNull Project project, @NotNull VirtualFile file) {
if (file.getFileType() != BuildFileType.INSTANCE) {
if (!isProjectAwareFile(file)) {
return null;
}
if (!BazelImportCurrentProjectAction.projectCouldBeImported(project)) {
Expand All @@ -51,7 +51,7 @@ public class BazelNotificationProvider implements EditorNotificationProvider, Du

return fileEditor -> {
EditorNotificationPanel panel = new EditorNotificationPanel(fileEditor, Status.Warning);
Runnable importAction = BazelImportCurrentProjectAction.createAction(panel, root);
Runnable importAction = BazelImportCurrentProjectAction.createAction(root);

panel.setText("Project is not configured");
panel.createActionLabel("Import Bazel project", importAction);
Expand All @@ -60,4 +60,8 @@ public class BazelNotificationProvider implements EditorNotificationProvider, Du
return panel;
};
}

protected boolean isProjectAwareFile(@NotNull VirtualFile file) {
return file.getFileType() == BuildFileType.INSTANCE;
}
}
5 changes: 4 additions & 1 deletion clwb/sdkcompat/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,8 @@ java_library(
"clion-2024.2": ["//clwb/sdkcompat/v242"],
}),
visibility = ["//clwb:__pkg__"],
deps = ["//intellij_platform_sdk:plugin_api"],
deps = [
"//base",
"//intellij_platform_sdk:plugin_api",
],
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* Copyright 2023 The Bazel Authors. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.google.idea.blaze.clwb;

import com.google.idea.blaze.base.wizard2.BazelNotificationProvider;
import com.intellij.openapi.vfs.VirtualFile;

import com.jetbrains.cidr.lang.OCLanguageUtilsBase;
import org.jetbrains.annotations.NotNull;

/**
* Provide notification for C-family files temporarily until moving to new CLion project status
* api.
*/
Comment on lines +25 to +28
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess we can drop this comment, no longer temporarily.

// #api241
public class BazelCNotificationProvider extends BazelNotificationProvider {

@Override
protected boolean isProjectAwareFile(@NotNull VirtualFile file) {
return OCLanguageUtilsBase.isSupported(file.getFileType());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* Copyright 2023 The Bazel Authors. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.idea.blaze.clwb;

import com.google.idea.blaze.base.settings.Blaze;
import com.intellij.openapi.project.Project;
import com.intellij.ui.EditorNotificationProvider;
import com.jetbrains.cidr.cpp.cmake.workspace.CMakeNotificationProvider;

// #api241
public class CLionNotificationProvider {

public static void register(Project project) {
if (Blaze.isBlazeProject(project)) {
// Note: We want to remove the CMake notification banner in case that the project is Bazel.
var exPoint = EditorNotificationProvider.EP_NAME.getPoint(project);
for (var extension : exPoint.getExtensions()) {
if (extension instanceof CMakeNotificationProvider) {
exPoint.unregisterExtension(extension);
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* Copyright 2023 The Bazel Authors. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.google.idea.blaze.clwb;

import com.google.idea.blaze.base.wizard2.BazelNotificationProvider;
import com.intellij.openapi.vfs.VirtualFile;

import com.jetbrains.cidr.lang.OCLanguageUtilsBase;
import org.jetbrains.annotations.NotNull;

/**
* Provide notification for C-family files temporarily until moving to new CLion project status
* api.
*/
// #api241
public class BazelCNotificationProvider extends BazelNotificationProvider {

@Override
protected boolean isProjectAwareFile(@NotNull VirtualFile file) {
return OCLanguageUtilsBase.isSupported(file.getFileType());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* Copyright 2023 The Bazel Authors. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.idea.blaze.clwb;

import com.google.idea.blaze.base.settings.Blaze;
import com.intellij.openapi.project.Project;
import com.intellij.ui.EditorNotificationProvider;
import com.jetbrains.cidr.cpp.cmake.workspace.CMakeNotificationProvider;

// #api241
public class CLionNotificationProvider {

public static void register(Project project) {
if (Blaze.isBlazeProject(project)) {
// Note: We want to remove the CMake notification banner in case that the project is Bazel.
var exPoint = EditorNotificationProvider.EP_NAME.getPoint(project);
for (var extension : exPoint.getExtensions()) {
if (extension instanceof CMakeNotificationProvider) {
exPoint.unregisterExtension(extension);
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* Copyright 2023 The Bazel Authors. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.google.idea.blaze.clwb;

import com.google.idea.blaze.base.wizard2.BazelNotificationProvider;
import com.intellij.openapi.vfs.VirtualFile;

import com.jetbrains.cidr.lang.OCLanguageUtilsBase;
import org.jetbrains.annotations.NotNull;

/**
* Provide notification for C-family files temporarily until moving to new CLion project status
* api.
*/
// #api241
public class BazelCNotificationProvider extends BazelNotificationProvider {

@Override
protected boolean isProjectAwareFile(@NotNull VirtualFile file) {
return OCLanguageUtilsBase.isSupported(file.getFileType());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* Copyright 2023 The Bazel Authors. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.idea.blaze.clwb;

import com.google.idea.blaze.base.settings.Blaze;
import com.intellij.openapi.project.Project;
import com.intellij.ui.EditorNotificationProvider;
import com.jetbrains.cidr.cpp.cmake.workspace.CMakeNotificationProvider;

// #api241
public class CLionNotificationProvider {

public static void register(Project project) {
if (Blaze.isBlazeProject(project)) {
// Note: We want to remove the CMake notification banner in case that the project is Bazel.
var exPoint = EditorNotificationProvider.EP_NAME.getPoint(project);
for (var extension : exPoint.getExtensions()) {
if (extension instanceof CMakeNotificationProvider) {
exPoint.unregisterExtension(extension);
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* Copyright 2023 The Bazel Authors. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.google.idea.blaze.clwb;

import com.google.idea.blaze.base.wizard2.BazelNotificationProvider;
import com.intellij.openapi.vfs.VirtualFile;

import com.jetbrains.cidr.lang.OCLanguageUtilsBase;
import org.jetbrains.annotations.NotNull;

/**
* Provide notification for C-family files temporarily until moving to new CLion project status
* api.
*/
// #api241
public class BazelCNotificationProvider extends BazelNotificationProvider {

@Override
protected boolean isProjectAwareFile(@NotNull VirtualFile file) {
return OCLanguageUtilsBase.isSupported(file.getFileType());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* Copyright 2023 The Bazel Authors. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.idea.blaze.clwb;

import com.google.idea.blaze.base.settings.Blaze;
import com.intellij.openapi.project.Project;
import com.intellij.ui.EditorNotificationProvider;
import com.jetbrains.cidr.cpp.cmake.workspace.CMakeNotificationProvider;

// #api241
public class CLionNotificationProvider {

public static void register(Project project) {
if (Blaze.isBlazeProject(project)) {
// Note: We want to remove the CMake notification banner in case that the project is Bazel.
var exPoint = EditorNotificationProvider.EP_NAME.getPoint(project);
for (var extension : exPoint.getExtensions()) {
if (extension instanceof CMakeNotificationProvider) {
exPoint.unregisterExtension(extension);
}
}
}
}
}
Loading
Loading