use of com.intellij.execution.Location in project intellij-community by JetBrains.
the class TestMethodGradleConfigurationProducer method doSetupConfigurationFromContext.
@Override
protected boolean doSetupConfigurationFromContext(ExternalSystemRunConfiguration configuration, ConfigurationContext context, Ref<PsiElement> sourceElement) {
if (RunConfigurationProducer.getInstance(PatternConfigurationProducer.class).isMultipleElementsSelected(context)) {
return false;
}
final Location contextLocation = context.getLocation();
assert contextLocation != null;
PsiMethod psiMethod = getPsiMethodForLocation(contextLocation);
if (psiMethod == null)
return false;
sourceElement.set(psiMethod);
final PsiClass containingClass = psiMethod.getContainingClass();
if (containingClass == null)
return false;
if (context.getModule() == null)
return false;
if (!applyTestMethodConfiguration(configuration, context, psiMethod, containingClass))
return false;
JavaRunConfigurationExtensionManager.getInstance().extendCreatedConfiguration(configuration, contextLocation);
return true;
}
use of com.intellij.execution.Location in project android by JetBrains.
the class AndroidConfigurationProducer method isConfigurationFromContext.
@Override
public boolean isConfigurationFromContext(AndroidRunConfiguration configuration, ConfigurationContext context) {
final Location location = context.getLocation();
if (location == null) {
return false;
}
final PsiClass activity = getActivityClass(location, context);
if (activity == null) {
return false;
}
final String activityName = activity.getQualifiedName();
if (activityName == null) {
return false;
}
final Module contextModule = AndroidUtils.getAndroidModule(context);
final Module confModule = configuration.getConfigurationModule().getModule();
return Comparing.equal(contextModule, confModule) && configuration.isLaunchingActivity(activityName);
}
use of com.intellij.execution.Location in project android by JetBrains.
the class TestPatternConfigurationProducer method setupConfigurationFromContext.
@Override
protected boolean setupConfigurationFromContext(AndroidJUnitConfiguration configuration, ConfigurationContext context, Ref<PsiElement> sourceElement) {
LinkedHashSet<String> classes = new LinkedHashSet<String>();
PsiElement element = checkPatterns(context, classes);
if (element == null) {
return false;
}
sourceElement.set(element);
JUnitConfiguration.Data data = configuration.getPersistentData();
data.setPatterns(classes);
data.TEST_OBJECT = JUnitConfiguration.TEST_PATTERN;
data.setScope(setupPackageConfiguration(context, configuration, data.getScope()));
configuration.setGeneratedName();
Location contextLocation = context.getLocation();
if (contextLocation instanceof PsiMemberParameterizedLocation) {
String paramSetName = ((PsiMemberParameterizedLocation) contextLocation).getParamSetName();
if (paramSetName != null) {
configuration.setProgramParameters(paramSetName);
}
}
return true;
}
use of com.intellij.execution.Location in project android by JetBrains.
the class AndroidTestConfigurationProducer method setupConfigurationFromContext.
@Override
protected boolean setupConfigurationFromContext(AndroidTestRunConfiguration configuration, ConfigurationContext context, Ref<PsiElement> sourceElement) {
Module module = AndroidUtils.getAndroidModule(context);
if (module == null) {
return false;
}
Location location = context.getLocation();
if (location == null) {
return false;
}
location = JavaExecutionUtil.stepIntoSingleClass(location);
if (location == null) {
return false;
}
final PsiElement element = location.getPsiElement();
AndroidFacet facet = AndroidFacet.getInstance(module);
if (facet == null) {
return false;
}
// TODO: Resolve direct AndroidGradleModel dep (b/22596984)
AndroidModuleModel androidModel = AndroidModuleModel.get(facet);
if (androidModel != null) {
// Only suggest the android test run configuration if it makes sense for the selected test artifact.
if (androidModel.getAndroidTestArtifactInSelectedVariant() == null) {
return false;
}
TestArtifactSearchScopes testScopes = TestArtifactSearchScopes.get(module);
if (testScopes == null) {
return false;
}
VirtualFile virtualFile = null;
if (element instanceof PsiDirectory) {
virtualFile = ((PsiDirectory) element).getVirtualFile();
} else {
PsiFile psiFile = element.getContainingFile();
if (psiFile != null) {
virtualFile = psiFile.getVirtualFile();
}
}
if (virtualFile == null) {
return false;
}
if (!testScopes.isAndroidTestSource(virtualFile)) {
return false;
}
}
setupInstrumentationTestRunner(configuration, facet);
if (setupAllInPackageConfiguration(configuration, element, context, sourceElement)) {
return true;
}
if (setupMethodConfiguration(configuration, element, context, sourceElement)) {
return true;
}
return setupClassConfiguration(configuration, element, context, sourceElement);
}
use of com.intellij.execution.Location in project intellij-plugins by JetBrains.
the class CfmlRunConfigurationProducer method isConfigurationFromContext.
@Override
public boolean isConfigurationFromContext(CfmlRunConfiguration configuration, ConfigurationContext context) {
final Location location = context.getLocation();
if (location == null)
return false;
final PsiElement anchor = location.getPsiElement();
final PsiFile containingFile = anchor.getContainingFile();
if (isValid(containingFile)) {
final String path;
path = buildPageUrl(context, containingFile.getVirtualFile());
URL url;
final String urlFromRunnerParameters = configuration.getRunnerParameters().getUrl();
if (urlFromRunnerParameters.isEmpty())
return false;
try {
url = new URL(urlFromRunnerParameters);
return StringUtil.equals(url.getPath(), path);
} catch (MalformedURLException e) {
LOG.error(CfmlBundle.message("cfml.producer.error.url", urlFromRunnerParameters));
}
}
return false;
}
Aggregations