Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit fc195a64 authored by George Mount's avatar George Mount
Browse files

Move to package android.databinding.

parent 77ab0a02
Loading
Loading
Loading
Loading
+41 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2015 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package android.databinding.annotationprocessor;

import java.lang.annotation.Annotation;
import java.util.ArrayList;
import java.util.List;

import javax.annotation.processing.RoundEnvironment;
import javax.lang.model.element.Element;

class AnnotationUtil {

    /**
     * Returns only the elements that are annotated with the given class. For some reason
     * RoundEnvironment is returning elements annotated by other annotations.
     */
    static List<Element> getElementsAnnotatedWith(RoundEnvironment roundEnv,
            Class<? extends Annotation> annotationClass) {
        ArrayList<Element> elements = new ArrayList<>();
        for (Element element : roundEnv.getElementsAnnotatedWith(annotationClass)) {
            if (element.getAnnotation(annotationClass) != null) {
                elements.add(element);
            }
        }
        return elements;
    }
}
+2 −5
Original line number Diff line number Diff line
@@ -14,15 +14,13 @@
 * limitations under the License.
 */

package com.android.databinding.annotationprocessor;
package android.databinding.annotationprocessor;

import com.google.common.base.Preconditions;

import android.binding.BindingBuildInfo;
import android.databinding.BindingBuildInfo;

import java.lang.annotation.Annotation;
import java.util.ArrayList;
import java.util.List;

import javax.annotation.processing.RoundEnvironment;
import javax.lang.model.element.Element;
@@ -49,6 +47,5 @@ public class BuildInfoUtil {
            result = info;
        }
        return result;

    }
}
+6 −7
Original line number Diff line number Diff line
@@ -14,15 +14,14 @@
 * limitations under the License.
 */

package com.android.databinding.annotationprocessor;
package android.databinding.annotationprocessor;

import com.google.common.base.Preconditions;

import com.android.databinding.util.GenerationalClassUtil;
import com.android.databinding.util.L;

import android.binding.Bindable;
import android.binding.BindingBuildInfo;
import android.databinding.Bindable;
import android.databinding.BindingBuildInfo;
import android.databinding.tool.util.GenerationalClassUtil;
import android.databinding.tool.util.L;

import java.io.Serializable;
import java.util.ArrayList;
@@ -56,7 +55,7 @@ public class ProcessBindable extends ProcessDataBinding.ProcessingStep {
        if (mProperties == null) {
            mProperties = new IntermediateV1(buildInfo.modulePackage());
        }
        for (Element element : roundEnv.getElementsAnnotatedWith(Bindable.class)) {
        for (Element element : AnnotationUtil.getElementsAnnotatedWith(roundEnv, Bindable.class)) {
            Element enclosingElement = element.getEnclosingElement();
            ElementKind kind = enclosingElement.getKind();
            if (kind != ElementKind.CLASS && kind != ElementKind.INTERFACE) {
+10 −11
Original line number Diff line number Diff line
@@ -14,13 +14,12 @@
 * limitations under the License.
 */

package com.android.databinding.annotationprocessor;
package android.databinding.annotationprocessor;

import com.android.databinding.reflection.ModelAnalyzer;
import com.android.databinding.writer.AnnotationJavaFileWriter;
import com.android.databinding.writer.JavaFileWriter;

import android.binding.BindingBuildInfo;
import android.databinding.BindingBuildInfo;
import android.databinding.tool.reflection.ModelAnalyzer;
import android.databinding.tool.writer.AnnotationJavaFileWriter;
import android.databinding.tool.writer.JavaFileWriter;

import java.util.Arrays;
import java.util.List;
@@ -35,11 +34,11 @@ import javax.lang.model.SourceVersion;
import javax.lang.model.element.TypeElement;

@SupportedAnnotationTypes({
        "android.binding.BindingAdapter",
        "android.binding.Untaggable",
        "android.binding.BindingMethods",
        "android.binding.BindingConversion",
        "android.binding.BindingBuildInfo"}
        "android.databinding.BindingAdapter",
        "android.databinding.Untaggable",
        "android.databinding.BindingMethods",
        "android.databinding.BindingConversion",
        "android.databinding.BindingBuildInfo"}
)
@SupportedSourceVersion(SourceVersion.RELEASE_7)
/**
+7 −8
Original line number Diff line number Diff line
@@ -14,18 +14,17 @@
 * limitations under the License.
 */

package com.android.databinding.annotationprocessor;

import com.android.databinding.CompilerChef;
import com.android.databinding.reflection.SdkUtil;
import com.android.databinding.store.ResourceBundle;
import com.android.databinding.util.GenerationalClassUtil;
import com.android.databinding.util.L;
package android.databinding.annotationprocessor;

import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils;

import android.binding.BindingBuildInfo;
import android.databinding.BindingBuildInfo;
import android.databinding.tool.CompilerChef;
import android.databinding.tool.reflection.SdkUtil;
import android.databinding.tool.store.ResourceBundle;
import android.databinding.tool.util.GenerationalClassUtil;
import android.databinding.tool.util.L;

import java.io.File;
import java.io.FilenameFilter;
Loading