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

Commit 283e7869 authored by Makoto Onuki's avatar Makoto Onuki Committed by Android (Google) Code Review
Browse files

Merge "HostStubGen: Support "ignore" annotation." into main

parents 2f6138bf b5cb6910
Loading
Loading
Loading
Loading
+34 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2024 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.hosttest.annotation;

import static java.lang.annotation.ElementType.CONSTRUCTOR;
import static java.lang.annotation.ElementType.METHOD;

import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
 * THIS ANNOTATION IS EXPERIMENTAL. REACH OUT TO g/ravenwood BEFORE USING IT, OR YOU HAVE ANY
 * QUESTIONS ABOUT IT.
 *
 * @hide
 */
@Target({METHOD, CONSTRUCTOR})
@Retention(RetentionPolicy.CLASS)
public @interface HostSideTestIgnore {
}
+3 −0
Original line number Diff line number Diff line
@@ -24,6 +24,9 @@
--remove-annotation
    android.hosttest.annotation.HostSideTestRemove

--ignore-annotation
    android.hosttest.annotation.HostSideTestIgnore

--substitute-annotation
    android.hosttest.annotation.HostSideTestSubstitute

+1 −0
Original line number Diff line number Diff line
@@ -166,6 +166,7 @@ class HostStubGen(val options: HostStubGenOptions) {
            options.keepClassAnnotations,
            options.throwAnnotations,
            options.removeAnnotations,
            options.ignoreAnnotations,
            options.substituteAnnotations,
            options.redirectAnnotations,
            options.redirectionClassAnnotations,
+5 −0
Original line number Diff line number Diff line
@@ -84,6 +84,7 @@ class HostStubGenOptions(
        var keepAnnotations: MutableSet<String> = mutableSetOf(),
        var throwAnnotations: MutableSet<String> = mutableSetOf(),
        var removeAnnotations: MutableSet<String> = mutableSetOf(),
        var ignoreAnnotations: MutableSet<String> = mutableSetOf(),
        var keepClassAnnotations: MutableSet<String> = mutableSetOf(),
        var redirectAnnotations: MutableSet<String> = mutableSetOf(),

@@ -184,6 +185,9 @@ class HostStubGenOptions(
                        "--remove-annotation" ->
                            ret.removeAnnotations.addUniqueAnnotationArg()

                        "--ignore-annotation" ->
                            ret.ignoreAnnotations.addUniqueAnnotationArg()

                        "--substitute-annotation" ->
                            ret.substituteAnnotations.addUniqueAnnotationArg()

@@ -277,6 +281,7 @@ class HostStubGenOptions(
              keepAnnotations=$keepAnnotations,
              throwAnnotations=$throwAnnotations,
              removeAnnotations=$removeAnnotations,
              ignoreAnnotations=$ignoreAnnotations,
              keepClassAnnotations=$keepClassAnnotations,
              substituteAnnotations=$substituteAnnotations,
              nativeSubstituteAnnotations=$redirectionClassAnnotations,
+4 −0
Original line number Diff line number Diff line
@@ -48,6 +48,7 @@ class AnnotationBasedFilter(
    keepClassAnnotations_: Set<String>,
    throwAnnotations_: Set<String>,
    removeAnnotations_: Set<String>,
    ignoreAnnotations_: Set<String>,
    substituteAnnotations_: Set<String>,
    redirectAnnotations_: Set<String>,
    redirectionClassAnnotations_: Set<String>,
@@ -60,6 +61,7 @@ class AnnotationBasedFilter(
    private val keepClassAnnotations = convertToInternalNames(keepClassAnnotations_)
    private val throwAnnotations = convertToInternalNames(throwAnnotations_)
    private val removeAnnotations = convertToInternalNames(removeAnnotations_)
    private val ignoreAnnotations = convertToInternalNames(ignoreAnnotations_)
    private val redirectAnnotations = convertToInternalNames(redirectAnnotations_)
    private val substituteAnnotations = convertToInternalNames(substituteAnnotations_)
    private val redirectionClassAnnotations =
@@ -73,6 +75,7 @@ class AnnotationBasedFilter(
            keepClassAnnotations +
            throwAnnotations +
            removeAnnotations +
            ignoreAnnotations +
            redirectAnnotations +
            substituteAnnotations

@@ -107,6 +110,7 @@ class AnnotationBasedFilter(
            in substituteAnnotations -> FilterPolicy.Substitute.withReason(REASON_ANNOTATION)
            in throwAnnotations -> FilterPolicy.Throw.withReason(REASON_ANNOTATION)
            in removeAnnotations -> FilterPolicy.Remove.withReason(REASON_ANNOTATION)
            in ignoreAnnotations -> FilterPolicy.Ignore.withReason(REASON_ANNOTATION)
            in redirectAnnotations -> FilterPolicy.Redirect.withReason(REASON_ANNOTATION)
            else -> null
        }
Loading