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

Commit 2fb05f5a authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge changes from topic "gradle" into main

* changes:
  [Catalyst] Clean up try-catch for Filer.createSourceFile
  Update supported source version for IndexableProcessor
parents 2632c401 19ed7094
Loading
Loading
Loading
Loading
+1 −9
Original line number Diff line number Diff line
@@ -114,15 +114,7 @@ class PreferenceScreenAnnotationProcessor : AbstractProcessor() {
    private fun generateCode(outputPkg: String, outputClass: String, outputFun: String) {
        // sort by screen keys to make the output deterministic and naturally fit to FixedArrayMap
        screens.sort()
        val javaFileObject =
            try {
                processingEnv.filer.createSourceFile("$outputPkg.$outputClass")
            } catch (e: Exception) {
                // quick fix: gradle runs this processor twice unexpectedly
                warn("cannot createSourceFile: $e")
                return
            }
        javaFileObject.openWriter().use {
        processingEnv.filer.createSourceFile("$outputPkg.$outputClass").openWriter().use {
            it.write("package $outputPkg;\n\n")
            it.write("import $PACKAGE.FixedArrayMap;\n")
            it.write("import $PACKAGE.FixedArrayMap.OrderedInitializer;\n")
+5 −2
Original line number Diff line number Diff line
@@ -35,7 +35,6 @@ import javax.annotation.processing.ProcessingEnvironment;
import javax.annotation.processing.RoundEnvironment;
import javax.annotation.processing.SupportedAnnotationTypes;
import javax.annotation.processing.SupportedOptions;
import javax.annotation.processing.SupportedSourceVersion;
import javax.lang.model.SourceVersion;
import javax.lang.model.element.Element;
import javax.lang.model.element.Modifier;
@@ -48,7 +47,6 @@ import javax.tools.Diagnostic.Kind;
 * Annotation processor for {@link SearchIndexable} that generates {@link SearchIndexableResources}
 * subclasses.
 */
@SupportedSourceVersion(SourceVersion.RELEASE_17)
@SupportedOptions(IndexableProcessor.PACKAGE_KEY)
@SupportedAnnotationTypes({"com.android.settingslib.search.SearchIndexable"})
public class IndexableProcessor extends AbstractProcessor {
@@ -68,6 +66,11 @@ public class IndexableProcessor extends AbstractProcessor {
    private Messager mMessager;
    private boolean mRanOnce;

    @Override
    public SourceVersion getSupportedSourceVersion() {
        return SourceVersion.latestSupported();
    }

    @Override
    public boolean process(Set<? extends TypeElement> annotations,
            RoundEnvironment roundEnvironment) {