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

Make //clwb(plugin) and //cpp(plugin) dependency on cidr.lang optional: plugin xmls split #5473

Merged
merged 5 commits into from
Oct 18, 2023
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
8 changes: 8 additions & 0 deletions clwb/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ load(
"//build_defs:build_defs.bzl",
"intellij_plugin",
"intellij_plugin_library",
"optional_plugin_xml",
"plugin_deploy_zip",
"repackaged_files",
"stamped_plugin_xml",
Expand All @@ -30,10 +31,17 @@ licenses(["notice"])
intellij_plugin_library(
name = "plugin_library",
plugin_xmls = ["src/META-INF/clwb.xml"],
optional_plugin_xmls = ["optional_clwb_oclang"],
visibility = PLUGIN_PACKAGES_VISIBILITY,
deps = [":clwb_lib"],
)

optional_plugin_xml(
name = "optional_clwb_oclang",
module = "com.intellij.modules.cidr.lang",
plugin_xml = "src/META-INF/clwb-oclang.xml",
)

stamped_plugin_xml(
name = "stamped_plugin_xml",
changelog_file = "//:changelog",
Expand Down
25 changes: 25 additions & 0 deletions clwb/src/META-INF/clwb-oclang.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<!--
~ 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.
-->
<idea-plugin>
<extensions defaultExtensionNs="cidr.debugger">
<languageSupport language="" implementationClass="com.google.idea.blaze.clwb.oclang.run.BlazeCidrDebuggerSupportFactory"/>
</extensions>

<extensions defaultExtensionNs="com.google.idea.blaze">
<clwb.googleTestUtilAdapter implementation="com.google.idea.blaze.clwb.oclang.run.CidrGoogleTestUtilAdapter"/>
<TestContextProvider implementation="com.google.idea.blaze.clwb.oclang.run.producers.CppTestContextProvider"/>
</extensions>
</idea-plugin>
11 changes: 5 additions & 6 deletions clwb/src/META-INF/clwb.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@
<depends>com.intellij.modules.clion</depends>
<depends>org.jetbrains.plugins.clion.test.google</depends>

<extensionPoints>
<extensionPoint qualifiedName="com.google.idea.blaze.clwb.googleTestUtilAdapter" interface="com.google.idea.blaze.clwb.run.GoogleTestUtilAdapter"/>
</extensionPoints>

<extensions defaultExtensionNs="com.intellij">
<consoleFilterProvider implementation="com.google.idea.blaze.clwb.run.BlazeCppPathConsoleFilter$Provider"/>

Expand All @@ -31,15 +35,10 @@
<registryKey defaultValue="false" description="Disable the extra debug flags in debug C/C++ builds" key="bazel.clwb.debug.extraflags.disabled"/>
</extensions>

<extensions defaultExtensionNs="cidr.debugger">
<languageSupport language="" implementationClass="com.google.idea.blaze.clwb.run.BlazeCidrDebuggerSupportFactory"/>
</extensions>

<extensions defaultExtensionNs="com.google.idea.blaze">
<SyncPlugin implementation="com.google.idea.blaze.clwb.sync.BlazeCLionSyncPlugin"/>
<BlazeCommandRunConfigurationHandlerProvider implementation="com.google.idea.blaze.clwb.run.BlazeCidrRunConfigurationHandlerProvider" order="first"/>
<BlazeTestEventsHandler implementation="com.google.idea.blaze.clwb.run.test.BlazeCidrTestEventsHandler"/>
<TestContextProvider implementation="com.google.idea.blaze.clwb.run.producers.CppTestContextProvider"/>
<BlazeTestEventsHandler implementation="com.google.idea.blaze.clwb.oclang.run.test.BlazeCidrTestEventsHandler"/>
</extensions>

<project-components>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.idea.blaze.clwb.run;
package com.google.idea.blaze.clwb.oclang.run;

import com.google.idea.blaze.base.run.BlazeCommandRunConfiguration;
import com.google.idea.blaze.clwb.run.RunConfigurationUtils;
import com.intellij.execution.configurations.RunProfile;
import com.intellij.xdebugger.evaluation.XDebuggerEditorsProvider;
import com.jetbrains.cidr.execution.debugger.OCDebuggerLanguageSupport;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.idea.blaze.clwb;
package com.google.idea.blaze.clwb.oclang.run;

import com.google.common.collect.Iterables;
import com.google.idea.blaze.clwb.run.GoogleTestUtilAdapter;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Couple;
import com.intellij.psi.PsiElement;
Expand All @@ -33,12 +34,7 @@
import javax.annotation.Nullable;

/** Adapter to bridge different SDK versions. */
public class CidrGoogleTestUtilAdapter {
@Nullable
public static PsiElement findGoogleTestSymbol(Project project) {
return findGoogleTestSymbol(project, testScopeElement -> true);
}

public class CidrGoogleTestUtilAdapter implements GoogleTestUtilAdapter {
@Nullable
public static PsiElement findGoogleTestSymbol(
Project project, String suiteName, String testName) {
Expand Down Expand Up @@ -132,7 +128,7 @@ public static Couple<String> extractFullSuiteNameFromMacro(PsiElement element) {
}

@Nullable
private static PsiElement findGoogleTestSymbol(
public PsiElement findGoogleTestSymbol(
Project project, Predicate<CidrTestScopeElement> predicate) {
CidrGoogleTestFramework instance = CidrGoogleTestFramework.getInstance();
FindFirstWithPredicateProcessor<CidrTestScopeElement> processor =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.idea.blaze.clwb.run.producers;
package com.google.idea.blaze.clwb.oclang.run.producers;

import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture;
Expand All @@ -25,8 +25,8 @@
import com.google.idea.blaze.base.run.producers.TestContext;
import com.google.idea.blaze.base.run.producers.TestContextProvider;
import com.google.idea.blaze.base.run.targetfinder.FuturesUtil;
import com.google.idea.blaze.clwb.run.test.GoogleTestLocation;
import com.google.idea.blaze.clwb.run.test.GoogleTestSpecification;
import com.google.idea.blaze.clwb.oclang.run.test.GoogleTestLocation;
import com.google.idea.blaze.clwb.oclang.run.test.GoogleTestSpecification;
import com.google.idea.blaze.cpp.CppBlazeRules.RuleTypes;
import com.intellij.execution.Location;
import com.intellij.execution.actions.ConfigurationContext;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.idea.blaze.clwb.run.test;
package com.google.idea.blaze.clwb.oclang.run.test;

import static com.google.common.collect.ImmutableList.toImmutableList;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.idea.blaze.clwb.run.test;
package com.google.idea.blaze.clwb.oclang.run.test;

import com.google.common.collect.ImmutableList;
import com.google.idea.blaze.base.run.smrunner.SmRunnerUtils;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.idea.blaze.clwb.run.test;
package com.google.idea.blaze.clwb.oclang.run.test;

import com.google.common.collect.ImmutableList;
import com.google.idea.blaze.clwb.CidrGoogleTestUtilAdapter;
import com.google.idea.blaze.clwb.oclang.run.CidrGoogleTestUtilAdapter;
import com.intellij.execution.Location;
import com.intellij.execution.testframework.sm.runner.SMTestLocator;
import com.intellij.openapi.project.Project;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.idea.blaze.clwb.run.test;
package com.google.idea.blaze.clwb.oclang.run.test;

import com.google.idea.blaze.base.sync.autosync.ProjectTargetManager.SyncStatus;
import com.google.idea.blaze.base.syncstatus.SyncStatusContributor;
import com.google.idea.blaze.clwb.CidrGoogleTestUtilAdapter;
import com.google.idea.blaze.clwb.oclang.run.CidrGoogleTestUtilAdapter;
import com.intellij.execution.Location;
import com.intellij.execution.PsiLocation;
import com.intellij.openapi.project.Project;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.idea.blaze.clwb.run.test;
package com.google.idea.blaze.clwb.oclang.run.test;

import com.google.common.base.Joiner;
import com.intellij.openapi.util.text.StringUtil;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
import com.google.idea.blaze.base.settings.Blaze;
import com.google.idea.blaze.base.settings.BlazeUserSettings;
import com.google.idea.blaze.base.settings.BuildSystemName;
import com.google.idea.blaze.clwb.CidrGoogleTestUtilAdapter;
import com.google.idea.blaze.clwb.ToolchainUtils;
import com.google.idea.blaze.cpp.CppBlazeRules;
import com.intellij.execution.ExecutionException;
Expand Down Expand Up @@ -296,7 +295,7 @@ private boolean shouldDisplayBazelTestFilterWarning() {
&& handlerState.getTestFilterFlag() != null
&& !PropertiesComponent.getInstance()
.getBoolean(DISABLE_BAZEL_GOOGLETEST_FILTER_WARNING, false)
&& CidrGoogleTestUtilAdapter.findGoogleTestSymbol(getProject()) != null;
&& GoogleTestUtilAdapter.findGoogleTestSymbol(getProject()) != null;
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
* 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.run;

import com.intellij.openapi.extensions.ExtensionPointName;
import com.intellij.openapi.project.Project;
import com.intellij.psi.PsiElement;
import com.jetbrains.cidr.execution.testing.CidrTestScopeElement;
import java.util.function.Predicate;
import javax.annotation.Nullable;

public interface GoogleTestUtilAdapter {
ExtensionPointName<GoogleTestUtilAdapter> EP_NAME =
ExtensionPointName.create("com.google.idea.blaze.clwb.googleTestUtilAdapter");

@Nullable
static PsiElement findGoogleTestSymbol(Project project) {
if (EP_NAME.getExtensionList().size() > 1) {
throw new IllegalStateException("More than 1 extension for " + EP_NAME.getName() + " is not supported");
}

GoogleTestUtilAdapter adapter = EP_NAME.getPoint().extensions().findFirst().orElse(null);
if (adapter != null) {
return adapter.findGoogleTestSymbol(project, testScopeElement -> true);
}

return null;
}

PsiElement findGoogleTestSymbol(
Project project, Predicate<CidrTestScopeElement> predicate);
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ static boolean canUseClionHandler(@Nullable Kind kind) {
|| kind == CppBlazeRules.RuleTypes.CC_BINARY.getKind();
}

static boolean canUseClionRunner(BlazeCommandRunConfiguration config) {
public static boolean canUseClionRunner(BlazeCommandRunConfiguration config) {
Kind kind = config.getTargetKind();
BlazeCommandRunConfigurationCommonState handlerState =
config.getHandlerStateIfType(BlazeCommandRunConfigurationCommonState.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,12 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.idea.blaze.clwb.run.test;
package com.google.idea.blaze.clwb.oclang.run.test;

import static com.google.common.truth.Truth.assertThat;

import com.google.idea.blaze.base.run.smrunner.SmRunnerUtils;
import com.google.idea.blaze.clwb.oclang.run.test.BlazeCppTestInfo;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
Expand Down
9 changes: 8 additions & 1 deletion cpp/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ java_library(
"src/com/google/idea/blaze/cpp/includes/*.java",
"src/com/google/idea/blaze/cpp/syncstatus/*.java",
"src/com/google/idea/blaze/cpp/navigation/*.java",
"src/com/google/idea/blaze/cpp/oclang/*.java",
]),
visibility = PLUGIN_PACKAGES_VISIBILITY,
deps = [
Expand All @@ -40,14 +41,20 @@ java_library(
],
)

stamped_plugin_xml(
name = "non_optional_cidr",
plugin_xml = "src/META-INF/blaze-cpp.xml",
)

optional_plugin_xml(
name = "optional_cidr",
module = "com.intellij.modules.cidr.lang",
plugin_xml = "src/META-INF/blaze-cpp.xml",
plugin_xml = "src/META-INF/blaze-cpp-oclang.xml",
)

intellij_plugin_library(
name = "plugin_library",
plugin_xmls = [":non_optional_cidr"],
optional_plugin_xmls = [":optional_cidr"],
visibility = PLUGIN_PACKAGES_VISIBILITY,
deps = [":cpp"],
Expand Down
27 changes: 27 additions & 0 deletions cpp/src/META-INF/blaze-cpp-oclang.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<!--
~ 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.
-->
<idea-plugin>
<extensions defaultExtensionNs="cidr.lang">
<autoImportHelper implementation="com.google.idea.blaze.cpp.oclang.BlazeCppAutoImportHelper"/>
<customHeaderProvider implementation="com.google.idea.blaze.cpp.oclang.BlazeCustomHeaderProvider"/>
<includeHelper implementation="com.google.idea.blaze.cpp.oclang.BlazeIncludeHelper"/>
</extensions>

<extensions defaultExtensionNs="com.google.idea.blaze">
<SyncStatusContributor implementation="com.google.idea.blaze.cpp.oclang.CppSyncStatusContributor"/>
<cpp.SourceFileFinder implementation="com.google.idea.blaze.cpp.oclang.OCSourceFileFinder"/>
</extensions>
</idea-plugin>
8 changes: 3 additions & 5 deletions cpp/src/META-INF/blaze-cpp.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
~ limitations under the License.
-->
<idea-plugin>
<depends>com.intellij.modules.cidr.lang</depends>
<depends>com.intellij.modules.cidr.debugger</depends>

<project-components>
Expand All @@ -26,22 +25,21 @@
<extensionPoints>
<extensionPoint qualifiedName="com.google.idea.blaze.cpp.BlazeCompilerFlagsProcessorProvider"
interface="com.google.idea.blaze.cpp.BlazeCompilerFlagsProcessor$Provider"/>

<extensionPoint qualifiedName="com.google.idea.blaze.cpp.SourceFileFinder"
interface="com.google.idea.blaze.cpp.SourceFileFinder"/>
</extensionPoints>

<extensions defaultExtensionNs="com.google.idea.blaze">
<SyncPlugin implementation="com.google.idea.blaze.cpp.BlazeCSyncPlugin"/>
<PrefetchFileSource implementation="com.google.idea.blaze.cpp.CPrefetchFileSource"/>
<SyncStatusContributor implementation="com.google.idea.blaze.cpp.syncstatus.CppSyncStatusContributor"/>
<cpp.BlazeCompilerFlagsProcessorProvider implementation="com.google.idea.blaze.cpp.IncludeRootFlagsProcessor$Provider"/>
<cpp.BlazeCompilerFlagsProcessorProvider implementation="com.google.idea.blaze.cpp.SysrootFlagsProcessor$Provider"/>
<TargetKindProvider implementation="com.google.idea.blaze.cpp.CppBlazeRules"/>
</extensions>

<extensions defaultExtensionNs="cidr.lang">
<languageKindHelper implementation="com.google.idea.blaze.cpp.BlazeLanguageKindCalculatorHelper"/>
<autoImportHelper implementation="com.google.idea.blaze.cpp.BlazeCppAutoImportHelper"/>
<customHeaderProvider implementation="com.google.idea.blaze.cpp.BlazeCustomHeaderProvider"/>
<includeHelper implementation="com.google.idea.blaze.cpp.BlazeIncludeHelper"/>
<ownModuleDetector implementation="com.google.idea.blaze.cpp.BlazeOwnModuleDetector"/>
</extensions>
<extensions defaultExtensionNs="com.intellij">
Expand Down
Loading
Loading