Search in sources :

Example 6 with GradleDslExpressionMap

use of com.android.tools.idea.gradle.dsl.parser.elements.GradleDslExpressionMap in project android by JetBrains.

the class ProductFlavorDslElement method addParsedElement.

@Override
public void addParsedElement(@NotNull String property, @NotNull GradleDslElement element) {
    if (property.equals("resConfigs") || property.equals("resConfig")) {
        addToParsedExpressionList("resConfigs", element);
        return;
    }
    if (property.equals("testInstrumentationRunnerArguments")) {
        if (!(element instanceof GradleDslExpressionMap)) {
            return;
        }
        GradleDslExpressionMap testInstrumentationRunnerArgumentsElement = getPropertyElement("testInstrumentationRunnerArguments", GradleDslExpressionMap.class);
        if (testInstrumentationRunnerArgumentsElement == null) {
            setParsedElement("testInstrumentationRunnerArguments", element);
        } else {
            testInstrumentationRunnerArgumentsElement.setPsiElement(element.getPsiElement());
            GradleDslExpressionMap elementsToAdd = (GradleDslExpressionMap) element;
            for (Map.Entry<String, GradleDslElement> entry : elementsToAdd.getPropertyElements().entrySet()) {
                testInstrumentationRunnerArgumentsElement.setParsedElement(entry.getKey(), entry.getValue());
            }
        }
        return;
    }
    if (property.equals("testInstrumentationRunnerArgument")) {
        if (!(element instanceof GradleDslExpressionList)) {
            return;
        }
        GradleDslExpressionList gradleDslExpressionList = (GradleDslExpressionList) element;
        List<GradleDslExpression> elements = gradleDslExpressionList.getExpressions();
        if (elements.size() != 2) {
            return;
        }
        String key = elements.get(0).getValue(String.class);
        if (key == null) {
            return;
        }
        GradleDslExpression value = elements.get(1);
        GradleDslExpressionMap testInstrumentationRunnerArgumentsElement = getPropertyElement("testInstrumentationRunnerArguments", GradleDslExpressionMap.class);
        if (testInstrumentationRunnerArgumentsElement == null) {
            testInstrumentationRunnerArgumentsElement = new GradleDslExpressionMap(this, "testInstrumentationRunnerArguments");
        }
        testInstrumentationRunnerArgumentsElement.setParsedElement(key, value);
        return;
    }
    super.addParsedElement(property, element);
}
Also used : GradleDslExpressionList(com.android.tools.idea.gradle.dsl.parser.elements.GradleDslExpressionList) GradleDslExpressionMap(com.android.tools.idea.gradle.dsl.parser.elements.GradleDslExpressionMap) GradleDslExpression(com.android.tools.idea.gradle.dsl.parser.elements.GradleDslExpression) GradleDslExpressionMap(com.android.tools.idea.gradle.dsl.parser.elements.GradleDslExpressionMap) Map(java.util.Map) GradleDslElement(com.android.tools.idea.gradle.dsl.parser.elements.GradleDslElement)

Aggregations

GradleDslExpressionMap (com.android.tools.idea.gradle.dsl.parser.elements.GradleDslExpressionMap)6 NotNull (org.jetbrains.annotations.NotNull)4 ArrayList (java.util.ArrayList)3 ApplyDslElement (com.android.tools.idea.gradle.dsl.parser.apply.ApplyDslElement)2 GradleNotNullValue (com.android.tools.idea.gradle.dsl.model.values.GradleNotNullValue)1 GradleDslElement (com.android.tools.idea.gradle.dsl.parser.elements.GradleDslElement)1 GradleDslElementList (com.android.tools.idea.gradle.dsl.parser.elements.GradleDslElementList)1 GradleDslExpression (com.android.tools.idea.gradle.dsl.parser.elements.GradleDslExpression)1 GradleDslExpressionList (com.android.tools.idea.gradle.dsl.parser.elements.GradleDslExpressionList)1 HashSet (com.intellij.util.containers.HashSet)1 Map (java.util.Map)1