use of com.intellij.execution.Location in project intellij by bazelbuild.
the class BlazeJavaAbstractTestCaseConfigurationProducer method getAbstractLocation.
@Nullable
private static AbstractTestLocation getAbstractLocation(ConfigurationContext context) {
if (!SmRunnerUtils.getSelectedSmRunnerTreeElements(context).isEmpty()) {
// handled by a different producer
return null;
}
PsiMethod method = getTestMethod(context);
if (method != null) {
PsiClass psiClass = method.getContainingClass();
return hasTestSubclasses(psiClass) ? new AbstractTestLocation(psiClass, method) : null;
}
Location location = context.getLocation();
if (location == null) {
return null;
}
location = JavaExecutionUtil.stepIntoSingleClass(location);
if (location == null) {
return null;
}
PsiClass psiClass = PsiTreeUtil.getParentOfType(location.getPsiElement(), PsiClass.class, false);
return hasTestSubclasses(psiClass) ? new AbstractTestLocation(psiClass, null) : null;
}
use of com.intellij.execution.Location in project intellij by bazelbuild.
the class BlazeAndroidTestClassRunConfigurationProducer method doIsConfigFromContext.
@Override
protected boolean doIsConfigFromContext(BlazeCommandRunConfiguration configuration, ConfigurationContext context) {
final Location contextLocation = context.getLocation();
assert contextLocation != null;
final Location location = JavaExecutionUtil.stepIntoSingleClass(contextLocation);
if (location == null) {
return false;
}
if (!SmRunnerUtils.getSelectedSmRunnerTreeElements(context).isEmpty()) {
// handled by a different producer
return false;
}
if (JUnitConfigurationUtil.isMultipleElementsSelected(context)) {
return false;
}
Location<PsiMethod> methodLocation = ProducerUtils.getMethodLocation(contextLocation);
if (methodLocation != null) {
return false;
}
PsiClass testClass = JUnitUtil.getTestClass(location);
if (testClass == null) {
return false;
}
return checkIfAttributesAreTheSame(configuration, testClass);
}
use of com.intellij.execution.Location in project intellij by bazelbuild.
the class BlazeAndroidTestMethodRunConfigurationProducer method doSetupConfigFromContext.
@Override
protected boolean doSetupConfigFromContext(BlazeCommandRunConfiguration configuration, ConfigurationContext context, Ref<PsiElement> sourceElement) {
if (!SmRunnerUtils.getSelectedSmRunnerTreeElements(context).isEmpty()) {
// handled by a different producer
return false;
}
if (JUnitConfigurationUtil.isMultipleElementsSelected(context)) {
return false;
}
final Location contextLocation = context.getLocation();
assert contextLocation != null;
Location<PsiMethod> methodLocation = ProducerUtils.getMethodLocation(contextLocation);
if (methodLocation == null) {
return false;
}
final PsiMethod psiMethod = methodLocation.getPsiElement();
sourceElement.set(psiMethod);
final PsiClass containingClass = psiMethod.getContainingClass();
if (containingClass == null) {
return false;
}
TargetInfo target = RunUtil.targetForTestClass(containingClass, null);
if (target == null) {
return false;
}
if (!Kind.ANDROID_TEST.equals(target.getKind())) {
return false;
}
configuration.setTargetInfo(target);
BlazeAndroidTestRunConfigurationState configState = configuration.getHandlerStateIfType(BlazeAndroidTestRunConfigurationState.class);
if (configState == null) {
return false;
}
configState.setTestingType(AndroidTestRunConfiguration.TEST_METHOD);
configState.setClassName(containingClass.getQualifiedName());
configState.setMethodName(psiMethod.getName());
configuration.setGeneratedName();
return true;
}
use of com.intellij.execution.Location in project intellij by bazelbuild.
the class BlazeAndroidTestMethodRunConfigurationProducer method doIsConfigFromContext.
@Override
protected boolean doIsConfigFromContext(BlazeCommandRunConfiguration configuration, ConfigurationContext context) {
if (!SmRunnerUtils.getSelectedSmRunnerTreeElements(context).isEmpty()) {
// handled by a different producer
return false;
}
if (JUnitConfigurationUtil.isMultipleElementsSelected(context)) {
return false;
}
final Location contextLocation = context.getLocation();
assert contextLocation != null;
Location<PsiMethod> methodLocation = ProducerUtils.getMethodLocation(contextLocation);
if (methodLocation == null) {
return false;
}
final PsiMethod psiMethod = methodLocation.getPsiElement();
final PsiClass containingClass = psiMethod.getContainingClass();
if (containingClass == null) {
return false;
}
return checkIfAttributesAreTheSame(configuration, psiMethod);
}
Aggregations