use of com.android.tools.idea.gradle.dsl.parser.elements.GradleDslMethodCall in project android by JetBrains.
the class DependenciesModel method remove.
@NotNull
public DependenciesModel remove(@NotNull DependencyModel dependency) {
GradleDslElementList gradleDslElementList = myDslElement.getPropertyElement(dependency.configurationName(), GradleDslElementList.class);
if (gradleDslElementList != null) {
GradleDslElement dependencyElement = dependency.getDslElement();
GradleDslElement parent = dependencyElement.getParent();
if (parent instanceof GradleDslMethodCall) {
GradleDslMethodCall methodCall = (GradleDslMethodCall) parent;
List<GradleDslElement> arguments = methodCall.getArguments();
if (arguments.size() == 1 && arguments.get(0).equals(dependencyElement)) {
// If this is the last argument, remove the method call altogether.
gradleDslElementList.removeElement(methodCall);
} else {
methodCall.remove(dependencyElement);
}
} else {
gradleDslElementList.removeElement(dependencyElement);
}
}
return this;
}
use of com.android.tools.idea.gradle.dsl.parser.elements.GradleDslMethodCall in project android by JetBrains.
the class DependenciesModel method all.
/**
* @return all the dependencies (artifact, module, etc.)
* WIP: Do not use.
*/
@NotNull
public List<DependencyModel> all() {
List<DependencyModel> dependencies = Lists.newArrayList();
for (String configurationName : myDslElement.getProperties()) {
GradleDslElementList list = myDslElement.getPropertyElement(configurationName, GradleDslElementList.class);
if (list != null) {
for (GradleDslElement element : list.getElements(GradleDslElement.class)) {
dependencies.addAll(ArtifactDependencyModel.create(element));
if (element instanceof GradleDslMethodCall) {
GradleDslMethodCall methodCall = (GradleDslMethodCall) element;
dependencies.addAll(ModuleDependencyModel.create(configurationName, methodCall));
}
}
}
}
return dependencies;
}
use of com.android.tools.idea.gradle.dsl.parser.elements.GradleDslMethodCall in project android by JetBrains.
the class LintOptionsModel method setFileValue.
private void setFileValue(@NotNull String property, @NotNull File file) {
GradleDslMethodCall fileElement = myDslElement.getPropertyElement(property, GradleDslMethodCall.class);
if (fileElement == null) {
fileElement = new GradleDslMethodCall(myDslElement, "file", property);
myDslElement.setNewElement(property, fileElement);
}
fileElement.setValue(file);
}
use of com.android.tools.idea.gradle.dsl.parser.elements.GradleDslMethodCall in project android by JetBrains.
the class AbiModel method addReset.
@NotNull
public AbiModel addReset() {
GradleDslMethodCall resetMethod = new GradleDslMethodCall(myDslElement, RESET, null);
// TODO: reset include
myDslElement.setNewElement(RESET, resetMethod);
return this;
}
use of com.android.tools.idea.gradle.dsl.parser.elements.GradleDslMethodCall in project android by JetBrains.
the class DensityModel method addReset.
@NotNull
public DensityModel addReset() {
GradleDslMethodCall resetMethod = new GradleDslMethodCall(myDslElement, RESET, null);
// TODO: reset include
myDslElement.setNewElement(RESET, resetMethod);
return this;
}
Aggregations