use of com.android.tools.idea.gradle.dsl.parser.elements.GradleDslElementList in project android by JetBrains.
the class RepositoriesDslElement method setParsedElement.
@Override
public void setParsedElement(@NotNull String name, @NotNull GradleDslElement repository) {
// Because we need to preserve the the order of the repositories defined, storing all the repository elements in a dummy element list.
// TODO: Consider extending RepositoriesDslElement directly from GradleDslElementList instead of GradlePropertiesDslElement.
GradleDslElementList repositoriesListElement = getOrCreateRepositoriesElement();
repositoriesListElement.addParsedElement(repository);
}
use of com.android.tools.idea.gradle.dsl.parser.elements.GradleDslElementList in project android by JetBrains.
the class BuildTypeDslElement method addParsedElement.
@Override
public void addParsedElement(@NotNull String property, @NotNull GradleDslElement element) {
if (property.equals("buildConfigField")) {
if (!(element instanceof GradleDslExpressionList)) {
return;
}
GradleDslExpressionList listElement = (GradleDslExpressionList) element;
if (listElement.getExpressions().size() != 3 || listElement.getValues(String.class).size() != 3) {
return;
}
GradleDslElementList elementList = getPropertyElement("buildConfigField", GradleDslElementList.class);
if (elementList == null) {
elementList = new GradleDslElementList(this, "buildConfigField");
setParsedElement("buildConfigField", elementList);
}
elementList.addParsedElement(element);
return;
}
super.addParsedElement(property, element);
}
use of com.android.tools.idea.gradle.dsl.parser.elements.GradleDslElementList in project android by JetBrains.
the class DependenciesModel method addArtifact.
@NotNull
public DependenciesModel addArtifact(@NotNull String configurationName, @NotNull ArtifactDependencySpec dependency, @NotNull List<ArtifactDependencySpec> excludes) {
GradleDslElementList list = getOrCreateGradleDslElementList(configurationName);
ArtifactDependencyModel.createAndAddToList(list, configurationName, dependency, excludes);
return this;
}
use of com.android.tools.idea.gradle.dsl.parser.elements.GradleDslElementList 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.GradleDslElementList in project android by JetBrains.
the class DependenciesModel method getOrCreateGradleDslElementList.
@NotNull
private GradleDslElementList getOrCreateGradleDslElementList(@NotNull String configurationName) {
GradleDslElementList list = myDslElement.getPropertyElement(configurationName, GradleDslElementList.class);
if (list == null) {
list = new GradleDslElementList(myDslElement, configurationName);
myDslElement.setNewElement(configurationName, list);
}
return list;
}
Aggregations