diff --git a/clwb/src/META-INF/clwb-oclang.xml b/clwb/src/META-INF/clwb-oclang.xml index 06643032b1c..ce48b2a6db8 100644 --- a/clwb/src/META-INF/clwb-oclang.xml +++ b/clwb/src/META-INF/clwb-oclang.xml @@ -19,6 +19,7 @@ + diff --git a/clwb/src/META-INF/clwb.xml b/clwb/src/META-INF/clwb.xml index c4b49e50984..b8ffab8b6d7 100644 --- a/clwb/src/META-INF/clwb.xml +++ b/clwb/src/META-INF/clwb.xml @@ -19,6 +19,10 @@ com.intellij.modules.clion org.jetbrains.plugins.clion.test.google + + + + diff --git a/clwb/src/com/google/idea/blaze/clwb/CidrGoogleTestUtilAdapter.java b/clwb/src/com/google/idea/blaze/clwb/oclang/run/CidrGoogleTestUtilAdapter.java similarity index 96% rename from clwb/src/com/google/idea/blaze/clwb/CidrGoogleTestUtilAdapter.java rename to clwb/src/com/google/idea/blaze/clwb/oclang/run/CidrGoogleTestUtilAdapter.java index 765b7865563..ec5aa1aeb4f 100644 --- a/clwb/src/com/google/idea/blaze/clwb/CidrGoogleTestUtilAdapter.java +++ b/clwb/src/com/google/idea/blaze/clwb/oclang/run/CidrGoogleTestUtilAdapter.java @@ -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; @@ -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) { @@ -132,7 +128,7 @@ public static Couple extractFullSuiteNameFromMacro(PsiElement element) { } @Nullable - private static PsiElement findGoogleTestSymbol( + public PsiElement findGoogleTestSymbol( Project project, Predicate predicate) { CidrGoogleTestFramework instance = CidrGoogleTestFramework.getInstance(); FindFirstWithPredicateProcessor processor = diff --git a/clwb/src/com/google/idea/blaze/clwb/oclang/run/test/BlazeCppTestLocator.java b/clwb/src/com/google/idea/blaze/clwb/oclang/run/test/BlazeCppTestLocator.java index 372ab6a82af..0f3442d24fe 100644 --- a/clwb/src/com/google/idea/blaze/clwb/oclang/run/test/BlazeCppTestLocator.java +++ b/clwb/src/com/google/idea/blaze/clwb/oclang/run/test/BlazeCppTestLocator.java @@ -16,7 +16,7 @@ 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; diff --git a/clwb/src/com/google/idea/blaze/clwb/oclang/run/test/GoogleTestLocation.java b/clwb/src/com/google/idea/blaze/clwb/oclang/run/test/GoogleTestLocation.java index 71d44e3e502..7aa388c605a 100644 --- a/clwb/src/com/google/idea/blaze/clwb/oclang/run/test/GoogleTestLocation.java +++ b/clwb/src/com/google/idea/blaze/clwb/oclang/run/test/GoogleTestLocation.java @@ -17,7 +17,7 @@ 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; diff --git a/clwb/src/com/google/idea/blaze/clwb/run/BlazeCidrLauncher.java b/clwb/src/com/google/idea/blaze/clwb/run/BlazeCidrLauncher.java index 87ba9925bef..b4da2bc712b 100644 --- a/clwb/src/com/google/idea/blaze/clwb/run/BlazeCidrLauncher.java +++ b/clwb/src/com/google/idea/blaze/clwb/run/BlazeCidrLauncher.java @@ -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; @@ -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; } /** diff --git a/clwb/src/com/google/idea/blaze/clwb/run/GoogleTestUtilAdapter.java b/clwb/src/com/google/idea/blaze/clwb/run/GoogleTestUtilAdapter.java new file mode 100644 index 00000000000..e86a539a044 --- /dev/null +++ b/clwb/src/com/google/idea/blaze/clwb/run/GoogleTestUtilAdapter.java @@ -0,0 +1,41 @@ +/* + * 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 EP_NAME = + ExtensionPointName.create("com.google.idea.blaze.clwb.googleTestUtilAdapter"); + + @Nullable + static PsiElement findGoogleTestSymbol(Project project) { + 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 predicate); +}