use of com.microsoft.azure.toolkit.intellij.common.AzureRunConfigurationBase in project azure-tools-for-java by Microsoft.
the class FunctionRunConfigurationProducer method setupConfigurationFromContext.
@Override
protected boolean setupConfigurationFromContext(AzureRunConfigurationBase runConfigurationBase, ConfigurationContext context, Ref ref) {
if (!(runConfigurationBase instanceof FunctionRunConfiguration || runConfigurationBase instanceof FunctionDeployConfiguration)) {
return false;
}
final Location contextLocation = context.getLocation();
assert contextLocation != null;
Location<PsiMethod> methodLocation = getAzureFunctionMethods(contextLocation);
if (methodLocation == null) {
return false;
}
AzureRunConfigurationBase configuration = runConfigurationBase;
if (configuration instanceof FunctionDeployConfiguration) {
final RunManagerEx manager = RunManagerEx.getInstanceEx(context.getProject());
// since deploy configuration doesn't support, we need to create a FunctionRunConfiguration
final RunnerAndConfigurationSettings settings = RunConfigurationUtils.getOrCreateRunConfigurationSettings(context.getModule(), manager, getConfigurationFactory());
configuration = (AzureRunConfigurationBase) settings.getConfiguration();
}
FunctionRunConfiguration runConfiguration = (FunctionRunConfiguration) configuration;
final RunnerAndConfigurationSettings template = context.getRunManager().getConfigurationTemplate(getConfigurationFactory());
final Module contextModule = context.getModule();
final Module predefinedModule = ((FunctionRunConfiguration) template.getConfiguration()).getModule();
if (predefinedModule != null) {
runConfiguration.initializeDefaults(predefinedModule);
} else {
final Module module = findModule(runConfiguration, contextModule);
if (module != null) {
runConfiguration.initializeDefaults(module);
} else {
return false;
}
}
if (StringUtils.isBlank(configuration.getName())) {
configuration.setName("Run Functions - " + runConfiguration.getModule().getName());
}
return true;
}
Aggregations