use of com.android.tools.idea.gradle.dsl.parser.elements.GradleDslExpression in project android by JetBrains.
the class SigningConfigModel method getStoreFileExpression.
@Nullable
private GradleDslExpression getStoreFileExpression() {
GradleDslMethodCall methodCall = myDslElement.getPropertyElement(STORE_FILE, GradleDslMethodCall.class);
if (methodCall == null || methodCall.getArguments().size() == 0) {
return null;
}
GradleDslElement argument = methodCall.getArguments().get(0);
if (argument instanceof GradleDslExpression) {
return (GradleDslExpression) argument;
}
return null;
}
use of com.android.tools.idea.gradle.dsl.parser.elements.GradleDslExpression in project android by JetBrains.
the class SigningConfigModel method setStoreFile.
public SigningConfigModel setStoreFile(@NotNull String storeFile) {
if (myDslElement.getPropertyElement(STORE_FILE) == null) {
GradleDslMethodCall methodCall = new GradleDslMethodCall(myDslElement, "file", STORE_FILE);
GradleDslLiteral literal = new GradleDslLiteral(methodCall, "");
literal.setValue(storeFile);
methodCall.addNewArgument(literal);
myDslElement.setNewElement(STORE_FILE, methodCall);
} else {
GradleDslExpression expression = getStoreFileExpression();
if (expression != null) {
expression.setValue(storeFile);
}
}
return this;
}
use of com.android.tools.idea.gradle.dsl.parser.elements.GradleDslExpression in project android by JetBrains.
the class SigningConfigModel method setPasswordValue.
private void setPasswordValue(@NotNull String property, @NotNull Type type, @NotNull String text) {
if (type == PLAIN_TEXT) {
myDslElement.setNewLiteral(property, text);
return;
}
GradleNullableValue<SigningConfigPassword> passwordValue = getPasswordValue(property);
SigningConfigPassword password = passwordValue.value();
if (password != null && password.getType() == type) {
GradleDslExpression element = getPasswordElement(property);
if (element != null) {
element.setValue(text);
return;
}
}
GradleDslMethodCall methodCall = null;
if (type == ENVIRONMENT_VARIABLE) {
methodCall = new GradleDslMethodCall(myDslElement, SYSTEM_GETENV, property);
} else if (type == CONSOLE_READ) {
methodCall = new GradleDslMethodCall(myDslElement, SYSTEM_CONSOLE_READ_LINE, property);
}
if (methodCall != null) {
GradleDslLiteral argumentElement = new GradleDslLiteral(methodCall, methodCall.getName());
argumentElement.setValue(text);
methodCall.addNewArgument(argumentElement);
myDslElement.setNewElement(property, methodCall);
}
}
use of com.android.tools.idea.gradle.dsl.parser.elements.GradleDslExpression 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.parser.elements.GradleDslExpression in project android by JetBrains.
the class SourceSetModel method setRoot.
@NotNull
public SourceSetModel setRoot(@NotNull String root) {
GradleDslExpression rootElement = myDslElement.getPropertyElement(ROOT, GradleDslExpression.class);
if (rootElement == null) {
myDslElement.setNewLiteral(ROOT, root);
return this;
}
if (rootElement instanceof GradleDslMethodCall) {
List<GradleDslElement> arguments = ((GradleDslMethodCall) rootElement).getArguments();
if (!arguments.isEmpty()) {
GradleDslElement pathArgument = arguments.get(0);
if (pathArgument instanceof GradleDslExpression) {
((GradleDslExpression) pathArgument).setValue(root);
return this;
}
}
}
rootElement.setValue(root);
return this;
}
Aggregations