use of com.android.tools.idea.gradle.dsl.model.values.GradleNullableValue in project android by JetBrains.
the class SourceSetModel method root.
@NotNull
public GradleNullableValue<String> root() {
GradleDslExpression rootElement = myDslElement.getPropertyElement(ROOT, GradleDslExpression.class);
if (rootElement == null) {
return new GradleNullableValue<>(myDslElement, null);
}
String value = null;
if (rootElement instanceof GradleDslMethodCall) {
List<GradleDslElement> arguments = ((GradleDslMethodCall) rootElement).getArguments();
if (!arguments.isEmpty()) {
GradleDslElement pathArgument = arguments.get(0);
if (pathArgument instanceof GradleDslExpression) {
value = ((GradleDslExpression) pathArgument).getValue(String.class);
}
}
} else {
value = rootElement.getValue(String.class);
}
return new GradleNullableValue<>(rootElement, value);
}
use of com.android.tools.idea.gradle.dsl.model.values.GradleNullableValue in project android by JetBrains.
the class AbstractBuildModel method path.
@NotNull
public GradleNullableValue<File> path() {
GradleDslElement pathElement = myDslElement.getPropertyElement(PATH);
if (pathElement == null) {
return new GradleNullableValue<>(myDslElement, null);
}
File value = null;
if (pathElement instanceof GradleDslMethodCall || pathElement instanceof GradleDslNewExpression) {
value = ((GradleDslExpression) pathElement).getValue(File.class);
} else if (pathElement instanceof GradleDslExpression) {
String path = ((GradleDslExpression) pathElement).getValue(String.class);
if (path != null) {
value = new File(path);
}
}
return new GradleNullableValue<>(pathElement, value);
}
use of com.android.tools.idea.gradle.dsl.model.values.GradleNullableValue in project android by JetBrains.
the class SigningConfigModel method getPasswordValue.
@NotNull
private GradleNullableValue<SigningConfigPassword> getPasswordValue(@NotNull String property) {
GradleDslExpression passwordElement = getPasswordElement(property);
if (passwordElement == null) {
return new GradleNullableValue<>(myDslElement, null);
}
Type passwordType;
switch(passwordElement.getName()) {
case SYSTEM_GETENV:
passwordType = ENVIRONMENT_VARIABLE;
break;
case SYSTEM_CONSOLE_READ_LINE:
passwordType = CONSOLE_READ;
break;
default:
passwordType = PLAIN_TEXT;
break;
}
String passwordText = passwordElement.getValue(String.class);
if (passwordText != null) {
return new GradleNullableValue<>(passwordElement, new SigningConfigPassword(passwordType, passwordText));
}
return new GradleNullableValue<>(passwordElement, null);
}
Aggregations