Merge changes I1eb2d81e,I3f39e521 into androidx-main

* changes:
  Add @JvmStatic to companion and object class functions.
  Move util functions in XProcessingStep to be extension functions.
diff --git a/room/compiler-processing/src/main/java/androidx/room/compiler/processing/JavaPoetExt.kt b/room/compiler-processing/src/main/java/androidx/room/compiler/processing/JavaPoetExt.kt
index 8824318..b850d16 100644
--- a/room/compiler-processing/src/main/java/androidx/room/compiler/processing/JavaPoetExt.kt
+++ b/room/compiler-processing/src/main/java/androidx/room/compiler/processing/JavaPoetExt.kt
@@ -96,6 +96,7 @@
      * * [Override] annotation is added and other annotations are dropped
      * * thrown types are copied if the backing element is from java
      */
+    @JvmStatic
     fun overridingWithFinalParams(
         elm: XMethodElement,
         owner: XType
diff --git a/room/compiler-processing/src/main/java/androidx/room/compiler/processing/XMessager.kt b/room/compiler-processing/src/main/java/androidx/room/compiler/processing/XMessager.kt
index 29ff818..16f1bba 100644
--- a/room/compiler-processing/src/main/java/androidx/room/compiler/processing/XMessager.kt
+++ b/room/compiler-processing/src/main/java/androidx/room/compiler/processing/XMessager.kt
@@ -30,7 +30,7 @@
      * @param msg The actual message to report to the compiler
      * @param element The element with whom the message should be associated with
      */
-    final fun printMessage(kind: Diagnostic.Kind, msg: String, element: XElement? = null) {
+    fun printMessage(kind: Diagnostic.Kind, msg: String, element: XElement? = null) {
         watchers.forEach {
             it.printMessage(kind, msg, element)
         }
diff --git a/room/compiler-processing/src/main/java/androidx/room/compiler/processing/XProcessingEnv.kt b/room/compiler-processing/src/main/java/androidx/room/compiler/processing/XProcessingEnv.kt
index c7e67cc..da29394 100644
--- a/room/compiler-processing/src/main/java/androidx/room/compiler/processing/XProcessingEnv.kt
+++ b/room/compiler-processing/src/main/java/androidx/room/compiler/processing/XProcessingEnv.kt
@@ -132,11 +132,13 @@
         /**
          * Creates a new [XProcessingEnv] implementation derived from the given Java [env].
          */
+        @JvmStatic
         fun create(env: ProcessingEnvironment): XProcessingEnv = JavacProcessingEnv(env)
 
         /**
          * Creates a new [XProcessingEnv] implementation derived from the given KSP environment.
          */
+        @JvmStatic
         fun create(
             options: Map<String, String>,
             resolver: Resolver,
diff --git a/room/compiler-processing/src/main/java/androidx/room/compiler/processing/XProcessingStep.kt b/room/compiler-processing/src/main/java/androidx/room/compiler/processing/XProcessingStep.kt
index d9c43e0..b3bac7f 100644
--- a/room/compiler-processing/src/main/java/androidx/room/compiler/processing/XProcessingStep.kt
+++ b/room/compiler-processing/src/main/java/androidx/room/compiler/processing/XProcessingStep.kt
@@ -48,27 +48,32 @@
      */
     fun annotations(): Set<String>
 
-    /**
-     * Wraps current [XProcessingStep] into an Auto Common
-     * [BasicAnnotationProcessor.ProcessingStep].
-     */
-    fun asAutoCommonProcessor(
-        env: ProcessingEnvironment
-    ): BasicAnnotationProcessor.Step {
-        return JavacProcessingStepDelegate(
-            env = env,
-            delegate = this
-        )
-    }
+    companion object {
 
-    fun executeInKsp(env: XProcessingEnv): List<KSAnnotated> {
-        check(env is KspProcessingEnv)
-        val round = XRoundEnv.create(env)
-        val args = annotations().associateWith { annotation ->
-            round.getElementsAnnotatedWith(annotation)
+        /**
+         * Wraps current [XProcessingStep] into an Auto Common
+         * [BasicAnnotationProcessor.ProcessingStep].
+         */
+        @JvmStatic
+        fun XProcessingStep.asAutoCommonProcessor(
+            env: ProcessingEnvironment
+        ): BasicAnnotationProcessor.Step {
+            return JavacProcessingStepDelegate(
+                env = env,
+                delegate = this
+            )
         }
-        return process(env, args)
-            .map { (it as KspElement).declaration }
+
+        @JvmStatic
+        fun XProcessingStep.executeInKsp(env: XProcessingEnv): List<KSAnnotated> {
+            check(env is KspProcessingEnv)
+            val round = XRoundEnv.create(env)
+            val args = annotations().associateWith { annotation ->
+                round.getElementsAnnotatedWith(annotation)
+            }
+            return process(env, args)
+                .map { (it as KspElement).declaration }
+        }
     }
 }
 
diff --git a/room/compiler-processing/src/main/java/androidx/room/compiler/processing/XRoundEnv.kt b/room/compiler-processing/src/main/java/androidx/room/compiler/processing/XRoundEnv.kt
index c7c9bb1..a260f5a 100644
--- a/room/compiler-processing/src/main/java/androidx/room/compiler/processing/XRoundEnv.kt
+++ b/room/compiler-processing/src/main/java/androidx/room/compiler/processing/XRoundEnv.kt
@@ -45,6 +45,7 @@
         /**
          * Creates an [XRoundEnv] from the given Java processing parameters.
          */
+        @JvmStatic
         fun create(
             processingEnv: XProcessingEnv,
             roundEnvironment: RoundEnvironment? = null
diff --git a/room/compiler-processing/src/test/java/androidx/room/compiler/processing/XProcessingStepTest.kt b/room/compiler-processing/src/test/java/androidx/room/compiler/processing/XProcessingStepTest.kt
index 7f9c555..dae5e5a 100644
--- a/room/compiler-processing/src/test/java/androidx/room/compiler/processing/XProcessingStepTest.kt
+++ b/room/compiler-processing/src/test/java/androidx/room/compiler/processing/XProcessingStepTest.kt
@@ -16,6 +16,8 @@
 
 package androidx.room.compiler.processing
 
+import androidx.room.compiler.processing.XProcessingStep.Companion.asAutoCommonProcessor
+import androidx.room.compiler.processing.XProcessingStep.Companion.executeInKsp
 import androidx.room.compiler.processing.testcode.MainAnnotation
 import androidx.room.compiler.processing.testcode.OtherAnnotation
 import com.google.auto.common.BasicAnnotationProcessor
diff --git a/room/compiler/src/main/kotlin/androidx/room/RoomKspProcessor.kt b/room/compiler/src/main/kotlin/androidx/room/RoomKspProcessor.kt
index cf32d67..d28541f 100644
--- a/room/compiler/src/main/kotlin/androidx/room/RoomKspProcessor.kt
+++ b/room/compiler/src/main/kotlin/androidx/room/RoomKspProcessor.kt
@@ -17,6 +17,7 @@
 package androidx.room
 
 import androidx.room.compiler.processing.XProcessingEnv
+import androidx.room.compiler.processing.XProcessingStep.Companion.executeInKsp
 import com.google.devtools.ksp.processing.CodeGenerator
 import com.google.devtools.ksp.processing.KSPLogger
 import com.google.devtools.ksp.processing.Resolver
diff --git a/room/compiler/src/main/kotlin/androidx/room/RoomProcessor.kt b/room/compiler/src/main/kotlin/androidx/room/RoomProcessor.kt
index ed1595c..8119102 100644
--- a/room/compiler/src/main/kotlin/androidx/room/RoomProcessor.kt
+++ b/room/compiler/src/main/kotlin/androidx/room/RoomProcessor.kt
@@ -17,6 +17,7 @@
 package androidx.room
 
 import androidx.room.compiler.processing.XProcessingEnv
+import androidx.room.compiler.processing.XProcessingStep.Companion.asAutoCommonProcessor
 import androidx.room.processor.Context
 import androidx.room.processor.ProcessorErrors
 import androidx.room.util.SimpleJavaVersion