From 89bbb7a3a0193e64106a24a51d996f1c83b591e0 Mon Sep 17 00:00:00 2001 From: Tomasz Pasternak Date: Fri, 11 Oct 2024 18:09:25 +0400 Subject: [PATCH] fix: Disable python codegen support by default --- .../sections/EnablePythonCodegenSupport.java | 32 +++++++++++++++++++ .../section/sections/Sections.java | 1 + .../base/sync/SyncProjectTargetsHelper.java | 3 +- .../tools/intellij/.managed.bazelproject | 9 ++++++ 4 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 base/src/com/google/idea/blaze/base/projectview/section/sections/EnablePythonCodegenSupport.java create mode 100644 examples/python/simple_code_generator/tools/intellij/.managed.bazelproject diff --git a/base/src/com/google/idea/blaze/base/projectview/section/sections/EnablePythonCodegenSupport.java b/base/src/com/google/idea/blaze/base/projectview/section/sections/EnablePythonCodegenSupport.java new file mode 100644 index 00000000000..d7aa9241a1b --- /dev/null +++ b/base/src/com/google/idea/blaze/base/projectview/section/sections/EnablePythonCodegenSupport.java @@ -0,0 +1,32 @@ +/* + * Copyright 2024 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.base.projectview.section.sections; + +import com.google.idea.blaze.base.projectview.section.ScalarSection; +import com.google.idea.blaze.base.projectview.section.SectionKey; +import com.google.idea.blaze.base.projectview.section.SectionParser; + +public class EnablePythonCodegenSupport { + public static final SectionKey> KEY = + SectionKey.of("enable_python_codegen_support"); + public static final SectionParser PARSER = new BooleanSectionParser( + KEY, + """ + If set to true, enables Python codegen support. + More info here + """ + ); +} diff --git a/base/src/com/google/idea/blaze/base/projectview/section/sections/Sections.java b/base/src/com/google/idea/blaze/base/projectview/section/sections/Sections.java index 08a62870be6..f2822a39127 100644 --- a/base/src/com/google/idea/blaze/base/projectview/section/sections/Sections.java +++ b/base/src/com/google/idea/blaze/base/projectview/section/sections/Sections.java @@ -40,6 +40,7 @@ public class Sections { SyncFlagsSection.PARSER, TestFlagsSection.PARSER, ImportTargetOutputSection.PARSER, + EnablePythonCodegenSupport.PARSER, ExcludeTargetSection.PARSER, ExcludedSourceSection.PARSER, RunConfigurationsSection.PARSER, diff --git a/base/src/com/google/idea/blaze/base/sync/SyncProjectTargetsHelper.java b/base/src/com/google/idea/blaze/base/sync/SyncProjectTargetsHelper.java index 311a8990569..82600d55291 100644 --- a/base/src/com/google/idea/blaze/base/sync/SyncProjectTargetsHelper.java +++ b/base/src/com/google/idea/blaze/base/sync/SyncProjectTargetsHelper.java @@ -29,6 +29,7 @@ import com.google.idea.blaze.base.model.primitives.WorkspaceRoot; import com.google.idea.blaze.base.projectview.ProjectViewSet; import com.google.idea.blaze.base.projectview.section.sections.AutomaticallyDeriveTargetsSection; +import com.google.idea.blaze.base.projectview.section.sections.EnablePythonCodegenSupport; import com.google.idea.blaze.base.projectview.section.sections.SyncManualTargetsSection; import com.google.idea.blaze.base.projectview.section.sections.TargetSection; import com.google.idea.blaze.base.scope.BlazeContext; @@ -194,7 +195,7 @@ private static ImmutableList deriveTargetsFromDirectories( .filter(Objects::nonNull) .collect(Collectors.toSet()); - if (!activeLanguageCodeGeneratorTags.isEmpty()) { + if (!activeLanguageCodeGeneratorTags.isEmpty() && projectViewSet.getScalarValue(EnablePythonCodegenSupport.KEY).orElse(false)) { retainedByCodeGen = TargetTagFilter.filterCodeGen( project, context, diff --git a/examples/python/simple_code_generator/tools/intellij/.managed.bazelproject b/examples/python/simple_code_generator/tools/intellij/.managed.bazelproject new file mode 100644 index 00000000000..cf1bfbb1ffd --- /dev/null +++ b/examples/python/simple_code_generator/tools/intellij/.managed.bazelproject @@ -0,0 +1,9 @@ +directories: + . + +derive_targets_from_directories: true + +additional_languages: + python + +enable_python_codegen_support: true