Clean up usages of "method" in KDocs & generated code.
This CL refactors all references "method"s to "function"s since we should be using KSP-compatible terminology in the KSP version of Room.
Bug: 364902863
Test: Existing tests.
Change-Id: Iba8b25da3e80ee69359b602ba654fccc47dd59a4
diff --git a/room/integration-tests/kotlintestapp/src/androidTest/java/androidx/room/integration/kotlintestapp/test/SuspendingQueryTest.kt b/room/integration-tests/kotlintestapp/src/androidTest/java/androidx/room/integration/kotlintestapp/test/SuspendingQueryTest.kt
index 05d1a91..3d67b8b 100644
--- a/room/integration-tests/kotlintestapp/src/androidTest/java/androidx/room/integration/kotlintestapp/test/SuspendingQueryTest.kt
+++ b/room/integration-tests/kotlintestapp/src/androidTest/java/androidx/room/integration/kotlintestapp/test/SuspendingQueryTest.kt
@@ -223,7 +223,7 @@
@Test
@Suppress("DEPRECATION")
- fun suspendingBlock_beginEndTransaction_blockingDaoMethods() {
+ fun suspendingBlock_beginEndTransaction_blockingDaoFunctions() {
runBlocking {
try {
database.beginTransaction()
@@ -266,7 +266,7 @@
}
@Test
- fun suspendingBlock_blockingDaoMethods() {
+ fun suspendingBlock_blockingDaoFunctions() {
runBlocking {
booksDao.insertPublisherSuspend(TestUtil.PUBLISHER.publisherId, TestUtil.PUBLISHER.name)
@@ -624,7 +624,7 @@
}
@Test
- fun withTransaction_blockingDaoMethods() {
+ fun withTransaction_blockingDaoFunctions() {
runBlocking {
database.withTransaction {
booksDao.insertPublisherSuspend(
@@ -641,7 +641,7 @@
}
@Test
- fun withTransaction_blockingDaoMethods_contextSwitch() {
+ fun withTransaction_blockingDaoFunctions_contextSwitch() {
runBlocking {
database.withTransaction {
// normal query
@@ -907,7 +907,7 @@
.addCallback(
object : RoomDatabase.Callback() {
override fun onOpen(db: SupportSQLiteDatabase) {
- // this causes all transaction methods to throw, this can happen IRL
+ // this causes all transaction functions to throw, this can happen IRL
throw RuntimeException("Error opening Database.")
}
}
diff --git a/room/room-compiler/src/main/kotlin/androidx/room/DatabaseProcessingStep.kt b/room/room-compiler/src/main/kotlin/androidx/room/DatabaseProcessingStep.kt
index 0f00fc6..82f9c6d 100644
--- a/room/room-compiler/src/main/kotlin/androidx/room/DatabaseProcessingStep.kt
+++ b/room/room-compiler/src/main/kotlin/androidx/room/DatabaseProcessingStep.kt
@@ -27,7 +27,7 @@
import androidx.room.processor.Context.BooleanProcessorOptions.GENERATE_KOTLIN
import androidx.room.processor.DatabaseProcessor
import androidx.room.processor.ProcessorErrors
-import androidx.room.vo.DaoMethod
+import androidx.room.vo.DaoFunction
import androidx.room.vo.Warning
import androidx.room.writer.AutoMigrationWriter
import androidx.room.writer.DaoWriter
@@ -91,12 +91,12 @@
}
}
- val daoMethodsMap = databases?.flatMap { db -> db.daoMethods.map { it to db } }?.toMap()
- daoMethodsMap?.let {
+ val daoFunctionsMap = databases?.flatMap { db -> db.daoFunctions.map { it to db } }?.toMap()
+ daoFunctionsMap?.let {
prepareDaosForWriting(databases, it.keys.toList())
- it.forEach { (daoMethod, db) ->
+ it.forEach { (daoFunction, db) ->
DaoWriter(
- dao = daoMethod.dao,
+ dao = daoFunction.dao,
dbElement = db.element,
writerContext = TypeWriter.WriterContext.fromProcessingContext(context)
)
@@ -166,31 +166,33 @@
}
}
- /** Traverses all dao methods and assigns them suffix if they are used in multiple databases. */
+ /**
+ * Traverses all dao functions and assigns them suffix if they are used in multiple databases.
+ */
private fun prepareDaosForWriting(
databases: List<androidx.room.vo.Database>,
- daoMethods: List<DaoMethod>
+ daoFunctions: List<DaoFunction>
) {
- daoMethods
+ daoFunctions
.groupBy { it.dao.typeName }
// if used only in 1 database, nothing to do.
.filter { entry -> entry.value.size > 1 }
.forEach { entry ->
entry.value
- .groupBy { daoMethod ->
+ .groupBy { daoFunction ->
// first suffix guess: Database's simple name
- val db = databases.first { db -> db.daoMethods.contains(daoMethod) }
+ val db = databases.first { db -> db.daoFunctions.contains(daoFunction) }
db.typeName.simpleNames.last()
}
- .forEach { (dbName, methods) ->
- if (methods.size == 1) {
+ .forEach { (dbName, functions) ->
+ if (functions.size == 1) {
// good, db names do not clash, use db name as suffix
- methods.first().dao.setSuffix(dbName)
+ functions.first().dao.setSuffix(dbName)
} else {
// ok looks like a dao is used in 2 different databases both of
// which have the same name. enumerate.
- methods.forEachIndexed { index, method ->
- method.dao.setSuffix("${dbName}_$index")
+ functions.forEachIndexed { index, function ->
+ function.dao.setSuffix("${dbName}_$index")
}
}
}
diff --git a/room/room-compiler/src/main/kotlin/androidx/room/processor/DaoProcessor.kt b/room/room-compiler/src/main/kotlin/androidx/room/processor/DaoProcessor.kt
index a52c017..ce81e10 100644
--- a/room/room-compiler/src/main/kotlin/androidx/room/processor/DaoProcessor.kt
+++ b/room/room-compiler/src/main/kotlin/androidx/room/processor/DaoProcessor.kt
@@ -30,8 +30,8 @@
import androidx.room.compiler.processing.XTypeElement
import androidx.room.verifier.DatabaseVerifier
import androidx.room.vo.Dao
-import androidx.room.vo.KotlinBoxedPrimitiveMethodDelegate
-import androidx.room.vo.KotlinDefaultMethodDelegate
+import androidx.room.vo.KotlinBoxedPrimitiveFunctionDelegate
+import androidx.room.vo.KotlinDefaultFunctionDelegate
import androidx.room.vo.Warning
class DaoProcessor(
@@ -60,15 +60,15 @@
return Dao(
element = element,
type = element.type,
- queryMethods = emptyList(),
- rawQueryMethods = emptyList(),
- insertMethods = emptyList(),
- upsertMethods = emptyList(),
- deleteMethods = emptyList(),
- updateMethods = emptyList(),
- transactionMethods = emptyList(),
- kotlinBoxedPrimitiveMethodDelegates = emptyList(),
- kotlinDefaultMethodDelegates = emptyList(),
+ queryFunctions = emptyList(),
+ rawQueryFunctions = emptyList(),
+ insertFunctions = emptyList(),
+ upsertFunctions = emptyList(),
+ deleteFunctions = emptyList(),
+ updateFunctions = emptyList(),
+ transactionFunctions = emptyList(),
+ kotlinBoxedPrimitiveFunctionDelegates = emptyList(),
+ kotlinDefaultFunctionDelegates = emptyList(),
constructorParamType = null
)
}
@@ -84,43 +84,43 @@
)
val declaredType = element.type
- val allMethods = element.getAllMethods()
- val methods =
- allMethods
+ val allFunctions = element.getAllMethods()
+ val functions =
+ allFunctions
.filter { it.isAbstract() && !it.hasKotlinDefaultImpl() }
- .groupBy { method ->
- if (method.isKotlinPropertyMethod()) {
+ .groupBy { function ->
+ if (function.isKotlinPropertyMethod()) {
context.checker.check(
- predicate = method.hasAnnotation(Query::class),
- element = method,
+ predicate = function.hasAnnotation(Query::class),
+ element = function,
errorMsg = ProcessorErrors.INVALID_ANNOTATION_IN_DAO_PROPERTY
)
} else {
context.checker.check(
predicate =
- PROCESSED_ANNOTATIONS.count { method.hasAnnotation(it) } <= 1,
- element = method,
- errorMsg = ProcessorErrors.INVALID_ANNOTATION_COUNT_IN_DAO_METHOD
+ PROCESSED_ANNOTATIONS.count { function.hasAnnotation(it) } <= 1,
+ element = function,
+ errorMsg = ProcessorErrors.INVALID_ANNOTATION_COUNT_IN_DAO_FUNCTION
)
}
- if (method.hasAnnotation(JvmName::class)) {
+ if (function.hasAnnotation(JvmName::class)) {
context.logger.w(
- Warning.JVM_NAME_ON_OVERRIDDEN_METHOD,
- method,
- ProcessorErrors.JVM_NAME_ON_OVERRIDDEN_METHOD
+ Warning.JVM_NAME_ON_OVERRIDDEN_FUNCTION,
+ function,
+ ProcessorErrors.JVM_NAME_ON_OVERRIDDEN_FUNCTION
)
}
- if (method.hasAnnotation(Query::class)) {
+ if (function.hasAnnotation(Query::class)) {
Query::class
- } else if (method.hasAnnotation(Insert::class)) {
+ } else if (function.hasAnnotation(Insert::class)) {
Insert::class
- } else if (method.hasAnnotation(Delete::class)) {
+ } else if (function.hasAnnotation(Delete::class)) {
Delete::class
- } else if (method.hasAnnotation(Update::class)) {
+ } else if (function.hasAnnotation(Update::class)) {
Update::class
- } else if (method.hasAnnotation(RawQuery::class)) {
+ } else if (function.hasAnnotation(RawQuery::class)) {
RawQuery::class
- } else if (method.hasAnnotation(Upsert::class)) {
+ } else if (function.hasAnnotation(Upsert::class)) {
Upsert::class
} else {
Any::class
@@ -137,9 +137,9 @@
dbVerifier
}
- val queryMethods =
- methods[Query::class]?.map {
- QueryMethodProcessor(
+ val queryFunctions =
+ functions[Query::class]?.map {
+ QueryFunctionProcessor(
baseContext = context,
containing = declaredType,
executableElement = it,
@@ -148,9 +148,9 @@
.process()
} ?: emptyList()
- val rawQueryMethods =
- methods[RawQuery::class]?.map {
- RawQueryMethodProcessor(
+ val rawQueryFunctions =
+ functions[RawQuery::class]?.map {
+ RawQueryFunctionProcessor(
baseContext = context,
containing = declaredType,
executableElement = it
@@ -158,9 +158,9 @@
.process()
} ?: emptyList()
- val insertMethods =
- methods[Insert::class]?.map {
- InsertMethodProcessor(
+ val insertFunctions =
+ functions[Insert::class]?.map {
+ InsertFunctionProcessor(
baseContext = context,
containing = declaredType,
executableElement = it
@@ -168,9 +168,9 @@
.process()
} ?: emptyList()
- val deleteMethods =
- methods[Delete::class]?.map {
- DeleteMethodProcessor(
+ val deleteFunctions =
+ functions[Delete::class]?.map {
+ DeleteFunctionProcessor(
baseContext = context,
containing = declaredType,
executableElement = it
@@ -178,9 +178,9 @@
.process()
} ?: emptyList()
- val updateMethods =
- methods[Update::class]?.map {
- UpdateMethodProcessor(
+ val updateFunctions =
+ functions[Update::class]?.map {
+ UpdateFunctionProcessor(
baseContext = context,
containing = declaredType,
executableElement = it
@@ -188,9 +188,9 @@
.process()
} ?: emptyList()
- val upsertMethods =
- methods[Upsert::class]?.map {
- UpsertMethodProcessor(
+ val upsertFunctions =
+ functions[Upsert::class]?.map {
+ UpsertFunctionProcessor(
baseContext = context,
containing = declaredType,
executableElement = it
@@ -198,14 +198,14 @@
.process()
} ?: emptyList()
- val transactionMethods =
- allMethods
+ val transactionFunctions =
+ allFunctions
.filter { member ->
member.hasAnnotation(Transaction::class) &&
PROCESSED_ANNOTATIONS.none { member.hasAnnotation(it) }
}
.map {
- TransactionMethodProcessor(
+ TransactionFunctionProcessor(
baseContext = context,
containingElement = element,
containingType = declaredType,
@@ -214,29 +214,29 @@
.process()
}
- // Only try to find Kotlin boxed bridge methods when the dao extends a class or
- // implements an interface since otherwise there are no bridge method generated by
+ // Only try to find Kotlin boxed bridge functions when the dao extends a class or
+ // implements an interface since otherwise there are no bridge function generated by
// Kotlin.
- val unannotatedMethods = methods[Any::class] ?: emptyList()
- val kotlinBoxedPrimitiveBridgeMethods =
+ val unannotatedFunctions = functions[Any::class] ?: emptyList()
+ val kotlinBoxedPrimitiveBridgeFunctions =
if (element.superClass != null || element.getSuperInterfaceElements().isNotEmpty()) {
- matchKotlinBoxedPrimitiveMethods(
- unannotatedMethods,
- methods.values.flatten() - unannotatedMethods
+ matchKotlinBoxedPrimitiveFunctions(
+ unannotatedFunctions,
+ functions.values.flatten() - unannotatedFunctions
)
} else {
emptyList()
}
- val kotlinDefaultMethodDelegates =
+ val kotlinDefaultFunctionDelegates =
if (element.isInterface()) {
- val allProcessedMethods =
- methods.values.flatten() + transactionMethods.map { it.element }
- allMethods
- .filterNot { allProcessedMethods.contains(it) }
- .mapNotNull { method ->
- if (method.hasKotlinDefaultImpl()) {
- KotlinDefaultMethodDelegate(element = method)
+ val allProcessedFunctions =
+ functions.values.flatten() + transactionFunctions.map { it.element }
+ allFunctions
+ .filterNot { allProcessedFunctions.contains(it) }
+ .mapNotNull { function ->
+ if (function.hasKotlinDefaultImpl()) {
+ KotlinDefaultFunctionDelegate(element = function)
} else {
null
}
@@ -264,24 +264,24 @@
ProcessorErrors.CANNOT_USE_UNBOUND_GENERICS_IN_DAO_CLASSES
)
- val invalidAnnotatedMethods =
- unannotatedMethods - kotlinBoxedPrimitiveBridgeMethods.map { it.element }
- invalidAnnotatedMethods.forEach {
- context.logger.e(it, ProcessorErrors.INVALID_ANNOTATION_COUNT_IN_DAO_METHOD)
+ val invalidAnnotatedFunctions =
+ unannotatedFunctions - kotlinBoxedPrimitiveBridgeFunctions.map { it.element }
+ invalidAnnotatedFunctions.forEach {
+ context.logger.e(it, ProcessorErrors.INVALID_ANNOTATION_COUNT_IN_DAO_FUNCTION)
}
return Dao(
element = element,
type = declaredType,
- queryMethods = queryMethods,
- rawQueryMethods = rawQueryMethods,
- insertMethods = insertMethods,
- deleteMethods = deleteMethods,
- updateMethods = updateMethods,
- upsertMethods = upsertMethods,
- transactionMethods = transactionMethods.toList(),
- kotlinBoxedPrimitiveMethodDelegates = kotlinBoxedPrimitiveBridgeMethods,
- kotlinDefaultMethodDelegates = kotlinDefaultMethodDelegates.toList(),
+ queryFunctions = queryFunctions,
+ rawQueryFunctions = rawQueryFunctions,
+ insertFunctions = insertFunctions,
+ deleteFunctions = deleteFunctions,
+ updateFunctions = updateFunctions,
+ upsertFunctions = upsertFunctions,
+ transactionFunctions = transactionFunctions.toList(),
+ kotlinBoxedPrimitiveFunctionDelegates = kotlinBoxedPrimitiveBridgeFunctions,
+ kotlinDefaultFunctionDelegates = kotlinDefaultFunctionDelegates.toList(),
constructorParamType = constructorParamType
)
}
@@ -299,17 +299,17 @@
}
/**
- * Find Kotlin bridge methods generated for overrides of primitives, see KT-46650. When
- * generating the Java implementation of the DAO, Room needs to also override the bridge method
- * generated by Kotlin for the boxed version, it will contain the same name, return type and
- * parameter, but the generic primitive params will be boxed.
+ * Find Kotlin bridge functions generated for overrides of primitives, see KT-46650. When
+ * generating the Java implementation of the DAO, Room needs to also override the bridge
+ * function generated by Kotlin for the boxed version, it will contain the same name, return
+ * type and parameter, but the generic primitive params will be boxed.
*/
- private fun matchKotlinBoxedPrimitiveMethods(
- unannotatedMethods: List<XMethodElement>,
- annotatedMethods: List<XMethodElement>
+ private fun matchKotlinBoxedPrimitiveFunctions(
+ unannotatedFunctions: List<XMethodElement>,
+ annotatedFunctions: List<XMethodElement>
) =
- unannotatedMethods.mapNotNull { unannotated ->
- annotatedMethods
+ unannotatedFunctions.mapNotNull { unannotated ->
+ annotatedFunctions
.firstOrNull {
if (it.jvmName != unannotated.jvmName) {
return@firstOrNull false
@@ -341,8 +341,8 @@
}
return@firstOrNull true
}
- ?.let { matchingMethod ->
- KotlinBoxedPrimitiveMethodDelegate(unannotated, matchingMethod)
+ ?.let { matchingFunction ->
+ KotlinBoxedPrimitiveFunctionDelegate(unannotated, matchingFunction)
}
}
}
diff --git a/room/room-compiler/src/main/kotlin/androidx/room/processor/DataClassMethodProcessor.kt b/room/room-compiler/src/main/kotlin/androidx/room/processor/DataClassFunctionProcessor.kt
similarity index 83%
rename from room/room-compiler/src/main/kotlin/androidx/room/processor/DataClassMethodProcessor.kt
rename to room/room-compiler/src/main/kotlin/androidx/room/processor/DataClassFunctionProcessor.kt
index 6f295d1e..aa6252b 100644
--- a/room/room-compiler/src/main/kotlin/androidx/room/processor/DataClassMethodProcessor.kt
+++ b/room/room-compiler/src/main/kotlin/androidx/room/processor/DataClassFunctionProcessor.kt
@@ -18,16 +18,16 @@
import androidx.room.compiler.processing.XMethodElement
import androidx.room.compiler.processing.XType
-import androidx.room.vo.DataClassMethod
+import androidx.room.vo.DataClassFunction
/** processes an executable element as member of the owning class */
-class DataClassMethodProcessor(
+class DataClassFunctionProcessor(
private val context: Context,
private val element: XMethodElement,
private val owner: XType
) {
- fun process(): DataClassMethod {
+ fun process(): DataClassFunction {
val asMember = element.asMemberOf(owner)
- return DataClassMethod(element = element, resolvedType = asMember)
+ return DataClassFunction(element = element, resolvedType = asMember)
}
}
diff --git a/room/room-compiler/src/main/kotlin/androidx/room/processor/DataClassProcessor.kt b/room/room-compiler/src/main/kotlin/androidx/room/processor/DataClassProcessor.kt
index efed0d7..a80892c 100644
--- a/room/room-compiler/src/main/kotlin/androidx/room/processor/DataClassProcessor.kt
+++ b/room/room-compiler/src/main/kotlin/androidx/room/processor/DataClassProcessor.kt
@@ -38,7 +38,7 @@
import androidx.room.vo.CallType
import androidx.room.vo.Constructor
import androidx.room.vo.DataClass
-import androidx.room.vo.DataClassMethod
+import androidx.room.vo.DataClassFunction
import androidx.room.vo.EmbeddedField
import androidx.room.vo.Entity
import androidx.room.vo.EntityOrView
@@ -230,7 +230,11 @@
.asSequence()
.filter { !it.isAbstract() && !it.hasAnnotation(Ignore::class) }
.map {
- DataClassMethodProcessor(context = context, element = it, owner = declaredType)
+ DataClassFunctionProcessor(
+ context = context,
+ element = it,
+ owner = declaredType
+ )
.process()
}
.toList()
@@ -748,11 +752,11 @@
return referenceRecursionList.joinToString(" -> ")
}
- private fun assignGetters(fields: List<Field>, getterCandidates: List<DataClassMethod>) {
+ private fun assignGetters(fields: List<Field>, getterCandidates: List<DataClassFunction>) {
fields.forEach { field -> assignGetter(field, getterCandidates) }
}
- private fun assignGetter(field: Field, getterCandidates: List<DataClassMethod>) {
+ private fun assignGetter(field: Field, getterCandidates: List<DataClassFunction>) {
val success =
chooseAssignment(
field = field,
@@ -818,7 +822,7 @@
private fun assignSetters(
fields: List<Field>,
- setterCandidates: List<DataClassMethod>,
+ setterCandidates: List<DataClassFunction>,
constructor: Constructor?
) {
fields.forEach { field -> assignSetter(field, setterCandidates, constructor) }
@@ -826,7 +830,7 @@
private fun assignSetter(
field: Field,
- setterCandidates: List<DataClassMethod>,
+ setterCandidates: List<DataClassFunction>,
constructor: Constructor?
) {
if (constructor != null && constructor.hasField(field)) {
@@ -910,11 +914,11 @@
*/
private fun chooseAssignment(
field: Field,
- candidates: List<DataClassMethod>,
+ candidates: List<DataClassFunction>,
nameVariations: List<String>,
- getType: (DataClassMethod) -> XType,
+ getType: (DataClassFunction) -> XType,
assignFromField: () -> Unit,
- assignFromMethod: (DataClassMethod) -> Unit,
+ assignFromMethod: (DataClassFunction) -> Unit,
reportAmbiguity: (List<String>) -> Unit
): Boolean {
if (field.element.isPublic()) {
@@ -955,9 +959,9 @@
}
private fun verifyAndChooseOneFrom(
- candidates: List<DataClassMethod>?,
+ candidates: List<DataClassFunction>?,
reportAmbiguity: (List<String>) -> Unit
- ): DataClassMethod? {
+ ): DataClassFunction? {
if (candidates == null) {
return null
}
diff --git a/room/room-compiler/src/main/kotlin/androidx/room/processor/DatabaseProcessor.kt b/room/room-compiler/src/main/kotlin/androidx/room/processor/DatabaseProcessor.kt
index 6cf7930..5892c05 100644
--- a/room/room-compiler/src/main/kotlin/androidx/room/processor/DatabaseProcessor.kt
+++ b/room/room-compiler/src/main/kotlin/androidx/room/processor/DatabaseProcessor.kt
@@ -32,7 +32,7 @@
import androidx.room.verifier.DatabaseVerificationErrors
import androidx.room.verifier.DatabaseVerifier
import androidx.room.vo.Dao
-import androidx.room.vo.DaoMethod
+import androidx.room.vo.DaoFunction
import androidx.room.vo.Database
import androidx.room.vo.DatabaseConstructor
import androidx.room.vo.DatabaseView
@@ -87,7 +87,7 @@
validateUniqueTableAndViewNames(element, entities, views)
val declaredType = element.type
- val daoMethods =
+ val daoFunctions =
element
.getAllMethods()
.filter { it.isAbstract() }
@@ -104,25 +104,25 @@
if (daoElement == null) {
context.logger.e(
executable,
- ProcessorErrors.DATABASE_INVALID_DAO_METHOD_RETURN_TYPE
+ ProcessorErrors.DATABASE_INVALID_DAO_FUNCTION_RETURN_TYPE
)
null
} else {
if (executable.hasAnnotation(JvmName::class)) {
context.logger.w(
- Warning.JVM_NAME_ON_OVERRIDDEN_METHOD,
+ Warning.JVM_NAME_ON_OVERRIDDEN_FUNCTION,
executable,
- ProcessorErrors.JVM_NAME_ON_OVERRIDDEN_METHOD
+ ProcessorErrors.JVM_NAME_ON_OVERRIDDEN_FUNCTION
)
}
val dao =
DaoProcessor(context, daoElement, declaredType, dbVerifier).process()
- DaoMethod(executable, dao)
+ DaoFunction(executable, dao)
}
}
.toList()
- validateUniqueDaoClasses(element, daoMethods, entities)
+ validateUniqueDaoClasses(element, daoFunctions, entities)
validateUniqueIndices(element, entities)
val hasForeignKeys = entities.any { it.foreignKeys.isNotEmpty() }
@@ -145,7 +145,7 @@
type = element.type,
entities = entities,
views = views,
- daoMethods = daoMethods,
+ daoFunctions = daoFunctions,
exportSchema = dbAnnotation.value.exportSchema,
enableForeignKeys = hasForeignKeys,
overrideClearAllTables = hasClearAllTables,
@@ -315,23 +315,23 @@
private fun validateUniqueDaoClasses(
dbElement: XTypeElement,
- daoMethods: List<DaoMethod>,
+ daoFunctions: List<DaoFunction>,
entities: List<Entity>
) {
val entityTypeNames = entities.map { it.typeName }.toSet()
- daoMethods
+ daoFunctions
.groupBy { it.dao.typeName }
.forEach {
if (it.value.size > 1) {
val error =
ProcessorErrors.duplicateDao(
dao = it.key.toString(context.codeLanguage),
- methodNames = it.value.map { it.element.name }
+ functionNames = it.value.map { it.element.name }
)
- it.value.forEach { daoMethod ->
+ it.value.forEach { daoFunction ->
context.logger.e(
- daoMethod.element,
- ProcessorErrors.DAO_METHOD_CONFLICTS_WITH_OTHERS
+ daoFunction.element,
+ ProcessorErrors.DAO_FUNCTION_CONFLICTS_WITH_OTHERS
)
}
// also report the full error for the database
@@ -353,15 +353,15 @@
}
}
}
- daoMethods.forEach { daoMethod ->
- daoMethod.dao.deleteOrUpdateShortcutMethods.forEach { method ->
+ daoFunctions.forEach { daoFunction ->
+ daoFunction.dao.mDeleteOrUpdateShortcutFunctions.forEach { method ->
method.entities.forEach {
- check(method.element, daoMethod.dao, it.value.entityTypeName)
+ check(method.element, daoFunction.dao, it.value.entityTypeName)
}
}
- daoMethod.dao.insertOrUpsertShortcutMethods.forEach { method ->
+ daoFunction.dao.mInsertOrUpsertShortcutFunctions.forEach { method ->
method.entities.forEach {
- check(method.element, daoMethod.dao, it.value.entityTypeName)
+ check(method.element, daoFunction.dao, it.value.entityTypeName)
}
}
}
diff --git a/room/room-compiler/src/main/kotlin/androidx/room/processor/DeleteMethodProcessor.kt b/room/room-compiler/src/main/kotlin/androidx/room/processor/DeleteFunctionProcessor.kt
similarity index 80%
rename from room/room-compiler/src/main/kotlin/androidx/room/processor/DeleteMethodProcessor.kt
rename to room/room-compiler/src/main/kotlin/androidx/room/processor/DeleteFunctionProcessor.kt
index 6967b93..0cf83d2 100644
--- a/room/room-compiler/src/main/kotlin/androidx/room/processor/DeleteMethodProcessor.kt
+++ b/room/room-compiler/src/main/kotlin/androidx/room/processor/DeleteFunctionProcessor.kt
@@ -18,26 +18,26 @@
import androidx.room.Delete
import androidx.room.compiler.processing.XMethodElement
import androidx.room.compiler.processing.XType
-import androidx.room.vo.DeleteMethod
+import androidx.room.vo.DeleteFunction
-class DeleteMethodProcessor(
+class DeleteFunctionProcessor(
baseContext: Context,
val containing: XType,
val executableElement: XMethodElement
) {
val context = baseContext.fork(executableElement)
- fun process(): DeleteMethod {
- val delegate = ShortcutMethodProcessor(context, containing, executableElement)
+ fun process(): DeleteFunction {
+ val delegate = ShortcutFunctionProcessor(context, containing, executableElement)
val annotation =
delegate.extractAnnotation(Delete::class, ProcessorErrors.MISSING_DELETE_ANNOTATION)
val returnType = delegate.extractReturnType()
- val methodBinder = delegate.findDeleteOrUpdateMethodBinder(returnType)
+ val functionBinder = delegate.findDeleteOrUpdateFunctionBinder(returnType)
context.checker.check(
- methodBinder.adapter != null,
+ functionBinder.adapter != null,
executableElement,
ProcessorErrors.CANNOT_FIND_DELETE_RESULT_ADAPTER
)
@@ -49,11 +49,11 @@
onValidatePartialEntity = { _, _ -> }
)
- return DeleteMethod(
+ return DeleteFunction(
element = delegate.executableElement,
entities = entities,
parameters = params,
- methodBinder = methodBinder
+ functionBinder = functionBinder
)
}
}
diff --git a/room/room-compiler/src/main/kotlin/androidx/room/processor/MethodProcessorDelegate.kt b/room/room-compiler/src/main/kotlin/androidx/room/processor/FunctionProcessorDelegate.kt
similarity index 72%
rename from room/room-compiler/src/main/kotlin/androidx/room/processor/MethodProcessorDelegate.kt
rename to room/room-compiler/src/main/kotlin/androidx/room/processor/FunctionProcessorDelegate.kt
index da5e301..d7b77ec 100644
--- a/room/room-compiler/src/main/kotlin/androidx/room/processor/MethodProcessorDelegate.kt
+++ b/room/room-compiler/src/main/kotlin/androidx/room/processor/FunctionProcessorDelegate.kt
@@ -36,20 +36,20 @@
import androidx.room.solver.prepared.binder.PreparedQueryResultBinder
import androidx.room.solver.query.result.CoroutineResultBinder
import androidx.room.solver.query.result.QueryResultBinder
-import androidx.room.solver.shortcut.binder.CoroutineDeleteOrUpdateMethodBinder
-import androidx.room.solver.shortcut.binder.CoroutineInsertOrUpsertMethodBinder
-import androidx.room.solver.shortcut.binder.DeleteOrUpdateMethodBinder
-import androidx.room.solver.shortcut.binder.InsertOrUpsertMethodBinder
-import androidx.room.solver.transaction.binder.CoroutineTransactionMethodBinder
-import androidx.room.solver.transaction.binder.InstantTransactionMethodBinder
-import androidx.room.solver.transaction.binder.TransactionMethodBinder
-import androidx.room.solver.transaction.result.TransactionMethodAdapter
+import androidx.room.solver.shortcut.binder.CoroutineDeleteOrUpdateFunctionBinder
+import androidx.room.solver.shortcut.binder.CoroutineInsertOrUpsertFunctionBinder
+import androidx.room.solver.shortcut.binder.DeleteOrUpdateFunctionBinder
+import androidx.room.solver.shortcut.binder.InsertOrUpsertFunctionBinder
+import androidx.room.solver.transaction.binder.CoroutineTransactionFunctionBinder
+import androidx.room.solver.transaction.binder.InstantTransactionFunctionBinder
+import androidx.room.solver.transaction.binder.TransactionFunctionBinder
+import androidx.room.solver.transaction.result.TransactionFunctionAdapter
import androidx.room.vo.QueryParameter
import androidx.room.vo.ShortcutQueryParameter
-import androidx.room.vo.TransactionMethod
+import androidx.room.vo.TransactionFunction
-/** Delegate class with common functionality for DAO method processors. */
-abstract class MethodProcessorDelegate(
+/** Delegate class with common functionality for DAO function processors. */
+abstract class FunctionProcessorDelegate(
val context: Context,
val containing: XType,
val executableElement: XMethodElement
@@ -84,39 +84,39 @@
query: ParsedQuery
): PreparedQueryResultBinder
- abstract fun findInsertMethodBinder(
+ abstract fun findInsertFunctionBinder(
returnType: XType,
params: List<ShortcutQueryParameter>
- ): InsertOrUpsertMethodBinder
+ ): InsertOrUpsertFunctionBinder
- abstract fun findDeleteOrUpdateMethodBinder(returnType: XType): DeleteOrUpdateMethodBinder
+ abstract fun findDeleteOrUpdateFunctionBinder(returnType: XType): DeleteOrUpdateFunctionBinder
- abstract fun findUpsertMethodBinder(
+ abstract fun findUpsertFunctionBinder(
returnType: XType,
params: List<ShortcutQueryParameter>
- ): InsertOrUpsertMethodBinder
+ ): InsertOrUpsertFunctionBinder
- abstract fun findTransactionMethodBinder(
- callType: TransactionMethod.CallType
- ): TransactionMethodBinder
+ abstract fun findTransactionFunctionBinder(
+ callType: TransactionFunction.CallType
+ ): TransactionFunctionBinder
companion object {
fun createFor(
context: Context,
containing: XType,
executableElement: XMethodElement
- ): MethodProcessorDelegate {
+ ): FunctionProcessorDelegate {
val asMember = executableElement.asMemberOf(containing)
return if (asMember.isSuspendFunction()) {
- SuspendMethodProcessorDelegate(context, containing, executableElement, asMember)
+ SuspendFunctionProcessorDelegate(context, containing, executableElement, asMember)
} else {
- DefaultMethodProcessorDelegate(context, containing, executableElement, asMember)
+ DefaultFunctionProcessorDelegate(context, containing, executableElement, asMember)
}
}
}
}
-fun MethodProcessorDelegate.returnsDeferredType(): Boolean {
+fun FunctionProcessorDelegate.returnsDeferredType(): Boolean {
val deferredTypes =
DEFERRED_TYPES.mapNotNull { context.processingEnv.findType(it.canonicalName) }
val returnType = extractReturnType()
@@ -125,13 +125,13 @@
}
}
-/** Default delegate for DAO methods. */
-class DefaultMethodProcessorDelegate(
+/** Default delegate for DAO functions. */
+class DefaultFunctionProcessorDelegate(
context: Context,
containing: XType,
executableElement: XMethodElement,
val executableType: XMethodType
-) : MethodProcessorDelegate(context, containing, executableElement) {
+) : FunctionProcessorDelegate(context, containing, executableElement) {
override fun extractReturnType(): XType {
return executableType.returnType
@@ -148,34 +148,34 @@
override fun findPreparedResultBinder(returnType: XType, query: ParsedQuery) =
context.typeAdapterStore.findPreparedQueryResultBinder(returnType, query)
- override fun findInsertMethodBinder(returnType: XType, params: List<ShortcutQueryParameter>) =
- context.typeAdapterStore.findInsertMethodBinder(returnType, params)
+ override fun findInsertFunctionBinder(returnType: XType, params: List<ShortcutQueryParameter>) =
+ context.typeAdapterStore.findInsertFunctionBinder(returnType, params)
- override fun findDeleteOrUpdateMethodBinder(returnType: XType) =
- context.typeAdapterStore.findDeleteOrUpdateMethodBinder(returnType)
+ override fun findDeleteOrUpdateFunctionBinder(returnType: XType) =
+ context.typeAdapterStore.findDeleteOrUpdateFunctionBinder(returnType)
- override fun findUpsertMethodBinder(returnType: XType, params: List<ShortcutQueryParameter>) =
- context.typeAdapterStore.findUpsertMethodBinder(returnType, params)
+ override fun findUpsertFunctionBinder(returnType: XType, params: List<ShortcutQueryParameter>) =
+ context.typeAdapterStore.findUpsertFunctionBinder(returnType, params)
- override fun findTransactionMethodBinder(callType: TransactionMethod.CallType) =
- InstantTransactionMethodBinder(
+ override fun findTransactionFunctionBinder(callType: TransactionFunction.CallType) =
+ InstantTransactionFunctionBinder(
returnType = executableElement.returnType,
adapter =
- TransactionMethodAdapter(
- methodName = executableElement.name,
+ TransactionFunctionAdapter(
+ functionName = executableElement.name,
jvmMethodName = executableElement.jvmName,
callType = callType
),
)
}
-/** Delegate for DAO methods that are a suspend function. */
-class SuspendMethodProcessorDelegate(
+/** Delegate for DAO functions that are a suspend functions. */
+class SuspendFunctionProcessorDelegate(
context: Context,
containing: XType,
executableElement: XMethodElement,
val executableType: XSuspendMethodType
-) : MethodProcessorDelegate(context, containing, executableElement) {
+) : FunctionProcessorDelegate(context, containing, executableElement) {
private val continuationParam: XVariableElement by lazy {
val continuationType =
@@ -208,33 +208,33 @@
continuationParamName = continuationParam.name
)
- override fun findInsertMethodBinder(returnType: XType, params: List<ShortcutQueryParameter>) =
- CoroutineInsertOrUpsertMethodBinder(
+ override fun findInsertFunctionBinder(returnType: XType, params: List<ShortcutQueryParameter>) =
+ CoroutineInsertOrUpsertFunctionBinder(
typeArg = returnType,
adapter = context.typeAdapterStore.findInsertAdapter(returnType, params),
continuationParamName = continuationParam.name
)
- override fun findUpsertMethodBinder(returnType: XType, params: List<ShortcutQueryParameter>) =
- CoroutineInsertOrUpsertMethodBinder(
+ override fun findUpsertFunctionBinder(returnType: XType, params: List<ShortcutQueryParameter>) =
+ CoroutineInsertOrUpsertFunctionBinder(
typeArg = returnType,
adapter = context.typeAdapterStore.findUpsertAdapter(returnType, params),
continuationParamName = continuationParam.name
)
- override fun findDeleteOrUpdateMethodBinder(returnType: XType) =
- CoroutineDeleteOrUpdateMethodBinder(
+ override fun findDeleteOrUpdateFunctionBinder(returnType: XType) =
+ CoroutineDeleteOrUpdateFunctionBinder(
typeArg = returnType,
adapter = context.typeAdapterStore.findDeleteOrUpdateAdapter(returnType),
continuationParamName = continuationParam.name
)
- override fun findTransactionMethodBinder(callType: TransactionMethod.CallType) =
- CoroutineTransactionMethodBinder(
+ override fun findTransactionFunctionBinder(callType: TransactionFunction.CallType) =
+ CoroutineTransactionFunctionBinder(
returnType = executableElement.returnType,
adapter =
- TransactionMethodAdapter(
- methodName = executableElement.name,
+ TransactionFunctionAdapter(
+ functionName = executableElement.name,
jvmMethodName = executableElement.jvmName,
callType = callType
),
diff --git a/room/room-compiler/src/main/kotlin/androidx/room/processor/InsertMethodProcessor.kt b/room/room-compiler/src/main/kotlin/androidx/room/processor/InsertFunctionProcessor.kt
similarity index 90%
rename from room/room-compiler/src/main/kotlin/androidx/room/processor/InsertMethodProcessor.kt
rename to room/room-compiler/src/main/kotlin/androidx/room/processor/InsertFunctionProcessor.kt
index 3337480..f0b6ace 100644
--- a/room/room-compiler/src/main/kotlin/androidx/room/processor/InsertMethodProcessor.kt
+++ b/room/room-compiler/src/main/kotlin/androidx/room/processor/InsertFunctionProcessor.kt
@@ -22,18 +22,18 @@
import androidx.room.OnConflictStrategy
import androidx.room.compiler.processing.XMethodElement
import androidx.room.compiler.processing.XType
-import androidx.room.vo.InsertMethod
+import androidx.room.vo.InsertFunction
import androidx.room.vo.findFieldByColumnName
-class InsertMethodProcessor(
+class InsertFunctionProcessor(
baseContext: Context,
val containing: XType,
val executableElement: XMethodElement
) {
val context = baseContext.fork(executableElement)
- fun process(): InsertMethod {
- val delegate = ShortcutMethodProcessor(context, containing, executableElement)
+ fun process(): InsertFunction {
+ val delegate = ShortcutFunctionProcessor(context, containing, executableElement)
val annotation =
delegate.extractAnnotation(Insert::class, ProcessorErrors.MISSING_INSERT_ANNOTATION)
@@ -48,7 +48,7 @@
context.checker.notUnbound(
returnType,
executableElement,
- ProcessorErrors.CANNOT_USE_UNBOUND_GENERICS_IN_INSERT_METHODS
+ ProcessorErrors.CANNOT_USE_UNBOUND_GENERICS_IN_INSERT_FUNCTIONS
)
val (entities, params) =
@@ -88,21 +88,21 @@
}
)
- val methodBinder = delegate.findInsertMethodBinder(returnType, params)
+ val functionBinder = delegate.findInsertFunctionBinder(returnType, params)
context.checker.check(
- methodBinder.adapter != null,
+ functionBinder.adapter != null,
executableElement,
ProcessorErrors.CANNOT_FIND_INSERT_RESULT_ADAPTER
)
- return InsertMethod(
+ return InsertFunction(
element = executableElement,
returnType = returnType,
entities = entities,
parameters = params,
onConflict = onConflict,
- methodBinder = methodBinder
+ functionBinder = functionBinder
)
}
}
diff --git a/room/room-compiler/src/main/kotlin/androidx/room/processor/ProcessorErrors.kt b/room/room-compiler/src/main/kotlin/androidx/room/processor/ProcessorErrors.kt
index afaa03d..c2a18e1 100644
--- a/room/room-compiler/src/main/kotlin/androidx/room/processor/ProcessorErrors.kt
+++ b/room/room-compiler/src/main/kotlin/androidx/room/processor/ProcessorErrors.kt
@@ -36,56 +36,59 @@
return this.trimIndent().replace("\n", " ")
}
- val ISSUE_TRACKER_LINK = "https://issuetracker.google.com/issues/new?component=413107"
+ const val ISSUE_TRACKER_LINK = "https://issuetracker.google.com/issues/new?component=413107"
- val MISSING_QUERY_ANNOTATION = "Query methods must be annotated with ${Query::class.java}"
- val MISSING_INSERT_ANNOTATION = "Insert methods must be annotated with ${Insert::class.java}"
- val MISSING_DELETE_ANNOTATION = "Delete methods must be annotated with ${Delete::class.java}"
- val MISSING_UPDATE_ANNOTATION = "Update methods must be annotated with ${Update::class.java}"
- val MISSING_UPSERT_ANNOTATION = "Upsert methods must be annotated with ${Upsert::class.java}"
+ val MISSING_QUERY_ANNOTATION = "Query functions must be annotated with ${Query::class.java}"
+ val MISSING_INSERT_ANNOTATION = "Insert functions must be annotated with ${Insert::class.java}"
+ val MISSING_DELETE_ANNOTATION = "Delete functions must be annotated with ${Delete::class.java}"
+ val MISSING_UPDATE_ANNOTATION = "Update functions must be annotated with ${Update::class.java}"
+ val MISSING_UPSERT_ANNOTATION = "Upsert functions must be annotated with ${Upsert::class.java}"
val MISSING_RAWQUERY_ANNOTATION =
- "RawQuery methods must be annotated with" + " ${RawQuery::class.java}"
- val INVALID_ON_CONFLICT_VALUE = "On conflict value must be one of @OnConflictStrategy values."
- val TRANSACTION_REFERENCE_DOCS =
+ "RawQuery functions must be annotated with" + " ${RawQuery::class.java}"
+ const val INVALID_ON_CONFLICT_VALUE =
+ "On conflict value must be one of @OnConflictStrategy values."
+ const val TRANSACTION_REFERENCE_DOCS =
"https://developer.android.com/reference/androidx/" + "room/Transaction.html"
- val INVALID_ANNOTATION_COUNT_IN_DAO_METHOD =
- "An abstract DAO method must be" +
+ val INVALID_ANNOTATION_COUNT_IN_DAO_FUNCTION =
+ "An abstract DAO function must be" +
" annotated with one and only one of the following annotations: " +
DaoProcessor.PROCESSED_ANNOTATIONS.joinToString(", ") { "@" + it.java.simpleName }
val INVALID_ANNOTATION_IN_DAO_PROPERTY =
"An abstract DAO property must be" + " annotated with @get:${Query::class.java}."
- val CANNOT_RESOLVE_RETURN_TYPE = "Cannot resolve return type for %s"
- val CANNOT_USE_UNBOUND_GENERICS_IN_QUERY_METHODS =
+ const val CANNOT_RESOLVE_RETURN_TYPE = "Cannot resolve return type for %s"
+ const val CANNOT_USE_UNBOUND_GENERICS_IN_QUERY_FUNCTIONS =
"Cannot use unbound generics in query" +
- " methods. It must be bound to a type through base Dao class."
- val CANNOT_USE_UNBOUND_GENERICS_IN_INSERT_METHODS =
+ " functions. It must be bound to a type through base Dao class."
+ const val CANNOT_USE_UNBOUND_GENERICS_IN_INSERT_FUNCTIONS =
"Cannot use unbound generics in" +
- " insert methods. It must be bound to a type through base Dao class."
- val CANNOT_USE_UNBOUND_GENERICS_IN_UPSERT_METHODS =
+ " insert functions. It must be bound to a type through base Dao class."
+ const val CANNOT_USE_UNBOUND_GENERICS_IN_UPSERT_FUNCTIONS =
"Cannot use unbound generics in" +
- " upsert methods. It must be bound to a type through base Dao class."
- val CANNOT_USE_UNBOUND_GENERICS_IN_ENTITY_FIELDS = "Cannot use unbound fields in entities."
- val CANNOT_USE_UNBOUND_GENERICS_IN_DAO_CLASSES =
+ " upsert functions. It must be bound to a type through base Dao class."
+ const val CANNOT_USE_UNBOUND_GENERICS_IN_ENTITY_FIELDS =
+ "Cannot use unbound fields in entities."
+ const val CANNOT_USE_UNBOUND_GENERICS_IN_DAO_CLASSES =
"Cannot use unbound generics in Dao classes." +
" If you are trying to create a base DAO, create a normal class, extend it with type" +
" params then mark the subclass with @Dao."
- val CANNOT_USE_MAP_COLUMN_AND_MAP_INFO_SIMULTANEOUSLY =
+ const val CANNOT_USE_MAP_COLUMN_AND_MAP_INFO_SIMULTANEOUSLY =
"Cannot use @MapColumn and " +
" @MapInfo annotation in the same function. Please prefer using @MapColumn only."
- val CANNOT_FIND_GETTER_FOR_FIELD = "Cannot find getter for field."
- val CANNOT_FIND_SETTER_FOR_FIELD = "Cannot find setter for field."
- val MISSING_PRIMARY_KEY = "An entity must have at least 1 field annotated with @PrimaryKey"
- val AUTO_INCREMENTED_PRIMARY_KEY_IS_NOT_INT =
+ const val CANNOT_FIND_GETTER_FOR_FIELD = "Cannot find getter for field."
+ const val CANNOT_FIND_SETTER_FOR_FIELD = "Cannot find setter for field."
+ const val MISSING_PRIMARY_KEY =
+ "An entity must have at least 1 field annotated with @PrimaryKey"
+ const val AUTO_INCREMENTED_PRIMARY_KEY_IS_NOT_INT =
"If a primary key is annotated with" +
" autoGenerate, its type must be int, Integer, long or Long."
- val AUTO_INCREMENT_EMBEDDED_HAS_MULTIPLE_FIELDS =
+ const val AUTO_INCREMENT_EMBEDDED_HAS_MULTIPLE_FIELDS =
"When @PrimaryKey annotation is used on a" +
" field annotated with @Embedded, the embedded class should have only 1 field."
- val INVALID_INDEX_ORDERS_SIZE =
+ const val INVALID_INDEX_ORDERS_SIZE =
"The number of entries in @Index#orders() should be " +
"equal to the amount of columns defined in the @Index value."
- val DO_NOT_USE_GENERIC_IMMUTABLE_MULTIMAP =
+ const val DO_NOT_USE_GENERIC_IMMUTABLE_MULTIMAP =
"Do not use ImmutableMultimap as a type (as with" +
" Multimap itself). Instead use the subtypes such as ImmutableSetMultimap or " +
"ImmutableListMultimap."
@@ -104,9 +107,9 @@
" Available column names:${allColumns.joinToString(", ")}"
}
- val DAO_MUST_BE_AN_ABSTRACT_CLASS_OR_AN_INTERFACE =
+ const val DAO_MUST_BE_AN_ABSTRACT_CLASS_OR_AN_INTERFACE =
"Dao class must be an abstract class or" + " an interface"
- val DAO_MUST_BE_ANNOTATED_WITH_DAO = "Dao class must be annotated with @Dao"
+ const val DAO_MUST_BE_ANNOTATED_WITH_DAO = "Dao class must be annotated with @Dao"
fun daoMustHaveMatchingConstructor(daoName: String, dbName: String): String {
return """
@@ -116,81 +119,82 @@
.trim()
}
- val ENTITY_MUST_BE_ANNOTATED_WITH_ENTITY = "Entity class must be annotated with @Entity"
- val DATABASE_ANNOTATION_MUST_HAVE_LIST_OF_ENTITIES =
+ const val ENTITY_MUST_BE_ANNOTATED_WITH_ENTITY = "Entity class must be annotated with @Entity"
+ const val DATABASE_ANNOTATION_MUST_HAVE_LIST_OF_ENTITIES =
"@Database annotation must specify list" + " of entities"
- val COLUMN_NAME_CANNOT_BE_EMPTY =
+ const val COLUMN_NAME_CANNOT_BE_EMPTY =
"Column name cannot be blank. If you don't want to set it" +
", just remove the @ColumnInfo annotation or use @ColumnInfo.INHERIT_FIELD_NAME."
- val ENTITY_TABLE_NAME_CANNOT_BE_EMPTY =
+ const val ENTITY_TABLE_NAME_CANNOT_BE_EMPTY =
"Entity table name cannot be blank. If you don't want" +
" to set it, just remove the tableName property."
- val ENTITY_TABLE_NAME_CANNOT_START_WITH_SQLITE =
+ const val ENTITY_TABLE_NAME_CANNOT_START_WITH_SQLITE =
"Entity table name cannot start with \"sqlite_\"."
- val VIEW_MUST_BE_ANNOTATED_WITH_DATABASE_VIEW =
+ const val VIEW_MUST_BE_ANNOTATED_WITH_DATABASE_VIEW =
"View class must be annotated with " + "@DatabaseView"
- val VIEW_NAME_CANNOT_BE_EMPTY =
+ const val VIEW_NAME_CANNOT_BE_EMPTY =
"View name cannot be blank. If you don't want" +
" to set it, just remove the viewName property."
- val VIEW_NAME_CANNOT_START_WITH_SQLITE = "View name cannot start with \"sqlite_\"."
- val VIEW_QUERY_MUST_BE_SELECT = "Query for @DatabaseView must be a SELECT."
- val VIEW_QUERY_CANNOT_TAKE_ARGUMENTS = "Query for @DatabaseView cannot take any arguments."
+ const val VIEW_NAME_CANNOT_START_WITH_SQLITE = "View name cannot start with \"sqlite_\"."
+ const val VIEW_QUERY_MUST_BE_SELECT = "Query for @DatabaseView must be a SELECT."
+ const val VIEW_QUERY_CANNOT_TAKE_ARGUMENTS =
+ "Query for @DatabaseView cannot take any arguments."
fun viewCircularReferenceDetected(views: List<String>): String {
return "Circular reference detected among views: ${views.joinToString(", ")}"
}
- val CANNOT_BIND_QUERY_PARAMETER_INTO_STMT =
- "Query method parameters should either be a" +
+ const val CANNOT_BIND_QUERY_PARAMETER_INTO_STMT =
+ "Query function parameters should either be a" +
" type that can be converted into a database column or a List / Array that contains" +
" such type. You can consider adding a Type Adapter for this."
- val QUERY_PARAMETERS_CANNOT_START_WITH_UNDERSCORE =
- "Query/Insert method parameters cannot " + "start with underscore (_)."
+ const val QUERY_PARAMETERS_CANNOT_START_WITH_UNDERSCORE =
+ "Query/Insert function parameters cannot " + "start with underscore (_)."
fun cannotFindQueryResultAdapter(returnTypeName: String) =
- "Not sure how to convert the query result to this method's return type ($returnTypeName)."
+ "Not sure how to convert the query result to this function's return type ($returnTypeName)."
fun classMustImplementEqualsAndHashCode(keyType: String) =
"The key" +
- " of the provided method's multimap return type must implement equals() and " +
+ " of the provided function's multimap return type must implement equals() and " +
"hashCode(). Key type is: $keyType."
- val INSERT_DOES_NOT_HAVE_ANY_PARAMETERS_TO_INSERT =
- "Method annotated with" + " @Insert but does not have any parameters to insert."
+ const val INSERT_DOES_NOT_HAVE_ANY_PARAMETERS_TO_INSERT =
+ "Function annotated with" + " @Insert but does not have any parameters to insert."
- val UPSERT_DOES_NOT_HAVE_ANY_PARAMETERS_TO_UPSERT =
- "Method annotated with" + " @Upsert but does not have any parameters to insert or update."
+ const val UPSERT_DOES_NOT_HAVE_ANY_PARAMETERS_TO_UPSERT =
+ "Function annotated with" + " @Upsert but does not have any parameters to insert or update."
- val DELETE_MISSING_PARAMS =
- "Method annotated with" + " @Delete but does not have any parameters to delete."
+ const val DELETE_MISSING_PARAMS =
+ "Function annotated with" + " @Delete but does not have any parameters to delete."
fun cannotMapSpecifiedColumn(column: String, columnsInQuery: List<String>, annotation: String) =
"Column specified in the provided @$annotation annotation must be present in the query. " +
"Provided: $column. Columns found: ${columnsInQuery.joinToString(", ")}"
- val MAP_INFO_MUST_HAVE_AT_LEAST_ONE_COLUMN_PROVIDED =
+ const val MAP_INFO_MUST_HAVE_AT_LEAST_ONE_COLUMN_PROVIDED =
"To use the @MapInfo annotation, you " +
"must provide either the key column name, value column name, or both."
fun mayNeedMapColumn(columnArg: String): String {
return """
Looks like you may need to use @MapColumn to clarify the 'columnName' needed for
- type argument(s) in the return type of a method. Type argument that needs
+ type argument(s) in the return type of a function. Type argument that needs
@MapColumn: $columnArg
"""
.trim()
}
- val CANNOT_FIND_DELETE_RESULT_ADAPTER =
- "Not sure how to handle delete method's " +
+ const val CANNOT_FIND_DELETE_RESULT_ADAPTER =
+ "Not sure how to handle delete function's " +
"return type. Currently the supported return types are void, int or Int."
- val CANNOT_FIND_UPDATE_RESULT_ADAPTER =
- "Not sure how to handle update method's " +
+ const val CANNOT_FIND_UPDATE_RESULT_ADAPTER =
+ "Not sure how to handle update function's " +
"return type. Currently the supported return types are void, int or Int."
fun suspendReturnsDeferredType(returnTypeName: String) =
@@ -198,105 +202,107 @@
"modifier must not return a deferred/async type ($returnTypeName). Most probably this " +
"is an error. Consider changing the return type or removing the suspend modifier."
- val CANNOT_FIND_INSERT_RESULT_ADAPTER = "Not sure how to handle insert method's return type."
+ const val CANNOT_FIND_INSERT_RESULT_ADAPTER =
+ "Not sure how to handle insert function's return type."
- val CANNOT_FIND_UPSERT_RESULT_ADAPTER = "Not sure how to handle upsert method's return type."
+ const val CANNOT_FIND_UPSERT_RESULT_ADAPTER =
+ "Not sure how to handle upsert function's return type."
- val INSERT_MULTI_PARAM_SINGLE_RETURN_MISMATCH =
- "Insert method accepts multiple parameters " +
+ const val INSERT_MULTI_PARAM_SINGLE_RETURN_MISMATCH =
+ "Insert function accepts multiple parameters " +
"but the return type is a single element. Try using a multiple element return type."
- val UPSERT_MULTI_PARAM_SINGLE_RETURN_MISMATCH =
- "Upsert method accepts multiple parameters " +
+ const val UPSERT_MULTI_PARAM_SINGLE_RETURN_MISMATCH =
+ "Upsert function accepts multiple parameters " +
"but the return type is a single element. Try using a multiple element return type."
- val INSERT_SINGLE_PARAM_MULTI_RETURN_MISMATCH =
- "Insert method accepts a single parameter " +
+ const val INSERT_SINGLE_PARAM_MULTI_RETURN_MISMATCH =
+ "Insert function accepts a single parameter " +
"but the return type is a collection of elements. Try using a single element return type."
- val UPSERT_SINGLE_PARAM_MULTI_RETURN_MISMATCH =
- "Upsert method accepts a single parameter " +
+ const val UPSERT_SINGLE_PARAM_MULTI_RETURN_MISMATCH =
+ "Upsert function accepts a single parameter " +
"but the return type is a collection of elements. Try using a single element return type."
- val UPDATE_MISSING_PARAMS =
- "Method annotated with" + " @Update but does not have any parameters to update."
+ const val UPDATE_MISSING_PARAMS =
+ "Function annotated with" + " @Update but does not have any parameters to update."
- val TRANSACTION_METHOD_MODIFIERS =
- "Method annotated with @Transaction must not be " +
- "private, final, or abstract. It can be abstract only if the method is also" +
+ const val TRANSACTION_FUNCTION_MODIFIERS =
+ "Function annotated with @Transaction must not be " +
+ "private, final, or abstract. It can be abstract only if the function is also" +
" annotated with @Query."
- fun nullableParamInShortcutMethod(param: String) =
- "Methods annotated with [@Insert, " +
+ fun nullableParamInShortcutFunction(param: String) =
+ "Functions annotated with [@Insert, " +
"@Upsert, @Update, @Delete] shouldn't declare nullable parameters ($param)."
- fun transactionMethodAsync(returnTypeName: String) =
- "Method annotated with @Transaction must" +
+ fun transactionFunctionAsync(returnTypeName: String) =
+ "Function annotated with @Transaction must" +
" not return deferred/async return type $returnTypeName. Since transactions are" +
- " thread confined and Room cannot guarantee that all queries in the method" +
+ " thread confined and Room cannot guarantee that all queries in the function" +
" implementation are performed on the same thread, only synchronous @Transaction" +
- " implemented methods are allowed. If a transaction is started and a change of thread" +
+ " implemented functions are allowed. If a transaction is started and a change of thread" +
" is done and waited upon then a database deadlock can occur if the additional thread" +
" attempts to perform a query. This restrictions prevents such situation from" +
" occurring."
- val TRANSACTION_MISSING_ON_RELATION =
+ const val TRANSACTION_MISSING_ON_RELATION =
"The return value includes a data class with a @Relation." +
- " It is usually desired to annotate this method with @Transaction to avoid" +
+ " It is usually desired to annotate this function with @Transaction to avoid" +
" possibility of inconsistent results between the data class and its relations. See " +
TRANSACTION_REFERENCE_DOCS +
" for details."
- val CANNOT_FIND_ENTITY_FOR_SHORTCUT_QUERY_PARAMETER =
+ const val CANNOT_FIND_ENTITY_FOR_SHORTCUT_QUERY_PARAMETER =
"Type of the parameter must be a class " +
"annotated with @Entity or a collection/array of it."
val DB_MUST_EXTEND_ROOM_DB =
"Classes annotated with @Database should extend " + ROOM_DB.canonicalName
- val OBSERVABLE_QUERY_NOTHING_TO_OBSERVE =
+ const val OBSERVABLE_QUERY_NOTHING_TO_OBSERVE =
"Observable query return type (LiveData, Flowable" +
", DataSource, DataSourceFactory etc) can only be used with SELECT queries that" +
" directly or indirectly (via @Relation, for example) access at least one table. For" +
" @RawQuery, you should specify the list of tables to be observed via the" +
" observedEntities field."
- val RECURSIVE_REFERENCE_DETECTED =
+ const val RECURSIVE_REFERENCE_DETECTED =
"Recursive referencing through @Embedded and/or @Relation " + "detected: %s"
- private val TOO_MANY_MATCHING_GETTERS =
+ private const val TOO_MANY_MATCHING_GETTERS =
"Ambiguous getter for %s. All of the following " +
"match: %s. You can @Ignore the ones that you don't want to match."
- fun tooManyMatchingGetters(field: Field, methodNames: List<String>): String {
- return TOO_MANY_MATCHING_GETTERS.format(field, methodNames.joinToString(", "))
+ fun tooManyMatchingGetters(field: Field, functionNames: List<String>): String {
+ return TOO_MANY_MATCHING_GETTERS.format(field, functionNames.joinToString(", "))
}
- private val TOO_MANY_MATCHING_SETTERS =
+ private const val TOO_MANY_MATCHING_SETTERS =
"Ambiguous setter for %s. All of the following " +
"match: %s. You can @Ignore the ones that you don't want to match."
- fun tooManyMatchingSetter(field: Field, methodNames: List<String>): String {
- return TOO_MANY_MATCHING_SETTERS.format(field, methodNames.joinToString(", "))
+ fun tooManyMatchingSetter(field: Field, functionNames: List<String>): String {
+ return TOO_MANY_MATCHING_SETTERS.format(field, functionNames.joinToString(", "))
}
- val CANNOT_FIND_COLUMN_TYPE_ADAPTER =
+ const val CANNOT_FIND_COLUMN_TYPE_ADAPTER =
"Cannot figure out how to save this field into" +
" database. You can consider adding a type converter for it."
- val VALUE_CLASS_ONLY_SUPPORTED_IN_KSP =
+ const val VALUE_CLASS_ONLY_SUPPORTED_IN_KSP =
"Kotlin value classes are only supported " +
"in Room using KSP and generating Kotlin (room.generateKotlin=true)."
- val CANNOT_FIND_STMT_BINDER = "Cannot figure out how to bind this field into a statement."
+ const val CANNOT_FIND_STMT_BINDER = "Cannot figure out how to bind this field into a statement."
- val CANNOT_FIND_STMT_READER = "Cannot figure out how to read this field from a statement."
+ const val CANNOT_FIND_STMT_READER = "Cannot figure out how to read this field from a statement."
const val DEFAULT_VALUE_NULLABILITY = "Use of NULL as the default value of a non-null field"
- private val MISSING_PARAMETER_FOR_BIND =
+ private const val MISSING_PARAMETER_FOR_BIND =
"Each bind variable in the query must have a" +
- " matching method parameter. Cannot find method parameters for %s."
+ " matching function parameter. Cannot find function parameters for %s."
fun missingParameterForBindVariable(bindVarName: List<String>): String {
return MISSING_PARAMETER_FOR_BIND.format(bindVarName.joinToString(", "))
@@ -307,30 +313,30 @@
"Found $mapValueTypeName."
}
- private val UNUSED_QUERY_METHOD_PARAMETER = "Unused parameter%s: %s"
+ private const val UNUSED_QUERY_FUNCTION_PARAMETER = "Unused parameter%s: %s"
- fun unusedQueryMethodParameter(unusedParams: List<String>): String {
- return UNUSED_QUERY_METHOD_PARAMETER.format(
+ fun unusedQueryFunctionParameter(unusedParams: List<String>): String {
+ return UNUSED_QUERY_FUNCTION_PARAMETER.format(
if (unusedParams.size > 1) "s" else "",
unusedParams.joinToString(",")
)
}
- private val DUPLICATE_TABLES_OR_VIEWS =
+ private const val DUPLICATE_TABLES_OR_VIEWS =
"The name \"%s\" is used by multiple entities or views: %s"
fun duplicateTableNames(tableName: String, entityNames: List<String>): String {
return DUPLICATE_TABLES_OR_VIEWS.format(tableName, entityNames.joinToString(", "))
}
- val DAO_METHOD_CONFLICTS_WITH_OTHERS = "Dao method has conflicts."
+ const val DAO_FUNCTION_CONFLICTS_WITH_OTHERS = "Dao function has conflicts."
- fun duplicateDao(dao: String, methodNames: List<String>): String {
+ fun duplicateDao(dao: String, functionNames: List<String>): String {
return """
- All of these functions [${methodNames.joinToString(", ")}] return the same DAO
+ All of these functions [${functionNames.joinToString(", ")}] return the same DAO
class [$dao].
- A database can use a DAO only once so you should remove ${methodNames.size - 1} of
- these conflicting DAO methods. If you are implementing any of these to fulfill an
+ A database can use a DAO only once so you should remove ${functionNames.size - 1} of
+ these conflicting DAO functions. If you are implementing any of these to fulfill an
interface, don't make it abstract, instead, implement the code that calls the
other one.
"""
@@ -369,7 +375,7 @@
The query returns some columns [${unusedColumns.joinToString(", ")}] which are not
used by $dataClassNames. You can use @ColumnInfo annotation on the fields to specify
the mapping.
- You can annotate the method with @RewriteQueriesToDropUnusedColumns to direct Room
+ You can annotate the function with @RewriteQueriesToDropUnusedColumns to direct Room
to rewrite your query to avoid fetching unused columns.
"""
.trim()
@@ -389,28 +395,28 @@
return """
$unusedColumnsWarning
${unusedFieldsWarning.joinToString(separator = " ")}
- You can suppress this warning by annotating the method with
+ You can suppress this warning by annotating the function with
@SuppressWarnings(RoomWarnings.QUERY_MISMATCH).
Columns returned by the query: ${allColumns.joinToString(", ")}.
"""
.trim()
}
- val TYPE_CONVERTER_UNBOUND_GENERIC = "Cannot use unbound generics in Type Converters."
- val TYPE_CONVERTER_BAD_RETURN_TYPE = "Invalid return type for a type converter."
- val TYPE_CONVERTER_MUST_RECEIVE_1_PARAM = "Type converters must receive 1 parameter."
- val TYPE_CONVERTER_EMPTY_CLASS =
- "Class is referenced as a converter but it does not have any" + " converter methods."
- val TYPE_CONVERTER_MISSING_NOARG_CONSTRUCTOR =
+ const val TYPE_CONVERTER_UNBOUND_GENERIC = "Cannot use unbound generics in Type Converters."
+ const val TYPE_CONVERTER_BAD_RETURN_TYPE = "Invalid return type for a type converter."
+ const val TYPE_CONVERTER_MUST_RECEIVE_1_PARAM = "Type converters must receive 1 parameter."
+ const val TYPE_CONVERTER_EMPTY_CLASS =
+ "Class is referenced as a converter but it does not have any" + " converter functions."
+ const val TYPE_CONVERTER_MISSING_NOARG_CONSTRUCTOR =
"Classes that are used as TypeConverters must" +
" have no-argument public constructors. Use a ProvidedTypeConverter annotation if you" +
" need to take control over creating an instance of a TypeConverter."
- val TYPE_CONVERTER_MUST_BE_PUBLIC = "Type converters must be public."
- val INNER_CLASS_TYPE_CONVERTER_MUST_BE_STATIC =
+ const val TYPE_CONVERTER_MUST_BE_PUBLIC = "Type converters must be public."
+ const val INNER_CLASS_TYPE_CONVERTER_MUST_BE_STATIC =
"An inner class TypeConverter must be " + "static."
fun duplicateTypeConverters(converters: List<CustomTypeConverter>): String {
- return "Multiple methods define the same conversion. Conflicts with these:" +
+ return "Multiple functions define the same conversion. Conflicts with these:" +
" ${converters.joinToString(", ") { it.toString() }}"
}
@@ -419,7 +425,7 @@
}
// TODO must print field paths.
- val DATA_CLASS_FIELD_HAS_DUPLICATE_COLUMN_NAME = "Field has non-unique column name."
+ const val DATA_CLASS_FIELD_HAS_DUPLICATE_COLUMN_NAME = "Field has non-unique column name."
fun dataClassDuplicateFieldNames(columnName: String, fieldPaths: List<String>): String {
return "Multiple fields have the same columnName: $columnName." +
@@ -431,7 +437,7 @@
entityQName
}
- val INDEX_COLUMNS_CANNOT_BE_EMPTY = "List of columns in an index cannot be empty"
+ const val INDEX_COLUMNS_CANNOT_BE_EMPTY = "List of columns in an index cannot be empty"
fun indexColumnDoesNotExist(columnName: String, allColumns: List<String>): String {
return "$columnName referenced in the index does not exist in the Entity." +
@@ -478,7 +484,7 @@
" Alternatively, you can set inheritSuperIndices to true in the @Entity annotation."
}
- val NOT_ENTITY_OR_VIEW = "The class must be either @Entity or @DatabaseView."
+ const val NOT_ENTITY_OR_VIEW = "The class must be either @Entity or @DatabaseView."
fun relationCannotFindEntityField(
entityName: String,
@@ -522,7 +528,7 @@
"full table scan when resolving the relationship, it is highly advised to " +
"create an index that covers this column."
- val RELATION_IN_ENTITY = "Entities cannot have relations."
+ const val RELATION_IN_ENTITY = "Entities cannot have relations."
fun relationAffinityMismatch(
parentColumn: String,
@@ -585,13 +591,13 @@
.trim()
}
- val MISSING_SCHEMA_EXPORT_DIRECTORY =
+ const val MISSING_SCHEMA_EXPORT_DIRECTORY =
"Schema export directory was not provided to the" +
" annotation processor so Room cannot export the schema. You can either provide" +
" `room.schemaLocation` annotation processor argument by applying the Room Gradle plugin" +
" (id 'androidx.room') OR set exportSchema to false."
- val INVALID_FOREIGN_KEY_ACTION =
+ const val INVALID_FOREIGN_KEY_ACTION =
"Invalid foreign key action. It must be one of the constants" +
" defined in ForeignKey.Action"
@@ -603,7 +609,7 @@
.trim()
}
- val FOREIGN_KEY_CANNOT_FIND_PARENT = "Cannot find parent entity class."
+ const val FOREIGN_KEY_CANNOT_FIND_PARENT = "Cannot find parent entity class."
fun foreignKeyChildColumnDoesNotExist(columnName: String, allColumns: List<String>): String {
return "($columnName) referenced in the foreign key does not exist in the Entity." +
@@ -619,9 +625,11 @@
" ${allColumns.joinToString(",")}"
}
- val FOREIGN_KEY_EMPTY_CHILD_COLUMN_LIST = "Must specify at least 1 column name for the child"
+ const val FOREIGN_KEY_EMPTY_CHILD_COLUMN_LIST =
+ "Must specify at least 1 column name for the child"
- val FOREIGN_KEY_EMPTY_PARENT_COLUMN_LIST = "Must specify at least 1 column name for the parent"
+ const val FOREIGN_KEY_EMPTY_PARENT_COLUMN_LIST =
+ "Must specify at least 1 column name for the parent"
fun foreignKeyColumnNumberMismatch(
childColumns: List<String>,
@@ -687,33 +695,33 @@
.trim()
}
- val MISSING_ROOM_GUAVA_ARTIFACT =
+ const val MISSING_ROOM_GUAVA_ARTIFACT =
"To use Guava features, you must add `guava`" +
" artifact from Room as a dependency. androidx.room:room-guava:<version>"
- val MISSING_ROOM_RXJAVA2_ARTIFACT =
+ const val MISSING_ROOM_RXJAVA2_ARTIFACT =
"To use RxJava2 features, you must add `rxjava2`" +
" artifact from Room as a dependency. androidx.room:room-rxjava2:<version>"
- val MISSING_ROOM_RXJAVA3_ARTIFACT =
+ const val MISSING_ROOM_RXJAVA3_ARTIFACT =
"To use RxJava3 features, you must add `rxjava3`" +
" artifact from Room as a dependency. androidx.room:room-rxjava3:<version>"
- val MISSING_ROOM_PAGING_ARTIFACT =
+ const val MISSING_ROOM_PAGING_ARTIFACT =
"To use PagingSource, you must add `room-paging`" +
" artifact from Room as a dependency. androidx.room:room-paging:<version>"
- val MISSING_ROOM_PAGING_GUAVA_ARTIFACT =
+ const val MISSING_ROOM_PAGING_GUAVA_ARTIFACT =
"To use ListenableFuturePagingSource, you must " +
"add `room-paging-guava` artifact from Room as a dependency. " +
"androidx.room:room-paging-guava:<version>"
- val MISSING_ROOM_PAGING_RXJAVA2_ARTIFACT =
+ const val MISSING_ROOM_PAGING_RXJAVA2_ARTIFACT =
"To use RxPagingSource, you must " +
"add `room-paging-rxjava2` artifact from Room as a dependency. " +
"androidx.room:room-paging-rxjava2:<version>"
- val MISSING_ROOM_PAGING_RXJAVA3_ARTIFACT =
+ const val MISSING_ROOM_PAGING_RXJAVA3_ARTIFACT =
"To use RxPagingSource, you must " +
"add `room-paging-rxjava3` artifact from Room as a dependency. " +
"androidx.room:room-paging-rxjava3:<version>"
@@ -753,12 +761,13 @@
"""
.trim()
- val PAGING_SPECIFY_DATA_SOURCE_TYPE = "For now, Room only supports PositionalDataSource class."
+ const val PAGING_SPECIFY_DATA_SOURCE_TYPE =
+ "For now, Room only supports PositionalDataSource class."
- val PAGING_SPECIFY_PAGING_SOURCE_TYPE =
+ const val PAGING_SPECIFY_PAGING_SOURCE_TYPE =
"For now, Room only supports PagingSource with Key of" + " type Int."
- val PAGING_SPECIFY_PAGING_SOURCE_VALUE_TYPE =
+ const val PAGING_SPECIFY_PAGING_SOURCE_VALUE_TYPE =
"For now, Room only supports PagingSource with" + " Value that is not of Collection type."
fun primaryKeyNull(field: String): String {
@@ -768,13 +777,14 @@
"https://www.sqlite.org/lang_createtable.html"
}
- val INVALID_COLUMN_NAME =
+ const val INVALID_COLUMN_NAME =
"Invalid column name. Room does not allow using ` or \" in column" + " names"
- val INVALID_TABLE_NAME = "Invalid table name. Room does not allow using ` or \" in table names"
+ const val INVALID_TABLE_NAME =
+ "Invalid table name. Room does not allow using ` or \" in table names"
- val RAW_QUERY_BAD_PARAMS =
- "RawQuery methods should have 1 and only 1 parameter with type" + " SupportSQLiteQuery"
+ const val RAW_QUERY_BAD_PARAMS =
+ "RawQuery functions should have 1 and only 1 parameter with type" + " SupportSQLiteQuery"
fun parameterCannotBeNullable(parameterName: String) =
"""
@@ -782,7 +792,7 @@
"""
.trimIndent()
- val RAW_QUERY_BAD_RETURN_TYPE = "RawQuery methods must return a non-void type."
+ const val RAW_QUERY_BAD_RETURN_TYPE = "RawQuery functions must return a non-void type."
fun rawQueryBadEntity(typeName: String): String {
return """
@@ -798,43 +808,45 @@
"@RawQuery does not allow passing a string anymore." +
" Please use ${RoomTypeNames.RAW_QUERY.canonicalName}."
- val MISSING_COPY_ANNOTATIONS =
+ const val MISSING_COPY_ANNOTATIONS =
"Annotated property getter is missing " + "@AutoValue.CopyAnnotations."
fun invalidAnnotationTarget(annotationName: String, elementKindName: String): String {
return "@$annotationName is not allowed in this $elementKindName."
}
- val INDICES_IN_FTS_ENTITY = "Indices not allowed in FTS Entity."
+ const val INDICES_IN_FTS_ENTITY = "Indices not allowed in FTS Entity."
- val FOREIGN_KEYS_IN_FTS_ENTITY = "Foreign Keys not allowed in FTS Entity."
+ const val FOREIGN_KEYS_IN_FTS_ENTITY = "Foreign Keys not allowed in FTS Entity."
- val MISSING_PRIMARY_KEYS_ANNOTATION_IN_ROW_ID =
+ const val MISSING_PRIMARY_KEYS_ANNOTATION_IN_ROW_ID =
"The field with column name 'rowid' in " +
"an FTS entity must be annotated with @PrimaryKey."
- val TOO_MANY_PRIMARY_KEYS_IN_FTS_ENTITY = "An FTS entity can only have a single primary key."
+ const val TOO_MANY_PRIMARY_KEYS_IN_FTS_ENTITY =
+ "An FTS entity can only have a single primary key."
- val INVALID_FTS_ENTITY_PRIMARY_KEY_NAME =
+ const val INVALID_FTS_ENTITY_PRIMARY_KEY_NAME =
"The single primary key field in an FTS entity " +
"must either be named 'rowid' or must be annotated with @ColumnInfo(name = \"rowid\")"
- val INVALID_FTS_ENTITY_PRIMARY_KEY_AFFINITY =
+ const val INVALID_FTS_ENTITY_PRIMARY_KEY_AFFINITY =
"The single @PrimaryKey annotated field in an " + "FTS entity must be of INTEGER affinity."
fun missingLanguageIdField(columnName: String) =
- "The specified 'languageid' column: " + "\"$columnName\", was not found."
+ "The specified 'languageid' column: \"$columnName\", was not found."
- val INVALID_FTS_ENTITY_LANGUAGE_ID_AFFINITY =
+ const val INVALID_FTS_ENTITY_LANGUAGE_ID_AFFINITY =
"The 'languageid' field must be of INTEGER " + "affinity."
fun missingNotIndexedField(missingNotIndexedColumns: List<String>) =
"Non-existent columns are specified to be not indexed in notIndexed: " +
missingNotIndexedColumns.joinToString(",")
- val INVALID_FTS_ENTITY_PREFIX_SIZES = "Prefix sizes to index must non-zero positive values."
+ const val INVALID_FTS_ENTITY_PREFIX_SIZES =
+ "Prefix sizes to index must non-zero positive values."
- val FTS_EXTERNAL_CONTENT_CANNOT_FIND_ENTITY = "Cannot find external content entity class."
+ const val FTS_EXTERNAL_CONTENT_CANNOT_FIND_ENTITY = "Cannot find external content entity class."
fun externalContentNotAnEntity(className: String) =
"External content entity referenced in " +
@@ -855,10 +867,10 @@
"$entityName that matches with this partial entity field. If you don't wish to use " +
"the field then you can annotate it with @Ignore."
- val INVALID_TARGET_ENTITY_IN_SHORTCUT_METHOD =
+ const val INVALID_TARGET_ENTITY_IN_SHORTCUT_FUNCTION =
"Target entity declared in @Insert, @Update " + "or @Delete must be annotated with @Entity."
- val INVALID_RELATION_IN_PARTIAL_ENTITY = "Partial entities cannot have relations."
+ const val INVALID_RELATION_IN_PARTIAL_ENTITY = "Partial entities cannot have relations."
fun invalidQueryForSingleColumnArray(returnType: String) =
"If a DAO function has a " +
@@ -911,20 +923,20 @@
fun cannotFindPreparedQueryResultAdapter(returnType: String, type: QueryType) =
StringBuilder()
.apply {
- append("Not sure how to handle query method's return type ($returnType). ")
+ append("Not sure how to handle query function's return type ($returnType). ")
if (type == QueryType.INSERT) {
append(
- "INSERT query methods must either return void " +
+ "INSERT query functions must either return void " +
"or long (the rowid of the inserted row)."
)
} else if (type == QueryType.UPDATE) {
append(
- "UPDATE query methods must either return void " +
+ "UPDATE query functions must either return void " +
"or int (the number of updated rows)."
)
} else if (type == QueryType.DELETE) {
append(
- "DELETE query methods must either return void " +
+ "DELETE query functions must either return void " +
"or int (the number of deleted rows)."
)
}
@@ -968,8 +980,8 @@
"""
.trim()
- val DATABASE_INVALID_DAO_METHOD_RETURN_TYPE =
- "Abstract database methods must return a @Dao " + "annotated class or interface."
+ const val DATABASE_INVALID_DAO_FUNCTION_RETURN_TYPE =
+ "Abstract database functions must return a @Dao " + "annotated class or interface."
fun invalidEntityTypeInDatabaseAnnotation(typeName: String): String {
return "Invalid Entity type: $typeName. An entity in the database must be a class."
@@ -985,22 +997,22 @@
"an @AutoMigration annotation."
}
- val EMBEDDED_TYPES_MUST_BE_A_CLASS_OR_INTERFACE =
+ const val EMBEDDED_TYPES_MUST_BE_A_CLASS_OR_INTERFACE =
"The type of an Embedded field must be a " + "class or an interface."
- val RELATION_TYPE_MUST_BE_A_CLASS_OR_INTERFACE =
+ const val RELATION_TYPE_MUST_BE_A_CLASS_OR_INTERFACE =
"Entity type in a Relation must be a class " + "or an interface."
- fun shortcutMethodArgumentMustBeAClass(typeName: String): String {
+ fun shortcutFunctionArgumentMustBeAClass(typeName: String): String {
return "Invalid query argument: $typeName. It must be a class or an interface."
}
- val AUTOMIGRATION_SPEC_MUST_BE_CLASS = "The AutoMigration spec " + "type must be a class."
+ const val AUTOMIGRATION_SPEC_MUST_BE_CLASS = "The AutoMigration spec " + "type must be a class."
fun autoMigrationElementMustImplementSpec(spec: String): String {
- return "The AutoMigration spec " + "$spec must implement the AutoMigrationSpec interface."
+ return "The AutoMigration spec $spec must implement the AutoMigrationSpec interface."
}
- // TODO: (b/180389433) If the files don't exist the getSchemaFile() method should return
+ // TODO: (b/180389433) If the files don't exist the getSchemaFile() function should return
// null and before calling process
fun autoMigrationToVersionMustBeGreaterThanFrom(to: Int, from: Int) =
if (from > to) {
@@ -1147,10 +1159,10 @@
return "Conflicting @RenameColumn annotations found: [$annotations]"
}
- val AUTO_MIGRATION_FOUND_BUT_EXPORT_SCHEMA_OFF =
+ const val AUTO_MIGRATION_FOUND_BUT_EXPORT_SCHEMA_OFF =
"Cannot create auto migrations when " + "exportSchema is false."
- val AUTO_MIGRATION_SCHEMA_IN_FOLDER_NULL =
+ const val AUTO_MIGRATION_SCHEMA_IN_FOLDER_NULL =
"Schema import directory was not provided to the" +
" annotation processor so Room cannot read older schemas. To generate auto migrations," +
" you must provide `room.schemaLocation` annotation processor arguments by applying the" +
@@ -1162,15 +1174,15 @@
" a different name."
}
- val INNER_CLASS_AUTOMIGRATION_SPEC_MUST_BE_STATIC =
+ const val INNER_CLASS_AUTOMIGRATION_SPEC_MUST_BE_STATIC =
"An inner class AutoMigrationSpec must be" + " static."
- val AUTOMIGRATION_SPEC_MISSING_NOARG_CONSTRUCTOR =
+ const val AUTOMIGRATION_SPEC_MISSING_NOARG_CONSTRUCTOR =
"Classes that are used as " +
"AutoMigrationSpec " +
"implementations must have no-argument public constructors."
- val JVM_NAME_ON_OVERRIDDEN_METHOD =
+ const val JVM_NAME_ON_OVERRIDDEN_FUNCTION =
"Using @JvmName annotation on a function or accessor " +
"that will be overridden by Room is not supported. If this is important for your use " +
"case, please file a bug at $ISSUE_TRACKER_LINK with details."
@@ -1198,7 +1210,7 @@
return "The column '$columnName' $locationDesc is ambiguous and cannot be properly " +
"resolved. Please alias the column and $recommendation. Otherwise there is a risk of " +
"the query returning invalid values. You can suppress this warning by annotating " +
- "the method with @SuppressWarnings(RoomWarnings.AMBIGUOUS_COLUMN_IN_RESULT)."
+ "the function with @SuppressWarnings(RoomWarnings.AMBIGUOUS_COLUMN_IN_RESULT)."
}
enum class AmbiguousColumnLocation {
@@ -1207,25 +1219,25 @@
ENTITY,
}
- val NONNULL_VOID =
+ const val NONNULL_VOID =
"Invalid non-null declaration of 'Void', should be nullable. The 'Void' " +
"class represents a placeholder type that is uninstantiable and 'null' is always returned."
- fun nullableCollectionOrArrayReturnTypeInDaoMethod(
+ fun nullableCollectionOrArrayReturnTypeInDaoFunction(
typeName: String,
returnType: String
): String {
- return "The nullable `$returnType` ($typeName) return type in a DAO method is " +
+ return "The nullable `$returnType` ($typeName) return type in a DAO function is " +
"meaningless because Room will instead return an empty `$returnType` if no rows are " +
"returned from the query."
}
- fun nullableComponentInDaoMethodReturnType(typeName: String): String {
- return "The DAO method return type ($typeName) with the nullable type argument " +
+ fun nullableComponentInDaoFunctionReturnType(typeName: String): String {
+ return "The DAO function return type ($typeName) with the nullable type argument " +
"is meaningless because for now Room will never put a null value in a result."
}
- val EXPORTING_SCHEMA_TO_RESOURCES =
+ const val EXPORTING_SCHEMA_TO_RESOURCES =
"Schema export is set to be outputted as a resource" +
" (i.e. room.exportSchemaResource is set to true), this means Room will write the current" +
" schema version file into the produced JAR. Such flag must only be used for generating" +
@@ -1233,42 +1245,42 @@
" the schema file will end up in the final artifact which is typically not desired. This" +
" warning serves as a reminder to use room.exportSchemaResource cautiously."
- val INVALID_GRADLE_PLUGIN_AND_SCHEMA_LOCATION_OPTION =
+ const val INVALID_GRADLE_PLUGIN_AND_SCHEMA_LOCATION_OPTION =
"The Room Gradle plugin " +
"(id 'androidx.room') cannot be used with an explicit use of the annotation processor" +
"option `room.schemaLocation`, please remove the configuration of the option and " +
"configure the schema location via the plugin project extension: " +
"`room { schemaDirectory(...) }`."
- val INVALID_DATABASE_VERSION = "Database version must be greater than 0"
+ const val INVALID_DATABASE_VERSION = "Database version must be greater than 0"
- val JAVA_CODEGEN_ON_NON_ANDROID_TARGET =
+ const val JAVA_CODEGEN_ON_NON_ANDROID_TARGET =
"Cannot generate Java targeting a non-Android " +
"platform. To generate Java, you must only have Android as a target platform. " +
"To process a non-Android target platform, you must enable Kotlin code " +
"generation in KSP."
- val INVALID_BLOCKING_DAO_FUNCTION_NON_ANDROID =
+ const val INVALID_BLOCKING_DAO_FUNCTION_NON_ANDROID =
"Only suspend functions are allowed in DAOs" +
" declared in source sets targeting non-Android platforms."
val INVALID_KOTLIN_CODE_GEN_IN_JAVAC =
"${Context.BooleanProcessorOptions.GENERATE_KOTLIN.argName} can only be enabled in KSP."
- val RAW_QUERY_NOT_SUPPORTED_ON_NON_ANDROID =
+ const val RAW_QUERY_NOT_SUPPORTED_ON_NON_ANDROID =
"@RawQuery annotated DAO functions are currently not supported in source sets targeting " +
"non-Android platforms."
- val MISSING_CONSTRUCTED_BY_ANNOTATION =
+ const val MISSING_CONSTRUCTED_BY_ANNOTATION =
"The @Database class must be annotated with @ConstructedBy since the source is targeting " +
"non-Android platforms."
- val INVALID_CONSTRUCTED_BY_CLASS = "The @ConstructedBy 'value' must be a valid class."
+ const val INVALID_CONSTRUCTED_BY_CLASS = "The @ConstructedBy 'value' must be a valid class."
- val INVALID_CONSTRUCTED_BY_NOT_OBJECT =
+ const val INVALID_CONSTRUCTED_BY_NOT_OBJECT =
"The @ConstructedBy definition must be an 'object' declaration."
- val INVALID_CONSTRUCTED_BY_NOT_EXPECT =
+ const val INVALID_CONSTRUCTED_BY_NOT_EXPECT =
"The @ConstructedBy definition must be an 'expect' declaration."
fun invalidConstructedBySuperInterface(expected: String) =
diff --git a/room/room-compiler/src/main/kotlin/androidx/room/processor/QueryMethodProcessor.kt b/room/room-compiler/src/main/kotlin/androidx/room/processor/QueryFunctionProcessor.kt
similarity index 88%
rename from room/room-compiler/src/main/kotlin/androidx/room/processor/QueryMethodProcessor.kt
rename to room/room-compiler/src/main/kotlin/androidx/room/processor/QueryFunctionProcessor.kt
index f01ca3d..1304860 100644
--- a/room/room-compiler/src/main/kotlin/androidx/room/processor/QueryMethodProcessor.kt
+++ b/room/room-compiler/src/main/kotlin/androidx/room/processor/QueryFunctionProcessor.kt
@@ -33,13 +33,13 @@
import androidx.room.verifier.DatabaseVerificationErrors
import androidx.room.verifier.DatabaseVerifier
import androidx.room.vo.MapInfo
-import androidx.room.vo.QueryMethod
+import androidx.room.vo.QueryFunction
import androidx.room.vo.QueryParameter
-import androidx.room.vo.ReadQueryMethod
+import androidx.room.vo.ReadQueryFunction
import androidx.room.vo.Warning
-import androidx.room.vo.WriteQueryMethod
+import androidx.room.vo.WriteQueryFunction
-class QueryMethodProcessor(
+class QueryFunctionProcessor(
baseContext: Context,
val containing: XType,
val executableElement: XMethodElement,
@@ -48,11 +48,11 @@
val context = baseContext.fork(executableElement)
/**
- * The processing of the method might happen in multiple steps if we decide to rewrite the query
- * after the first processing. To allow it while respecting the Context, it is implemented as a
- * sub procedure in [InternalQueryProcessor].
+ * The processing of the function might happen in multiple steps if we decide to rewrite the
+ * query after the first processing. To allow it while respecting the Context, it is implemented
+ * as a sub procedure in [InternalQueryProcessor].
*/
- fun process(): QueryMethod {
+ fun process(): QueryFunction {
val annotation = executableElement.getAnnotation(Query::class)?.value
context.checker.check(
annotation != null,
@@ -76,7 +76,7 @@
}
// check if want to swap the query for a better one
val finalResult =
- if (initialResult is ReadQueryMethod) {
+ if (initialResult is ReadQueryFunction) {
val resultAdapter = initialResult.queryResultBinder.adapter
val originalQuery = initialResult.query
val finalQuery =
@@ -112,8 +112,8 @@
val containing: XType,
val dbVerifier: DatabaseVerifier? = null
) {
- fun processQuery(input: String?): QueryMethod {
- val delegate = MethodProcessorDelegate.createFor(context, containing, executableElement)
+ fun processQuery(input: String?): QueryFunction {
+ val delegate = FunctionProcessorDelegate.createFor(context, containing, executableElement)
val returnType = delegate.extractReturnType()
val returnsDeferredType = delegate.returnsDeferredType()
@@ -156,23 +156,23 @@
context.checker.notUnbound(
returnType,
executableElement,
- ProcessorErrors.CANNOT_USE_UNBOUND_GENERICS_IN_QUERY_METHODS
+ ProcessorErrors.CANNOT_USE_UNBOUND_GENERICS_IN_QUERY_FUNCTIONS
)
val isPreparedQuery = PREPARED_TYPES.contains(query.type)
- val queryMethod =
+ val queryFunction =
if (isPreparedQuery) {
- getPreparedQueryMethod(delegate, returnType, query)
+ getPreparedQueryFunction(delegate, returnType, query)
} else {
- getQueryMethod(delegate, returnType, query)
+ getQueryFunction(delegate, returnType, query)
}
- return processQueryMethod(queryMethod)
+ return processQueryFunction(queryFunction)
}
- private fun processQueryMethod(queryMethod: QueryMethod): QueryMethod {
+ private fun processQueryFunction(queryFunction: QueryFunction): QueryFunction {
val missing =
- queryMethod.sectionToParamMapping.filter { it.second == null }.map { it.first.text }
+ queryFunction.sectionToParamMapping.filter { it.second == null }.map { it.first.text }
if (missing.isNotEmpty()) {
context.logger.e(
executableElement,
@@ -181,14 +181,19 @@
}
val unused =
- queryMethod.parameters
- .filterNot { param -> queryMethod.sectionToParamMapping.any { it.second == param } }
+ queryFunction.parameters
+ .filterNot { param ->
+ queryFunction.sectionToParamMapping.any { it.second == param }
+ }
.map(QueryParameter::sqlName)
if (unused.isNotEmpty()) {
- context.logger.e(executableElement, ProcessorErrors.unusedQueryMethodParameter(unused))
+ context.logger.e(
+ executableElement,
+ ProcessorErrors.unusedQueryFunctionParameter(unused)
+ )
}
- return queryMethod
+ return queryFunction
}
private fun validateQuery(query: ParsedQuery) {
@@ -205,11 +210,11 @@
}
}
- private fun getPreparedQueryMethod(
- delegate: MethodProcessorDelegate,
+ private fun getPreparedQueryFunction(
+ delegate: FunctionProcessorDelegate,
returnType: XType,
query: ParsedQuery
- ): WriteQueryMethod {
+ ): WriteQueryFunction {
val resultBinder = delegate.findPreparedResultBinder(returnType, query)
context.checker.check(
resultBinder.adapter != null,
@@ -221,7 +226,7 @@
)
val parameters = delegate.extractQueryParams(query)
- return WriteQueryMethod(
+ return WriteQueryFunction(
element = executableElement,
query = query,
returnType = returnType,
@@ -231,11 +236,11 @@
}
@Suppress("DEPRECATION") // Due to MapInfo usage
- private fun getQueryMethod(
- delegate: MethodProcessorDelegate,
+ private fun getQueryFunction(
+ delegate: FunctionProcessorDelegate,
returnType: XType,
query: ParsedQuery
- ): QueryMethod {
+ ): QueryFunction {
val resultBinder =
delegate.findResultBinder(returnType, query) {
delegate.executableElement.getAnnotation(androidx.room.MapInfo::class)?.let {
@@ -303,7 +308,7 @@
val parameters = delegate.extractQueryParams(query)
- return ReadQueryMethod(
+ return ReadQueryFunction(
element = executableElement,
query = query,
returnType = returnType,
diff --git a/room/room-compiler/src/main/kotlin/androidx/room/processor/RawQueryMethodProcessor.kt b/room/room-compiler/src/main/kotlin/androidx/room/processor/RawQueryFunctionProcessor.kt
similarity index 93%
rename from room/room-compiler/src/main/kotlin/androidx/room/processor/RawQueryMethodProcessor.kt
rename to room/room-compiler/src/main/kotlin/androidx/room/processor/RawQueryFunctionProcessor.kt
index 158cb27..6b7ecef 100644
--- a/room/room-compiler/src/main/kotlin/androidx/room/processor/RawQueryMethodProcessor.kt
+++ b/room/room-compiler/src/main/kotlin/androidx/room/processor/RawQueryFunctionProcessor.kt
@@ -28,17 +28,17 @@
import androidx.room.parser.SqlParser
import androidx.room.processor.ProcessorErrors.RAW_QUERY_STRING_PARAMETER_REMOVED
import androidx.room.vo.MapInfo
-import androidx.room.vo.RawQueryMethod
+import androidx.room.vo.RawQueryFunction
-class RawQueryMethodProcessor(
+class RawQueryFunctionProcessor(
baseContext: Context,
val containing: XType,
val executableElement: XMethodElement
) {
val context = baseContext.fork(executableElement)
- fun process(): RawQueryMethod {
- val delegate = MethodProcessorDelegate.createFor(context, containing, executableElement)
+ fun process(): RawQueryFunction {
+ val delegate = FunctionProcessorDelegate.createFor(context, containing, executableElement)
val returnType = delegate.extractReturnType()
context.checker.check(
@@ -50,7 +50,7 @@
context.checker.notUnbound(
returnType,
executableElement,
- ProcessorErrors.CANNOT_USE_UNBOUND_GENERICS_IN_QUERY_METHODS
+ ProcessorErrors.CANNOT_USE_UNBOUND_GENERICS_IN_QUERY_FUNCTIONS
)
val returnsDeferredType = delegate.returnsDeferredType()
@@ -91,8 +91,8 @@
val runtimeQueryParam = findRuntimeQueryParameter(delegate.extractParams())
val inTransaction = executableElement.hasAnnotation(Transaction::class)
- val rawQueryMethod =
- RawQueryMethod(
+ val rawQueryFunction =
+ RawQueryFunction(
element = executableElement,
observedTableNames = observedTableNames,
returnType = returnType,
@@ -102,11 +102,11 @@
)
// TODO: Lift this restriction, to allow for INSERT, UPDATE and DELETE raw statements.
context.checker.check(
- rawQueryMethod.returnsValue,
+ rawQueryFunction.returnsValue,
executableElement,
ProcessorErrors.RAW_QUERY_BAD_RETURN_TYPE
)
- return rawQueryMethod
+ return rawQueryFunction
}
private fun processObservedTables(): Set<String> {
@@ -151,7 +151,7 @@
private fun findRuntimeQueryParameter(
extractParams: List<XVariableElement>
- ): RawQueryMethod.RuntimeQueryParameter? {
+ ): RawQueryFunction.RuntimeQueryParameter? {
if (extractParams.size == 1 && !executableElement.isVarArgs()) {
val param = extractParams.first().asMemberOf(containing)
val processingEnv = context.processingEnv
@@ -167,7 +167,7 @@
processingEnv.findType(RoomTypeNames.RAW_QUERY)?.let { rawQueryType ->
if (rawQueryType.isAssignableFrom(param)) {
- return RawQueryMethod.RuntimeQueryParameter(
+ return RawQueryFunction.RuntimeQueryParameter(
paramName = extractParams[0].name,
typeName = rawQueryType.asTypeName()
)
@@ -176,7 +176,7 @@
processingEnv.findType(SupportDbTypeNames.QUERY)?.let { supportQueryType ->
if (supportQueryType.isAssignableFrom(param)) {
- return RawQueryMethod.RuntimeQueryParameter(
+ return RawQueryFunction.RuntimeQueryParameter(
paramName = extractParams[0].name,
typeName = supportQueryType.asTypeName()
)
diff --git a/room/room-compiler/src/main/kotlin/androidx/room/processor/ShortcutMethodProcessor.kt b/room/room-compiler/src/main/kotlin/androidx/room/processor/ShortcutFunctionProcessor.kt
similarity index 92%
rename from room/room-compiler/src/main/kotlin/androidx/room/processor/ShortcutMethodProcessor.kt
rename to room/room-compiler/src/main/kotlin/androidx/room/processor/ShortcutFunctionProcessor.kt
index 6507652..2291a2c 100644
--- a/room/room-compiler/src/main/kotlin/androidx/room/processor/ShortcutMethodProcessor.kt
+++ b/room/room-compiler/src/main/kotlin/androidx/room/processor/ShortcutFunctionProcessor.kt
@@ -27,14 +27,15 @@
import androidx.room.vo.findFieldByColumnName
import kotlin.reflect.KClass
-/** Common functionality for shortcut method processors */
-class ShortcutMethodProcessor(
+/** Common functionality for shortcut function processors */
+class ShortcutFunctionProcessor(
baseContext: Context,
val containing: XType,
val executableElement: XMethodElement
) {
val context = baseContext.fork(executableElement)
- private val delegate = MethodProcessorDelegate.createFor(context, containing, executableElement)
+ private val delegate =
+ FunctionProcessorDelegate.createFor(context, containing, executableElement)
fun <T : Annotation> extractAnnotation(klass: KClass<T>, errorMsg: String): XAnnotationBox<T>? {
val annotation = executableElement.getAnnotation(klass)
@@ -87,7 +88,7 @@
if (targetTypeElement == null) {
context.logger.e(
executableElement,
- ProcessorErrors.INVALID_TARGET_ENTITY_IN_SHORTCUT_METHOD
+ ProcessorErrors.INVALID_TARGET_ENTITY_IN_SHORTCUT_FUNCTION
)
null
} else {
@@ -96,7 +97,7 @@
onInvalid = {
context.logger.e(
executableElement,
- ProcessorErrors.INVALID_TARGET_ENTITY_IN_SHORTCUT_METHOD
+ ProcessorErrors.INVALID_TARGET_ENTITY_IN_SHORTCUT_FUNCTION
)
return emptyMap<String, ShortcutEntity>() to emptyList()
}
@@ -138,7 +139,7 @@
if (pojoTypeElement == null) {
context.logger.e(
targetEntity.element,
- ProcessorErrors.shortcutMethodArgumentMustBeAClass(
+ ProcessorErrors.shortcutFunctionArgumentMustBeAClass(
typeName =
param.pojoType.asTypeName().toString(context.codeLanguage)
)
@@ -229,12 +230,12 @@
null
}
- fun findInsertMethodBinder(returnType: XType, params: List<ShortcutQueryParameter>) =
- delegate.findInsertMethodBinder(returnType, params)
+ fun findInsertFunctionBinder(returnType: XType, params: List<ShortcutQueryParameter>) =
+ delegate.findInsertFunctionBinder(returnType, params)
- fun findUpsertMethodBinder(returnType: XType, params: List<ShortcutQueryParameter>) =
- delegate.findUpsertMethodBinder(returnType, params)
+ fun findUpsertFunctionBinder(returnType: XType, params: List<ShortcutQueryParameter>) =
+ delegate.findUpsertFunctionBinder(returnType, params)
- fun findDeleteOrUpdateMethodBinder(returnType: XType) =
- delegate.findDeleteOrUpdateMethodBinder(returnType)
+ fun findDeleteOrUpdateFunctionBinder(returnType: XType) =
+ delegate.findDeleteOrUpdateFunctionBinder(returnType)
}
diff --git a/room/room-compiler/src/main/kotlin/androidx/room/processor/ShortcutParameterProcessor.kt b/room/room-compiler/src/main/kotlin/androidx/room/processor/ShortcutParameterProcessor.kt
index 9b3dfdf..765526f 100644
--- a/room/room-compiler/src/main/kotlin/androidx/room/processor/ShortcutParameterProcessor.kt
+++ b/room/room-compiler/src/main/kotlin/androidx/room/processor/ShortcutParameterProcessor.kt
@@ -36,7 +36,7 @@
context.logger.e(
element = element,
msg =
- ProcessorErrors.nullableParamInShortcutMethod(
+ ProcessorErrors.nullableParamInShortcutFunction(
asMember.asTypeName().toString(context.codeLanguage)
)
)
diff --git a/room/room-compiler/src/main/kotlin/androidx/room/processor/TransactionMethodProcessor.kt b/room/room-compiler/src/main/kotlin/androidx/room/processor/TransactionFunctionProcessor.kt
similarity index 83%
rename from room/room-compiler/src/main/kotlin/androidx/room/processor/TransactionMethodProcessor.kt
rename to room/room-compiler/src/main/kotlin/androidx/room/processor/TransactionFunctionProcessor.kt
index 8667172..3994d4f 100644
--- a/room/room-compiler/src/main/kotlin/androidx/room/processor/TransactionMethodProcessor.kt
+++ b/room/room-compiler/src/main/kotlin/androidx/room/processor/TransactionFunctionProcessor.kt
@@ -21,9 +21,9 @@
import androidx.room.compiler.processing.XType
import androidx.room.compiler.processing.XTypeElement
import androidx.room.ext.DEFERRED_TYPES
-import androidx.room.vo.TransactionMethod
+import androidx.room.vo.TransactionFunction
-class TransactionMethodProcessor(
+class TransactionFunctionProcessor(
baseContext: Context,
val containingElement: XTypeElement,
val containingType: XType,
@@ -32,14 +32,15 @@
val context = baseContext.fork(executableElement)
- fun process(): TransactionMethod {
- val delegate = MethodProcessorDelegate.createFor(context, containingType, executableElement)
+ fun process(): TransactionFunction {
+ val delegate =
+ FunctionProcessorDelegate.createFor(context, containingType, executableElement)
val hasKotlinDefaultImpl = executableElement.hasKotlinDefaultImpl()
context.checker.check(
executableElement.isOverrideableIgnoringContainer() &&
(!executableElement.isAbstract() || hasKotlinDefaultImpl),
executableElement,
- ProcessorErrors.TRANSACTION_METHOD_MODIFIERS
+ ProcessorErrors.TRANSACTION_FUNCTION_MODIFIERS
)
val returnType = delegate.extractReturnType()
@@ -54,7 +55,7 @@
}
if (deferredReturnTypeName != null) {
context.logger.e(
- ProcessorErrors.transactionMethodAsync(
+ ProcessorErrors.transactionFunctionAsync(
deferredReturnTypeName.toString(context.codeLanguage)
),
executableElement
@@ -76,10 +77,10 @@
val callType =
when {
containingElement.isInterface() && executableElement.isJavaDefault() ->
- TransactionMethod.CallType.DEFAULT_JAVA8
+ TransactionFunction.CallType.DEFAULT_JAVA8
containingElement.isInterface() && hasKotlinDefaultImpl ->
- TransactionMethod.CallType.DEFAULT_KOTLIN
- else -> TransactionMethod.CallType.CONCRETE
+ TransactionFunction.CallType.DEFAULT_KOTLIN
+ else -> TransactionFunction.CallType.CONCRETE
}
val parameters = delegate.extractParams()
@@ -93,12 +94,12 @@
}
}
- return TransactionMethod(
+ return TransactionFunction(
element = executableElement,
returnType = returnType,
parameterNames = processedParamNames,
callType = callType,
- methodBinder = delegate.findTransactionMethodBinder(callType)
+ functionBinder = delegate.findTransactionFunctionBinder(callType)
)
}
}
diff --git a/room/room-compiler/src/main/kotlin/androidx/room/processor/UpdateMethodProcessor.kt b/room/room-compiler/src/main/kotlin/androidx/room/processor/UpdateFunctionProcessor.kt
similarity index 87%
rename from room/room-compiler/src/main/kotlin/androidx/room/processor/UpdateMethodProcessor.kt
rename to room/room-compiler/src/main/kotlin/androidx/room/processor/UpdateFunctionProcessor.kt
index 15c1dd8..704b25d 100644
--- a/room/room-compiler/src/main/kotlin/androidx/room/processor/UpdateMethodProcessor.kt
+++ b/room/room-compiler/src/main/kotlin/androidx/room/processor/UpdateFunctionProcessor.kt
@@ -20,18 +20,18 @@
import androidx.room.Update
import androidx.room.compiler.processing.XMethodElement
import androidx.room.compiler.processing.XType
-import androidx.room.vo.UpdateMethod
+import androidx.room.vo.UpdateFunction
import androidx.room.vo.findFieldByColumnName
-class UpdateMethodProcessor(
+class UpdateFunctionProcessor(
baseContext: Context,
val containing: XType,
val executableElement: XMethodElement
) {
val context = baseContext.fork(executableElement)
- fun process(): UpdateMethod {
- val delegate = ShortcutMethodProcessor(context, containing, executableElement)
+ fun process(): UpdateFunction {
+ val delegate = ShortcutFunctionProcessor(context, containing, executableElement)
val annotation =
delegate.extractAnnotation(Update::class, ProcessorErrors.MISSING_UPDATE_ANNOTATION)
@@ -63,19 +63,19 @@
)
val returnType = delegate.extractReturnType()
- val methodBinder = delegate.findDeleteOrUpdateMethodBinder(returnType)
+ val functionBinder = delegate.findDeleteOrUpdateFunctionBinder(returnType)
context.checker.check(
- methodBinder.adapter != null,
+ functionBinder.adapter != null,
executableElement,
ProcessorErrors.CANNOT_FIND_UPDATE_RESULT_ADAPTER
)
- return UpdateMethod(
+ return UpdateFunction(
element = delegate.executableElement,
entities = entities,
onConflictStrategy = onConflict,
- methodBinder = methodBinder,
+ functionBinder = functionBinder,
parameters = params
)
}
diff --git a/room/room-compiler/src/main/kotlin/androidx/room/processor/UpsertMethodProcessor.kt b/room/room-compiler/src/main/kotlin/androidx/room/processor/UpsertFunctionProcessor.kt
similarity index 89%
rename from room/room-compiler/src/main/kotlin/androidx/room/processor/UpsertMethodProcessor.kt
rename to room/room-compiler/src/main/kotlin/androidx/room/processor/UpsertFunctionProcessor.kt
index b65836c..cf4eff5 100644
--- a/room/room-compiler/src/main/kotlin/androidx/room/processor/UpsertMethodProcessor.kt
+++ b/room/room-compiler/src/main/kotlin/androidx/room/processor/UpsertFunctionProcessor.kt
@@ -19,18 +19,18 @@
import androidx.room.Upsert
import androidx.room.compiler.processing.XMethodElement
import androidx.room.compiler.processing.XType
-import androidx.room.vo.UpsertMethod
+import androidx.room.vo.UpsertFunction
import androidx.room.vo.findFieldByColumnName
-class UpsertMethodProcessor(
+class UpsertFunctionProcessor(
baseContext: Context,
val containing: XType,
val executableElement: XMethodElement
) {
val context = baseContext.fork(executableElement)
- fun process(): UpsertMethod {
- val delegate = ShortcutMethodProcessor(context, containing, executableElement)
+ fun process(): UpsertFunction {
+ val delegate = ShortcutFunctionProcessor(context, containing, executableElement)
val annotation =
delegate.extractAnnotation(Upsert::class, ProcessorErrors.MISSING_UPSERT_ANNOTATION)
@@ -39,7 +39,7 @@
context.checker.notUnbound(
returnType,
executableElement,
- ProcessorErrors.CANNOT_USE_UNBOUND_GENERICS_IN_UPSERT_METHODS
+ ProcessorErrors.CANNOT_USE_UNBOUND_GENERICS_IN_UPSERT_FUNCTIONS
)
val (entities, params) =
@@ -79,20 +79,20 @@
}
)
- val methodBinder = delegate.findUpsertMethodBinder(returnType, params)
+ val functionBinder = delegate.findUpsertFunctionBinder(returnType, params)
context.checker.check(
- methodBinder.adapter != null,
+ functionBinder.adapter != null,
executableElement,
ProcessorErrors.CANNOT_FIND_UPSERT_RESULT_ADAPTER
)
- return UpsertMethod(
+ return UpsertFunction(
element = executableElement,
returnType = returnType,
entities = entities,
parameters = params,
- methodBinder = methodBinder
+ functionBinder = functionBinder
)
}
}
diff --git a/room/room-compiler/src/main/kotlin/androidx/room/solver/KotlinBoxedPrimitiveMethodDelegateBinder.kt b/room/room-compiler/src/main/kotlin/androidx/room/solver/KotlinBoxedPrimitiveFunctionDelegateBinder.kt
similarity index 86%
rename from room/room-compiler/src/main/kotlin/androidx/room/solver/KotlinBoxedPrimitiveMethodDelegateBinder.kt
rename to room/room-compiler/src/main/kotlin/androidx/room/solver/KotlinBoxedPrimitiveFunctionDelegateBinder.kt
index 32c2d77..07817be 100644
--- a/room/room-compiler/src/main/kotlin/androidx/room/solver/KotlinBoxedPrimitiveMethodDelegateBinder.kt
+++ b/room/room-compiler/src/main/kotlin/androidx/room/solver/KotlinBoxedPrimitiveFunctionDelegateBinder.kt
@@ -22,18 +22,18 @@
import androidx.room.compiler.codegen.unbox
import androidx.room.compiler.processing.XType
import androidx.room.compiler.processing.isVoid
-import androidx.room.vo.KotlinBoxedPrimitiveMethodDelegate
+import androidx.room.vo.KotlinBoxedPrimitiveFunctionDelegate
/**
- * Method binder that delegates to a sibling DAO function in a Kotlin interface or abstract class
+ * Function binder that delegates to a sibling DAO function in a Kotlin interface or abstract class
* and specifically to a sibling function with unboxed primitive parameters.
*
- * @see [KotlinBoxedPrimitiveMethodDelegate]
+ * @see [KotlinBoxedPrimitiveFunctionDelegate]
*/
-object KotlinBoxedPrimitiveMethodDelegateBinder {
+object KotlinBoxedPrimitiveFunctionDelegateBinder {
fun execute(
- methodName: String,
+ functionName: String,
returnType: XType,
parameters: List<Pair<XTypeName, String>>,
scope: CodeGenScope
@@ -45,7 +45,7 @@
append("return ")
}
append("%L(")
- params.add(methodName)
+ params.add(functionName)
parameters.forEachIndexed { i, (typeName, name) ->
if (typeName.isPrimitive) {
append("(%T) %L")
diff --git a/room/room-compiler/src/main/kotlin/androidx/room/solver/KotlinDefaultMethodDelegateBinder.kt b/room/room-compiler/src/main/kotlin/androidx/room/solver/KotlinDefaultFunctionDelegateBinder.kt
similarity index 85%
rename from room/room-compiler/src/main/kotlin/androidx/room/solver/KotlinDefaultMethodDelegateBinder.kt
rename to room/room-compiler/src/main/kotlin/androidx/room/solver/KotlinDefaultFunctionDelegateBinder.kt
index a83c58f..a1beae3 100644
--- a/room/room-compiler/src/main/kotlin/androidx/room/solver/KotlinDefaultMethodDelegateBinder.kt
+++ b/room/room-compiler/src/main/kotlin/androidx/room/solver/KotlinDefaultFunctionDelegateBinder.kt
@@ -22,19 +22,19 @@
import androidx.room.compiler.processing.XType
import androidx.room.compiler.processing.isVoid
import androidx.room.ext.DEFAULT_IMPLS_CLASS_NAME
-import androidx.room.vo.KotlinDefaultMethodDelegate
+import androidx.room.vo.KotlinDefaultFunctionDelegate
/**
- * Method binder that delegates to concrete DAO function in a Kotlin interface, specifically to a
+ * Function binder that delegates to concrete DAO function in a Kotlin interface, specifically to a
* function where the implementation is in the DefaultImpl Kotlin generated class.
*
- * @see [KotlinDefaultMethodDelegate]
+ * @see [KotlinDefaultFunctionDelegate]
*/
-object KotlinDefaultMethodDelegateBinder {
+object KotlinDefaultFunctionDelegateBinder {
fun executeAndReturn(
daoName: XClassName,
daoImplName: XClassName,
- methodName: String,
+ functionName: String,
returnType: XType,
parameterNames: List<String>,
scope: CodeGenScope
@@ -48,7 +48,7 @@
append("%T.%L.%L(%T.this")
params.add(daoName)
params.add(DEFAULT_IMPLS_CLASS_NAME)
- params.add(methodName)
+ params.add(functionName)
params.add(daoImplName)
parameterNames.forEach {
append(", %L")
diff --git a/room/room-compiler/src/main/kotlin/androidx/room/solver/TypeAdapterStore.kt b/room/room-compiler/src/main/kotlin/androidx/room/solver/TypeAdapterStore.kt
index 31bb21d..65790cc 100644
--- a/room/room-compiler/src/main/kotlin/androidx/room/solver/TypeAdapterStore.kt
+++ b/room/room-compiler/src/main/kotlin/androidx/room/solver/TypeAdapterStore.kt
@@ -90,18 +90,18 @@
import androidx.room.solver.query.result.SingleColumnRowAdapter
import androidx.room.solver.query.result.SingleItemQueryResultAdapter
import androidx.room.solver.query.result.SingleNamedColumnRowAdapter
-import androidx.room.solver.shortcut.binder.DeleteOrUpdateMethodBinder
-import androidx.room.solver.shortcut.binder.InsertOrUpsertMethodBinder
-import androidx.room.solver.shortcut.binderprovider.DeleteOrUpdateMethodBinderProvider
-import androidx.room.solver.shortcut.binderprovider.GuavaListenableFutureDeleteOrUpdateMethodBinderProvider
-import androidx.room.solver.shortcut.binderprovider.GuavaListenableFutureInsertOrUpsertMethodBinderProvider
-import androidx.room.solver.shortcut.binderprovider.InsertOrUpsertMethodBinderProvider
-import androidx.room.solver.shortcut.binderprovider.InstantDeleteOrUpdateMethodBinderProvider
-import androidx.room.solver.shortcut.binderprovider.InstantInsertOrUpsertMethodBinderProvider
-import androidx.room.solver.shortcut.binderprovider.RxCallableDeleteOrUpdateMethodBinderProvider
-import androidx.room.solver.shortcut.binderprovider.RxCallableInsertOrUpsertMethodBinderProvider
-import androidx.room.solver.shortcut.result.DeleteOrUpdateMethodAdapter
-import androidx.room.solver.shortcut.result.InsertOrUpsertMethodAdapter
+import androidx.room.solver.shortcut.binder.DeleteOrUpdateFunctionBinder
+import androidx.room.solver.shortcut.binder.InsertOrUpsertFunctionBinder
+import androidx.room.solver.shortcut.binderprovider.DeleteOrUpdateFunctionBinderProvider
+import androidx.room.solver.shortcut.binderprovider.GuavaListenableFutureDeleteOrUpdateFunctionBinderProvider
+import androidx.room.solver.shortcut.binderprovider.GuavaListenableFutureInsertOrUpsertFunctionBinderProvider
+import androidx.room.solver.shortcut.binderprovider.InsertOrUpsertFunctionBinderProvider
+import androidx.room.solver.shortcut.binderprovider.InstantDeleteOrUpdateFunctionBinderProvider
+import androidx.room.solver.shortcut.binderprovider.InstantInsertOrUpsertFunctionBinderProvider
+import androidx.room.solver.shortcut.binderprovider.RxCallableDeleteOrUpdateFunctionBinderProvider
+import androidx.room.solver.shortcut.binderprovider.RxCallableInsertOrUpsertFunctionBinderProvider
+import androidx.room.solver.shortcut.result.DeleteOrUpdateFunctionAdapter
+import androidx.room.solver.shortcut.result.InsertOrUpsertFunctionAdapter
import androidx.room.solver.types.BoxedBooleanToBoxedIntConverter
import androidx.room.solver.types.BoxedPrimitiveColumnTypeAdapter
import androidx.room.solver.types.ByteArrayColumnTypeAdapter
@@ -229,18 +229,18 @@
add(InstantPreparedQueryResultBinderProvider(context))
}
- private val insertOrUpsertBinderProviders: List<InsertOrUpsertMethodBinderProvider> =
- mutableListOf<InsertOrUpsertMethodBinderProvider>().apply {
- addAll(RxCallableInsertOrUpsertMethodBinderProvider.getAll(context))
- add(GuavaListenableFutureInsertOrUpsertMethodBinderProvider(context))
- add(InstantInsertOrUpsertMethodBinderProvider(context))
+ private val insertOrUpsertBinderProviders: List<InsertOrUpsertFunctionBinderProvider> =
+ mutableListOf<InsertOrUpsertFunctionBinderProvider>().apply {
+ addAll(RxCallableInsertOrUpsertFunctionBinderProvider.getAll(context))
+ add(GuavaListenableFutureInsertOrUpsertFunctionBinderProvider(context))
+ add(InstantInsertOrUpsertFunctionBinderProvider(context))
}
- private val deleteOrUpdateBinderProvider: List<DeleteOrUpdateMethodBinderProvider> =
- mutableListOf<DeleteOrUpdateMethodBinderProvider>().apply {
- addAll(RxCallableDeleteOrUpdateMethodBinderProvider.getAll(context))
- add(GuavaListenableFutureDeleteOrUpdateMethodBinderProvider(context))
- add(InstantDeleteOrUpdateMethodBinderProvider(context))
+ private val deleteOrUpdateBinderProvider: List<DeleteOrUpdateFunctionBinderProvider> =
+ mutableListOf<DeleteOrUpdateFunctionBinderProvider>().apply {
+ addAll(RxCallableDeleteOrUpdateFunctionBinderProvider.getAll(context))
+ add(GuavaListenableFutureDeleteOrUpdateFunctionBinderProvider(context))
+ add(InstantDeleteOrUpdateFunctionBinderProvider(context))
}
/** Searches 1 way to bind a value into a statement. */
@@ -413,23 +413,23 @@
}
}
- fun findDeleteOrUpdateMethodBinder(typeMirror: XType): DeleteOrUpdateMethodBinder {
+ fun findDeleteOrUpdateFunctionBinder(typeMirror: XType): DeleteOrUpdateFunctionBinder {
return deleteOrUpdateBinderProvider.first { it.matches(typeMirror) }.provide(typeMirror)
}
- fun findInsertMethodBinder(
+ fun findInsertFunctionBinder(
typeMirror: XType,
params: List<ShortcutQueryParameter>
- ): InsertOrUpsertMethodBinder {
+ ): InsertOrUpsertFunctionBinder {
return insertOrUpsertBinderProviders
.first { it.matches(typeMirror) }
.provide(typeMirror, params, false)
}
- fun findUpsertMethodBinder(
+ fun findUpsertFunctionBinder(
typeMirror: XType,
params: List<ShortcutQueryParameter>
- ): InsertOrUpsertMethodBinder {
+ ): InsertOrUpsertFunctionBinder {
return insertOrUpsertBinderProviders
.first { it.matches(typeMirror) }
.provide(typeMirror, params, true)
@@ -465,22 +465,22 @@
fun findPreparedQueryResultAdapter(typeMirror: XType, query: ParsedQuery) =
PreparedQueryResultAdapter.create(typeMirror, query.type)
- fun findDeleteOrUpdateAdapter(typeMirror: XType): DeleteOrUpdateMethodAdapter? {
- return DeleteOrUpdateMethodAdapter.create(typeMirror)
+ fun findDeleteOrUpdateAdapter(typeMirror: XType): DeleteOrUpdateFunctionAdapter? {
+ return DeleteOrUpdateFunctionAdapter.create(typeMirror)
}
fun findInsertAdapter(
typeMirror: XType,
params: List<ShortcutQueryParameter>
- ): InsertOrUpsertMethodAdapter? {
- return InsertOrUpsertMethodAdapter.createInsert(context, typeMirror, params)
+ ): InsertOrUpsertFunctionAdapter? {
+ return InsertOrUpsertFunctionAdapter.createInsert(context, typeMirror, params)
}
fun findUpsertAdapter(
typeMirror: XType,
params: List<ShortcutQueryParameter>
- ): InsertOrUpsertMethodAdapter? {
- return InsertOrUpsertMethodAdapter.createUpsert(context, typeMirror, params)
+ ): InsertOrUpsertFunctionAdapter? {
+ return InsertOrUpsertFunctionAdapter.createUpsert(context, typeMirror, params)
}
fun findQueryResultAdapter(
@@ -766,7 +766,7 @@
if (collectionType.nullability != XNullability.NONNULL) {
context.logger.w(
Warning.UNNECESSARY_NULLABILITY_IN_DAO_RETURN_TYPE,
- ProcessorErrors.nullableCollectionOrArrayReturnTypeInDaoMethod(
+ ProcessorErrors.nullableCollectionOrArrayReturnTypeInDaoFunction(
searchingType.asTypeName().toString(context.codeLanguage),
typeKeyword
)
@@ -777,7 +777,7 @@
if (arrayComponentType != null && arrayComponentType.nullability != XNullability.NONNULL) {
context.logger.w(
Warning.UNNECESSARY_NULLABILITY_IN_DAO_RETURN_TYPE,
- ProcessorErrors.nullableComponentInDaoMethodReturnType(
+ ProcessorErrors.nullableComponentInDaoFunctionReturnType(
searchingType.asTypeName().toString(context.codeLanguage)
)
)
@@ -788,7 +788,7 @@
if (typeArg.nullability != XNullability.NONNULL) {
context.logger.w(
Warning.UNNECESSARY_NULLABILITY_IN_DAO_RETURN_TYPE,
- ProcessorErrors.nullableComponentInDaoMethodReturnType(
+ ProcessorErrors.nullableComponentInDaoFunctionReturnType(
searchingType.asTypeName().toString(context.codeLanguage)
)
)
diff --git a/room/room-compiler/src/main/kotlin/androidx/room/solver/shortcut/binder/CoroutineDeleteOrUpdateMethodBinder.kt b/room/room-compiler/src/main/kotlin/androidx/room/solver/shortcut/binder/CoroutineDeleteOrUpdateFunctionBinder.kt
similarity index 91%
rename from room/room-compiler/src/main/kotlin/androidx/room/solver/shortcut/binder/CoroutineDeleteOrUpdateMethodBinder.kt
rename to room/room-compiler/src/main/kotlin/androidx/room/solver/shortcut/binder/CoroutineDeleteOrUpdateFunctionBinder.kt
index 348f3a1..4799df2 100644
--- a/room/room-compiler/src/main/kotlin/androidx/room/solver/shortcut/binder/CoroutineDeleteOrUpdateMethodBinder.kt
+++ b/room/room-compiler/src/main/kotlin/androidx/room/solver/shortcut/binder/CoroutineDeleteOrUpdateFunctionBinder.kt
@@ -26,15 +26,15 @@
import androidx.room.ext.RoomMemberNames.DB_UTIL_PERFORM_SUSPENDING
import androidx.room.ext.SQLiteDriverTypeNames
import androidx.room.solver.CodeGenScope
-import androidx.room.solver.shortcut.result.DeleteOrUpdateMethodAdapter
+import androidx.room.solver.shortcut.result.DeleteOrUpdateFunctionAdapter
import androidx.room.vo.ShortcutQueryParameter
/** Binder for suspending delete and update methods. */
-class CoroutineDeleteOrUpdateMethodBinder(
+class CoroutineDeleteOrUpdateFunctionBinder(
val typeArg: XType,
- adapter: DeleteOrUpdateMethodAdapter?,
+ adapter: DeleteOrUpdateFunctionAdapter?,
private val continuationParamName: String
-) : DeleteOrUpdateMethodBinder(adapter) {
+) : DeleteOrUpdateFunctionBinder(adapter) {
override fun convertAndReturn(
parameters: List<ShortcutQueryParameter>,
@@ -62,7 +62,7 @@
javaLambdaSyntaxAvailable = scope.javaLambdaSyntaxAvailable
) {
override fun XCodeBlock.Builder.body(scope: CodeGenScope) {
- adapter.generateMethodBody(
+ adapter.generateFunctionBody(
scope = scope,
parameters = parameters,
adapters = adapters,
diff --git a/room/room-compiler/src/main/kotlin/androidx/room/solver/shortcut/binder/CoroutineInsertOrUpsertMethodBinder.kt b/room/room-compiler/src/main/kotlin/androidx/room/solver/shortcut/binder/CoroutineInsertOrUpsertFunctionBinder.kt
similarity index 91%
rename from room/room-compiler/src/main/kotlin/androidx/room/solver/shortcut/binder/CoroutineInsertOrUpsertMethodBinder.kt
rename to room/room-compiler/src/main/kotlin/androidx/room/solver/shortcut/binder/CoroutineInsertOrUpsertFunctionBinder.kt
index e8043e3..dae6d52b 100644
--- a/room/room-compiler/src/main/kotlin/androidx/room/solver/shortcut/binder/CoroutineInsertOrUpsertMethodBinder.kt
+++ b/room/room-compiler/src/main/kotlin/androidx/room/solver/shortcut/binder/CoroutineInsertOrUpsertFunctionBinder.kt
@@ -25,15 +25,15 @@
import androidx.room.ext.RoomMemberNames.DB_UTIL_PERFORM_SUSPENDING
import androidx.room.ext.SQLiteDriverTypeNames
import androidx.room.solver.CodeGenScope
-import androidx.room.solver.shortcut.result.InsertOrUpsertMethodAdapter
+import androidx.room.solver.shortcut.result.InsertOrUpsertFunctionAdapter
import androidx.room.vo.ShortcutQueryParameter
/** Binder for suspending insert or upsert methods. */
-class CoroutineInsertOrUpsertMethodBinder(
+class CoroutineInsertOrUpsertFunctionBinder(
val typeArg: XType,
- adapter: InsertOrUpsertMethodAdapter?,
+ adapter: InsertOrUpsertFunctionAdapter?,
private val continuationParamName: String
-) : InsertOrUpsertMethodBinder(adapter) {
+) : InsertOrUpsertFunctionBinder(adapter) {
override fun convertAndReturn(
parameters: List<ShortcutQueryParameter>,
@@ -61,7 +61,7 @@
javaLambdaSyntaxAvailable = scope.javaLambdaSyntaxAvailable
) {
override fun XCodeBlock.Builder.body(scope: CodeGenScope) {
- adapter.generateMethodBody(
+ adapter.generateFunctionBody(
scope = scope,
parameters = parameters,
adapters = adapters,
diff --git a/room/room-compiler/src/main/kotlin/androidx/room/solver/shortcut/binder/DeleteOrUpdateMethodBinder.kt b/room/room-compiler/src/main/kotlin/androidx/room/solver/shortcut/binder/DeleteOrUpdateFunctionBinder.kt
similarity index 72%
rename from room/room-compiler/src/main/kotlin/androidx/room/solver/shortcut/binder/DeleteOrUpdateMethodBinder.kt
rename to room/room-compiler/src/main/kotlin/androidx/room/solver/shortcut/binder/DeleteOrUpdateFunctionBinder.kt
index 25342d5..525256e 100644
--- a/room/room-compiler/src/main/kotlin/androidx/room/solver/shortcut/binder/DeleteOrUpdateMethodBinder.kt
+++ b/room/room-compiler/src/main/kotlin/androidx/room/solver/shortcut/binder/DeleteOrUpdateFunctionBinder.kt
@@ -19,17 +19,18 @@
import androidx.room.compiler.codegen.XPropertySpec
import androidx.room.compiler.codegen.XTypeSpec
import androidx.room.solver.CodeGenScope
-import androidx.room.solver.shortcut.result.DeleteOrUpdateMethodAdapter
+import androidx.room.solver.shortcut.result.DeleteOrUpdateFunctionAdapter
import androidx.room.vo.ShortcutQueryParameter
/**
- * Connects the delete or update method, the database and the [DeleteOrUpdateMethodAdapter].
+ * Connects the delete or update method, the database and the [DeleteOrUpdateFunctionAdapter].
*
- * The default implementation is [InstantDeleteOrUpdateMethodBinder] that executes the delete/update
- * synchronously. If the delete/update is deferred, rather than synchronously, alternatives
- * implementations can be implemented using this interface (e.g. RxJava, coroutines etc).
+ * The default implementation is [InstantDeleteOrUpdateFunctionBinder] that executes the
+ * delete/update synchronously. If the delete/update is deferred, rather than synchronously,
+ * alternatives implementations can be implemented using this interface (e.g. RxJava, coroutines
+ * etc).
*/
-abstract class DeleteOrUpdateMethodBinder(val adapter: DeleteOrUpdateMethodAdapter?) {
+abstract class DeleteOrUpdateFunctionBinder(val adapter: DeleteOrUpdateFunctionAdapter?) {
/**
* Received the delete/update method parameters, the adapters and generates the code that runs
diff --git a/room/room-compiler/src/main/kotlin/androidx/room/solver/shortcut/binder/InsertOrUpsertMethodBinder.kt b/room/room-compiler/src/main/kotlin/androidx/room/solver/shortcut/binder/InsertOrUpsertFunctionBinder.kt
similarity index 85%
rename from room/room-compiler/src/main/kotlin/androidx/room/solver/shortcut/binder/InsertOrUpsertMethodBinder.kt
rename to room/room-compiler/src/main/kotlin/androidx/room/solver/shortcut/binder/InsertOrUpsertFunctionBinder.kt
index 67fb0fd..fb180a4 100644
--- a/room/room-compiler/src/main/kotlin/androidx/room/solver/shortcut/binder/InsertOrUpsertMethodBinder.kt
+++ b/room/room-compiler/src/main/kotlin/androidx/room/solver/shortcut/binder/InsertOrUpsertFunctionBinder.kt
@@ -18,11 +18,11 @@
import androidx.room.compiler.codegen.XPropertySpec
import androidx.room.solver.CodeGenScope
-import androidx.room.solver.shortcut.result.InsertOrUpsertMethodAdapter
+import androidx.room.solver.shortcut.result.InsertOrUpsertFunctionAdapter
import androidx.room.vo.ShortcutQueryParameter
-/** Connects the insert and upsert method, the database and the [InsertOrUpsertMethodAdapter]. */
-abstract class InsertOrUpsertMethodBinder(val adapter: InsertOrUpsertMethodAdapter?) {
+/** Connects the insert and upsert method, the database and the [InsertOrUpsertFunctionAdapter]. */
+abstract class InsertOrUpsertFunctionBinder(val adapter: InsertOrUpsertFunctionAdapter?) {
/**
* Received an insert or upsert method parameters, their adapters and generations the code that
diff --git a/room/room-compiler/src/main/kotlin/androidx/room/solver/shortcut/binder/InstantDeleteOrUpdateMethodBinder.kt b/room/room-compiler/src/main/kotlin/androidx/room/solver/shortcut/binder/InstantDeleteOrUpdateFunctionBinder.kt
similarity index 92%
rename from room/room-compiler/src/main/kotlin/androidx/room/solver/shortcut/binder/InstantDeleteOrUpdateMethodBinder.kt
rename to room/room-compiler/src/main/kotlin/androidx/room/solver/shortcut/binder/InstantDeleteOrUpdateFunctionBinder.kt
index 34e4967..6dcbdb3 100644
--- a/room/room-compiler/src/main/kotlin/androidx/room/solver/shortcut/binder/InstantDeleteOrUpdateMethodBinder.kt
+++ b/room/room-compiler/src/main/kotlin/androidx/room/solver/shortcut/binder/InstantDeleteOrUpdateFunctionBinder.kt
@@ -27,12 +27,12 @@
import androidx.room.ext.SQLiteDriverTypeNames
import androidx.room.ext.isNotVoid
import androidx.room.solver.CodeGenScope
-import androidx.room.solver.shortcut.result.DeleteOrUpdateMethodAdapter
+import androidx.room.solver.shortcut.result.DeleteOrUpdateFunctionAdapter
import androidx.room.vo.ShortcutQueryParameter
/** Binder that knows how to write instant (blocking) delete and update methods. */
-class InstantDeleteOrUpdateMethodBinder(adapter: DeleteOrUpdateMethodAdapter?) :
- DeleteOrUpdateMethodBinder(adapter) {
+class InstantDeleteOrUpdateFunctionBinder(adapter: DeleteOrUpdateFunctionAdapter?) :
+ DeleteOrUpdateFunctionBinder(adapter) {
override fun convertAndReturn(
parameters: List<ShortcutQueryParameter>,
@@ -59,7 +59,7 @@
javaLambdaSyntaxAvailable = scope.javaLambdaSyntaxAvailable
) {
override fun XCodeBlock.Builder.body(scope: CodeGenScope) {
- adapter.generateMethodBody(
+ adapter.generateFunctionBody(
scope = scope,
parameters = parameters,
adapters = adapters,
diff --git a/room/room-compiler/src/main/kotlin/androidx/room/solver/shortcut/binder/InstantInsertOrUpsertMethodBinder.kt b/room/room-compiler/src/main/kotlin/androidx/room/solver/shortcut/binder/InstantInsertOrUpsertFunctionBinder.kt
similarity index 91%
rename from room/room-compiler/src/main/kotlin/androidx/room/solver/shortcut/binder/InstantInsertOrUpsertMethodBinder.kt
rename to room/room-compiler/src/main/kotlin/androidx/room/solver/shortcut/binder/InstantInsertOrUpsertFunctionBinder.kt
index 322e206..a740eeb 100644
--- a/room/room-compiler/src/main/kotlin/androidx/room/solver/shortcut/binder/InstantInsertOrUpsertMethodBinder.kt
+++ b/room/room-compiler/src/main/kotlin/androidx/room/solver/shortcut/binder/InstantInsertOrUpsertFunctionBinder.kt
@@ -26,12 +26,12 @@
import androidx.room.ext.SQLiteDriverTypeNames
import androidx.room.ext.isNotVoid
import androidx.room.solver.CodeGenScope
-import androidx.room.solver.shortcut.result.InsertOrUpsertMethodAdapter
+import androidx.room.solver.shortcut.result.InsertOrUpsertFunctionAdapter
import androidx.room.vo.ShortcutQueryParameter
/** Binder that knows how to write instant (blocking) insert or upsert methods. */
-class InstantInsertOrUpsertMethodBinder(adapter: InsertOrUpsertMethodAdapter?) :
- InsertOrUpsertMethodBinder(adapter) {
+class InstantInsertOrUpsertFunctionBinder(adapter: InsertOrUpsertFunctionAdapter?) :
+ InsertOrUpsertFunctionBinder(adapter) {
override fun convertAndReturn(
parameters: List<ShortcutQueryParameter>,
@@ -58,7 +58,7 @@
javaLambdaSyntaxAvailable = scope.javaLambdaSyntaxAvailable
) {
override fun XCodeBlock.Builder.body(scope: CodeGenScope) {
- adapter.generateMethodBody(
+ adapter.generateFunctionBody(
scope = scope,
parameters = parameters,
adapters = adapters,
diff --git a/room/room-compiler/src/main/kotlin/androidx/room/solver/shortcut/binder/LambdaDeleteOrUpdateMethodBinder.kt b/room/room-compiler/src/main/kotlin/androidx/room/solver/shortcut/binder/LambdaDeleteOrUpdateFunctionBinder.kt
similarity index 91%
rename from room/room-compiler/src/main/kotlin/androidx/room/solver/shortcut/binder/LambdaDeleteOrUpdateMethodBinder.kt
rename to room/room-compiler/src/main/kotlin/androidx/room/solver/shortcut/binder/LambdaDeleteOrUpdateFunctionBinder.kt
index 3cdca44..1d01edb 100644
--- a/room/room-compiler/src/main/kotlin/androidx/room/solver/shortcut/binder/LambdaDeleteOrUpdateMethodBinder.kt
+++ b/room/room-compiler/src/main/kotlin/androidx/room/solver/shortcut/binder/LambdaDeleteOrUpdateFunctionBinder.kt
@@ -25,7 +25,7 @@
import androidx.room.ext.LambdaSpec
import androidx.room.ext.SQLiteDriverTypeNames
import androidx.room.solver.CodeGenScope
-import androidx.room.solver.shortcut.result.DeleteOrUpdateMethodAdapter
+import androidx.room.solver.shortcut.result.DeleteOrUpdateFunctionAdapter
import androidx.room.vo.ShortcutQueryParameter
/**
@@ -34,11 +34,11 @@
* This binder generates code that invokes [functionName] with a lambda whose body will delegate to
* the given [adapter].
*/
-class LambdaDeleteOrUpdateMethodBinder(
+class LambdaDeleteOrUpdateFunctionBinder(
val typeArg: XType,
val functionName: XMemberName,
- adapter: DeleteOrUpdateMethodAdapter?
-) : DeleteOrUpdateMethodBinder(adapter) {
+ adapter: DeleteOrUpdateFunctionAdapter?
+) : DeleteOrUpdateFunctionBinder(adapter) {
override fun convertAndReturn(
parameters: List<ShortcutQueryParameter>,
adapters: Map<String, Pair<XPropertySpec, XTypeSpec>>,
@@ -64,7 +64,7 @@
javaLambdaSyntaxAvailable = scope.javaLambdaSyntaxAvailable
) {
override fun XCodeBlock.Builder.body(scope: CodeGenScope) {
- adapter.generateMethodBody(
+ adapter.generateFunctionBody(
scope = scope,
parameters = parameters,
adapters = adapters,
diff --git a/room/room-compiler/src/main/kotlin/androidx/room/solver/shortcut/binder/LambdaInsertOrUpsertMethodBinder.kt b/room/room-compiler/src/main/kotlin/androidx/room/solver/shortcut/binder/LambdaInsertOrUpsertFunctionBinder.kt
similarity index 91%
rename from room/room-compiler/src/main/kotlin/androidx/room/solver/shortcut/binder/LambdaInsertOrUpsertMethodBinder.kt
rename to room/room-compiler/src/main/kotlin/androidx/room/solver/shortcut/binder/LambdaInsertOrUpsertFunctionBinder.kt
index af0a2ea..2619f3d 100644
--- a/room/room-compiler/src/main/kotlin/androidx/room/solver/shortcut/binder/LambdaInsertOrUpsertMethodBinder.kt
+++ b/room/room-compiler/src/main/kotlin/androidx/room/solver/shortcut/binder/LambdaInsertOrUpsertFunctionBinder.kt
@@ -24,7 +24,7 @@
import androidx.room.ext.LambdaSpec
import androidx.room.ext.SQLiteDriverTypeNames
import androidx.room.solver.CodeGenScope
-import androidx.room.solver.shortcut.result.InsertOrUpsertMethodAdapter
+import androidx.room.solver.shortcut.result.InsertOrUpsertFunctionAdapter
import androidx.room.vo.ShortcutQueryParameter
/**
@@ -33,11 +33,11 @@
* This binder generates code that invokes [functionName] with a lambda whose body will delegate to
* the given [adapter].
*/
-class LambdaInsertOrUpsertMethodBinder(
+class LambdaInsertOrUpsertFunctionBinder(
val typeArg: XType,
val functionName: XMemberName,
- adapter: InsertOrUpsertMethodAdapter?
-) : InsertOrUpsertMethodBinder(adapter) {
+ adapter: InsertOrUpsertFunctionAdapter?
+) : InsertOrUpsertFunctionBinder(adapter) {
override fun convertAndReturn(
parameters: List<ShortcutQueryParameter>,
@@ -64,7 +64,7 @@
javaLambdaSyntaxAvailable = scope.javaLambdaSyntaxAvailable
) {
override fun XCodeBlock.Builder.body(scope: CodeGenScope) {
- adapter.generateMethodBody(
+ adapter.generateFunctionBody(
scope = scope,
parameters = parameters,
adapters = adapters,
diff --git a/room/room-compiler/src/main/kotlin/androidx/room/solver/shortcut/binderprovider/DeleteOrUpdateMethodBinderProvider.kt b/room/room-compiler/src/main/kotlin/androidx/room/solver/shortcut/binderprovider/DeleteOrUpdateFunctionBinderProvider.kt
similarity index 70%
rename from room/room-compiler/src/main/kotlin/androidx/room/solver/shortcut/binderprovider/DeleteOrUpdateMethodBinderProvider.kt
rename to room/room-compiler/src/main/kotlin/androidx/room/solver/shortcut/binderprovider/DeleteOrUpdateFunctionBinderProvider.kt
index bf22009..d6d5215 100644
--- a/room/room-compiler/src/main/kotlin/androidx/room/solver/shortcut/binderprovider/DeleteOrUpdateMethodBinderProvider.kt
+++ b/room/room-compiler/src/main/kotlin/androidx/room/solver/shortcut/binderprovider/DeleteOrUpdateFunctionBinderProvider.kt
@@ -17,15 +17,15 @@
package androidx.room.solver.shortcut.binderprovider
import androidx.room.compiler.processing.XType
-import androidx.room.solver.shortcut.binder.DeleteOrUpdateMethodBinder
-import androidx.room.solver.shortcut.result.DeleteOrUpdateMethodAdapter
+import androidx.room.solver.shortcut.binder.DeleteOrUpdateFunctionBinder
+import androidx.room.solver.shortcut.result.DeleteOrUpdateFunctionAdapter
/** Provider for delete or update binders */
-interface DeleteOrUpdateMethodBinderProvider {
+interface DeleteOrUpdateFunctionBinderProvider {
- /** Check whether the [XType] can be handled by the [DeleteOrUpdateMethodBinder] */
+ /** Check whether the [XType] can be handled by the [DeleteOrUpdateFunctionBinder] */
fun matches(declared: XType): Boolean
- /** Provider of [DeleteOrUpdateMethodAdapter], based on the [XType] */
- fun provide(declared: XType): DeleteOrUpdateMethodBinder
+ /** Provider of [DeleteOrUpdateFunctionAdapter], based on the [XType] */
+ fun provide(declared: XType): DeleteOrUpdateFunctionBinder
}
diff --git a/room/room-compiler/src/main/kotlin/androidx/room/solver/shortcut/binderprovider/GuavaListenableFutureDeleteOrUpdateMethodBinderProvider.kt b/room/room-compiler/src/main/kotlin/androidx/room/solver/shortcut/binderprovider/GuavaListenableFutureDeleteOrUpdateFunctionBinderProvider.kt
similarity index 85%
rename from room/room-compiler/src/main/kotlin/androidx/room/solver/shortcut/binderprovider/GuavaListenableFutureDeleteOrUpdateMethodBinderProvider.kt
rename to room/room-compiler/src/main/kotlin/androidx/room/solver/shortcut/binderprovider/GuavaListenableFutureDeleteOrUpdateFunctionBinderProvider.kt
index bca756c..88e0680 100644
--- a/room/room-compiler/src/main/kotlin/androidx/room/solver/shortcut/binderprovider/GuavaListenableFutureDeleteOrUpdateMethodBinderProvider.kt
+++ b/room/room-compiler/src/main/kotlin/androidx/room/solver/shortcut/binderprovider/GuavaListenableFutureDeleteOrUpdateFunctionBinderProvider.kt
@@ -24,12 +24,12 @@
import androidx.room.ext.RoomGuavaTypeNames.GUAVA_ROOM_MARKER
import androidx.room.processor.Context
import androidx.room.processor.ProcessorErrors
-import androidx.room.solver.shortcut.binder.DeleteOrUpdateMethodBinder
-import androidx.room.solver.shortcut.binder.LambdaDeleteOrUpdateMethodBinder
+import androidx.room.solver.shortcut.binder.DeleteOrUpdateFunctionBinder
+import androidx.room.solver.shortcut.binder.LambdaDeleteOrUpdateFunctionBinder
/** Provider for Guava ListenableFuture binders. */
-class GuavaListenableFutureDeleteOrUpdateMethodBinderProvider(val context: Context) :
- DeleteOrUpdateMethodBinderProvider {
+class GuavaListenableFutureDeleteOrUpdateFunctionBinderProvider(val context: Context) :
+ DeleteOrUpdateFunctionBinderProvider {
private val hasGuavaRoom by lazy {
context.processingEnv.getElementsFromPackage(GUAVA_ROOM_MARKER.packageName).isNotEmpty()
@@ -39,7 +39,7 @@
declared.typeArguments.size == 1 &&
declared.rawType.asTypeName() == GuavaUtilConcurrentTypeNames.LISTENABLE_FUTURE
- override fun provide(declared: XType): DeleteOrUpdateMethodBinder {
+ override fun provide(declared: XType): DeleteOrUpdateFunctionBinder {
if (!hasGuavaRoom) {
context.logger.e(ProcessorErrors.MISSING_ROOM_GUAVA_ARTIFACT)
}
@@ -49,7 +49,7 @@
context.logger.e(ProcessorErrors.NONNULL_VOID)
}
- return LambdaDeleteOrUpdateMethodBinder(
+ return LambdaDeleteOrUpdateFunctionBinder(
typeArg = typeArg,
functionName = GUAVA_ROOM_CREATE_LISTENABLE_FUTURE,
adapter = context.typeAdapterStore.findDeleteOrUpdateAdapter(typeArg)
diff --git a/room/room-compiler/src/main/kotlin/androidx/room/solver/shortcut/binderprovider/GuavaListenableFutureInsertOrUpsertMethodBinderProvider.kt b/room/room-compiler/src/main/kotlin/androidx/room/solver/shortcut/binderprovider/GuavaListenableFutureInsertOrUpsertFunctionBinderProvider.kt
similarity index 88%
rename from room/room-compiler/src/main/kotlin/androidx/room/solver/shortcut/binderprovider/GuavaListenableFutureInsertOrUpsertMethodBinderProvider.kt
rename to room/room-compiler/src/main/kotlin/androidx/room/solver/shortcut/binderprovider/GuavaListenableFutureInsertOrUpsertFunctionBinderProvider.kt
index 0153c10..3a67fa9 100644
--- a/room/room-compiler/src/main/kotlin/androidx/room/solver/shortcut/binderprovider/GuavaListenableFutureInsertOrUpsertMethodBinderProvider.kt
+++ b/room/room-compiler/src/main/kotlin/androidx/room/solver/shortcut/binderprovider/GuavaListenableFutureInsertOrUpsertFunctionBinderProvider.kt
@@ -24,13 +24,13 @@
import androidx.room.ext.RoomGuavaTypeNames.GUAVA_ROOM_MARKER
import androidx.room.processor.Context
import androidx.room.processor.ProcessorErrors
-import androidx.room.solver.shortcut.binder.InsertOrUpsertMethodBinder
-import androidx.room.solver.shortcut.binder.LambdaInsertOrUpsertMethodBinder
+import androidx.room.solver.shortcut.binder.InsertOrUpsertFunctionBinder
+import androidx.room.solver.shortcut.binder.LambdaInsertOrUpsertFunctionBinder
import androidx.room.vo.ShortcutQueryParameter
/** Provider for Guava ListenableFuture binders. */
-class GuavaListenableFutureInsertOrUpsertMethodBinderProvider(private val context: Context) :
- InsertOrUpsertMethodBinderProvider {
+class GuavaListenableFutureInsertOrUpsertFunctionBinderProvider(private val context: Context) :
+ InsertOrUpsertFunctionBinderProvider {
private val hasGuavaRoom by lazy {
context.processingEnv.findTypeElement(GUAVA_ROOM_MARKER.canonicalName) != null
@@ -44,7 +44,7 @@
declared: XType,
params: List<ShortcutQueryParameter>,
forUpsert: Boolean
- ): InsertOrUpsertMethodBinder {
+ ): InsertOrUpsertFunctionBinder {
if (!hasGuavaRoom) {
context.logger.e(ProcessorErrors.MISSING_ROOM_GUAVA_ARTIFACT)
}
@@ -54,7 +54,7 @@
context.logger.e(ProcessorErrors.NONNULL_VOID)
}
- return LambdaInsertOrUpsertMethodBinder(
+ return LambdaInsertOrUpsertFunctionBinder(
typeArg = typeArg,
functionName = GUAVA_ROOM_CREATE_LISTENABLE_FUTURE,
adapter =
diff --git a/room/room-compiler/src/main/kotlin/androidx/room/solver/shortcut/binderprovider/InsertOrUpsertMethodBinderProvider.kt b/room/room-compiler/src/main/kotlin/androidx/room/solver/shortcut/binderprovider/InsertOrUpsertFunctionBinderProvider.kt
similarity index 73%
rename from room/room-compiler/src/main/kotlin/androidx/room/solver/shortcut/binderprovider/InsertOrUpsertMethodBinderProvider.kt
rename to room/room-compiler/src/main/kotlin/androidx/room/solver/shortcut/binderprovider/InsertOrUpsertFunctionBinderProvider.kt
index 57e8bba..dac8c97 100644
--- a/room/room-compiler/src/main/kotlin/androidx/room/solver/shortcut/binderprovider/InsertOrUpsertMethodBinderProvider.kt
+++ b/room/room-compiler/src/main/kotlin/androidx/room/solver/shortcut/binderprovider/InsertOrUpsertFunctionBinderProvider.kt
@@ -17,19 +17,21 @@
package androidx.room.solver.shortcut.binderprovider
import androidx.room.compiler.processing.XType
-import androidx.room.solver.shortcut.binder.InsertOrUpsertMethodBinder
+import androidx.room.solver.shortcut.binder.InsertOrUpsertFunctionBinder
import androidx.room.vo.ShortcutQueryParameter
-/** Provider for insert and upsert method binders. */
-interface InsertOrUpsertMethodBinderProvider {
+/** Provider for insert and upsert function binders. */
+interface InsertOrUpsertFunctionBinderProvider {
- /** Check whether the [XType] can be handled by the [InsertOrUpsertMethodBinder] */
+ /** Check whether the [XType] can be handled by the [InsertOrUpsertFunctionBinder] */
fun matches(declared: XType): Boolean
- /** Provider of [InsertOrUpsertMethodBinder], based on the [XType] and the list of parameters */
+ /**
+ * Provider of [InsertOrUpsertFunctionBinder], based on the [XType] and the list of parameters
+ */
fun provide(
declared: XType,
params: List<ShortcutQueryParameter>,
forUpsert: Boolean
- ): InsertOrUpsertMethodBinder
+ ): InsertOrUpsertFunctionBinder
}
diff --git a/room/room-compiler/src/main/kotlin/androidx/room/solver/shortcut/binderprovider/InstantDeleteOrUpdateMethodBinderProvider.kt b/room/room-compiler/src/main/kotlin/androidx/room/solver/shortcut/binderprovider/InstantDeleteOrUpdateFunctionBinderProvider.kt
similarity index 69%
rename from room/room-compiler/src/main/kotlin/androidx/room/solver/shortcut/binderprovider/InstantDeleteOrUpdateMethodBinderProvider.kt
rename to room/room-compiler/src/main/kotlin/androidx/room/solver/shortcut/binderprovider/InstantDeleteOrUpdateFunctionBinderProvider.kt
index 3e8ef08..8abbd94 100644
--- a/room/room-compiler/src/main/kotlin/androidx/room/solver/shortcut/binderprovider/InstantDeleteOrUpdateMethodBinderProvider.kt
+++ b/room/room-compiler/src/main/kotlin/androidx/room/solver/shortcut/binderprovider/InstantDeleteOrUpdateFunctionBinderProvider.kt
@@ -18,17 +18,17 @@
import androidx.room.compiler.processing.XType
import androidx.room.processor.Context
-import androidx.room.solver.shortcut.binder.DeleteOrUpdateMethodBinder
-import androidx.room.solver.shortcut.binder.InstantDeleteOrUpdateMethodBinder
+import androidx.room.solver.shortcut.binder.DeleteOrUpdateFunctionBinder
+import androidx.room.solver.shortcut.binder.InstantDeleteOrUpdateFunctionBinder
-/** Provider for instant (blocking) delete or update method binder */
-class InstantDeleteOrUpdateMethodBinderProvider(private val context: Context) :
- DeleteOrUpdateMethodBinderProvider {
+/** Provider for instant (blocking) delete or update function binder */
+class InstantDeleteOrUpdateFunctionBinderProvider(private val context: Context) :
+ DeleteOrUpdateFunctionBinderProvider {
override fun matches(declared: XType) = true
- override fun provide(declared: XType): DeleteOrUpdateMethodBinder {
+ override fun provide(declared: XType): DeleteOrUpdateFunctionBinder {
val adapter = context.typeAdapterStore.findDeleteOrUpdateAdapter(declared)
- return InstantDeleteOrUpdateMethodBinder(adapter)
+ return InstantDeleteOrUpdateFunctionBinder(adapter)
}
}
diff --git a/room/room-compiler/src/main/kotlin/androidx/room/solver/shortcut/binderprovider/InstantInsertOrUpsertMethodBinder.kt b/room/room-compiler/src/main/kotlin/androidx/room/solver/shortcut/binderprovider/InstantInsertOrUpsertFunctionBinder.kt
similarity index 77%
rename from room/room-compiler/src/main/kotlin/androidx/room/solver/shortcut/binderprovider/InstantInsertOrUpsertMethodBinder.kt
rename to room/room-compiler/src/main/kotlin/androidx/room/solver/shortcut/binderprovider/InstantInsertOrUpsertFunctionBinder.kt
index e902119..99fcd51 100644
--- a/room/room-compiler/src/main/kotlin/androidx/room/solver/shortcut/binderprovider/InstantInsertOrUpsertMethodBinder.kt
+++ b/room/room-compiler/src/main/kotlin/androidx/room/solver/shortcut/binderprovider/InstantInsertOrUpsertFunctionBinder.kt
@@ -18,13 +18,13 @@
import androidx.room.compiler.processing.XType
import androidx.room.processor.Context
-import androidx.room.solver.shortcut.binder.InsertOrUpsertMethodBinder
-import androidx.room.solver.shortcut.binder.InstantInsertOrUpsertMethodBinder
+import androidx.room.solver.shortcut.binder.InsertOrUpsertFunctionBinder
+import androidx.room.solver.shortcut.binder.InstantInsertOrUpsertFunctionBinder
import androidx.room.vo.ShortcutQueryParameter
-/** Provider for instant (blocking) insert or upsert method binder. */
-class InstantInsertOrUpsertMethodBinderProvider(private val context: Context) :
- InsertOrUpsertMethodBinderProvider {
+/** Provider for instant (blocking) insert or upsert function binders. */
+class InstantInsertOrUpsertFunctionBinderProvider(private val context: Context) :
+ InsertOrUpsertFunctionBinderProvider {
override fun matches(declared: XType) = true
@@ -32,8 +32,8 @@
declared: XType,
params: List<ShortcutQueryParameter>,
forUpsert: Boolean
- ): InsertOrUpsertMethodBinder {
- return InstantInsertOrUpsertMethodBinder(
+ ): InsertOrUpsertFunctionBinder {
+ return InstantInsertOrUpsertFunctionBinder(
if (forUpsert) {
context.typeAdapterStore.findUpsertAdapter(declared, params)
} else {
diff --git a/room/room-compiler/src/main/kotlin/androidx/room/solver/shortcut/binderprovider/RxCallableDeleteOrUpdateMethodBinderProvider.kt b/room/room-compiler/src/main/kotlin/androidx/room/solver/shortcut/binderprovider/RxCallableDeleteOrUpdateFunctionBinderProvider.kt
similarity index 70%
rename from room/room-compiler/src/main/kotlin/androidx/room/solver/shortcut/binderprovider/RxCallableDeleteOrUpdateMethodBinderProvider.kt
rename to room/room-compiler/src/main/kotlin/androidx/room/solver/shortcut/binderprovider/RxCallableDeleteOrUpdateFunctionBinderProvider.kt
index 535e608..d152405 100644
--- a/room/room-compiler/src/main/kotlin/androidx/room/solver/shortcut/binderprovider/RxCallableDeleteOrUpdateMethodBinderProvider.kt
+++ b/room/room-compiler/src/main/kotlin/androidx/room/solver/shortcut/binderprovider/RxCallableDeleteOrUpdateFunctionBinderProvider.kt
@@ -21,13 +21,13 @@
import androidx.room.ext.KotlinTypeNames
import androidx.room.processor.Context
import androidx.room.solver.RxType
-import androidx.room.solver.shortcut.binder.DeleteOrUpdateMethodBinder
-import androidx.room.solver.shortcut.binder.LambdaDeleteOrUpdateMethodBinder
+import androidx.room.solver.shortcut.binder.DeleteOrUpdateFunctionBinder
+import androidx.room.solver.shortcut.binder.LambdaDeleteOrUpdateFunctionBinder
/** Provider for Rx Callable binders. */
-open class RxCallableDeleteOrUpdateMethodBinderProvider
+open class RxCallableDeleteOrUpdateFunctionBinderProvider
internal constructor(val context: Context, private val rxType: RxType) :
- DeleteOrUpdateMethodBinderProvider {
+ DeleteOrUpdateFunctionBinderProvider {
/**
* [Single] and [Maybe] are generics but [Completable] is not so each implementation of this
@@ -42,10 +42,10 @@
return declared.rawType.asTypeName() == rxType.className
}
- override fun provide(declared: XType): DeleteOrUpdateMethodBinder {
+ override fun provide(declared: XType): DeleteOrUpdateFunctionBinder {
val typeArg = extractTypeArg(declared)
val adapter = context.typeAdapterStore.findDeleteOrUpdateAdapter(typeArg)
- return LambdaDeleteOrUpdateMethodBinder(
+ return LambdaDeleteOrUpdateFunctionBinder(
typeArg = typeArg,
functionName = rxType.factoryMethodName,
adapter = adapter
@@ -55,18 +55,18 @@
companion object {
fun getAll(context: Context) =
listOf(
- RxSingleOrMaybeDeleteOrUpdateMethodBinderProvider(context, RxType.RX2_SINGLE),
- RxSingleOrMaybeDeleteOrUpdateMethodBinderProvider(context, RxType.RX2_MAYBE),
- RxCompletableDeleteOrUpdateMethodBinderProvider(context, RxType.RX2_COMPLETABLE),
- RxSingleOrMaybeDeleteOrUpdateMethodBinderProvider(context, RxType.RX3_SINGLE),
- RxSingleOrMaybeDeleteOrUpdateMethodBinderProvider(context, RxType.RX3_MAYBE),
- RxCompletableDeleteOrUpdateMethodBinderProvider(context, RxType.RX3_COMPLETABLE)
+ RxSingleOrMaybeDeleteOrUpdateFunctionBinderProvider(context, RxType.RX2_SINGLE),
+ RxSingleOrMaybeDeleteOrUpdateFunctionBinderProvider(context, RxType.RX2_MAYBE),
+ RxCompletableDeleteOrUpdateFunctionBinderProvider(context, RxType.RX2_COMPLETABLE),
+ RxSingleOrMaybeDeleteOrUpdateFunctionBinderProvider(context, RxType.RX3_SINGLE),
+ RxSingleOrMaybeDeleteOrUpdateFunctionBinderProvider(context, RxType.RX3_MAYBE),
+ RxCompletableDeleteOrUpdateFunctionBinderProvider(context, RxType.RX3_COMPLETABLE)
)
}
}
-private class RxCompletableDeleteOrUpdateMethodBinderProvider(context: Context, rxType: RxType) :
- RxCallableDeleteOrUpdateMethodBinderProvider(context, rxType) {
+private class RxCompletableDeleteOrUpdateFunctionBinderProvider(context: Context, rxType: RxType) :
+ RxCallableDeleteOrUpdateFunctionBinderProvider(context, rxType) {
private val completableType: XRawType? by lazy {
context.processingEnv.findType(rxType.className.canonicalName)?.rawType
@@ -87,8 +87,10 @@
}
}
-private class RxSingleOrMaybeDeleteOrUpdateMethodBinderProvider(context: Context, rxType: RxType) :
- RxCallableDeleteOrUpdateMethodBinderProvider(context, rxType) {
+private class RxSingleOrMaybeDeleteOrUpdateFunctionBinderProvider(
+ context: Context,
+ rxType: RxType
+) : RxCallableDeleteOrUpdateFunctionBinderProvider(context, rxType) {
/** Since Maybe can have null values, the lambda returned must allow for null values. */
override fun extractTypeArg(declared: XType): XType =
diff --git a/room/room-compiler/src/main/kotlin/androidx/room/solver/shortcut/binderprovider/RxCallableInsertOrUpsertMethodBinderProvider.kt b/room/room-compiler/src/main/kotlin/androidx/room/solver/shortcut/binderprovider/RxCallableInsertOrUpsertFunctionBinderProvider.kt
similarity index 73%
rename from room/room-compiler/src/main/kotlin/androidx/room/solver/shortcut/binderprovider/RxCallableInsertOrUpsertMethodBinderProvider.kt
rename to room/room-compiler/src/main/kotlin/androidx/room/solver/shortcut/binderprovider/RxCallableInsertOrUpsertFunctionBinderProvider.kt
index 9b0223d..ef89ede 100644
--- a/room/room-compiler/src/main/kotlin/androidx/room/solver/shortcut/binderprovider/RxCallableInsertOrUpsertMethodBinderProvider.kt
+++ b/room/room-compiler/src/main/kotlin/androidx/room/solver/shortcut/binderprovider/RxCallableInsertOrUpsertFunctionBinderProvider.kt
@@ -21,14 +21,14 @@
import androidx.room.ext.KotlinTypeNames
import androidx.room.processor.Context
import androidx.room.solver.RxType
-import androidx.room.solver.shortcut.binder.InsertOrUpsertMethodBinder
-import androidx.room.solver.shortcut.binder.LambdaInsertOrUpsertMethodBinder
+import androidx.room.solver.shortcut.binder.InsertOrUpsertFunctionBinder
+import androidx.room.solver.shortcut.binder.LambdaInsertOrUpsertFunctionBinder
import androidx.room.vo.ShortcutQueryParameter
/** Provider for Rx Callable binders. */
-open class RxCallableInsertOrUpsertMethodBinderProvider
+open class RxCallableInsertOrUpsertFunctionBinderProvider
internal constructor(val context: Context, private val rxType: RxType) :
- InsertOrUpsertMethodBinderProvider {
+ InsertOrUpsertFunctionBinderProvider {
/**
* [Single] and [Maybe] are generics but [Completable] is not so each implementation of this
@@ -47,7 +47,7 @@
declared: XType,
params: List<ShortcutQueryParameter>,
forUpsert: Boolean
- ): InsertOrUpsertMethodBinder {
+ ): InsertOrUpsertFunctionBinder {
val typeArg = extractTypeArg(declared)
val adapter =
if (forUpsert) {
@@ -55,7 +55,7 @@
} else {
context.typeAdapterStore.findInsertAdapter(typeArg, params)
}
- return LambdaInsertOrUpsertMethodBinder(
+ return LambdaInsertOrUpsertFunctionBinder(
typeArg = typeArg,
functionName = rxType.factoryMethodName,
adapter = adapter
@@ -65,18 +65,18 @@
companion object {
fun getAll(context: Context) =
listOf(
- RxSingleOrMaybeInsertOrUpsertMethodBinderProvider(context, RxType.RX2_SINGLE),
- RxSingleOrMaybeInsertOrUpsertMethodBinderProvider(context, RxType.RX2_MAYBE),
- RxCompletableInsertOrUpsertMethodBinderProvider(context, RxType.RX2_COMPLETABLE),
- RxSingleOrMaybeInsertOrUpsertMethodBinderProvider(context, RxType.RX3_SINGLE),
- RxSingleOrMaybeInsertOrUpsertMethodBinderProvider(context, RxType.RX3_MAYBE),
- RxCompletableInsertOrUpsertMethodBinderProvider(context, RxType.RX3_COMPLETABLE)
+ RxSingleOrMaybeInsertOrUpsertFunctionBinderProvider(context, RxType.RX2_SINGLE),
+ RxSingleOrMaybeInsertOrUpsertFunctionBinderProvider(context, RxType.RX2_MAYBE),
+ RxCompletableInsertOrUpsertFunctionBinderProvider(context, RxType.RX2_COMPLETABLE),
+ RxSingleOrMaybeInsertOrUpsertFunctionBinderProvider(context, RxType.RX3_SINGLE),
+ RxSingleOrMaybeInsertOrUpsertFunctionBinderProvider(context, RxType.RX3_MAYBE),
+ RxCompletableInsertOrUpsertFunctionBinderProvider(context, RxType.RX3_COMPLETABLE)
)
}
}
-private class RxCompletableInsertOrUpsertMethodBinderProvider(context: Context, rxType: RxType) :
- RxCallableInsertOrUpsertMethodBinderProvider(context, rxType) {
+private class RxCompletableInsertOrUpsertFunctionBinderProvider(context: Context, rxType: RxType) :
+ RxCallableInsertOrUpsertFunctionBinderProvider(context, rxType) {
private val completableType: XRawType? by lazy {
context.processingEnv.findType(rxType.className.canonicalName)?.rawType
@@ -97,8 +97,10 @@
}
}
-private class RxSingleOrMaybeInsertOrUpsertMethodBinderProvider(context: Context, rxType: RxType) :
- RxCallableInsertOrUpsertMethodBinderProvider(context, rxType) {
+private class RxSingleOrMaybeInsertOrUpsertFunctionBinderProvider(
+ context: Context,
+ rxType: RxType
+) : RxCallableInsertOrUpsertFunctionBinderProvider(context, rxType) {
/** Since Maybe can have null values, the lambda returned must allow for null values. */
override fun extractTypeArg(declared: XType): XType =
diff --git a/room/room-compiler/src/main/kotlin/androidx/room/solver/shortcut/result/DeleteOrUpdateMethodAdapter.kt b/room/room-compiler/src/main/kotlin/androidx/room/solver/shortcut/result/DeleteOrUpdateFunctionAdapter.kt
similarity index 90%
rename from room/room-compiler/src/main/kotlin/androidx/room/solver/shortcut/result/DeleteOrUpdateMethodAdapter.kt
rename to room/room-compiler/src/main/kotlin/androidx/room/solver/shortcut/result/DeleteOrUpdateFunctionAdapter.kt
index 512d877..e89ebbd 100644
--- a/room/room-compiler/src/main/kotlin/androidx/room/solver/shortcut/result/DeleteOrUpdateMethodAdapter.kt
+++ b/room/room-compiler/src/main/kotlin/androidx/room/solver/shortcut/result/DeleteOrUpdateFunctionAdapter.kt
@@ -32,12 +32,12 @@
import androidx.room.solver.CodeGenScope
import androidx.room.vo.ShortcutQueryParameter
-/** Class that knows how to generate a delete or update method body. */
-class DeleteOrUpdateMethodAdapter private constructor(val returnType: XType) {
+/** Class that knows how to generate a delete or update function body. */
+class DeleteOrUpdateFunctionAdapter private constructor(val returnType: XType) {
companion object {
- fun create(returnType: XType): DeleteOrUpdateMethodAdapter? {
+ fun create(returnType: XType): DeleteOrUpdateFunctionAdapter? {
if (isDeleteOrUpdateValid(returnType)) {
- return DeleteOrUpdateMethodAdapter(returnType)
+ return DeleteOrUpdateFunctionAdapter(returnType)
}
return null
}
@@ -50,7 +50,7 @@
}
}
- fun generateMethodBody(
+ fun generateFunctionBody(
scope: CodeGenScope,
parameters: List<ShortcutQueryParameter>,
adapters: Map<String, Pair<XPropertySpec, Any>>,
@@ -81,7 +81,7 @@
"%L%L.%L(%L, %L)",
if (resultVar == null) "" else "$resultVar += ",
adapter.name,
- param.handleMethodName,
+ param.handleFunctionName,
connectionVar,
param.name
)
diff --git a/room/room-compiler/src/main/kotlin/androidx/room/solver/shortcut/result/InsertOrUpsertMethodAdapter.kt b/room/room-compiler/src/main/kotlin/androidx/room/solver/shortcut/result/InsertOrUpsertFunctionAdapter.kt
similarity index 83%
rename from room/room-compiler/src/main/kotlin/androidx/room/solver/shortcut/result/InsertOrUpsertMethodAdapter.kt
rename to room/room-compiler/src/main/kotlin/androidx/room/solver/shortcut/result/InsertOrUpsertFunctionAdapter.kt
index c6b9dbd..22d0950e 100644
--- a/room/room-compiler/src/main/kotlin/androidx/room/solver/shortcut/result/InsertOrUpsertMethodAdapter.kt
+++ b/room/room-compiler/src/main/kotlin/androidx/room/solver/shortcut/result/InsertOrUpsertFunctionAdapter.kt
@@ -37,20 +37,20 @@
import androidx.room.solver.CodeGenScope
import androidx.room.vo.ShortcutQueryParameter
-class InsertOrUpsertMethodAdapter private constructor(private val methodInfo: MethodInfo) {
- internal val returnType = methodInfo.returnType
+class InsertOrUpsertFunctionAdapter private constructor(private val functionInfo: FunctionInfo) {
+ internal val returnType = functionInfo.returnType
companion object {
fun createInsert(
context: Context,
returnType: XType,
params: List<ShortcutQueryParameter>
- ): InsertOrUpsertMethodAdapter? {
- return createMethod(
+ ): InsertOrUpsertFunctionAdapter? {
+ return createFunction(
context = context,
returnType = returnType,
params = params,
- methodInfoClass = ::InsertMethodInfo,
+ functionInfoClass = ::InsertFunctionInfo,
multiParamSingleReturnError =
ProcessorErrors.INSERT_MULTI_PARAM_SINGLE_RETURN_MISMATCH,
singleParamMultiReturnError =
@@ -62,12 +62,12 @@
context: Context,
returnType: XType,
params: List<ShortcutQueryParameter>
- ): InsertOrUpsertMethodAdapter? {
- return createMethod(
+ ): InsertOrUpsertFunctionAdapter? {
+ return createFunction(
context = context,
returnType = returnType,
params = params,
- methodInfoClass = ::UpsertMethodInfo,
+ functionInfoClass = ::UpsertFunctionInfo,
multiParamSingleReturnError =
ProcessorErrors.UPSERT_MULTI_PARAM_SINGLE_RETURN_MISMATCH,
singleParamMultiReturnError =
@@ -75,27 +75,27 @@
)
}
- private fun createMethod(
+ private fun createFunction(
context: Context,
returnType: XType,
params: List<ShortcutQueryParameter>,
- methodInfoClass: (returnInfo: ReturnInfo, returnType: XType) -> MethodInfo,
+ functionInfoClass: (returnInfo: ReturnInfo, returnType: XType) -> FunctionInfo,
multiParamSingleReturnError: String,
singleParamMultiReturnError: String
- ): InsertOrUpsertMethodAdapter? {
- val methodReturnType = getReturnType(returnType)
+ ): InsertOrUpsertFunctionAdapter? {
+ val functionReturnType = getReturnType(returnType)
if (
- methodReturnType != null &&
+ functionReturnType != null &&
isReturnValid(
context,
- methodReturnType,
+ functionReturnType,
params,
multiParamSingleReturnError,
singleParamMultiReturnError
)
) {
- val methodInfo = methodInfoClass(methodReturnType, returnType)
- return InsertOrUpsertMethodAdapter(methodInfo = methodInfo)
+ val functionInfo = functionInfoClass(functionReturnType, returnType)
+ return InsertOrUpsertFunctionAdapter(functionInfo = functionInfo)
}
return null
}
@@ -175,7 +175,7 @@
}
}
- fun generateMethodBody(
+ fun generateFunctionBody(
scope: CodeGenScope,
connectionVar: String,
parameters: List<ShortcutQueryParameter>,
@@ -198,19 +198,19 @@
XCodeBlock.of(
"%L.%L(%L, %L)",
upsertAdapter.name,
- methodInfo.methodName,
+ functionInfo.functionName,
connectionVar,
param.name
)
.let {
if (
scope.language == CodeLanguage.KOTLIN &&
- methodInfo.returnInfo == ReturnInfo.ID_ARRAY_BOX &&
- methodInfo.returnType.asTypeName() ==
- methodInfo.returnInfo.typeName
+ functionInfo.returnInfo == ReturnInfo.ID_ARRAY_BOX &&
+ functionInfo.returnType.asTypeName() ==
+ functionInfo.returnInfo.typeName
) {
XCodeBlock.ofCast(
- typeName = methodInfo.returnInfo.typeName,
+ typeName = functionInfo.returnInfo.typeName,
expressionBlock = it
)
} else {
@@ -219,7 +219,7 @@
}
when (scope.language) {
CodeLanguage.JAVA -> {
- when (methodInfo.returnInfo) {
+ when (functionInfo.returnInfo) {
ReturnInfo.VOID,
ReturnInfo.VOID_OBJECT -> {
if (param == parameters.last()) {
@@ -262,21 +262,21 @@
}
}
- sealed class MethodInfo(val returnInfo: ReturnInfo, val returnType: XType) {
- abstract val methodName: String
+ sealed class FunctionInfo(val returnInfo: ReturnInfo, val returnType: XType) {
+ abstract val functionName: String
}
- class InsertMethodInfo(returnInfo: ReturnInfo, returnType: XType) :
- MethodInfo(returnInfo, returnType) {
- override val methodName: String = "insert${returnInfo.methodSuffix}"
+ class InsertFunctionInfo(returnInfo: ReturnInfo, returnType: XType) :
+ FunctionInfo(returnInfo, returnType) {
+ override val functionName: String = "insert${returnInfo.functionSuffix}"
}
- class UpsertMethodInfo(returnInfo: ReturnInfo, returnType: XType) :
- MethodInfo(returnInfo, returnType) {
- override val methodName: String = "upsert${returnInfo.methodSuffix}"
+ class UpsertFunctionInfo(returnInfo: ReturnInfo, returnType: XType) :
+ FunctionInfo(returnInfo, returnType) {
+ override val functionName: String = "upsert${returnInfo.functionSuffix}"
}
- enum class ReturnInfo(val methodSuffix: String, val typeName: XTypeName) {
+ enum class ReturnInfo(val functionSuffix: String, val typeName: XTypeName) {
VOID("", XTypeName.UNIT_VOID), // return void
VOID_OBJECT("", CommonTypeNames.VOID), // return Void
UNIT("", XTypeName.UNIT_VOID), // return kotlin.Unit.INSTANCE
diff --git a/room/room-compiler/src/main/kotlin/androidx/room/solver/transaction/binder/CoroutineTransactionMethodBinder.kt b/room/room-compiler/src/main/kotlin/androidx/room/solver/transaction/binder/CoroutineTransactionFunctionBinder.kt
similarity index 94%
rename from room/room-compiler/src/main/kotlin/androidx/room/solver/transaction/binder/CoroutineTransactionMethodBinder.kt
rename to room/room-compiler/src/main/kotlin/androidx/room/solver/transaction/binder/CoroutineTransactionFunctionBinder.kt
index f1ae556..b999825 100644
--- a/room/room-compiler/src/main/kotlin/androidx/room/solver/transaction/binder/CoroutineTransactionMethodBinder.kt
+++ b/room/room-compiler/src/main/kotlin/androidx/room/solver/transaction/binder/CoroutineTransactionFunctionBinder.kt
@@ -27,14 +27,14 @@
import androidx.room.ext.LambdaSpec
import androidx.room.ext.RoomMemberNames.DB_UTIL_PERFORM_IN_TRANSACTION_SUSPENDING
import androidx.room.solver.CodeGenScope
-import androidx.room.solver.transaction.result.TransactionMethodAdapter
+import androidx.room.solver.transaction.result.TransactionFunctionAdapter
/** Binder that knows how to write suspending transaction wrapper methods. */
-class CoroutineTransactionMethodBinder(
+class CoroutineTransactionFunctionBinder(
private val returnType: XType,
- adapter: TransactionMethodAdapter,
+ adapter: TransactionFunctionAdapter,
private val continuationParamName: String
-) : TransactionMethodBinder(adapter) {
+) : TransactionFunctionBinder(adapter) {
override fun executeAndReturn(
parameterNames: List<String>,
daoName: XClassName,
diff --git a/room/room-compiler/src/main/kotlin/androidx/room/solver/transaction/binder/InstantTransactionMethodBinder.kt b/room/room-compiler/src/main/kotlin/androidx/room/solver/transaction/binder/InstantTransactionFunctionBinder.kt
similarity index 95%
rename from room/room-compiler/src/main/kotlin/androidx/room/solver/transaction/binder/InstantTransactionMethodBinder.kt
rename to room/room-compiler/src/main/kotlin/androidx/room/solver/transaction/binder/InstantTransactionFunctionBinder.kt
index e2e6208..ff0b66e 100644
--- a/room/room-compiler/src/main/kotlin/androidx/room/solver/transaction/binder/InstantTransactionMethodBinder.kt
+++ b/room/room-compiler/src/main/kotlin/androidx/room/solver/transaction/binder/InstantTransactionFunctionBinder.kt
@@ -30,13 +30,13 @@
import androidx.room.ext.RoomMemberNames.DB_UTIL_PERFORM_BLOCKING
import androidx.room.ext.SQLiteDriverTypeNames
import androidx.room.solver.CodeGenScope
-import androidx.room.solver.transaction.result.TransactionMethodAdapter
+import androidx.room.solver.transaction.result.TransactionFunctionAdapter
/** Binder that knows how to write instant (blocking) transaction wrapper methods. */
-class InstantTransactionMethodBinder(
+class InstantTransactionFunctionBinder(
private val returnType: XType,
- adapter: TransactionMethodAdapter,
-) : TransactionMethodBinder(adapter) {
+ adapter: TransactionFunctionAdapter,
+) : TransactionFunctionBinder(adapter) {
override fun executeAndReturn(
parameterNames: List<String>,
daoName: XClassName,
diff --git a/room/room-compiler/src/main/kotlin/androidx/room/solver/transaction/binder/TransactionMethodBinder.kt b/room/room-compiler/src/main/kotlin/androidx/room/solver/transaction/binder/TransactionFunctionBinder.kt
similarity index 65%
rename from room/room-compiler/src/main/kotlin/androidx/room/solver/transaction/binder/TransactionMethodBinder.kt
rename to room/room-compiler/src/main/kotlin/androidx/room/solver/transaction/binder/TransactionFunctionBinder.kt
index 6665400..7705da5 100644
--- a/room/room-compiler/src/main/kotlin/androidx/room/solver/transaction/binder/TransactionMethodBinder.kt
+++ b/room/room-compiler/src/main/kotlin/androidx/room/solver/transaction/binder/TransactionFunctionBinder.kt
@@ -19,20 +19,20 @@
import androidx.room.compiler.codegen.XClassName
import androidx.room.compiler.codegen.XPropertySpec
import androidx.room.solver.CodeGenScope
-import androidx.room.solver.transaction.result.TransactionMethodAdapter
+import androidx.room.solver.transaction.result.TransactionFunctionAdapter
/**
- * Connects a transaction method, database and a [TransactionMethodAdapter].
+ * Connects a transaction function, database and a [TransactionFunctionAdapter].
*
- * The default implementation is [InstantTransactionMethodBinder] that executes the transaction
+ * The default implementation is [InstantTransactionFunctionBinder] that executes the transaction
* synchronously. Other deferred transactions are unsupported expect for coroutines, for such
- * binding then [CoroutineTransactionMethodBinder] is used.
+ * binding then [CoroutineTransactionFunctionBinder] is used.
*/
-abstract class TransactionMethodBinder(val adapter: TransactionMethodAdapter) {
+abstract class TransactionFunctionBinder(val adapter: TransactionFunctionAdapter) {
/**
- * Receives the method's return type, parameters along with the Dao class names to generate the
- * transaction wrapper body that delegates to the non-abstract or default dao method.
+ * Receives the function's return type, parameters along with the Dao class names to generate
+ * the transaction wrapper body that delegates to the non-abstract or default dao function.
*/
abstract fun executeAndReturn(
parameterNames: List<String>,
diff --git a/room/room-compiler/src/main/kotlin/androidx/room/solver/transaction/result/TransactionMethodAdapter.kt b/room/room-compiler/src/main/kotlin/androidx/room/solver/transaction/result/TransactionFunctionAdapter.kt
similarity index 83%
rename from room/room-compiler/src/main/kotlin/androidx/room/solver/transaction/result/TransactionMethodAdapter.kt
rename to room/room-compiler/src/main/kotlin/androidx/room/solver/transaction/result/TransactionFunctionAdapter.kt
index 3811e48..8ccbca2 100644
--- a/room/room-compiler/src/main/kotlin/androidx/room/solver/transaction/result/TransactionMethodAdapter.kt
+++ b/room/room-compiler/src/main/kotlin/androidx/room/solver/transaction/result/TransactionFunctionAdapter.kt
@@ -21,16 +21,16 @@
import androidx.room.compiler.codegen.XCodeBlock
import androidx.room.ext.DEFAULT_IMPLS_CLASS_NAME
import androidx.room.solver.CodeGenScope
-import androidx.room.vo.TransactionMethod
+import androidx.room.vo.TransactionFunction
/**
- * Class that knows how to generate the transaction method delegate code. Callers should take care
+ * Class that knows how to generate the transaction function delegate code. Callers should take care
* of using the invocation code in a statement or in another block (such as a lambda).
*/
-class TransactionMethodAdapter(
- private val methodName: String,
+class TransactionFunctionAdapter(
+ private val functionName: String,
private val jvmMethodName: String,
- private val callType: TransactionMethod.CallType
+ private val callType: TransactionFunction.CallType
) {
fun createDelegateToSuperCode(
parameterNames: List<String>,
@@ -51,7 +51,7 @@
if (
scope.language == CodeLanguage.JAVA &&
- callType == TransactionMethod.CallType.DEFAULT_KOTLIN &&
+ callType == TransactionFunction.CallType.DEFAULT_KOTLIN &&
parameterNames.isNotEmpty()
) {
// An invoke to DefaultImpls has an extra 1st param so we need a comma if there
@@ -76,13 +76,13 @@
daoImplName: XClassName,
): XCodeBlock =
when (callType) {
- TransactionMethod.CallType.CONCRETE -> {
+ TransactionFunction.CallType.CONCRETE -> {
XCodeBlock.of("%T.super.%N(", daoImplName, jvmMethodName)
}
- TransactionMethod.CallType.DEFAULT_JAVA8 -> {
+ TransactionFunction.CallType.DEFAULT_JAVA8 -> {
XCodeBlock.of("%T.super.%N(", daoName, jvmMethodName)
}
- TransactionMethod.CallType.DEFAULT_KOTLIN -> {
+ TransactionFunction.CallType.DEFAULT_KOTLIN -> {
XCodeBlock.of(
"%T.%N.%N(%T.this",
daoName,
@@ -95,5 +95,5 @@
private fun CodeGenScope.getKotlinInvokeExpr(
daoImplName: XClassName,
- ): XCodeBlock = XCodeBlock.of("super@%T.%N(", daoImplName, methodName)
+ ): XCodeBlock = XCodeBlock.of("super@%T.%N(", daoImplName, functionName)
}
diff --git a/room/room-compiler/src/main/kotlin/androidx/room/vo/Dao.kt b/room/room-compiler/src/main/kotlin/androidx/room/vo/Dao.kt
index 0f0d8b6..e24f25b 100644
--- a/room/room-compiler/src/main/kotlin/androidx/room/vo/Dao.kt
+++ b/room/room-compiler/src/main/kotlin/androidx/room/vo/Dao.kt
@@ -24,15 +24,15 @@
data class Dao(
val element: XTypeElement,
val type: XType,
- val queryMethods: List<QueryMethod>,
- val rawQueryMethods: List<RawQueryMethod>,
- val insertMethods: List<InsertMethod>,
- val deleteMethods: List<DeleteMethod>,
- val updateMethods: List<UpdateMethod>,
- val upsertMethods: List<UpsertMethod>,
- val transactionMethods: List<TransactionMethod>,
- val kotlinBoxedPrimitiveMethodDelegates: List<KotlinBoxedPrimitiveMethodDelegate>,
- val kotlinDefaultMethodDelegates: List<KotlinDefaultMethodDelegate>,
+ val queryFunctions: List<QueryFunction>,
+ val rawQueryFunctions: List<RawQueryFunction>,
+ val insertFunctions: List<InsertFunction>,
+ val deleteFunctions: List<DeleteFunction>,
+ val updateFunctions: List<UpdateFunction>,
+ val upsertFunctions: List<UpsertFunction>,
+ val transactionFunctions: List<TransactionFunction>,
+ val kotlinBoxedPrimitiveFunctionDelegates: List<KotlinBoxedPrimitiveFunctionDelegate>,
+ val kotlinDefaultFunctionDelegates: List<KotlinDefaultFunctionDelegate>,
val constructorParamType: XTypeName?
) {
// parsed dao might have a suffix if it is used in multiple databases.
@@ -46,12 +46,12 @@
val typeName: XClassName by lazy { element.asClassName() }
- val deleteOrUpdateShortcutMethods: List<DeleteOrUpdateShortcutMethod> by lazy {
- deleteMethods + updateMethods
+ val mDeleteOrUpdateShortcutFunctions: List<DeleteOrUpdateShortcutFunction> by lazy {
+ deleteFunctions + updateFunctions
}
- val insertOrUpsertShortcutMethods: List<InsertOrUpsertShortcutMethod> by lazy {
- insertMethods + upsertMethods
+ val mInsertOrUpsertShortcutFunctions: List<InsertOrUpsertShortcutFunction> by lazy {
+ insertFunctions + upsertFunctions
}
val implTypeName: XClassName by lazy {
diff --git a/room/room-compiler/src/main/kotlin/androidx/room/vo/DaoMethod.kt b/room/room-compiler/src/main/kotlin/androidx/room/vo/DaoFunction.kt
similarity index 85%
rename from room/room-compiler/src/main/kotlin/androidx/room/vo/DaoMethod.kt
rename to room/room-compiler/src/main/kotlin/androidx/room/vo/DaoFunction.kt
index 32fab37..a3bbbd2 100644
--- a/room/room-compiler/src/main/kotlin/androidx/room/vo/DaoMethod.kt
+++ b/room/room-compiler/src/main/kotlin/androidx/room/vo/DaoFunction.kt
@@ -18,7 +18,7 @@
import androidx.room.compiler.processing.XMethodElement
-/** References a method that returns a dao in a Database */
-data class DaoMethod(val element: XMethodElement, val dao: Dao) {
+/** References a function that returns a dao in a Database */
+data class DaoFunction(val element: XMethodElement, val dao: Dao) {
val isProperty = element.isKotlinPropertyMethod()
}
diff --git a/room/room-compiler/src/main/kotlin/androidx/room/vo/DataClassMethod.kt b/room/room-compiler/src/main/kotlin/androidx/room/vo/DataClassFunction.kt
similarity index 96%
rename from room/room-compiler/src/main/kotlin/androidx/room/vo/DataClassMethod.kt
rename to room/room-compiler/src/main/kotlin/androidx/room/vo/DataClassFunction.kt
index b8d948d..153b1d1 100644
--- a/room/room-compiler/src/main/kotlin/androidx/room/vo/DataClassMethod.kt
+++ b/room/room-compiler/src/main/kotlin/androidx/room/vo/DataClassFunction.kt
@@ -20,7 +20,7 @@
import androidx.room.compiler.processing.XMethodType
/** An executable element processed as member of a class (data class or entity) */
-class DataClassMethod(
+class DataClassFunction(
val element: XMethodElement,
val resolvedType: XMethodType,
)
diff --git a/room/room-compiler/src/main/kotlin/androidx/room/vo/Database.kt b/room/room-compiler/src/main/kotlin/androidx/room/vo/Database.kt
index 15f95d4..02efebf 100644
--- a/room/room-compiler/src/main/kotlin/androidx/room/vo/Database.kt
+++ b/room/room-compiler/src/main/kotlin/androidx/room/vo/Database.kt
@@ -35,7 +35,7 @@
val type: XType,
val entities: List<Entity>,
val views: List<DatabaseView>,
- val daoMethods: List<DaoMethod>,
+ val daoFunctions: List<DaoFunction>,
val version: Int,
val exportSchema: Boolean,
val enableForeignKeys: Boolean,
diff --git a/room/room-compiler/src/main/kotlin/androidx/room/vo/DeleteMethod.kt b/room/room-compiler/src/main/kotlin/androidx/room/vo/DeleteFunction.kt
similarity index 78%
rename from room/room-compiler/src/main/kotlin/androidx/room/vo/DeleteMethod.kt
rename to room/room-compiler/src/main/kotlin/androidx/room/vo/DeleteFunction.kt
index 7e69f5f..016e9b4 100644
--- a/room/room-compiler/src/main/kotlin/androidx/room/vo/DeleteMethod.kt
+++ b/room/room-compiler/src/main/kotlin/androidx/room/vo/DeleteFunction.kt
@@ -16,11 +16,11 @@
package androidx.room.vo
import androidx.room.compiler.processing.XMethodElement
-import androidx.room.solver.shortcut.binder.DeleteOrUpdateMethodBinder
+import androidx.room.solver.shortcut.binder.DeleteOrUpdateFunctionBinder
-class DeleteMethod(
+class DeleteFunction(
element: XMethodElement,
entities: Map<String, ShortcutEntity>,
parameters: List<ShortcutQueryParameter>,
- methodBinder: DeleteOrUpdateMethodBinder?
-) : DeleteOrUpdateShortcutMethod(element, entities, parameters, methodBinder)
+ functionBinder: DeleteOrUpdateFunctionBinder?
+) : DeleteOrUpdateShortcutFunction(element, entities, parameters, functionBinder)
diff --git a/room/room-compiler/src/main/kotlin/androidx/room/vo/DeleteOrUpdateShortcutMethod.kt b/room/room-compiler/src/main/kotlin/androidx/room/vo/DeleteOrUpdateShortcutFunction.kt
similarity index 78%
rename from room/room-compiler/src/main/kotlin/androidx/room/vo/DeleteOrUpdateShortcutMethod.kt
rename to room/room-compiler/src/main/kotlin/androidx/room/vo/DeleteOrUpdateShortcutFunction.kt
index ce477a6..4de4de6e 100644
--- a/room/room-compiler/src/main/kotlin/androidx/room/vo/DeleteOrUpdateShortcutMethod.kt
+++ b/room/room-compiler/src/main/kotlin/androidx/room/vo/DeleteOrUpdateShortcutFunction.kt
@@ -17,12 +17,12 @@
package androidx.room.vo
import androidx.room.compiler.processing.XMethodElement
-import androidx.room.solver.shortcut.binder.DeleteOrUpdateMethodBinder
+import androidx.room.solver.shortcut.binder.DeleteOrUpdateFunctionBinder
-/** Base class for shortcut methods in @DAO. */
-abstract class DeleteOrUpdateShortcutMethod(
+/** Base class for shortcut functions in @DAO. */
+abstract class DeleteOrUpdateShortcutFunction(
val element: XMethodElement,
val entities: Map<String, ShortcutEntity>,
val parameters: List<ShortcutQueryParameter>,
- val methodBinder: DeleteOrUpdateMethodBinder?
+ val functionBinder: DeleteOrUpdateFunctionBinder?
)
diff --git a/room/room-compiler/src/main/kotlin/androidx/room/vo/InsertMethod.kt b/room/room-compiler/src/main/kotlin/androidx/room/vo/InsertFunction.kt
similarity index 80%
rename from room/room-compiler/src/main/kotlin/androidx/room/vo/InsertMethod.kt
rename to room/room-compiler/src/main/kotlin/androidx/room/vo/InsertFunction.kt
index c97af3d..3a966ff 100644
--- a/room/room-compiler/src/main/kotlin/androidx/room/vo/InsertMethod.kt
+++ b/room/room-compiler/src/main/kotlin/androidx/room/vo/InsertFunction.kt
@@ -19,13 +19,13 @@
import androidx.room.OnConflictStrategy
import androidx.room.compiler.processing.XMethodElement
import androidx.room.compiler.processing.XType
-import androidx.room.solver.shortcut.binder.InsertOrUpsertMethodBinder
+import androidx.room.solver.shortcut.binder.InsertOrUpsertFunctionBinder
-class InsertMethod(
+class InsertFunction(
element: XMethodElement,
@OnConflictStrategy val onConflict: Int,
entities: Map<String, ShortcutEntity>,
returnType: XType,
parameters: List<ShortcutQueryParameter>,
- methodBinder: InsertOrUpsertMethodBinder
-) : InsertOrUpsertShortcutMethod(element, entities, returnType, parameters, methodBinder)
+ functionBinder: InsertOrUpsertFunctionBinder
+) : InsertOrUpsertShortcutFunction(element, entities, returnType, parameters, functionBinder)
diff --git a/room/room-compiler/src/main/kotlin/androidx/room/vo/InsertOrUpsertShortcutMethod.kt b/room/room-compiler/src/main/kotlin/androidx/room/vo/InsertOrUpsertShortcutFunction.kt
similarity index 79%
rename from room/room-compiler/src/main/kotlin/androidx/room/vo/InsertOrUpsertShortcutMethod.kt
rename to room/room-compiler/src/main/kotlin/androidx/room/vo/InsertOrUpsertShortcutFunction.kt
index 2d04873..94b1b47 100644
--- a/room/room-compiler/src/main/kotlin/androidx/room/vo/InsertOrUpsertShortcutMethod.kt
+++ b/room/room-compiler/src/main/kotlin/androidx/room/vo/InsertOrUpsertShortcutFunction.kt
@@ -18,13 +18,13 @@
import androidx.room.compiler.processing.XMethodElement
import androidx.room.compiler.processing.XType
-import androidx.room.solver.shortcut.binder.InsertOrUpsertMethodBinder
+import androidx.room.solver.shortcut.binder.InsertOrUpsertFunctionBinder
-/** Base class for shortcut methods in @DAO. */
-abstract class InsertOrUpsertShortcutMethod(
+/** Base class for shortcut functions in @DAO. */
+abstract class InsertOrUpsertShortcutFunction(
val element: XMethodElement,
val entities: Map<String, ShortcutEntity>,
val returnType: XType,
val parameters: List<ShortcutQueryParameter>,
- val methodBinder: InsertOrUpsertMethodBinder?
+ val functionBinder: InsertOrUpsertFunctionBinder?
)
diff --git a/room/room-compiler/src/main/kotlin/androidx/room/vo/KotlinBoxedPrimitiveMethodDelegate.kt b/room/room-compiler/src/main/kotlin/androidx/room/vo/KotlinBoxedPrimitiveFunctionDelegate.kt
similarity index 65%
rename from room/room-compiler/src/main/kotlin/androidx/room/vo/KotlinBoxedPrimitiveMethodDelegate.kt
rename to room/room-compiler/src/main/kotlin/androidx/room/vo/KotlinBoxedPrimitiveFunctionDelegate.kt
index 0a7ed24..4b5076d 100644
--- a/room/room-compiler/src/main/kotlin/androidx/room/vo/KotlinBoxedPrimitiveMethodDelegate.kt
+++ b/room/room-compiler/src/main/kotlin/androidx/room/vo/KotlinBoxedPrimitiveFunctionDelegate.kt
@@ -19,11 +19,11 @@
import androidx.room.compiler.processing.XMethodElement
/**
- * Represents a DAO bridge method that to supported the boxed version of a generic abstract class or
- * interface in Kotlin. When generating the Java implementation of the DAO, Room needs to also
- * override the bridge method generated by Kotlin for the boxed version support, see KT-46650.
+ * Represents a DAO bridge function that to supported the boxed version of a generic abstract class
+ * or interface in Kotlin. When generating the Java implementation of the DAO, Room needs to also
+ * override the bridge function generated by Kotlin for the boxed version support, see KT-46650.
*/
-data class KotlinBoxedPrimitiveMethodDelegate(
+data class KotlinBoxedPrimitiveFunctionDelegate(
val element: XMethodElement,
- val concreteMethod: XMethodElement
+ val concreteFunction: XMethodElement
)
diff --git a/room/room-compiler/src/main/kotlin/androidx/room/vo/KotlinDefaultMethodDelegate.kt b/room/room-compiler/src/main/kotlin/androidx/room/vo/KotlinDefaultFunctionDelegate.kt
similarity index 86%
rename from room/room-compiler/src/main/kotlin/androidx/room/vo/KotlinDefaultMethodDelegate.kt
rename to room/room-compiler/src/main/kotlin/androidx/room/vo/KotlinDefaultFunctionDelegate.kt
index a6a43b4..de4ffe0 100644
--- a/room/room-compiler/src/main/kotlin/androidx/room/vo/KotlinDefaultMethodDelegate.kt
+++ b/room/room-compiler/src/main/kotlin/androidx/room/vo/KotlinDefaultFunctionDelegate.kt
@@ -19,10 +19,10 @@
import androidx.room.compiler.processing.XMethodElement
/**
- * Represents a DAO method that delegates to a concrete implementation, specifically to override a
+ * Represents a DAO function that delegates to a concrete implementation, specifically to override a
* Kotlin interface whose implementation is in the DefaultImpl generated class.
*/
-data class KotlinDefaultMethodDelegate(
+data class KotlinDefaultFunctionDelegate(
// the original element, not the stub that is generated for DefaultImpls
val element: XMethodElement
)
diff --git a/room/room-compiler/src/main/kotlin/androidx/room/vo/QueryMethod.kt b/room/room-compiler/src/main/kotlin/androidx/room/vo/QueryFunction.kt
similarity index 81%
rename from room/room-compiler/src/main/kotlin/androidx/room/vo/QueryMethod.kt
rename to room/room-compiler/src/main/kotlin/androidx/room/vo/QueryFunction.kt
index 6d837c0..0ff3413 100644
--- a/room/room-compiler/src/main/kotlin/androidx/room/vo/QueryMethod.kt
+++ b/room/room-compiler/src/main/kotlin/androidx/room/vo/QueryFunction.kt
@@ -23,10 +23,10 @@
import androidx.room.solver.query.result.QueryResultBinder
/**
- * A class that holds information about a QueryMethod. It is self sufficient and must have all
+ * A class that holds information about a QueryFunction. It is self sufficient and must have all
* generics etc resolved once created.
*/
-sealed class QueryMethod(
+sealed class QueryFunction(
val element: XMethodElement,
val query: ParsedQuery,
val returnType: XType,
@@ -46,23 +46,23 @@
}
}
-/** A query method who's query is a SELECT statement. */
-class ReadQueryMethod(
+/** A query function who's query is a SELECT statement. */
+class ReadQueryFunction(
element: XMethodElement,
query: ParsedQuery,
returnType: XType,
parameters: List<QueryParameter>,
val inTransaction: Boolean,
val queryResultBinder: QueryResultBinder
-) : QueryMethod(element, query, returnType, parameters) {
+) : QueryFunction(element, query, returnType, parameters) {
val isProperty = element.isKotlinPropertyMethod()
}
-/** A query method who's query is a INSERT, UPDATE or DELETE statement. */
-class WriteQueryMethod(
+/** A query function who's query is a INSERT, UPDATE or DELETE statement. */
+class WriteQueryFunction(
element: XMethodElement,
query: ParsedQuery,
returnType: XType,
parameters: List<QueryParameter>,
val preparedQueryResultBinder: PreparedQueryResultBinder
-) : QueryMethod(element, query, returnType, parameters)
+) : QueryFunction(element, query, returnType, parameters)
diff --git a/room/room-compiler/src/main/kotlin/androidx/room/vo/RawQueryMethod.kt b/room/room-compiler/src/main/kotlin/androidx/room/vo/RawQueryFunction.kt
similarity index 89%
rename from room/room-compiler/src/main/kotlin/androidx/room/vo/RawQueryMethod.kt
rename to room/room-compiler/src/main/kotlin/androidx/room/vo/RawQueryFunction.kt
index c447dd3..c359a85 100644
--- a/room/room-compiler/src/main/kotlin/androidx/room/vo/RawQueryMethod.kt
+++ b/room/room-compiler/src/main/kotlin/androidx/room/vo/RawQueryFunction.kt
@@ -27,10 +27,10 @@
import androidx.room.solver.query.result.QueryResultBinder
/**
- * A class that holds information about a method annotated with RawQuery. It is self sufficient and
- * must have all generics etc resolved once created.
+ * A class that holds information about a function annotated with RawQuery. It is self sufficient
+ * and must have all generics etc resolved once created.
*/
-data class RawQueryMethod(
+data class RawQueryFunction(
val element: XMethodElement,
val returnType: XType,
val inTransaction: Boolean,
diff --git a/room/room-compiler/src/main/kotlin/androidx/room/vo/ShortcutQueryParameter.kt b/room/room-compiler/src/main/kotlin/androidx/room/vo/ShortcutQueryParameter.kt
index 90196b8..425eb69 100644
--- a/room/room-compiler/src/main/kotlin/androidx/room/vo/ShortcutQueryParameter.kt
+++ b/room/room-compiler/src/main/kotlin/androidx/room/vo/ShortcutQueryParameter.kt
@@ -20,7 +20,7 @@
import androidx.room.compiler.processing.XType
import androidx.room.compiler.processing.XVariableElement
-/** Parameters used in DAO methods that are annotated with Insert, Delete, Update, and Upsert. */
+/** Parameters used in DAO functions that are annotated with Insert, Delete, Update, and Upsert. */
data class ShortcutQueryParameter(
val element: XVariableElement,
val name: String,
@@ -28,8 +28,8 @@
val pojoType: XType?, // extracted type, never a Collection
val isMultiple: Boolean
) {
- /** Method name in entity insertion or update adapter. */
- val handleMethodName =
+ /** Function name in entity insertion or update adapter. */
+ val handleFunctionName =
if (isMultiple) {
"handleMultiple"
} else {
diff --git a/room/room-compiler/src/main/kotlin/androidx/room/vo/TransactionMethod.kt b/room/room-compiler/src/main/kotlin/androidx/room/vo/TransactionFunction.kt
similarity index 83%
rename from room/room-compiler/src/main/kotlin/androidx/room/vo/TransactionMethod.kt
rename to room/room-compiler/src/main/kotlin/androidx/room/vo/TransactionFunction.kt
index a63abbc..6edaef4 100644
--- a/room/room-compiler/src/main/kotlin/androidx/room/vo/TransactionMethod.kt
+++ b/room/room-compiler/src/main/kotlin/androidx/room/vo/TransactionFunction.kt
@@ -18,17 +18,17 @@
import androidx.room.compiler.processing.XMethodElement
import androidx.room.compiler.processing.XType
-import androidx.room.solver.transaction.binder.TransactionMethodBinder
+import androidx.room.solver.transaction.binder.TransactionFunctionBinder
-class TransactionMethod(
+class TransactionFunction(
val element: XMethodElement,
val returnType: XType,
val parameterNames: List<String>,
val callType: CallType,
- val methodBinder: TransactionMethodBinder
+ val functionBinder: TransactionFunctionBinder
) {
enum class CallType {
- /** Directly call the method, it has a super implementation */
+ /** Directly call the function, it has a super implementation */
CONCRETE,
/**
diff --git a/room/room-compiler/src/main/kotlin/androidx/room/vo/UpdateMethod.kt b/room/room-compiler/src/main/kotlin/androidx/room/vo/UpdateFunction.kt
similarity index 79%
rename from room/room-compiler/src/main/kotlin/androidx/room/vo/UpdateMethod.kt
rename to room/room-compiler/src/main/kotlin/androidx/room/vo/UpdateFunction.kt
index bbcc6fa..fbf3eaa 100644
--- a/room/room-compiler/src/main/kotlin/androidx/room/vo/UpdateMethod.kt
+++ b/room/room-compiler/src/main/kotlin/androidx/room/vo/UpdateFunction.kt
@@ -18,12 +18,12 @@
import androidx.room.OnConflictStrategy
import androidx.room.compiler.processing.XMethodElement
-import androidx.room.solver.shortcut.binder.DeleteOrUpdateMethodBinder
+import androidx.room.solver.shortcut.binder.DeleteOrUpdateFunctionBinder
-class UpdateMethod(
+class UpdateFunction(
element: XMethodElement,
entities: Map<String, ShortcutEntity>,
parameters: List<ShortcutQueryParameter>,
- methodBinder: DeleteOrUpdateMethodBinder?,
+ functionBinder: DeleteOrUpdateFunctionBinder?,
@OnConflictStrategy val onConflictStrategy: Int
-) : DeleteOrUpdateShortcutMethod(element, entities, parameters, methodBinder)
+) : DeleteOrUpdateShortcutFunction(element, entities, parameters, functionBinder)
diff --git a/room/room-compiler/src/main/kotlin/androidx/room/vo/UpsertMethod.kt b/room/room-compiler/src/main/kotlin/androidx/room/vo/UpsertFunction.kt
similarity index 78%
rename from room/room-compiler/src/main/kotlin/androidx/room/vo/UpsertMethod.kt
rename to room/room-compiler/src/main/kotlin/androidx/room/vo/UpsertFunction.kt
index 161aa46..5ebb039 100644
--- a/room/room-compiler/src/main/kotlin/androidx/room/vo/UpsertMethod.kt
+++ b/room/room-compiler/src/main/kotlin/androidx/room/vo/UpsertFunction.kt
@@ -18,12 +18,12 @@
import androidx.room.compiler.processing.XMethodElement
import androidx.room.compiler.processing.XType
-import androidx.room.solver.shortcut.binder.InsertOrUpsertMethodBinder
+import androidx.room.solver.shortcut.binder.InsertOrUpsertFunctionBinder
-class UpsertMethod(
+class UpsertFunction(
element: XMethodElement,
entities: Map<String, ShortcutEntity>,
returnType: XType,
parameters: List<ShortcutQueryParameter>,
- methodBinder: InsertOrUpsertMethodBinder
-) : InsertOrUpsertShortcutMethod(element, entities, returnType, parameters, methodBinder)
+ functionBinder: InsertOrUpsertFunctionBinder
+) : InsertOrUpsertShortcutFunction(element, entities, returnType, parameters, functionBinder)
diff --git a/room/room-compiler/src/main/kotlin/androidx/room/vo/Warning.kt b/room/room-compiler/src/main/kotlin/androidx/room/vo/Warning.kt
index 181bf5b..cdfbbc8 100644
--- a/room/room-compiler/src/main/kotlin/androidx/room/vo/Warning.kt
+++ b/room/room-compiler/src/main/kotlin/androidx/room/vo/Warning.kt
@@ -48,7 +48,7 @@
// expand projection is removed.
EXPAND_PROJECTION_WITH_REMOVE_UNUSED_COLUMNS("ROOM_EXPAND_PROJECTION_WITH_UNUSED_COLUMNS"),
// We shouldn't let devs suppress this error via Room so there is no runtime constant for it
- JVM_NAME_ON_OVERRIDDEN_METHOD("ROOM_JVM_NAME_IN_OVERRIDDEN_METHOD"),
+ JVM_NAME_ON_OVERRIDDEN_FUNCTION("ROOM_JVM_NAME_IN_OVERRIDDEN_FUNCTION"),
AMBIGUOUS_COLUMN_IN_RESULT("ROOM_AMBIGUOUS_COLUMN_IN_RESULT"),
UNNECESSARY_NULLABILITY_IN_DAO_RETURN_TYPE("ROOM_UNNECESSARY_NULLABILITY_IN_DAO_RETURN_TYPE");
diff --git a/room/room-compiler/src/main/kotlin/androidx/room/writer/DaoWriter.kt b/room/room-compiler/src/main/kotlin/androidx/room/writer/DaoWriter.kt
index 4f73947..5130e72 100644
--- a/room/room-compiler/src/main/kotlin/androidx/room/writer/DaoWriter.kt
+++ b/room/room-compiler/src/main/kotlin/androidx/room/writer/DaoWriter.kt
@@ -45,21 +45,21 @@
import androidx.room.ext.capitalize
import androidx.room.processor.OnConflictProcessor
import androidx.room.solver.CodeGenScope
-import androidx.room.solver.KotlinBoxedPrimitiveMethodDelegateBinder
-import androidx.room.solver.KotlinDefaultMethodDelegateBinder
+import androidx.room.solver.KotlinBoxedPrimitiveFunctionDelegateBinder
+import androidx.room.solver.KotlinDefaultFunctionDelegateBinder
import androidx.room.solver.types.getRequiredTypeConverters
import androidx.room.vo.Dao
-import androidx.room.vo.DeleteOrUpdateShortcutMethod
-import androidx.room.vo.InsertMethod
-import androidx.room.vo.KotlinBoxedPrimitiveMethodDelegate
-import androidx.room.vo.KotlinDefaultMethodDelegate
-import androidx.room.vo.RawQueryMethod
-import androidx.room.vo.ReadQueryMethod
+import androidx.room.vo.DeleteOrUpdateShortcutFunction
+import androidx.room.vo.InsertFunction
+import androidx.room.vo.KotlinBoxedPrimitiveFunctionDelegate
+import androidx.room.vo.KotlinDefaultFunctionDelegate
+import androidx.room.vo.RawQueryFunction
+import androidx.room.vo.ReadQueryFunction
import androidx.room.vo.ShortcutEntity
-import androidx.room.vo.TransactionMethod
-import androidx.room.vo.UpdateMethod
-import androidx.room.vo.UpsertMethod
-import androidx.room.vo.WriteQueryMethod
+import androidx.room.vo.TransactionFunction
+import androidx.room.vo.UpdateFunction
+import androidx.room.vo.UpsertFunction
+import androidx.room.vo.WriteQueryFunction
import com.squareup.kotlinpoet.FunSpec
import com.squareup.kotlinpoet.KModifier
import com.squareup.kotlinpoet.jvm.jvmName
@@ -82,7 +82,7 @@
private val companionTypeBuilder = lazy { XTypeSpec.companionObjectBuilder() }
companion object {
- const val GET_LIST_OF_TYPE_CONVERTERS_METHOD = "getRequiredConverters"
+ const val GET_LIST_OF_TYPE_CONVERTERS_FUNCTION = "getRequiredConverters"
const val DB_PROPERTY_NAME = "__db"
@@ -103,14 +103,14 @@
override fun createTypeSpecBuilder(): XTypeSpec.Builder {
val builder = XTypeSpec.classBuilder(className)
- val preparedQueries = dao.queryMethods.filterIsInstance<WriteQueryMethod>()
+ val preparedQueries = dao.queryFunctions.filterIsInstance<WriteQueryFunction>()
- val shortcutMethods = buildList {
- addAll(createInsertMethods())
- addAll(createDeleteMethods())
- addAll(createUpdateMethods())
- addAll(createTransactionMethods())
- addAll(createUpsertMethods())
+ val shortcutFunctions = buildList {
+ addAll(createInsertFunctions())
+ addAll(createDeleteFunctions())
+ addAll(createUpdateFunctions())
+ addAll(createTransactionFunctions())
+ addAll(createUpsertFunctions())
}
builder.apply {
@@ -130,20 +130,20 @@
addProperty(dbProperty)
setPrimaryConstructor(
- createConstructor(shortcutMethods, dao.constructorParamType != null)
+ createConstructor(shortcutFunctions, dao.constructorParamType != null)
)
- shortcutMethods.forEach { addFunction(it.functionImpl) }
- dao.queryMethods.filterIsInstance<ReadQueryMethod>().forEach { method ->
- addFunction(createSelectMethod(method))
- if (method.isProperty) {
+ shortcutFunctions.forEach { addFunction(it.functionImpl) }
+ dao.queryFunctions.filterIsInstance<ReadQueryFunction>().forEach { function ->
+ addFunction(createSelectFunction(function))
+ if (function.isProperty) {
// DAO function is a getter from a Kotlin property, generate property override.
applyToKotlinPoet {
addProperty(
- PropertySpecHelper.overriding(method.element, declaredDao)
+ PropertySpecHelper.overriding(function.element, declaredDao)
.getter(
FunSpec.getterBuilder()
- .addCode("return %L()", method.element.name)
+ .addCode("return %L()", function.element.name)
.build()
)
.build()
@@ -151,20 +151,20 @@
}
}
}
- preparedQueries.forEach { addFunction(createPreparedQueryMethod(it)) }
- dao.rawQueryMethods.forEach { addFunction(createRawQueryMethod(it)) }
+ preparedQueries.forEach { addFunction(createPreparedQueryFunction(it)) }
+ dao.rawQueryFunctions.forEach { addFunction(createRawQueryFunction(it)) }
applyTo(CodeLanguage.JAVA) {
- dao.kotlinDefaultMethodDelegates.forEach {
- addFunction(createDefaultImplMethodDelegate(it))
+ dao.kotlinDefaultFunctionDelegates.forEach {
+ addFunction(createDefaultImplFunctionDelegate(it))
}
- dao.kotlinBoxedPrimitiveMethodDelegates.forEach {
- addFunction(createBoxedPrimitiveBridgeMethodDelegate(it))
+ dao.kotlinBoxedPrimitiveFunctionDelegates.forEach {
+ addFunction(createBoxedPrimitiveBridgeFunctionDelegate(it))
}
}
// Keep this the last one to be generated because used custom converters will
// register fields with a payload which we collect in dao to report used
// Type Converters.
- addConverterListMethod(this)
+ addConverterListFunction(this)
applyTo(CodeLanguage.KOTLIN) {
if (companionTypeBuilder.isInitialized()) {
addType(companionTypeBuilder.value.build())
@@ -174,16 +174,16 @@
return builder
}
- private fun addConverterListMethod(typeSpecBuilder: XTypeSpec.Builder) {
+ private fun addConverterListFunction(typeSpecBuilder: XTypeSpec.Builder) {
// For Java a static method is created
- typeSpecBuilder.applyTo(CodeLanguage.JAVA) { addFunction(createConverterListMethod()) }
+ typeSpecBuilder.applyTo(CodeLanguage.JAVA) { addFunction(createConverterListFunction()) }
// For Kotlin a function in the companion object is created
companionTypeBuilder.value.applyTo(CodeLanguage.KOTLIN) {
- addFunction(createConverterListMethod())
+ addFunction(createConverterListFunction())
}
}
- private fun createConverterListMethod(): XFunSpec {
+ private fun createConverterListFunction(): XFunSpec {
val body = buildCodeBlock { language ->
val requiredTypeConverters = getRequiredTypeConverters()
if (requiredTypeConverters.isEmpty()) {
@@ -218,7 +218,7 @@
}
}
}
- return XFunSpec.builder(GET_LIST_OF_TYPE_CONVERTERS_METHOD, VisibilityModifier.PUBLIC)
+ return XFunSpec.builder(GET_LIST_OF_TYPE_CONVERTERS_FUNCTION, VisibilityModifier.PUBLIC)
.applyToJavaPoet { addModifiers(javax.lang.model.element.Modifier.STATIC) }
.applyTo { language ->
returns(
@@ -234,33 +234,33 @@
.build()
}
- private fun createTransactionMethods(): List<PreparedStmtQuery> {
- return dao.transactionMethods.map {
- PreparedStmtQuery(emptyMap(), createTransactionMethodBody(it))
+ private fun createTransactionFunctions(): List<PreparedStmtQuery> {
+ return dao.transactionFunctions.map {
+ PreparedStmtQuery(emptyMap(), createTransactionFunctionBody(it))
}
}
- private fun createTransactionMethodBody(method: TransactionMethod): XFunSpec {
+ private fun createTransactionFunctionBody(function: TransactionFunction): XFunSpec {
val scope = CodeGenScope(this)
- method.methodBinder.executeAndReturn(
- parameterNames = method.parameterNames,
+ function.functionBinder.executeAndReturn(
+ parameterNames = function.parameterNames,
daoName = dao.typeName,
daoImplName = dao.implTypeName,
dbProperty = dbProperty,
scope = scope
)
- return overrideWithoutAnnotations(method.element, declaredDao)
+ return overrideWithoutAnnotations(function.element, declaredDao)
.addCode(scope.generate())
.build()
}
private fun createConstructor(
- shortcutMethods: List<PreparedStmtQuery>,
+ shortcutFunctions: List<PreparedStmtQuery>,
callSuper: Boolean
): XFunSpec {
val body = buildCodeBlock {
addStatement("this.%N = %L", dbProperty, dbProperty.name)
- shortcutMethods
+ shortcutFunctions
.asSequence()
.filterNot { it.fields.isEmpty() }
.map { it.fields.values }
@@ -282,11 +282,11 @@
.build()
}
- private fun createSelectMethod(method: ReadQueryMethod): XFunSpec {
- return overrideWithoutAnnotations(method.element, declaredDao)
+ private fun createSelectFunction(function: ReadQueryFunction): XFunSpec {
+ return overrideWithoutAnnotations(function.element, declaredDao)
.applyToKotlinPoet {
// TODO: Update XPoet to better handle this case.
- if (method.isProperty) {
+ if (function.isProperty) {
// When the DAO function is from a Kotlin property, we'll still generate
// a DAO function, but it won't be an override and it'll be private, to be
// called from the overridden property's getter.
@@ -302,34 +302,34 @@
context.targetPlatforms.size == 1 &&
context.targetPlatforms.contains(XProcessingEnv.Platform.JVM)
) {
- jvmName("_private${method.element.name.capitalize(Locale.US)}")
+ jvmName("_private${function.element.name.capitalize(Locale.US)}")
}
}
}
- .addCode(createQueryMethodBody(method))
+ .addCode(createQueryFunctionBody(function))
.build()
}
- private fun createRawQueryMethod(method: RawQueryMethod): XFunSpec {
- return overrideWithoutAnnotations(method.element, declaredDao)
+ private fun createRawQueryFunction(function: RawQueryFunction): XFunSpec {
+ return overrideWithoutAnnotations(function.element, declaredDao)
.addCode(
if (
- method.runtimeQueryParam == null ||
- method.queryResultBinder.usesCompatQueryWriter
+ function.runtimeQueryParam == null ||
+ function.queryResultBinder.usesCompatQueryWriter
) {
- compatCreateRawQueryMethodBody(method)
+ compatCreateRawQueryFunctionBody(function)
} else {
- createRawQueryMethodBody(method)
+ createRawQueryFunctionBody(function)
}
)
.build()
}
- private fun createRawQueryMethodBody(method: RawQueryMethod): XCodeBlock {
+ private fun createRawQueryFunctionBody(function: RawQueryFunction): XCodeBlock {
val scope = CodeGenScope(this@DaoWriter)
val sqlQueryVar = scope.getTmpVar("_sql")
val rawQueryParamName =
- if (method.runtimeQueryParam!!.isSupportQuery()) {
+ if (function.runtimeQueryParam!!.isSupportQuery()) {
val rawQueryVar = scope.getTmpVar("_rawQuery")
scope.builder.addLocalVariable(
name = rawQueryVar,
@@ -338,12 +338,12 @@
XCodeBlock.of(
format = "%T.copyFrom(%L).toRoomRawQuery()",
ROOM_SQL_QUERY,
- method.runtimeQueryParam.paramName
+ function.runtimeQueryParam.paramName
)
)
rawQueryVar
} else {
- method.runtimeQueryParam.paramName
+ function.runtimeQueryParam.paramName
}
scope.builder.addLocalVal(
@@ -354,8 +354,8 @@
XCodeBlock.ofString(java = "getSql()", kotlin = "sql")
)
- if (method.returnsValue) {
- method.queryResultBinder.convertAndReturn(
+ if (function.returnsValue) {
+ function.queryResultBinder.convertAndReturn(
sqlQueryVar = sqlQueryVar,
dbProperty = dbProperty,
bindStatement = { stmtVar ->
@@ -365,8 +365,8 @@
stmtVar
)
},
- returnTypeName = method.returnType.asTypeName(),
- inTransaction = method.inTransaction,
+ returnTypeName = function.returnType.asTypeName(),
+ inTransaction = function.inTransaction,
scope = scope
)
}
@@ -374,12 +374,12 @@
}
/** Used by the Non-KMP Paging3 binders and the Paging2 binders. */
- private fun compatCreateRawQueryMethodBody(method: RawQueryMethod): XCodeBlock =
+ private fun compatCreateRawQueryFunctionBody(function: RawQueryFunction): XCodeBlock =
XCodeBlock.builder()
.apply {
val scope = CodeGenScope(this@DaoWriter)
val roomSQLiteQueryVar: String
- val queryParam = method.runtimeQueryParam
+ val queryParam = function.runtimeQueryParam
if (queryParam?.isSupportQuery() == true) {
queryParam.paramName
} else if (queryParam?.isString() == true) {
@@ -408,10 +408,10 @@
),
)
}
- val rawQueryParamName = method.runtimeQueryParam?.paramName
+ val rawQueryParamName = function.runtimeQueryParam?.paramName
if (rawQueryParamName != null) {
- if (method.returnsValue) {
- method.queryResultBinder.convertAndReturn(
+ if (function.returnsValue) {
+ function.queryResultBinder.convertAndReturn(
sqlQueryVar = rawQueryParamName,
dbProperty = dbProperty,
bindStatement = { stmtVar ->
@@ -421,8 +421,8 @@
stmtVar
)
},
- returnTypeName = method.returnType.asTypeName(),
- inTransaction = method.inTransaction,
+ returnTypeName = function.returnType.asTypeName(),
+ inTransaction = function.inTransaction,
scope = scope
)
}
@@ -431,48 +431,48 @@
}
.build()
- private fun createPreparedQueryMethod(method: WriteQueryMethod): XFunSpec {
- return overrideWithoutAnnotations(method.element, declaredDao)
- .addCode(createPreparedQueryMethodBody(method))
+ private fun createPreparedQueryFunction(function: WriteQueryFunction): XFunSpec {
+ return overrideWithoutAnnotations(function.element, declaredDao)
+ .addCode(createPreparedQueryFunctionBody(function))
.build()
}
/**
- * Groups all insert methods based on the insert statement they will use then creates all field
- * specs, EntityInsertAdapterWriter and actual insert methods.
+ * Groups all insert functions based on the insert statement they will use then creates all
+ * field specs, EntityInsertAdapterWriter and actual insert functions.
*/
- private fun createInsertMethods(): List<PreparedStmtQuery> {
- return dao.insertMethods.map { insertMethod ->
- val onConflict = OnConflictProcessor.onConflictText(insertMethod.onConflict)
- val entities = insertMethod.entities
+ private fun createInsertFunctions(): List<PreparedStmtQuery> {
+ return dao.insertFunctions.map { insertFunction ->
+ val onConflict = OnConflictProcessor.onConflictText(insertFunction.onConflict)
+ val entities = insertFunction.entities
val fields =
entities.mapValues {
- val spec = getOrCreateProperty(InsertMethodProperty(it.value, onConflict))
+ val spec = getOrCreateProperty(InsertFunctionProperty(it.value, onConflict))
val impl =
EntityInsertAdapterWriter.create(it.value, onConflict)
.createAnonymous(this@DaoWriter)
spec to impl
}
- val methodImpl =
- overrideWithoutAnnotations(insertMethod.element, declaredDao)
- .apply { addCode(createInsertMethodBody(insertMethod, fields)) }
+ val functionImpl =
+ overrideWithoutAnnotations(insertFunction.element, declaredDao)
+ .apply { addCode(createInsertFunctionBody(insertFunction, fields)) }
.build()
- PreparedStmtQuery(fields, methodImpl)
+ PreparedStmtQuery(fields, functionImpl)
}
}
- private fun createInsertMethodBody(
- method: InsertMethod,
+ private fun createInsertFunctionBody(
+ function: InsertFunction,
insertAdapters: Map<String, Pair<XPropertySpec, XTypeSpec>>
): XCodeBlock {
- if (insertAdapters.isEmpty() || method.methodBinder == null) {
+ if (insertAdapters.isEmpty() || function.functionBinder == null) {
return XCodeBlock.builder().build()
}
val scope = CodeGenScope(writer = this)
- ShortcutQueryParameterWriter.addNullCheckValidation(scope, method.parameters)
- method.methodBinder.convertAndReturn(
- parameters = method.parameters,
+ ShortcutQueryParameterWriter.addNullCheckValidation(scope, function.parameters)
+ function.functionBinder.convertAndReturn(
+ parameters = function.parameters,
adapters = insertAdapters,
dbProperty = dbProperty,
scope = scope
@@ -480,34 +480,34 @@
return scope.generate()
}
- /** Creates EntityUpdateAdapter for each delete method. */
- private fun createDeleteMethods(): List<PreparedStmtQuery> {
- return createShortcutMethods(dao.deleteMethods, "delete") { _, entity ->
+ /** Creates EntityUpdateAdapter for each delete function. */
+ private fun createDeleteFunctions(): List<PreparedStmtQuery> {
+ return createShortcutFunctions(dao.deleteFunctions, "delete") { _, entity ->
EntityDeleteAdapterWriter.create(entity).createAnonymous(this@DaoWriter)
}
}
- /** Creates EntityUpdateAdapter for each @Update method. */
- private fun createUpdateMethods(): List<PreparedStmtQuery> {
- return createShortcutMethods(dao.updateMethods, "update") { update, entity ->
+ /** Creates EntityUpdateAdapter for each @Update function. */
+ private fun createUpdateFunctions(): List<PreparedStmtQuery> {
+ return createShortcutFunctions(dao.updateFunctions, "update") { update, entity ->
val onConflict = OnConflictProcessor.onConflictText(update.onConflictStrategy)
EntityUpdateAdapterWriter.create(entity, onConflict).createAnonymous(this@DaoWriter)
}
}
- private fun <T : DeleteOrUpdateShortcutMethod> createShortcutMethods(
- methods: List<T>,
- methodPrefix: String,
+ private fun <T : DeleteOrUpdateShortcutFunction> createShortcutFunctions(
+ functions: List<T>,
+ functionPrefix: String,
implCallback: (T, ShortcutEntity) -> XTypeSpec
): List<PreparedStmtQuery> {
- return methods.mapNotNull { method ->
- val entities = method.entities
+ return functions.mapNotNull { function ->
+ val entities = function.entities
if (entities.isEmpty()) {
null
} else {
val onConflict =
- if (method is UpdateMethod) {
- OnConflictProcessor.onConflictText(method.onConflictStrategy)
+ if (function is UpdateFunction) {
+ OnConflictProcessor.onConflictText(function.onConflictStrategy)
} else {
""
}
@@ -515,31 +515,31 @@
entities.mapValues {
val spec =
getOrCreateProperty(
- DeleteOrUpdateAdapterProperty(it.value, methodPrefix, onConflict)
+ DeleteOrUpdateAdapterProperty(it.value, functionPrefix, onConflict)
)
- val impl = implCallback(method, it.value)
+ val impl = implCallback(function, it.value)
spec to impl
}
- val methodSpec =
- overrideWithoutAnnotations(method.element, declaredDao)
- .apply { addCode(createDeleteOrUpdateMethodBody(method, fields)) }
+ val functionSpec =
+ overrideWithoutAnnotations(function.element, declaredDao)
+ .apply { addCode(createDeleteOrUpdateFunctionBody(function, fields)) }
.build()
- PreparedStmtQuery(fields, methodSpec)
+ PreparedStmtQuery(fields, functionSpec)
}
}
}
- private fun createDeleteOrUpdateMethodBody(
- method: DeleteOrUpdateShortcutMethod,
+ private fun createDeleteOrUpdateFunctionBody(
+ function: DeleteOrUpdateShortcutFunction,
adapters: Map<String, Pair<XPropertySpec, XTypeSpec>>
): XCodeBlock {
- if (adapters.isEmpty() || method.methodBinder == null) {
+ if (adapters.isEmpty() || function.functionBinder == null) {
return XCodeBlock.builder().build()
}
val scope = CodeGenScope(writer = this)
- ShortcutQueryParameterWriter.addNullCheckValidation(scope, method.parameters)
- method.methodBinder.convertAndReturn(
- parameters = method.parameters,
+ ShortcutQueryParameterWriter.addNullCheckValidation(scope, function.parameters)
+ function.functionBinder.convertAndReturn(
+ parameters = function.parameters,
adapters = adapters,
dbProperty = dbProperty,
scope = scope
@@ -548,12 +548,12 @@
}
/**
- * Groups all upsert methods based on the upsert statement they will use then creates all field
- * specs, EntityUpsertAdapterWriter and actual upsert methods.
+ * Groups all upsert functions based on the upsert statement they will use then creates all
+ * field specs, EntityUpsertAdapterWriter and actual upsert functions.
*/
- private fun createUpsertMethods(): List<PreparedStmtQuery> {
- return dao.upsertMethods.map { upsertMethod ->
- val entities = upsertMethod.entities
+ private fun createUpsertFunctions(): List<PreparedStmtQuery> {
+ return dao.upsertFunctions.map { upsertFunctions ->
+ val entities = upsertFunctions.entities
val fields =
entities.mapValues {
val spec = getOrCreateProperty(UpsertAdapterProperty(it.value))
@@ -562,25 +562,25 @@
.createConcrete(it.value, this@DaoWriter)
spec to impl
}
- val methodImpl =
- overrideWithoutAnnotations(upsertMethod.element, declaredDao)
- .apply { addCode(createUpsertMethodBody(upsertMethod, fields)) }
+ val functionImpl =
+ overrideWithoutAnnotations(upsertFunctions.element, declaredDao)
+ .apply { addCode(createUpsertFunctionBody(upsertFunctions, fields)) }
.build()
- PreparedStmtQuery(fields, methodImpl)
+ PreparedStmtQuery(fields, functionImpl)
}
}
- private fun createUpsertMethodBody(
- method: UpsertMethod,
+ private fun createUpsertFunctionBody(
+ function: UpsertFunction,
upsertAdapters: Map<String, Pair<XPropertySpec, XCodeBlock>>
): XCodeBlock {
- if (upsertAdapters.isEmpty() || method.methodBinder == null) {
+ if (upsertAdapters.isEmpty() || function.functionBinder == null) {
return XCodeBlock.builder().build()
}
val scope = CodeGenScope(writer = this)
- ShortcutQueryParameterWriter.addNullCheckValidation(scope, method.parameters)
- method.methodBinder.convertAndReturn(
- parameters = method.parameters,
+ ShortcutQueryParameterWriter.addNullCheckValidation(scope, function.parameters)
+ function.functionBinder.convertAndReturn(
+ parameters = function.parameters,
adapters = upsertAdapters,
dbProperty = dbProperty,
scope = scope
@@ -588,28 +588,28 @@
return scope.generate()
}
- private fun createPreparedQueryMethodBody(method: WriteQueryMethod): XCodeBlock {
+ private fun createPreparedQueryFunctionBody(function: WriteQueryFunction): XCodeBlock {
val scope = CodeGenScope(this)
- val queryWriter = QueryWriter(method)
+ val queryWriter = QueryWriter(function)
val sqlVar = scope.getTmpVar("_sql")
val listSizeArgs = queryWriter.prepareQuery(sqlVar, scope)
- method.preparedQueryResultBinder.executeAndReturn(
+ function.preparedQueryResultBinder.executeAndReturn(
sqlQueryVar = sqlVar,
dbProperty = dbProperty,
bindStatement = { stmtVar -> queryWriter.bindArgs(stmtVar, listSizeArgs, this) },
- returnTypeName = method.returnType.asTypeName(),
+ returnTypeName = function.returnType.asTypeName(),
scope = scope
)
return scope.generate()
}
- private fun createQueryMethodBody(method: ReadQueryMethod): XCodeBlock {
+ private fun createQueryFunctionBody(function: ReadQueryFunction): XCodeBlock {
val scope = CodeGenScope(this)
- val queryWriter = QueryWriter(method)
+ val queryWriter = QueryWriter(function)
val sqlStringVar = scope.getTmpVar("_sql")
val (sqlVar, listSizeArgs) =
- if (method.queryResultBinder.usesCompatQueryWriter) {
+ if (function.queryResultBinder.usesCompatQueryWriter) {
val roomSQLiteQueryVar = scope.getTmpVar("_statement")
queryWriter.prepareReadAndBind(sqlStringVar, roomSQLiteQueryVar, scope)
roomSQLiteQueryVar to emptyList()
@@ -624,12 +624,12 @@
null
}
- method.queryResultBinder.convertAndReturn(
+ function.queryResultBinder.convertAndReturn(
sqlQueryVar = sqlVar,
dbProperty = dbProperty,
bindStatement = bindStatement,
- returnTypeName = method.returnType.asTypeName(),
- inTransaction = method.inTransaction,
+ returnTypeName = function.returnType.asTypeName(),
+ inTransaction = function.inTransaction,
scope = scope
)
@@ -637,16 +637,18 @@
}
// TODO(b/251459654): Handle @JvmOverloads in delegating functions with Kotlin codegen.
- private fun createDefaultImplMethodDelegate(method: KotlinDefaultMethodDelegate): XFunSpec {
+ private fun createDefaultImplFunctionDelegate(
+ function: KotlinDefaultFunctionDelegate
+ ): XFunSpec {
val scope = CodeGenScope(this)
- return overrideWithoutAnnotations(method.element, declaredDao)
+ return overrideWithoutAnnotations(function.element, declaredDao)
.apply {
- KotlinDefaultMethodDelegateBinder.executeAndReturn(
+ KotlinDefaultFunctionDelegateBinder.executeAndReturn(
daoName = dao.typeName,
daoImplName = dao.implTypeName,
- methodName = method.element.jvmName,
- returnType = method.element.returnType,
- parameterNames = method.element.parameters.map { it.name },
+ functionName = function.element.jvmName,
+ returnType = function.element.returnType,
+ parameterNames = function.element.parameters.map { it.name },
scope = scope
)
addCode(scope.generate())
@@ -654,17 +656,19 @@
.build()
}
- private fun createBoxedPrimitiveBridgeMethodDelegate(
- method: KotlinBoxedPrimitiveMethodDelegate
+ private fun createBoxedPrimitiveBridgeFunctionDelegate(
+ function: KotlinBoxedPrimitiveFunctionDelegate
): XFunSpec {
val scope = CodeGenScope(this)
- return overrideWithoutAnnotations(method.element, declaredDao)
+ return overrideWithoutAnnotations(function.element, declaredDao)
.apply {
- KotlinBoxedPrimitiveMethodDelegateBinder.execute(
- methodName = method.element.jvmName,
- returnType = method.element.returnType,
+ KotlinBoxedPrimitiveFunctionDelegateBinder.execute(
+ functionName = function.element.jvmName,
+ returnType = function.element.returnType,
parameters =
- method.concreteMethod.parameters.map { it.type.asTypeName() to it.name },
+ function.concreteFunction.parameters.map {
+ it.type.asTypeName() to it.name
+ },
scope = scope
)
addCode(scope.generate())
@@ -680,22 +684,22 @@
* Represents a query statement prepared in Dao implementation.
*
* @param fields This map holds all the member properties necessary for this query. The key is
- * the corresponding parameter name in the defining query method. The value is a pair from the
- * property declaration to definition.
- * @param functionImpl The body of the query method implementation.
+ * the corresponding parameter name in the defining query function. The value is a pair from
+ * the property declaration to definition.
+ * @param functionImpl The body of the query function implementation.
*/
data class PreparedStmtQuery(
val fields: Map<String, Pair<XPropertySpec, Any>>,
val functionImpl: XFunSpec
) {
companion object {
- // The key to be used in `fields` where the method requires a field that is not
+ // The key to be used in `fields` where the function requires a field that is not
// associated with any of its parameters
const val NO_PARAM_FIELD = "-"
}
}
- private class InsertMethodProperty(
+ private class InsertFunctionProperty(
val shortcutEntity: ShortcutEntity,
val onConflictText: String,
) :
@@ -713,18 +717,18 @@
class DeleteOrUpdateAdapterProperty(
val shortcutEntity: ShortcutEntity,
- val methodPrefix: String,
+ val functionPrefix: String,
val onConflictText: String,
) :
SharedPropertySpec(
- baseName = "${methodPrefix}AdapterOf${shortcutEntityFieldNamePart(shortcutEntity)}",
+ baseName = "${functionPrefix}AdapterOf${shortcutEntityFieldNamePart(shortcutEntity)}",
type = DELETE_OR_UPDATE_ADAPTER.parametrizedBy(shortcutEntity.dataClass.typeName)
) {
override fun prepare(writer: TypeWriter, builder: XPropertySpec.Builder) {}
override fun getUniqueKey(): String {
return "${shortcutEntity.dataClass.typeName}-${shortcutEntity.entityTypeName}" +
- "$methodPrefix$onConflictText"
+ "$functionPrefix$onConflictText"
}
}
diff --git a/room/room-compiler/src/main/kotlin/androidx/room/writer/DatabaseWriter.kt b/room/room-compiler/src/main/kotlin/androidx/room/writer/DatabaseWriter.kt
index 7d0e36f..f66b224 100644
--- a/room/room-compiler/src/main/kotlin/androidx/room/writer/DatabaseWriter.kt
+++ b/room/room-compiler/src/main/kotlin/androidx/room/writer/DatabaseWriter.kt
@@ -40,7 +40,7 @@
import androidx.room.ext.decapitalize
import androidx.room.ext.stripNonJava
import androidx.room.solver.CodeGenScope
-import androidx.room.vo.DaoMethod
+import androidx.room.vo.DaoFunction
import androidx.room.vo.Database
import java.util.Locale
import javax.lang.model.element.Modifier
@@ -112,7 +112,7 @@
KotlinCollectionMemberNames.MUTABLE_MAP_OF
)
}
- database.daoMethods.forEach {
+ database.daoFunctions.forEach {
addStatement(
"%L.put(%L, %T.%L())",
typeConvertersVar,
@@ -121,7 +121,7 @@
CodeLanguage.KOTLIN -> XCodeBlock.ofKotlinClassLiteral(it.dao.typeName)
},
it.dao.implTypeName,
- DaoWriter.GET_LIST_OF_TYPE_CONVERTERS_METHOD
+ DaoWriter.GET_LIST_OF_TYPE_CONVERTERS_FUNCTION
)
}
addStatement("return %L", typeConvertersVar)
@@ -351,7 +351,7 @@
private fun addDaoImpls(builder: XTypeSpec.Builder) {
val scope = CodeGenScope(this)
- database.daoMethods.forEach { method ->
+ database.daoFunctions.forEach { method ->
val name =
method.dao.typeName.simpleNames.first().decapitalize(Locale.US).stripNonJava()
val privateDaoProperty =
@@ -411,7 +411,7 @@
}
}
- private fun createDaoGetter(method: DaoMethod, daoProperty: XPropertySpec): XFunSpec {
+ private fun createDaoGetter(method: DaoFunction, daoProperty: XPropertySpec): XFunSpec {
val body =
XCodeBlock.builder().applyTo { language ->
// For Java we implement the memoization logic in the Dao getter, meanwhile for
diff --git a/room/room-compiler/src/main/kotlin/androidx/room/writer/QueryWriter.kt b/room/room-compiler/src/main/kotlin/androidx/room/writer/QueryWriter.kt
index 0869212..f152389 100644
--- a/room/room-compiler/src/main/kotlin/androidx/room/writer/QueryWriter.kt
+++ b/room/room-compiler/src/main/kotlin/androidx/room/writer/QueryWriter.kt
@@ -28,7 +28,7 @@
import androidx.room.parser.ParsedQuery
import androidx.room.parser.Section
import androidx.room.solver.CodeGenScope
-import androidx.room.vo.QueryMethod
+import androidx.room.vo.QueryFunction
import androidx.room.vo.QueryParameter
/** Writes the SQL query and arguments for a QueryMethod. */
@@ -39,8 +39,8 @@
) {
constructor(
- queryMethod: QueryMethod
- ) : this(queryMethod.parameters, queryMethod.sectionToParamMapping, queryMethod.query)
+ queryFunction: QueryFunction
+ ) : this(queryFunction.parameters, queryFunction.sectionToParamMapping, queryFunction.query)
fun prepareReadAndBind(
outSqlQueryName: String,
diff --git a/room/room-compiler/src/main/kotlin/androidx/room/writer/RelationCollectorFunctionWriter.kt b/room/room-compiler/src/main/kotlin/androidx/room/writer/RelationCollectorFunctionWriter.kt
index 4d18e8a..c668ed4 100644
--- a/room/room-compiler/src/main/kotlin/androidx/room/writer/RelationCollectorFunctionWriter.kt
+++ b/room/room-compiler/src/main/kotlin/androidx/room/writer/RelationCollectorFunctionWriter.kt
@@ -56,7 +56,7 @@
override fun getUniqueKey(): String {
val relation = collector.relation
- return "RelationCollectorMethodWriter" +
+ return "RelationCollectorFunctionWriter" +
"-${collector.mapTypeName}" +
"-${relation.entity.typeName.toString(CodeLanguage.JAVA)}" +
"-${relation.entityField.columnName}" +
@@ -207,7 +207,7 @@
private fun XCodeBlock.Builder.addRecursiveFetchCall(
scope: CodeGenScope,
- methodName: String,
+ functionName: String,
) {
val utilFunction =
RELATION_UTIL.let {
@@ -239,7 +239,7 @@
val recursiveCall =
XCodeBlock.of(
"%L(%L, %L)",
- methodName,
+ functionName,
PARAM_CONNECTION_VARIABLE,
paramName
)
diff --git a/room/room-compiler/src/test/kotlin/androidx/room/processor/BaseDaoTest.kt b/room/room-compiler/src/test/kotlin/androidx/room/processor/BaseDaoTest.kt
index a8095c4..48fe74f 100644
--- a/room/room-compiler/src/test/kotlin/androidx/room/processor/BaseDaoTest.kt
+++ b/room/room-compiler/src/test/kotlin/androidx/room/processor/BaseDaoTest.kt
@@ -26,7 +26,7 @@
void insertMe(T t);
"""
) { dao ->
- assertThat(dao.insertMethods.size, `is`(1))
+ assertThat(dao.insertFunctions.size, `is`(1))
}
}
@@ -38,7 +38,7 @@
void insertMe(T[] t);
"""
) { dao ->
- assertThat(dao.insertMethods.size, `is`(1))
+ assertThat(dao.insertFunctions.size, `is`(1))
}
}
@@ -50,7 +50,7 @@
void insertMe(T... t);
"""
) { dao ->
- assertThat(dao.insertMethods.size, `is`(1))
+ assertThat(dao.insertFunctions.size, `is`(1))
}
}
@@ -62,7 +62,7 @@
void insertMe(List<T> t);
"""
) { dao ->
- assertThat(dao.insertMethods.size, `is`(1))
+ assertThat(dao.insertFunctions.size, `is`(1))
}
}
@@ -74,7 +74,7 @@
void deleteMe(T t);
"""
) { dao ->
- assertThat(dao.deleteMethods.size, `is`(1))
+ assertThat(dao.deleteFunctions.size, `is`(1))
}
}
@@ -86,7 +86,7 @@
void deleteMe(T[] t);
"""
) { dao ->
- assertThat(dao.deleteMethods.size, `is`(1))
+ assertThat(dao.deleteFunctions.size, `is`(1))
}
}
@@ -98,7 +98,7 @@
void deleteMe(T... t);
"""
) { dao ->
- assertThat(dao.deleteMethods.size, `is`(1))
+ assertThat(dao.deleteFunctions.size, `is`(1))
}
}
@@ -110,7 +110,7 @@
void deleteMe(List<T> t);
"""
) { dao ->
- assertThat(dao.deleteMethods.size, `is`(1))
+ assertThat(dao.deleteFunctions.size, `is`(1))
}
}
@@ -122,7 +122,7 @@
void updateMe(T t);
"""
) { dao ->
- assertThat(dao.updateMethods.size, `is`(1))
+ assertThat(dao.updateFunctions.size, `is`(1))
}
}
@@ -134,7 +134,7 @@
void updateMe(T[] t);
"""
) { dao ->
- assertThat(dao.updateMethods.size, `is`(1))
+ assertThat(dao.updateFunctions.size, `is`(1))
}
}
@@ -146,7 +146,7 @@
void updateMe(T... t);
"""
) { dao ->
- assertThat(dao.updateMethods.size, `is`(1))
+ assertThat(dao.updateFunctions.size, `is`(1))
}
}
@@ -158,7 +158,7 @@
void updateMe(List<T> t);
"""
) { dao ->
- assertThat(dao.updateMethods.size, `is`(1))
+ assertThat(dao.updateFunctions.size, `is`(1))
}
}
diff --git a/room/room-compiler/src/test/kotlin/androidx/room/processor/CustomConverterProcessorTest.kt b/room/room-compiler/src/test/kotlin/androidx/room/processor/CustomConverterProcessorTest.kt
index f4ff34f..5027258 100644
--- a/room/room-compiler/src/test/kotlin/androidx/room/processor/CustomConverterProcessorTest.kt
+++ b/room/room-compiler/src/test/kotlin/androidx/room/processor/CustomConverterProcessorTest.kt
@@ -286,7 +286,7 @@
.isEqualTo(XTypeName.BOXED_SHORT.copy(nullable = true))
assertThat(converter?.toTypeName).isEqualTo(XTypeName.BOXED_CHAR.copy(nullable = true))
invocation.assertCompilationResult {
- hasErrorContaining("Multiple methods define the same conversion")
+ hasErrorContaining("Multiple functions define the same conversion")
}
}
}
@@ -321,7 +321,7 @@
if (invocation.isKsp) {
// no error
} else {
- hasErrorContaining("Multiple methods define the same")
+ hasErrorContaining("Multiple functions define the same")
}
}
}
diff --git a/room/room-compiler/src/test/kotlin/androidx/room/processor/DaoProcessorTest.kt b/room/room-compiler/src/test/kotlin/androidx/room/processor/DaoProcessorTest.kt
index 6ebead5..c8303f2 100644
--- a/room/room-compiler/src/test/kotlin/androidx/room/processor/DaoProcessorTest.kt
+++ b/room/room-compiler/src/test/kotlin/androidx/room/processor/DaoProcessorTest.kt
@@ -23,13 +23,13 @@
import androidx.room.compiler.processing.util.XTestInvocation
import androidx.room.compiler.processing.util.compileFiles
import androidx.room.ext.RoomTypeNames.ROOM_DB
-import androidx.room.processor.ProcessorErrors.nullableCollectionOrArrayReturnTypeInDaoMethod
-import androidx.room.processor.ProcessorErrors.nullableComponentInDaoMethodReturnType
+import androidx.room.processor.ProcessorErrors.nullableCollectionOrArrayReturnTypeInDaoFunction
+import androidx.room.processor.ProcessorErrors.nullableComponentInDaoFunctionReturnType
import androidx.room.runKspTestWithK1
import androidx.room.runProcessorTestWithK1
import androidx.room.testing.context
import androidx.room.vo.Dao
-import androidx.room.vo.ReadQueryMethod
+import androidx.room.vo.ReadQueryFunction
import androidx.room.vo.Warning
import createVerifierFromEntitiesAndViews
import java.io.File
@@ -92,7 +92,7 @@
"""
) { _, invocation ->
invocation.assertCompilationResult {
- hasErrorContaining(ProcessorErrors.INVALID_ANNOTATION_COUNT_IN_DAO_METHOD)
+ hasErrorContaining(ProcessorErrors.INVALID_ANNOTATION_COUNT_IN_DAO_FUNCTION)
}
}
}
@@ -116,10 +116,10 @@
) { _, invocation ->
invocation.assertCompilationResult {
hasRawOutputContaining(
- ProcessorErrors.INVALID_ANNOTATION_COUNT_IN_DAO_METHOD +
+ ProcessorErrors.INVALID_ANNOTATION_COUNT_IN_DAO_FUNCTION +
" - test.library.MissingAnnotationsBaseDao.getFoo()"
)
- hasErrorContaining(ProcessorErrors.INVALID_ANNOTATION_COUNT_IN_DAO_METHOD)
+ hasErrorContaining(ProcessorErrors.INVALID_ANNOTATION_COUNT_IN_DAO_FUNCTION)
}
}
}
@@ -136,7 +136,8 @@
"""
) { _, invocation ->
invocation.assertCompilationResult {
- hasErrorContaining(ProcessorErrors.INVALID_ANNOTATION_COUNT_IN_DAO_METHOD).onLine(8)
+ hasErrorContaining(ProcessorErrors.INVALID_ANNOTATION_COUNT_IN_DAO_FUNCTION)
+ .onLine(8)
}
}
}
@@ -151,8 +152,8 @@
}
"""
) { dao, _ ->
- assertThat(dao.queryMethods.size, `is`(1))
- val method = dao.queryMethods.first()
+ assertThat(dao.queryFunctions.size, `is`(1))
+ val method = dao.queryFunctions.first()
assertThat(method.element.jvmName, `is`("getIds"))
}
}
@@ -167,8 +168,8 @@
}
"""
) { dao, _ ->
- assertThat(dao.queryMethods.size, `is`(1))
- val method = dao.queryMethods.first()
+ assertThat(dao.queryFunctions.size, `is`(1))
+ val method = dao.queryFunctions.first()
assertThat(method.element.jvmName, `is`("getIds"))
}
}
@@ -185,11 +186,11 @@
}
"""
) { dao, _ ->
- assertThat(dao.queryMethods.size, `is`(1))
- val method = dao.queryMethods.first()
+ assertThat(dao.queryFunctions.size, `is`(1))
+ val method = dao.queryFunctions.first()
assertThat(method.element.jvmName, `is`("getIds"))
- assertThat(dao.insertMethods.size, `is`(1))
- val insertMethod = dao.insertMethods.first()
+ assertThat(dao.insertFunctions.size, `is`(1))
+ val insertMethod = dao.insertFunctions.first()
assertThat(insertMethod.element.jvmName, `is`("insert"))
}
}
@@ -204,8 +205,8 @@
}
"""
) { dao, _ ->
- assertThat(dao.queryMethods.size, `is`(1))
- val method = dao.queryMethods.first()
+ assertThat(dao.queryFunctions.size, `is`(1))
+ val method = dao.queryFunctions.first()
assertThat(method.element.jvmName, `is`("getIds"))
}
}
@@ -229,9 +230,9 @@
`is`(setOf(Warning.ALL, Warning.QUERY_MISMATCH))
)
- dao.queryMethods.forEach {
+ dao.queryFunctions.forEach {
assertThat(
- QueryMethodProcessor(
+ QueryFunctionProcessor(
baseContext = daoProcessor.context,
containing = dao.element.type,
executableElement = it.element,
@@ -297,9 +298,9 @@
`is`(setOf(Warning.QUERY_MISMATCH))
)
- dao.queryMethods.forEach {
+ dao.queryFunctions.forEach {
assertThat(
- QueryMethodProcessor(
+ QueryFunctionProcessor(
baseContext = daoProcessor.context,
containing = dao.element.type,
executableElement = it.element,
@@ -332,9 +333,9 @@
}
"""
) { dao, invocation ->
- assertThat(dao.queryMethods.size, `is`(1))
+ assertThat(dao.queryFunctions.size, `is`(1))
assertThat(
- dao.queryMethods.filterIsInstance<ReadQueryMethod>().first().inTransaction,
+ dao.queryFunctions.filterIsInstance<ReadQueryFunction>().first().inTransaction,
`is`(false)
)
invocation.assertCompilationResult {
@@ -362,9 +363,9 @@
}
"""
) { dao, invocation ->
- assertThat(dao.queryMethods.size, `is`(1))
+ assertThat(dao.queryFunctions.size, `is`(1))
assertThat(
- dao.queryMethods.filterIsInstance<ReadQueryMethod>().first().inTransaction,
+ dao.queryFunctions.filterIsInstance<ReadQueryFunction>().first().inTransaction,
`is`(false)
)
invocation.assertCompilationResult { hasNoWarnings() }
@@ -391,9 +392,9 @@
"""
) { dao, invocation ->
// test sanity
- assertThat(dao.queryMethods.size, `is`(1))
+ assertThat(dao.queryFunctions.size, `is`(1))
assertThat(
- dao.queryMethods.filterIsInstance<ReadQueryMethod>().first().inTransaction,
+ dao.queryFunctions.filterIsInstance<ReadQueryFunction>().first().inTransaction,
`is`(true)
)
invocation.assertCompilationResult { hasNoWarnings() }
@@ -410,8 +411,8 @@
}
"""
) { dao, _ ->
- assertThat(dao.queryMethods.size, `is`(1))
- val method = dao.queryMethods.first()
+ assertThat(dao.queryFunctions.size, `is`(1))
+ val method = dao.queryFunctions.first()
assertThat(method.element.jvmName, `is`("deleteAllIds"))
}
}
@@ -426,8 +427,8 @@
}
"""
) { dao, invocation ->
- assertThat(dao.queryMethods.size, `is`(1))
- val method = dao.queryMethods.first()
+ assertThat(dao.queryFunctions.size, `is`(1))
+ val method = dao.queryFunctions.first()
assertThat(method.element.jvmName, `is`("getAllIds"))
invocation.assertCompilationResult {
hasErrorContaining(ProcessorErrors.cannotFindQueryResultAdapter("void"))
@@ -463,7 +464,7 @@
)
.process()
invocation.assertCompilationResult {
- hasWarningContaining(ProcessorErrors.JVM_NAME_ON_OVERRIDDEN_METHOD)
+ hasWarningContaining(ProcessorErrors.JVM_NAME_ON_OVERRIDDEN_FUNCTION)
}
}
}
@@ -656,55 +657,55 @@
.process()
invocation.assertCompilationResult {
hasWarningContaining(
- nullableCollectionOrArrayReturnTypeInDaoMethod(
+ nullableCollectionOrArrayReturnTypeInDaoFunction(
"kotlin.collections.List<MyEntity>?",
"Collection"
)
)
hasWarningContaining(
- nullableCollectionOrArrayReturnTypeInDaoMethod(
+ nullableCollectionOrArrayReturnTypeInDaoFunction(
"com.google.common.collect.ImmutableList<MyEntity>?",
"Collection"
)
)
hasWarningContaining(
- nullableCollectionOrArrayReturnTypeInDaoMethod(
+ nullableCollectionOrArrayReturnTypeInDaoFunction(
"kotlin.Array<MyEntity>?",
"Array"
)
)
hasWarningContaining(
- nullableCollectionOrArrayReturnTypeInDaoMethod(
+ nullableCollectionOrArrayReturnTypeInDaoFunction(
"java.util.Optional<MyEntity>?",
"Optional"
)
)
hasWarningContaining(
- nullableCollectionOrArrayReturnTypeInDaoMethod(
+ nullableCollectionOrArrayReturnTypeInDaoFunction(
"com.google.common.base.Optional<MyEntity>?",
"Optional"
)
)
hasWarningContaining(
- nullableCollectionOrArrayReturnTypeInDaoMethod(
+ nullableCollectionOrArrayReturnTypeInDaoFunction(
"kotlin.collections.Map<MyEntity, MyOtherEntity>?",
"Collection"
)
)
hasWarningContaining(
- nullableCollectionOrArrayReturnTypeInDaoMethod(
+ nullableCollectionOrArrayReturnTypeInDaoFunction(
"com.google.common.collect.ImmutableMap<MyEntity, MyOtherEntity>?",
"Collection"
)
)
hasWarningContaining(
- nullableCollectionOrArrayReturnTypeInDaoMethod(
+ nullableCollectionOrArrayReturnTypeInDaoFunction(
"com.google.common.collect.ImmutableSetMultimap<MyEntity, MyOtherEntity>?",
"Collection"
)
)
hasWarningContaining(
- nullableCollectionOrArrayReturnTypeInDaoMethod(
+ nullableCollectionOrArrayReturnTypeInDaoFunction(
"com.google.common.collect.ImmutableListMultimap<MyEntity, MyOtherEntity>?",
"Collection"
)
@@ -782,31 +783,31 @@
.process()
invocation.assertCompilationResult {
hasWarningContaining(
- nullableComponentInDaoMethodReturnType("kotlin.collections.List<MyEntity?>")
+ nullableComponentInDaoFunctionReturnType("kotlin.collections.List<MyEntity?>")
)
hasWarningContaining(
- nullableComponentInDaoMethodReturnType(
+ nullableComponentInDaoFunctionReturnType(
"com.google.common.collect.ImmutableList<MyEntity?>"
)
)
hasWarningContaining(
- nullableComponentInDaoMethodReturnType("kotlin.Array<MyEntity?>")
+ nullableComponentInDaoFunctionReturnType("kotlin.Array<MyEntity?>")
)
hasWarningContaining(
- nullableComponentInDaoMethodReturnType("java.util.Optional<MyEntity?>")
+ nullableComponentInDaoFunctionReturnType("java.util.Optional<MyEntity?>")
)
hasWarningContaining(
- nullableComponentInDaoMethodReturnType(
+ nullableComponentInDaoFunctionReturnType(
"com.google.common.base.Optional<MyEntity?>"
)
)
hasWarningContaining(
- nullableComponentInDaoMethodReturnType(
+ nullableComponentInDaoFunctionReturnType(
"kotlin.collections.Map<MyEntity?, MyOtherEntity>"
)
)
hasWarningContaining(
- nullableComponentInDaoMethodReturnType(
+ nullableComponentInDaoFunctionReturnType(
"com.google.common.collect.ImmutableMap<MyEntity?, MyOtherEntity>"
)
)
@@ -814,17 +815,17 @@
// convert the map to a mutable one and re-run the `findQueryResultAdapter`
// algorithm
hasWarningContaining(
- nullableComponentInDaoMethodReturnType(
+ nullableComponentInDaoFunctionReturnType(
"kotlin.collections.MutableMap<MyEntity?, MyOtherEntity>"
)
)
hasWarningContaining(
- nullableComponentInDaoMethodReturnType(
+ nullableComponentInDaoFunctionReturnType(
"com.google.common.collect.ImmutableSetMultimap<MyEntity?, MyOtherEntity>"
)
)
hasWarningContaining(
- nullableComponentInDaoMethodReturnType(
+ nullableComponentInDaoFunctionReturnType(
"com.google.common.collect.ImmutableListMultimap<MyEntity?, MyOtherEntity>"
)
)
diff --git a/room/room-compiler/src/test/kotlin/androidx/room/processor/DataClassProcessorTargetMethodTest.kt b/room/room-compiler/src/test/kotlin/androidx/room/processor/DataClassProcessorTargetFunctionTest.kt
similarity index 94%
rename from room/room-compiler/src/test/kotlin/androidx/room/processor/DataClassProcessorTargetMethodTest.kt
rename to room/room-compiler/src/test/kotlin/androidx/room/processor/DataClassProcessorTargetFunctionTest.kt
index 5fdb87b..3a1f875b 100644
--- a/room/room-compiler/src/test/kotlin/androidx/room/processor/DataClassProcessorTargetMethodTest.kt
+++ b/room/room-compiler/src/test/kotlin/androidx/room/processor/DataClassProcessorTargetFunctionTest.kt
@@ -26,7 +26,7 @@
import org.junit.runners.JUnit4
@RunWith(JUnit4::class)
-class DataClassProcessorTargetMethodTest {
+class DataClassProcessorTargetFunctionTest {
companion object {
val MY_DATA_CLASS = XClassName.get("foo.bar", "MyDataClass")
@@ -56,7 +56,7 @@
}
@Test
- fun invalidAnnotationInMethod() {
+ fun invalidAnnotationInFunction() {
val source =
Source.java(
MY_DATA_CLASS.canonicalName,
@@ -67,7 +67,7 @@
class MyDataClass {
@PrimaryKey
- void someRandomMethod() { }
+ void someRandomFunction() { }
}
"""
)
@@ -84,7 +84,7 @@
}
@Test
- fun invalidAnnotationInStaticMethod() {
+ fun invalidAnnotationInStaticFunction() {
val source =
Source.java(
MY_DATA_CLASS.canonicalName,
@@ -95,7 +95,7 @@
class MyDataClass {
@PrimaryKey
- static void someRandomMethod() { }
+ static void someRandomFunction() { }
}
"""
)
@@ -112,7 +112,7 @@
}
@Test
- fun invalidAnnotationInAbstractMethod() {
+ fun invalidAnnotationInAbstractFunction() {
val source =
Source.java(
MY_DATA_CLASS.canonicalName,
@@ -123,7 +123,7 @@
abstract class MyDataClass {
@PrimaryKey
- abstract void someRandomMethod();
+ abstract void someRandomFunction();
}
"""
)
@@ -140,14 +140,14 @@
}
@Test
- fun invalidAnnotationInAutoValueMethod() {
+ fun invalidAnnotationInAutoValueFunction() {
singleRun(
"""
@AutoValue.CopyAnnotations
@PrimaryKey
abstract long getId();
@ColumnInfo(name = "column_name")
- void someRandomMethod() { }
+ void someRandomFunction() { }
static MyDataClass create(long id) { return new AutoValue_MyDataClass(id); }
""",
"""
@@ -170,7 +170,7 @@
}
@Test
- fun invalidAnnotationInAutoValueParentMethod() {
+ fun invalidAnnotationInAutoValueParentFunction() {
val parent =
"""
package foo.bar;
@@ -181,7 +181,7 @@
@ColumnInfo(name = "column_name")
abstract String getValue();
@ColumnInfo(name = "another_column_name")
- void someRandomMethod() { }
+ void someRandomFunction() { }
}
"""
singleRunFullClass(
@@ -264,7 +264,7 @@
}
@Test
- fun validAnnotationInAutoValueAbstractMethod() {
+ fun validAnnotationInAutoValueAbstractFunction() {
singleRun(
"""
@AutoValue.CopyAnnotations
@@ -283,7 +283,7 @@
}
@Test
- fun validAnnotationInAutoValueParentMethod() {
+ fun validAnnotationInAutoValueParentFunction() {
val parent =
"""
package foo.bar;
@@ -328,7 +328,7 @@
}
@Test
- fun validAnnotationInAutoValueImplementedInterfaceMethod() {
+ fun validAnnotationInAutoValueImplementedInterfaceFunction() {
val parent =
"""
package foo.bar;
@@ -373,7 +373,7 @@
}
@Test
- fun validEmbeddedAnnotationInAutoValueAbstractMethod() {
+ fun validEmbeddedAnnotationInAutoValueAbstractFunction() {
val embeddedDataClass =
"""
package foo.bar;
@@ -415,7 +415,7 @@
}
@Test
- fun validRelationAnnotationInAutoValueAbstractMethod() {
+ fun validRelationAnnotationInAutoValueAbstractFunction() {
val embeddedDataClass =
"""
package foo.bar;
@@ -520,7 +520,7 @@
}
/**
- * KSP and JavaAP name methods different. To feel more native, we use the name based on the
+ * KSP and JavaAP name functions differently. To feel more native, we use the name based on the
* processor. It only matters for the test assertion
*/
private val XTestInvocation.functionKindName: String
diff --git a/room/room-compiler/src/test/kotlin/androidx/room/processor/DatabaseProcessorTest.kt b/room/room-compiler/src/test/kotlin/androidx/room/processor/DatabaseProcessorTest.kt
index bc483ad..be66f51a 100644
--- a/room/room-compiler/src/test/kotlin/androidx/room/processor/DatabaseProcessorTest.kt
+++ b/room/room-compiler/src/test/kotlin/androidx/room/processor/DatabaseProcessorTest.kt
@@ -40,7 +40,7 @@
import androidx.room.testing.context
import androidx.room.vo.Database
import androidx.room.vo.DatabaseView
-import androidx.room.vo.ReadQueryMethod
+import androidx.room.vo.ReadQueryFunction
import androidx.room.vo.Warning
import com.google.auto.service.processor.AutoServiceProcessor
import com.google.testing.junit.testparameterinjector.TestParameter
@@ -247,7 +247,7 @@
USER,
USER_DAO
) { db, _ ->
- assertThat(db.daoMethods.size, `is`(1))
+ assertThat(db.daoFunctions.size, `is`(1))
assertThat(db.entities.size, `is`(1))
}
}
@@ -267,9 +267,12 @@
BOOK,
BOOK_DAO
) { db, _ ->
- assertThat(db.daoMethods.size, `is`(2))
+ assertThat(db.daoFunctions.size, `is`(2))
assertThat(db.entities.size, `is`(2))
- assertThat(db.daoMethods.map { it.element.jvmName }, `is`(listOf("userDao", "bookDao")))
+ assertThat(
+ db.daoFunctions.map { it.element.jvmName },
+ `is`(listOf("userDao", "bookDao"))
+ )
assertThat(
db.entities.map { it.type.asTypeName().toString(CodeLanguage.JAVA) },
`is`(listOf("foo.bar.User", "foo.bar.Book"))
@@ -536,7 +539,7 @@
USER_DAO
) { _, invocation ->
invocation.assertCompilationResult {
- hasErrorContaining(ProcessorErrors.DAO_METHOD_CONFLICTS_WITH_OTHERS)
+ hasErrorContaining(ProcessorErrors.DAO_FUNCTION_CONFLICTS_WITH_OTHERS)
hasErrorContaining(
ProcessorErrors.duplicateDao("foo.bar.UserDao", listOf("userDao", "userDao2"))
)
@@ -924,11 +927,11 @@
USER,
USER_DAO
) { db, _ ->
- val userDao = db.daoMethods.first().dao
- val insertionMethod = userDao.insertMethods.find { it.element.jvmName == "insert" }
+ val userDao = db.daoFunctions.first().dao
+ val insertionMethod = userDao.insertFunctions.find { it.element.jvmName == "insert" }
assertThat(insertionMethod, notNullValue())
val loadOne =
- userDao.queryMethods.filterIsInstance<ReadQueryMethod>().find {
+ userDao.queryFunctions.filterIsInstance<ReadQueryFunction>().find {
it.element.jvmName == "loadOne"
}
assertThat(loadOne, notNullValue())
@@ -941,7 +944,7 @@
)
val withConverter =
- userDao.queryMethods.filterIsInstance<ReadQueryMethod>().find {
+ userDao.queryFunctions.filterIsInstance<ReadQueryFunction>().find {
it.element.jvmName == "loadWithConverter"
}
assertThat(withConverter, notNullValue())
@@ -970,9 +973,9 @@
USER,
USER_DAO
) { db, _ ->
- val userDao = db.daoMethods.first().dao
+ val userDao = db.daoFunctions.first().dao
val loadOne =
- userDao.queryMethods.filterIsInstance<ReadQueryMethod>().find {
+ userDao.queryFunctions.filterIsInstance<ReadQueryFunction>().find {
it.element.jvmName == "loadOneDataClass"
}
assertThat(loadOne, notNullValue())
@@ -981,7 +984,7 @@
val adapterDataClass = (adapter as DataClassRowAdapter).dataClass
val loadAll =
- userDao.queryMethods.filterIsInstance<ReadQueryMethod>().find {
+ userDao.queryFunctions.filterIsInstance<ReadQueryFunction>().find {
it.element.jvmName == "loadAllDataClasses"
}
assertThat(loadAll, notNullValue())
@@ -992,7 +995,7 @@
assertThat(adapterDataClass, sameInstance(loadAllDataClass))
val withConverter =
- userDao.queryMethods.filterIsInstance<ReadQueryMethod>().find {
+ userDao.queryFunctions.filterIsInstance<ReadQueryFunction>().find {
it.element.jvmName == "loadDataClassWithConverter"
}
assertThat(withConverter, notNullValue())
@@ -1261,9 +1264,9 @@
val element = invocation.processingEnv.requireTypeElement("foo.bar.MyDb")
val result =
DatabaseProcessor(baseContext = invocation.context, element = element).process()
- assertThat(result.daoMethods).hasSize(0)
+ assertThat(result.daoFunctions).hasSize(0)
invocation.assertCompilationResult {
- hasErrorContaining(ProcessorErrors.DATABASE_INVALID_DAO_METHOD_RETURN_TYPE)
+ hasErrorContaining(ProcessorErrors.DATABASE_INVALID_DAO_FUNCTION_RETURN_TYPE)
}
}
}
@@ -1598,7 +1601,7 @@
val element = invocation.processingEnv.requireTypeElement("foo.bar.MyDb")
DatabaseProcessor(baseContext = invocation.context, element = element).process()
invocation.assertCompilationResult {
- hasWarningContaining(ProcessorErrors.JVM_NAME_ON_OVERRIDDEN_METHOD)
+ hasWarningContaining(ProcessorErrors.JVM_NAME_ON_OVERRIDDEN_FUNCTION)
}
}
}
diff --git a/room/room-compiler/src/test/kotlin/androidx/room/processor/DeleteMethodProcessorTest.kt b/room/room-compiler/src/test/kotlin/androidx/room/processor/DeleteFunctionProcessorTest.kt
similarity index 83%
rename from room/room-compiler/src/test/kotlin/androidx/room/processor/DeleteMethodProcessorTest.kt
rename to room/room-compiler/src/test/kotlin/androidx/room/processor/DeleteFunctionProcessorTest.kt
index 0a78781..687a758 100644
--- a/room/room-compiler/src/test/kotlin/androidx/room/processor/DeleteMethodProcessorTest.kt
+++ b/room/room-compiler/src/test/kotlin/androidx/room/processor/DeleteFunctionProcessorTest.kt
@@ -20,14 +20,14 @@
import androidx.room.compiler.processing.XType
import androidx.room.processor.ProcessorErrors.CANNOT_FIND_DELETE_RESULT_ADAPTER
import androidx.room.processor.ProcessorErrors.DELETE_MISSING_PARAMS
-import androidx.room.vo.DeleteMethod
+import androidx.room.vo.DeleteFunction
import org.junit.runner.RunWith
import org.junit.runners.JUnit4
@Suppress("PLATFORM_CLASS_MAPPED_TO_KOTLIN")
@RunWith(JUnit4::class)
-class DeleteMethodProcessorTest :
- DeleteOrUpdateShortcutMethodProcessorTest<DeleteMethod>(Delete::class) {
+class DeleteFunctionProcessorTest :
+ DeleteOrUpdateShortcutFunctionProcessorTest<DeleteFunction>(Delete::class) {
override fun invalidReturnTypeError(): String = CANNOT_FIND_DELETE_RESULT_ADAPTER
override fun noParamsError(): String = DELETE_MISSING_PARAMS
@@ -36,7 +36,7 @@
baseContext: Context,
containing: XType,
executableElement: XMethodElement
- ): DeleteMethod {
- return DeleteMethodProcessor(baseContext, containing, executableElement).process()
+ ): DeleteFunction {
+ return DeleteFunctionProcessor(baseContext, containing, executableElement).process()
}
}
diff --git a/room/room-compiler/src/test/kotlin/androidx/room/processor/DeleteOrUpdateShortcutMethodProcessorTest.kt b/room/room-compiler/src/test/kotlin/androidx/room/processor/DeleteOrUpdateShortcutFunctionProcessorTest.kt
similarity index 95%
rename from room/room-compiler/src/test/kotlin/androidx/room/processor/DeleteOrUpdateShortcutMethodProcessorTest.kt
rename to room/room-compiler/src/test/kotlin/androidx/room/processor/DeleteOrUpdateShortcutFunctionProcessorTest.kt
index 8c900a7..2fd3542 100644
--- a/room/room-compiler/src/test/kotlin/androidx/room/processor/DeleteOrUpdateShortcutMethodProcessorTest.kt
+++ b/room/room-compiler/src/test/kotlin/androidx/room/processor/DeleteOrUpdateShortcutFunctionProcessorTest.kt
@@ -37,12 +37,12 @@
import androidx.room.ext.RxJava3TypeNames
import androidx.room.runProcessorTestWithK1
import androidx.room.testing.context
-import androidx.room.vo.DeleteOrUpdateShortcutMethod
+import androidx.room.vo.DeleteOrUpdateShortcutFunction
import kotlin.reflect.KClass
import org.junit.Test
-/** Base test class for shortcut methods. */
-abstract class DeleteOrUpdateShortcutMethodProcessorTest<out T : DeleteOrUpdateShortcutMethod>(
+/** Base test class for shortcut functions. */
+abstract class DeleteOrUpdateShortcutFunctionProcessorTest<out T : DeleteOrUpdateShortcutFunction>(
val annotation: KClass<out Annotation>
) {
companion object {
@@ -113,14 +113,14 @@
@Test
fun singleNullableParamError() {
- singleShortcutMethodKotlin(
+ singleShortcutFunction(
"""
@${annotation.java.canonicalName}
abstract fun foo(user: User?)
"""
) { _, invocation ->
invocation.assertCompilationResult {
- hasErrorContaining(ProcessorErrors.nullableParamInShortcutMethod("foo.bar.User"))
+ hasErrorContaining(ProcessorErrors.nullableParamInShortcutFunction("foo.bar.User"))
}
}
}
@@ -169,14 +169,14 @@
@Test
fun twoNullableParamError() {
- singleShortcutMethodKotlin(
+ singleShortcutFunction(
"""
@${annotation.java.canonicalName}
abstract fun foo(user1: User?, user2: User?)
"""
) { _, invocation ->
invocation.assertCompilationResult {
- hasErrorContaining(ProcessorErrors.nullableParamInShortcutMethod("foo.bar.User"))
+ hasErrorContaining(ProcessorErrors.nullableParamInShortcutFunction("foo.bar.User"))
hasErrorCount(2)
}
}
@@ -224,7 +224,7 @@
@Test
fun nullableListParamError() {
- singleShortcutMethodKotlin(
+ singleShortcutFunction(
"""
@${annotation.java.canonicalName}
abstract fun foo(users: List<User?>)
@@ -232,7 +232,7 @@
) { _, invocation ->
invocation.assertCompilationResult {
hasErrorContaining(
- ProcessorErrors.nullableParamInShortcutMethod(
+ ProcessorErrors.nullableParamInShortcutFunction(
"java.util.List<? extends foo.bar.User>"
)
)
@@ -264,14 +264,16 @@
@Test
fun nullableArrayParamError() {
- singleShortcutMethodKotlin(
+ singleShortcutFunction(
"""
@${annotation.java.canonicalName}
abstract fun foo(users: Array<User?>)
"""
) { _, invocation ->
invocation.assertCompilationResult {
- hasErrorContaining(ProcessorErrors.nullableParamInShortcutMethod("foo.bar.User[]"))
+ hasErrorContaining(
+ ProcessorErrors.nullableParamInShortcutFunction("foo.bar.User[]")
+ )
}
}
}
@@ -302,7 +304,7 @@
@Test
fun nullableSetParamError() {
- singleShortcutMethodKotlin(
+ singleShortcutFunction(
"""
@${annotation.java.canonicalName}
abstract fun foo(users: Set<User?>)
@@ -310,7 +312,7 @@
) { _, invocation ->
invocation.assertCompilationResult {
hasErrorContaining(
- ProcessorErrors.nullableParamInShortcutMethod(
+ ProcessorErrors.nullableParamInShortcutFunction(
"java.util.Set<? extends foo.bar.User>"
)
)
@@ -370,7 +372,7 @@
@Test
fun nullableCustomCollectionParamError() {
- singleShortcutMethodKotlin(
+ singleShortcutFunction(
"""
class MyList<Irrelevant, Item> : ArrayList<Item> {}
@${annotation.java.canonicalName}
@@ -379,7 +381,7 @@
) { _, invocation ->
invocation.assertCompilationResult {
hasErrorContaining(
- ProcessorErrors.nullableParamInShortcutMethod(
+ ProcessorErrors.nullableParamInShortcutFunction(
"foo.bar.MyClass.MyList<java.lang.String, foo.bar.User>"
)
)
@@ -428,15 +430,15 @@
@Test
fun twoNullableDifferentParamError() {
- singleShortcutMethodKotlin(
+ singleShortcutFunction(
"""
@${annotation.java.canonicalName}
abstract fun foo(user1: User?, book1: Book?)
"""
) { _, invocation ->
invocation.assertCompilationResult {
- hasErrorContaining(ProcessorErrors.nullableParamInShortcutMethod("foo.bar.User"))
- hasErrorContaining(ProcessorErrors.nullableParamInShortcutMethod("foo.bar.Book"))
+ hasErrorContaining(ProcessorErrors.nullableParamInShortcutFunction("foo.bar.User"))
+ hasErrorContaining(ProcessorErrors.nullableParamInShortcutFunction("foo.bar.Book"))
hasErrorCount(2)
}
}
@@ -492,7 +494,7 @@
"${KotlinTypeNames.FLOW.canonicalName}<Int>"
)
.forEach { type ->
- singleShortcutMethodKotlin(
+ singleShortcutFunction(
"""
@${annotation.java.canonicalName}
abstract suspend fun foo(user: User): $type
@@ -703,7 +705,7 @@
""",
) { _, invocation ->
invocation.assertCompilationResult {
- hasErrorContaining(ProcessorErrors.shortcutMethodArgumentMustBeAClass("long"))
+ hasErrorContaining(ProcessorErrors.shortcutFunctionArgumentMustBeAClass("long"))
}
}
}
@@ -735,7 +737,7 @@
@Test
fun nonNullVoidGuava() {
- singleShortcutMethodKotlin(
+ singleShortcutFunction(
"""
@${annotation.java.canonicalName}
abstract fun foo(user: User): ListenableFuture<Void>
@@ -799,7 +801,7 @@
}
}
- protected fun singleShortcutMethodKotlin(
+ protected fun singleShortcutFunction(
vararg input: String,
additionalSources: List<Source> = emptyList(),
handler: (T, XTestInvocation) -> Unit
@@ -834,7 +836,7 @@
sources = commonSources + additionalSources + inputSource,
options = mapOf(Context.BooleanProcessorOptions.GENERATE_KOTLIN.argName to "false"),
) { invocation ->
- val (owner, methods) =
+ val (owner, functions) =
invocation.roundEnv
.getElementsAnnotatedWith(Dao::class.qualifiedName!!)
.filterIsInstance<XTypeElement>()
@@ -850,7 +852,7 @@
process(
baseContext = invocation.context,
containing = owner.type,
- executableElement = methods.first()
+ executableElement = functions.first()
)
handler(processed, invocation)
}
diff --git a/room/room-compiler/src/test/kotlin/androidx/room/processor/InsertMethodProcessorTest.kt b/room/room-compiler/src/test/kotlin/androidx/room/processor/InsertFunctionProcessorTest.kt
similarity index 92%
rename from room/room-compiler/src/test/kotlin/androidx/room/processor/InsertMethodProcessorTest.kt
rename to room/room-compiler/src/test/kotlin/androidx/room/processor/InsertFunctionProcessorTest.kt
index 8aba5ee..f44f14b 100644
--- a/room/room-compiler/src/test/kotlin/androidx/room/processor/InsertMethodProcessorTest.kt
+++ b/room/room-compiler/src/test/kotlin/androidx/room/processor/InsertFunctionProcessorTest.kt
@@ -25,15 +25,15 @@
import androidx.room.processor.ProcessorErrors.INSERT_DOES_NOT_HAVE_ANY_PARAMETERS_TO_INSERT
import androidx.room.processor.ProcessorErrors.INSERT_MULTI_PARAM_SINGLE_RETURN_MISMATCH
import androidx.room.processor.ProcessorErrors.INSERT_SINGLE_PARAM_MULTI_RETURN_MISMATCH
-import androidx.room.vo.InsertMethod
+import androidx.room.vo.InsertFunction
import org.junit.Test
import org.junit.runner.RunWith
import org.junit.runners.JUnit4
@Suppress("PLATFORM_CLASS_MAPPED_TO_KOTLIN")
@RunWith(JUnit4::class)
-class InsertMethodProcessorTest :
- InsertOrUpsertShortcutMethodProcessorTest<InsertMethod>(Insert::class) {
+class InsertFunctionProcessorTest :
+ InsertOrUpsertShortcutFunctionProcessorTest<InsertFunction>(Insert::class) {
override fun noParamsError(): String = INSERT_DOES_NOT_HAVE_ANY_PARAMETERS_TO_INSERT
override fun missingPrimaryKey(
@@ -106,7 +106,7 @@
baseContext: Context,
containing: XType,
executableElement: XMethodElement
- ): InsertMethod {
- return InsertMethodProcessor(baseContext, containing, executableElement).process()
+ ): InsertFunction {
+ return InsertFunctionProcessor(baseContext, containing, executableElement).process()
}
}
diff --git a/room/room-compiler/src/test/kotlin/androidx/room/processor/InsertOrUpsertShortcutMethodProcessorTest.kt b/room/room-compiler/src/test/kotlin/androidx/room/processor/InsertOrUpsertShortcutFunctionProcessorTest.kt
similarity index 92%
rename from room/room-compiler/src/test/kotlin/androidx/room/processor/InsertOrUpsertShortcutMethodProcessorTest.kt
rename to room/room-compiler/src/test/kotlin/androidx/room/processor/InsertOrUpsertShortcutFunctionProcessorTest.kt
index 03be0b1..7857656 100644
--- a/room/room-compiler/src/test/kotlin/androidx/room/processor/InsertOrUpsertShortcutMethodProcessorTest.kt
+++ b/room/room-compiler/src/test/kotlin/androidx/room/processor/InsertOrUpsertShortcutFunctionProcessorTest.kt
@@ -36,14 +36,14 @@
import androidx.room.ext.RxJava2TypeNames
import androidx.room.ext.RxJava3TypeNames
import androidx.room.runProcessorTestWithK1
-import androidx.room.solver.shortcut.result.InsertOrUpsertMethodAdapter
+import androidx.room.solver.shortcut.result.InsertOrUpsertFunctionAdapter
import androidx.room.testing.context
-import androidx.room.vo.InsertOrUpsertShortcutMethod
+import androidx.room.vo.InsertOrUpsertShortcutFunction
import kotlin.reflect.KClass
import org.junit.Test
/** Base test class for insert and upsert methods. */
-abstract class InsertOrUpsertShortcutMethodProcessorTest<out T : InsertOrUpsertShortcutMethod>(
+abstract class InsertOrUpsertShortcutFunctionProcessorTest<out T : InsertOrUpsertShortcutFunction>(
val annotation: KClass<out Annotation>
) {
companion object {
@@ -139,14 +139,14 @@
@Test
fun singleNullableParamError() {
- singleInsertUpsertShortcutMethodKotlin(
+ singleInsertUpsertShortcutFunction(
"""
@${annotation.java.canonicalName}
abstract fun foo(user: User?)
"""
) { _, invocation ->
invocation.assertCompilationResult {
- hasErrorContaining(ProcessorErrors.nullableParamInShortcutMethod("foo.bar.User"))
+ hasErrorContaining(ProcessorErrors.nullableParamInShortcutFunction("foo.bar.User"))
}
}
}
@@ -183,14 +183,14 @@
@Test
fun twoNullableParamError() {
- singleInsertUpsertShortcutMethodKotlin(
+ singleInsertUpsertShortcutFunction(
"""
@${annotation.java.canonicalName}
abstract fun foo(user1: User?, user2: User?)
"""
) { _, invocation ->
invocation.assertCompilationResult {
- hasErrorContaining(ProcessorErrors.nullableParamInShortcutMethod("foo.bar.User"))
+ hasErrorContaining(ProcessorErrors.nullableParamInShortcutFunction("foo.bar.User"))
hasErrorCount(2)
}
}
@@ -234,7 +234,7 @@
@Test
fun nullableListParamError() {
- singleInsertUpsertShortcutMethodKotlin(
+ singleInsertUpsertShortcutFunction(
"""
@${annotation.java.canonicalName}
abstract fun foo(users: List<User?>)
@@ -242,7 +242,7 @@
) { _, invocation ->
invocation.assertCompilationResult {
hasErrorContaining(
- ProcessorErrors.nullableParamInShortcutMethod(
+ ProcessorErrors.nullableParamInShortcutFunction(
"java.util.List<? extends foo.bar.User>"
)
)
@@ -278,14 +278,16 @@
@Test
fun nullableArrayParamError() {
- singleInsertUpsertShortcutMethodKotlin(
+ singleInsertUpsertShortcutFunction(
"""
@${annotation.java.canonicalName}
abstract fun foo(users: Array<User?>)
"""
) { _, invocation ->
invocation.assertCompilationResult {
- hasErrorContaining(ProcessorErrors.nullableParamInShortcutMethod("foo.bar.User[]"))
+ hasErrorContaining(
+ ProcessorErrors.nullableParamInShortcutFunction("foo.bar.User[]")
+ )
}
}
}
@@ -320,7 +322,7 @@
@Test
fun nullableSetParamError() {
- singleInsertUpsertShortcutMethodKotlin(
+ singleInsertUpsertShortcutFunction(
"""
@${annotation.java.canonicalName}
abstract fun foo(users: Set<User?>)
@@ -328,7 +330,7 @@
) { _, invocation ->
invocation.assertCompilationResult {
hasErrorContaining(
- ProcessorErrors.nullableParamInShortcutMethod(
+ ProcessorErrors.nullableParamInShortcutFunction(
"java.util.Set<? extends foo.bar.User>"
)
)
@@ -422,7 +424,7 @@
@Test
fun nullableCustomCollectionParamError() {
- singleInsertUpsertShortcutMethodKotlin(
+ singleInsertUpsertShortcutFunction(
"""
class MyList<Irrelevant, Item> : ArrayList<Item> {}
@${annotation.java.canonicalName}
@@ -431,7 +433,7 @@
) { _, invocation ->
invocation.assertCompilationResult {
hasErrorContaining(
- ProcessorErrors.nullableParamInShortcutMethod(
+ ProcessorErrors.nullableParamInShortcutFunction(
"foo.bar.MyClass.MyList<java.lang.String, foo.bar.User>"
)
)
@@ -479,7 +481,7 @@
RxJava3TypeNames.COMPLETABLE.canonicalName
)
.forEach { type ->
- singleInsertUpsertShortcutMethodKotlin(
+ singleInsertUpsertShortcutFunction(
"""
@${annotation.java.canonicalName}
abstract fun bookUserCompletable(user: User, book: Book): $type
@@ -492,15 +494,15 @@
@Test
fun twoNullableDifferentParamError() {
- singleInsertUpsertShortcutMethodKotlin(
+ singleInsertUpsertShortcutFunction(
"""
@${annotation.java.canonicalName}
abstract fun foo(user1: User?, book1: Book?)
"""
) { _, invocation ->
invocation.assertCompilationResult {
- hasErrorContaining(ProcessorErrors.nullableParamInShortcutMethod("foo.bar.User"))
- hasErrorContaining(ProcessorErrors.nullableParamInShortcutMethod("foo.bar.Book"))
+ hasErrorContaining(ProcessorErrors.nullableParamInShortcutFunction("foo.bar.User"))
+ hasErrorContaining(ProcessorErrors.nullableParamInShortcutFunction("foo.bar.Book"))
hasErrorCount(2)
}
}
@@ -524,7 +526,7 @@
abstract public $type foo(User user);
"""
) { insertionUpsertion, invocation ->
- assertThat(insertionUpsertion.methodBinder?.adapter).isNull()
+ assertThat(insertionUpsertion.functionBinder?.adapter).isNull()
invocation.assertCompilationResult { hasErrorContaining(noAdapter()) }
}
@@ -547,7 +549,7 @@
abstract public $type foo(User user);
"""
) { insertionUpsertion, invocation ->
- assertThat(insertionUpsertion.methodBinder?.adapter).isNull()
+ assertThat(insertionUpsertion.functionBinder?.adapter).isNull()
invocation.assertCompilationResult {
hasErrorContaining(singleParamAndMultiReturnMismatchError())
@@ -571,7 +573,7 @@
abstract public $type foo(User... user);
"""
) { insertionUpsertion, invocation ->
- assertThat(insertionUpsertion.methodBinder?.adapter).isNull()
+ assertThat(insertionUpsertion.functionBinder?.adapter).isNull()
invocation.assertCompilationResult {
hasErrorContaining(multiParamAndSingleReturnMismatchError())
@@ -595,7 +597,7 @@
abstract public $type foo(User user1, User user2);
"""
) { insertionUpsertion, invocation ->
- assertThat(insertionUpsertion.methodBinder?.adapter).isNull()
+ assertThat(insertionUpsertion.functionBinder?.adapter).isNull()
invocation.assertCompilationResult { hasErrorContaining(noAdapter()) }
}
@@ -605,50 +607,50 @@
@Test
fun validReturnTypes() {
listOf(
- Pair("void", InsertOrUpsertMethodAdapter.ReturnInfo.VOID),
- Pair("long", InsertOrUpsertMethodAdapter.ReturnInfo.SINGLE_ID),
- Pair("long[]", InsertOrUpsertMethodAdapter.ReturnInfo.ID_ARRAY),
- Pair("Long[]", InsertOrUpsertMethodAdapter.ReturnInfo.ID_ARRAY_BOX),
- Pair("List<Long>", InsertOrUpsertMethodAdapter.ReturnInfo.ID_LIST),
+ Pair("void", InsertOrUpsertFunctionAdapter.ReturnInfo.VOID),
+ Pair("long", InsertOrUpsertFunctionAdapter.ReturnInfo.SINGLE_ID),
+ Pair("long[]", InsertOrUpsertFunctionAdapter.ReturnInfo.ID_ARRAY),
+ Pair("Long[]", InsertOrUpsertFunctionAdapter.ReturnInfo.ID_ARRAY_BOX),
+ Pair("List<Long>", InsertOrUpsertFunctionAdapter.ReturnInfo.ID_LIST),
Pair(
RxJava2TypeNames.COMPLETABLE.canonicalName,
- InsertOrUpsertMethodAdapter.ReturnInfo.VOID_OBJECT
+ InsertOrUpsertFunctionAdapter.ReturnInfo.VOID_OBJECT
),
Pair(
"${RxJava2TypeNames.SINGLE.canonicalName}<Long>",
- InsertOrUpsertMethodAdapter.ReturnInfo.SINGLE_ID
+ InsertOrUpsertFunctionAdapter.ReturnInfo.SINGLE_ID
),
Pair(
"${RxJava2TypeNames.SINGLE.canonicalName}<List<Long>>",
- InsertOrUpsertMethodAdapter.ReturnInfo.ID_LIST
+ InsertOrUpsertFunctionAdapter.ReturnInfo.ID_LIST
),
Pair(
"${RxJava2TypeNames.MAYBE.canonicalName}<Long>",
- InsertOrUpsertMethodAdapter.ReturnInfo.SINGLE_ID
+ InsertOrUpsertFunctionAdapter.ReturnInfo.SINGLE_ID
),
Pair(
"${RxJava2TypeNames.MAYBE.canonicalName}<List<Long>>",
- InsertOrUpsertMethodAdapter.ReturnInfo.ID_LIST
+ InsertOrUpsertFunctionAdapter.ReturnInfo.ID_LIST
),
Pair(
RxJava3TypeNames.COMPLETABLE.canonicalName,
- InsertOrUpsertMethodAdapter.ReturnInfo.VOID_OBJECT
+ InsertOrUpsertFunctionAdapter.ReturnInfo.VOID_OBJECT
),
Pair(
"${RxJava3TypeNames.SINGLE.canonicalName}<Long>",
- InsertOrUpsertMethodAdapter.ReturnInfo.SINGLE_ID
+ InsertOrUpsertFunctionAdapter.ReturnInfo.SINGLE_ID
),
Pair(
"${RxJava3TypeNames.SINGLE.canonicalName}<List<Long>>",
- InsertOrUpsertMethodAdapter.ReturnInfo.ID_LIST
+ InsertOrUpsertFunctionAdapter.ReturnInfo.ID_LIST
),
Pair(
"${RxJava3TypeNames.MAYBE.canonicalName}<Long>",
- InsertOrUpsertMethodAdapter.ReturnInfo.SINGLE_ID
+ InsertOrUpsertFunctionAdapter.ReturnInfo.SINGLE_ID
),
Pair(
"${RxJava3TypeNames.MAYBE.canonicalName}<List<Long>>",
- InsertOrUpsertMethodAdapter.ReturnInfo.ID_LIST
+ InsertOrUpsertFunctionAdapter.ReturnInfo.ID_LIST
)
)
.forEach { pair ->
@@ -656,9 +658,9 @@
if (
pair.second in
setOf(
- InsertOrUpsertMethodAdapter.ReturnInfo.ID_LIST,
- InsertOrUpsertMethodAdapter.ReturnInfo.ID_ARRAY,
- InsertOrUpsertMethodAdapter.ReturnInfo.ID_ARRAY_BOX
+ InsertOrUpsertFunctionAdapter.ReturnInfo.ID_LIST,
+ InsertOrUpsertFunctionAdapter.ReturnInfo.ID_ARRAY,
+ InsertOrUpsertFunctionAdapter.ReturnInfo.ID_ARRAY_BOX
)
) {
"..."
@@ -671,7 +673,7 @@
abstract public ${pair.first} foo(User$dots user);
"""
) { insertionUpsertion, _ ->
- assertThat(insertionUpsertion.methodBinder?.adapter).isNotNull()
+ assertThat(insertionUpsertion.functionBinder?.adapter).isNotNull()
}
}
}
@@ -1091,7 +1093,7 @@
"${KotlinTypeNames.FLOW.canonicalName}<Int>"
)
.forEach { type ->
- singleInsertUpsertShortcutMethodKotlin(
+ singleInsertUpsertShortcutFunction(
"""
@${annotation.java.canonicalName}
abstract suspend fun foo(user: User): $type
@@ -1107,7 +1109,7 @@
@Test
fun nonNullVoidGuava() {
- singleInsertUpsertShortcutMethodKotlin(
+ singleInsertUpsertShortcutFunction(
"""
@${annotation.java.canonicalName}
abstract fun foo(user: User): ListenableFuture<Void>
@@ -1168,7 +1170,7 @@
}
}
- protected fun singleInsertUpsertShortcutMethodKotlin(
+ protected fun singleInsertUpsertShortcutFunction(
vararg input: String,
additionalSources: List<Source> = emptyList(),
handler: (T, XTestInvocation) -> Unit
@@ -1202,7 +1204,7 @@
sources = commonSources + additionalSources + inputSource,
options = mapOf(Context.BooleanProcessorOptions.GENERATE_KOTLIN.argName to "false"),
) { invocation ->
- val (owner, methods) =
+ val (owner, functions) =
invocation.roundEnv
.getElementsAnnotatedWith(Dao::class.qualifiedName!!)
.filterIsInstance<XTypeElement>()
@@ -1217,7 +1219,7 @@
process(
baseContext = invocation.context,
containing = owner.type,
- executableElement = methods.first()
+ executableElement = functions.first()
)
handler(processed, invocation)
}
diff --git a/room/room-compiler/src/test/kotlin/androidx/room/processor/QueryMethodProcessorTest.kt b/room/room-compiler/src/test/kotlin/androidx/room/processor/QueryFunctionProcessorTest.kt
similarity index 94%
rename from room/room-compiler/src/test/kotlin/androidx/room/processor/QueryMethodProcessorTest.kt
rename to room/room-compiler/src/test/kotlin/androidx/room/processor/QueryFunctionProcessorTest.kt
index d00ef58..10f2366 100644
--- a/room/room-compiler/src/test/kotlin/androidx/room/processor/QueryMethodProcessorTest.kt
+++ b/room/room-compiler/src/test/kotlin/androidx/room/processor/QueryFunctionProcessorTest.kt
@@ -54,10 +54,10 @@
import androidx.room.solver.query.result.SingleItemQueryResultAdapter
import androidx.room.testing.context
import androidx.room.vo.Field
-import androidx.room.vo.QueryMethod
-import androidx.room.vo.ReadQueryMethod
+import androidx.room.vo.QueryFunction
+import androidx.room.vo.ReadQueryFunction
import androidx.room.vo.Warning
-import androidx.room.vo.WriteQueryMethod
+import androidx.room.vo.WriteQueryFunction
import createVerifierFromEntitiesAndViews
import mockElementAndType
import org.junit.AssumptionViolatedException
@@ -67,7 +67,7 @@
import org.mockito.Mockito
@RunWith(Parameterized::class)
-class QueryMethodProcessorTest(private val enableVerification: Boolean) {
+class QueryFunctionProcessorTest(private val enableVerification: Boolean) {
companion object {
const val DAO_PREFIX =
"""
@@ -115,7 +115,7 @@
@Test
fun testReadNoParams() {
- singleQueryMethod<ReadQueryMethod>(
+ singleQueryMethod<ReadQueryFunction>(
"""
@Query("SELECT uid from User")
abstract public int[] foo();
@@ -130,7 +130,7 @@
@Test
fun testSingleParam() {
- singleQueryMethod<ReadQueryMethod>(
+ singleQueryMethod<ReadQueryFunction>(
"""
@Query("SELECT * from User where uid = :x")
abstract public long foo(int x);
@@ -149,7 +149,7 @@
@Test
fun testVarArgs() {
- singleQueryMethod<ReadQueryMethod>(
+ singleQueryMethod<ReadQueryFunction>(
"""
@Query("SELECT * from User where uid in (:ids)")
abstract public long foo(int... ids);
@@ -168,7 +168,7 @@
@Test
fun testParamBindingMatchingNoName() {
- singleQueryMethod<ReadQueryMethod>(
+ singleQueryMethod<ReadQueryFunction>(
"""
@Query("SELECT uid from User where uid = :id")
abstract public long getIdById(int id);
@@ -184,7 +184,7 @@
@Test
fun testParamBindingMatchingSimpleBind() {
- singleQueryMethod<ReadQueryMethod>(
+ singleQueryMethod<ReadQueryFunction>(
"""
@Query("SELECT uid from User where uid = :id")
abstract public long getIdById(int id);
@@ -200,7 +200,7 @@
@Test
fun testParamBindingTwoBindVarsIntoTheSameParameter() {
- singleQueryMethod<ReadQueryMethod>(
+ singleQueryMethod<ReadQueryFunction>(
"""
@Query("SELECT uid from User where uid = :id OR uid = :id")
abstract public long getIdById(int id);
@@ -219,7 +219,7 @@
@Test
fun testMissingParameterForBinding() {
- singleQueryMethod<ReadQueryMethod>(
+ singleQueryMethod<ReadQueryFunction>(
"""
@Query("SELECT uid from User where uid = :id OR uid = :uid")
abstract public long getIdById(int id);
@@ -241,7 +241,7 @@
@Test
fun test2MissingParameterForBinding() {
- singleQueryMethod<ReadQueryMethod>(
+ singleQueryMethod<ReadQueryFunction>(
"""
@Query("SELECT uid from User where name = :bar AND uid = :id OR uid = :uid")
abstract public long getIdById(int id);
@@ -268,7 +268,7 @@
@Test
fun testUnusedParameters() {
- singleQueryMethod<ReadQueryMethod>(
+ singleQueryMethod<ReadQueryFunction>(
"""
@Query("SELECT uid from User where name = :bar")
abstract public long getIdById(int bar, int whyNotUseMe);
@@ -281,7 +281,7 @@
assertThat(parsedQuery.sectionToParamMapping).containsExactly(bar to barParam)
invocation.assertCompilationResult {
hasErrorContaining(
- ProcessorErrors.unusedQueryMethodParameter(listOf("whyNotUseMe"))
+ ProcessorErrors.unusedQueryFunctionParameter(listOf("whyNotUseMe"))
)
}
}
@@ -289,7 +289,7 @@
@Test
fun testNameWithUnderscore() {
- singleQueryMethod<ReadQueryMethod>(
+ singleQueryMethod<ReadQueryFunction>(
"""
@Query("select * from User where uid = :_blah")
abstract public long getSth(int _blah);
@@ -303,7 +303,7 @@
@Test
fun testGenericReturnType() {
- singleQueryMethod<ReadQueryMethod>(
+ singleQueryMethod<ReadQueryFunction>(
"""
@Query("select * from User")
abstract public <T> ${LIST.canonicalName}<T> foo(int x);
@@ -320,14 +320,14 @@
.copy(nullable = true)
assertThat(parsedQuery.returnType.asTypeName()).isEqualTo(expected)
invocation.assertCompilationResult {
- hasErrorContaining(ProcessorErrors.CANNOT_USE_UNBOUND_GENERICS_IN_QUERY_METHODS)
+ hasErrorContaining(ProcessorErrors.CANNOT_USE_UNBOUND_GENERICS_IN_QUERY_FUNCTIONS)
}
}
}
@Test
fun testBadQuery() {
- singleQueryMethod<ReadQueryMethod>(
+ singleQueryMethod<ReadQueryFunction>(
"""
@Query("select * from :1 :2")
abstract public long foo(int x);
@@ -340,7 +340,7 @@
@Test
fun testLiveDataWithWithClause() {
- singleQueryMethod<ReadQueryMethod>(
+ singleQueryMethod<ReadQueryFunction>(
"""
@Query("WITH RECURSIVE tempTable(n, fact) AS (SELECT 0, 1 UNION ALL SELECT n+1,"
+ " (n+1)*fact FROM tempTable WHERE n < 9) SELECT fact FROM tempTable, User")
@@ -356,7 +356,7 @@
@Test
fun testLiveDataWithNothingToObserve() {
- singleQueryMethod<ReadQueryMethod>(
+ singleQueryMethod<ReadQueryFunction>(
"""
@Query("SELECT 1")
abstract public ${LifecyclesTypeNames.LIVE_DATA.canonicalName}<Integer> getOne();
@@ -370,7 +370,7 @@
@Test
fun testLiveDataWithWithClauseAndNothingToObserve() {
- singleQueryMethod<ReadQueryMethod>(
+ singleQueryMethod<ReadQueryFunction>(
"""
@Query("WITH RECURSIVE tempTable(n, fact) AS (SELECT 0, 1 UNION ALL SELECT n+1,"
+ " (n+1)*fact FROM tempTable WHERE n < 9) SELECT fact FROM tempTable")
@@ -386,7 +386,7 @@
@Test
fun testBoundGeneric() {
- singleQueryMethod<ReadQueryMethod>(
+ singleQueryMethod<ReadQueryFunction>(
"""
static abstract class BaseModel<T> {
@Query("select COUNT(*) from User")
@@ -404,7 +404,7 @@
@Test
fun testBoundGenericParameter() {
- singleQueryMethod<ReadQueryMethod>(
+ singleQueryMethod<ReadQueryFunction>(
"""
static abstract class BaseModel<T> {
@Query("select COUNT(*) from User where :t")
@@ -422,7 +422,7 @@
@Test
fun testReadDeleteWithBadReturnType() {
- singleQueryMethod<WriteQueryMethod>(
+ singleQueryMethod<WriteQueryFunction>(
"""
@Query("DELETE from User where uid = :id")
abstract public float foo(int id);
@@ -438,7 +438,7 @@
@Test
fun testSimpleDelete() {
- singleQueryMethod<WriteQueryMethod>(
+ singleQueryMethod<WriteQueryFunction>(
"""
@Query("DELETE from User where uid = :id")
abstract public int foo(int id);
@@ -452,7 +452,7 @@
@Test
fun testVoidDeleteQuery() {
- singleQueryMethod<WriteQueryMethod>(
+ singleQueryMethod<WriteQueryFunction>(
"""
@Query("DELETE from User where uid = :id")
abstract public void foo(int id);
@@ -466,7 +466,7 @@
@Test
fun testVoidUpdateQuery() {
- singleQueryMethod<WriteQueryMethod>(
+ singleQueryMethod<WriteQueryFunction>(
"""
@Query("update user set name = :name")
abstract public void updateAllNames(String name);
@@ -482,7 +482,7 @@
@Test
fun testVoidInsertQuery() {
- singleQueryMethod<WriteQueryMethod>(
+ singleQueryMethod<WriteQueryFunction>(
"""
@Query("insert into user (name) values (:name)")
abstract public void insertUsername(String name);
@@ -498,7 +498,7 @@
@Test
fun testLongInsertQuery() {
- singleQueryMethod<WriteQueryMethod>(
+ singleQueryMethod<WriteQueryFunction>(
"""
@Query("insert into user (name) values (:name)")
abstract public long insertUsername(String name);
@@ -514,7 +514,7 @@
@Test
fun testInsertQueryWithBadReturnType() {
- singleQueryMethod<WriteQueryMethod>(
+ singleQueryMethod<WriteQueryFunction>(
"""
@Query("insert into user (name) values (:name)")
abstract public int insert(String name);
@@ -531,7 +531,7 @@
@Test
fun testLiveDataQuery() {
- singleQueryMethod<ReadQueryMethod>(
+ singleQueryMethod<ReadQueryFunction>(
"""
@Query("select name from user where uid = :id")
abstract ${LifecyclesTypeNames.LIVE_DATA.canonicalName}<String> nameLiveData(String id);
@@ -549,7 +549,7 @@
@Test
fun testBadReturnForDeleteQuery() {
- singleQueryMethod<WriteQueryMethod>(
+ singleQueryMethod<WriteQueryFunction>(
"""
@Query("delete from user where uid = :id")
abstract ${LifecyclesTypeNames.LIVE_DATA.canonicalName}<Integer> deleteLiveData(String id);
@@ -568,7 +568,7 @@
@Test
fun testBadReturnForUpdateQuery() {
- singleQueryMethod<WriteQueryMethod>(
+ singleQueryMethod<WriteQueryFunction>(
"""
@Query("update user set name = :name")
abstract ${LifecyclesTypeNames.LIVE_DATA.canonicalName}<Integer> updateNameLiveData(String name);
@@ -587,7 +587,7 @@
@Test
fun testDataSourceFactoryQuery() {
- singleQueryMethod<ReadQueryMethod>(
+ singleQueryMethod<ReadQueryFunction>(
"""
@Query("select name from user")
abstract ${PagingTypeNames.DATA_SOURCE_FACTORY.canonicalName}<Integer, String>
@@ -615,7 +615,7 @@
@Test
fun testMultiTableDataSourceFactoryQuery() {
- singleQueryMethod<ReadQueryMethod>(
+ singleQueryMethod<ReadQueryFunction>(
"""
@Query("select name from User u LEFT OUTER JOIN Book b ON u.uid == b.uid")
abstract ${PagingTypeNames.DATA_SOURCE_FACTORY.canonicalName}<Integer, String>
@@ -642,7 +642,7 @@
@Test
fun testBadChannelReturnForQuery() {
- singleQueryMethod<QueryMethod>(
+ singleQueryMethod<QueryFunction>(
"""
@Query("select * from user")
abstract ${KotlinTypeNames.CHANNEL.canonicalName}<User> getUsersChannel();
@@ -659,7 +659,7 @@
@Test
fun testBadSendChannelReturnForQuery() {
- singleQueryMethod<QueryMethod>(
+ singleQueryMethod<QueryFunction>(
"""
@Query("select * from user")
abstract ${KotlinTypeNames.SEND_CHANNEL.canonicalName}<User> getUsersChannel();
@@ -676,7 +676,7 @@
@Test
fun testBadReceiveChannelReturnForQuery() {
- singleQueryMethod<QueryMethod>(
+ singleQueryMethod<QueryFunction>(
"""
@Query("select * from user")
abstract ${KotlinTypeNames.RECEIVE_CHANNEL.canonicalName}<User> getUsersChannel();
@@ -695,7 +695,7 @@
@Test
fun query_detectTransaction_select() {
- singleQueryMethod<ReadQueryMethod>(
+ singleQueryMethod<ReadQueryFunction>(
"""
@Query("select * from user")
abstract int loadUsers();
@@ -707,7 +707,7 @@
@Test
fun query_detectTransaction_selectInTransaction() {
- singleQueryMethod<ReadQueryMethod>(
+ singleQueryMethod<ReadQueryFunction>(
"""
@Transaction
@Query("select * from user")
@@ -720,7 +720,7 @@
@Test
fun skipVerification() {
- singleQueryMethod<ReadQueryMethod>(
+ singleQueryMethod<ReadQueryFunction>(
"""
@SkipQueryVerification
@Query("SELECT foo from User")
@@ -736,7 +736,7 @@
@Test
fun skipVerificationDataClass() {
- singleQueryMethod<ReadQueryMethod>(
+ singleQueryMethod<ReadQueryFunction>(
"""
@SkipQueryVerification
@Query("SELECT bookId, uid FROM User")
@@ -758,7 +758,7 @@
@Test
fun suppressWarnings() {
- singleQueryMethod<ReadQueryMethod>(
+ singleQueryMethod<ReadQueryFunction>(
"""
@SuppressWarnings(RoomWarnings.QUERY_MISMATCH)
@Query("SELECT uid from User")
@@ -766,7 +766,7 @@
"""
) { method, invocation ->
assertThat(
- QueryMethodProcessor(
+ QueryFunctionProcessor(
baseContext = invocation.context,
containing = Mockito.mock(XType::class.java),
executableElement = method.element,
@@ -785,7 +785,7 @@
if (!enableVerification) {
return
}
- singleQueryMethod<ReadQueryMethod>(
+ singleQueryMethod<ReadQueryFunction>(
"""
static class Merged extends User {
@Relation(parentColumn = "name", entityColumn = "lastName",
@@ -865,7 +865,7 @@
if (!enableVerification) {
throw AssumptionViolatedException("nothing to test w/o db verification")
}
- singleQueryMethod<ReadQueryMethod>(
+ singleQueryMethod<ReadQueryFunction>(
"""
@RewriteQueriesToDropUnusedColumns
@Query("select 1 from user")
@@ -884,7 +884,7 @@
if (!enableVerification) {
throw AssumptionViolatedException("nothing to test w/o db verification")
}
- singleQueryMethod<ReadQueryMethod>(
+ singleQueryMethod<ReadQueryFunction>(
"""
public static class DataClass {
public String name;
@@ -923,7 +923,7 @@
"""
.trimIndent()
)
- singleQueryMethod<ReadQueryMethod>(
+ singleQueryMethod<ReadQueryFunction>(
"""
public static class Username {
public String name;
@@ -960,7 +960,7 @@
if (!enableVerification) {
throw AssumptionViolatedException("nothing to test w/o db verification")
}
- singleQueryMethod<ReadQueryMethod>(
+ singleQueryMethod<ReadQueryFunction>(
"""
public static class DataClass {
public String name;
@@ -1190,9 +1190,9 @@
dataClassFields: String,
queryColumns: List<String>,
options: Map<String, String> = emptyMap(),
- handler: (DataClassRowAdapter?, QueryMethod, XTestInvocation) -> Unit
+ handler: (DataClassRowAdapter?, QueryFunction, XTestInvocation) -> Unit
) {
- singleQueryMethod<ReadQueryMethod>(
+ singleQueryMethod<ReadQueryFunction>(
"""
static class DataClass {
$dataClassFields
@@ -1219,7 +1219,7 @@
}
}
- private fun <T : QueryMethod> singleQueryMethod(
+ private fun <T : QueryFunction> singleQueryMethod(
vararg input: String,
additionalSources: Iterable<Source> = emptyList(),
options: Map<String, String> = emptyMap(),
@@ -1269,7 +1269,7 @@
null
}
val parser =
- QueryMethodProcessor(
+ QueryFunctionProcessor(
baseContext = invocation.context,
containing = owner.type,
executableElement = methods.first(),
@@ -1280,7 +1280,7 @@
}
}
- private fun <T : QueryMethod> singleQueryMethodKotlin(
+ private fun <T : QueryFunction> singleQueryFunction(
vararg input: String,
additionalSources: Iterable<Source> = emptyList(),
options: Map<String, String> = emptyMap(),
@@ -1339,7 +1339,7 @@
null
}
val parser =
- QueryMethodProcessor(
+ QueryFunctionProcessor(
baseContext = invocation.context,
containing = owner.type,
executableElement = methods.first(),
@@ -1352,7 +1352,7 @@
@Test
fun testInvalidLinkedListCollectionInMultimapJoin() {
- singleQueryMethod<ReadQueryMethod>(
+ singleQueryMethod<ReadQueryFunction>(
"""
@Query("select * from User u JOIN Book b ON u.uid == b.uid")
abstract Map<User, LinkedList<Book>> getInvalidCollectionMultimap();
@@ -1362,7 +1362,7 @@
hasErrorCount(2)
hasErrorContaining("Multimap 'value' collection type must be a List, Set or Map.")
hasErrorContaining(
- "Not sure how to convert the query result to this method's return type"
+ "Not sure how to convert the query result to this function's return type"
)
}
}
@@ -1370,7 +1370,7 @@
@Test
fun testInvalidGenericMultimapJoin() {
- singleQueryMethod<ReadQueryMethod>(
+ singleQueryMethod<ReadQueryFunction>(
"""
@Query("select * from User u JOIN Book b ON u.uid == b.uid")
abstract com.google.common.collect.ImmutableMultimap<User, Book>
@@ -1381,7 +1381,7 @@
hasErrorCount(2)
hasErrorContaining(DO_NOT_USE_GENERIC_IMMUTABLE_MULTIMAP)
hasErrorContaining(
- "Not sure how to convert the query result to this method's return type"
+ "Not sure how to convert the query result to this function's return type"
)
}
}
@@ -1392,7 +1392,7 @@
if (!enableVerification) {
return
}
- singleQueryMethod<ReadQueryMethod>(
+ singleQueryMethod<ReadQueryFunction>(
"""
@MapInfo
@Query("select * from User u JOIN Book b ON u.uid == b.uid")
@@ -1411,7 +1411,7 @@
if (!enableVerification) {
return
}
- singleQueryMethod<ReadQueryMethod>(
+ singleQueryMethod<ReadQueryFunction>(
"""
@SuppressWarnings(
{RoomWarnings.QUERY_MISMATCH, RoomWarnings.AMBIGUOUS_COLUMN_IN_RESULT}
@@ -1430,7 +1430,7 @@
if (!enableVerification) {
return
}
- singleQueryMethod<ReadQueryMethod>(
+ singleQueryMethod<ReadQueryFunction>(
"""
@SuppressWarnings(
{RoomWarnings.QUERY_MISMATCH, RoomWarnings.AMBIGUOUS_COLUMN_IN_RESULT}
@@ -1449,7 +1449,7 @@
if (!enableVerification) {
return
}
- singleQueryMethod<ReadQueryMethod>(
+ singleQueryMethod<ReadQueryFunction>(
"""
@SuppressWarnings(RoomWarnings.QUERY_MISMATCH)
@MapInfo(keyColumn = "name", valueColumn = "bookCount")
@@ -1467,7 +1467,7 @@
if (!enableVerification) {
return
}
- singleQueryMethod<ReadQueryMethod>(
+ singleQueryMethod<ReadQueryFunction>(
"""
@SuppressWarnings(
{RoomWarnings.QUERY_MISMATCH, RoomWarnings.AMBIGUOUS_COLUMN_IN_RESULT}
@@ -1485,7 +1485,7 @@
if (!enableVerification) {
return
}
- singleQueryMethod<ReadQueryMethod>(
+ singleQueryMethod<ReadQueryFunction>(
"""
@SuppressWarnings(
{RoomWarnings.QUERY_MISMATCH, RoomWarnings.AMBIGUOUS_COLUMN_IN_RESULT}
@@ -1508,7 +1508,7 @@
if (!enableVerification) {
return
}
- singleQueryMethod<ReadQueryMethod>(
+ singleQueryMethod<ReadQueryFunction>(
"""
@SuppressWarnings(
{RoomWarnings.QUERY_MISMATCH, RoomWarnings.AMBIGUOUS_COLUMN_IN_RESULT}
@@ -1526,7 +1526,7 @@
if (!enableVerification) {
return
}
- singleQueryMethod<ReadQueryMethod>(
+ singleQueryMethod<ReadQueryFunction>(
"""
@SuppressWarnings(
{RoomWarnings.QUERY_MISMATCH, RoomWarnings.AMBIGUOUS_COLUMN_IN_RESULT}
@@ -1544,7 +1544,7 @@
if (!enableVerification) {
return
}
- singleQueryMethod<ReadQueryMethod>(
+ singleQueryMethod<ReadQueryFunction>(
"""
@SuppressWarnings(RoomWarnings.QUERY_MISMATCH)
@Query("SELECT name, (SELECT count(*) FROM User u JOIN Book b ON u.uid == b.uid) "
@@ -1561,7 +1561,7 @@
if (!enableVerification) {
return
}
- singleQueryMethod<ReadQueryMethod>(
+ singleQueryMethod<ReadQueryFunction>(
"""
@SuppressWarnings(
{RoomWarnings.QUERY_MISMATCH, RoomWarnings.AMBIGUOUS_COLUMN_IN_RESULT}
@@ -1579,7 +1579,7 @@
@Test
fun testDoesNotImplementEqualsAndHashcodeQuery() {
- singleQueryMethod<ReadQueryMethod>(
+ singleQueryMethod<ReadQueryFunction>(
"""
@Query("select * from User u JOIN Book b ON u.uid == b.uid")
abstract Map<User, Book> getMultimap();
@@ -1596,7 +1596,7 @@
@Test
fun testMissingMapInfoOneToOneString() {
- singleQueryMethod<ReadQueryMethod>(
+ singleQueryMethod<ReadQueryFunction>(
"""
@Query("select * from Artist JOIN Song ON Artist.mArtistName == Song.mArtist")
abstract Map<Artist, String> getAllArtistsWithAlbumCoverYear();
@@ -1610,7 +1610,7 @@
@Test
fun testOneToOneStringMapInfoForKeyInsteadOfColumn() {
- singleQueryMethod<ReadQueryMethod>(
+ singleQueryMethod<ReadQueryFunction>(
"""
@MapInfo(keyColumn = "mArtistName")
@Query("select * from Artist JOIN Song ON Artist.mArtistName == Song.mArtist")
@@ -1625,7 +1625,7 @@
@Test
fun testMissingMapInfoOneToManyString() {
- singleQueryMethod<ReadQueryMethod>(
+ singleQueryMethod<ReadQueryFunction>(
"""
@Query("select * from Artist JOIN Song ON Artist.mArtistName == Song.mArtist")
abstract Map<Artist, List<String>> getAllArtistsWithAlbumCoverYear();
@@ -1639,7 +1639,7 @@
@Test
fun testMissingMapInfoImmutableListMultimapOneToOneString() {
- singleQueryMethod<ReadQueryMethod>(
+ singleQueryMethod<ReadQueryFunction>(
"""
@Query("select * from Artist JOIN Song ON Artist.mArtistName == Song.mArtist")
abstract ImmutableListMultimap<Artist, String> getAllArtistsWithAlbumCoverYear();
@@ -1653,7 +1653,7 @@
@Test
fun testMissingMapInfoOneToOneLong() {
- singleQueryMethod<ReadQueryMethod>(
+ singleQueryMethod<ReadQueryFunction>(
"""
@Query("SELECT * FROM Artist JOIN Image ON Artist.mArtistName = Image.mArtistInImage")
Map<Artist, Long> getAllArtistsWithAlbumCoverYear();
@@ -1667,7 +1667,7 @@
@Test
fun testMissingMapInfoOneToManyLong() {
- singleQueryMethod<ReadQueryMethod>(
+ singleQueryMethod<ReadQueryFunction>(
"""
@Query("SELECT * FROM Artist JOIN Image ON Artist.mArtistName = Image.mArtistInImage")
Map<Artist, Set<Long>> getAllArtistsWithAlbumCoverYear();
@@ -1681,7 +1681,7 @@
@Test
fun testMissingMapInfoImmutableListMultimapOneToOneLong() {
- singleQueryMethod<ReadQueryMethod>(
+ singleQueryMethod<ReadQueryFunction>(
"""
@Query("SELECT * FROM Artist JOIN Image ON Artist.mArtistName = Image.mArtistInImage")
ImmutableListMultimap<Artist, Long> getAllArtistsWithAlbumCoverYear();
@@ -1695,7 +1695,7 @@
@Test
fun testMissingMapInfoImmutableListMultimapOneToOneTypeConverterKey() {
- singleQueryMethod<ReadQueryMethod>(
+ singleQueryMethod<ReadQueryFunction>(
"""
@TypeConverters(DateConverter.class)
@Query("SELECT * FROM Image JOIN Artist ON Artist.mArtistName = Image.mArtistInImage")
@@ -1710,7 +1710,7 @@
@Test
fun testMissingMapInfoImmutableListMultimapOneToOneTypeConverterValue() {
- singleQueryMethod<ReadQueryMethod>(
+ singleQueryMethod<ReadQueryFunction>(
"""
@TypeConverters(DateConverter.class)
@Query("SELECT * FROM Artist JOIN Image ON Artist.mArtistName = Image.mArtistInImage")
@@ -1728,7 +1728,7 @@
if (!enableVerification) {
return
}
- singleQueryMethod<ReadQueryMethod>(
+ singleQueryMethod<ReadQueryFunction>(
"""
@MapInfo(keyColumn="cat", valueColumn="dog")
@Query("select * from User u JOIN Book b ON u.uid == b.uid")
@@ -1759,7 +1759,7 @@
// No warning without verification, avoiding false positives
return
}
- singleQueryMethod<ReadQueryMethod>(
+ singleQueryMethod<ReadQueryFunction>(
"""
@SuppressWarnings(RoomWarnings.QUERY_MISMATCH)
@MapInfo(keyColumn = "uid")
@@ -1806,7 +1806,7 @@
"""
.trimIndent()
)
- singleQueryMethod<ReadQueryMethod>(
+ singleQueryMethod<ReadQueryFunction>(
"""
@SuppressWarnings(RoomWarnings.QUERY_MISMATCH)
@Query("SELECT * FROM User u JOIN Book b ON u.uid == b.uid")
@@ -1846,7 +1846,7 @@
"${KotlinTypeNames.FLOW.canonicalName}<Int>"
)
.forEach { type ->
- singleQueryMethodKotlin<WriteQueryMethod>(
+ singleQueryFunction<WriteQueryFunction>(
"""
@Query("DELETE from User where uid = :id")
abstract suspend fun foo(id: Int): $type
@@ -1862,7 +1862,7 @@
@Test
fun nonNullVoidGuava() {
- singleQueryMethodKotlin<WriteQueryMethod>(
+ singleQueryFunction<WriteQueryFunction>(
"""
@Query("DELETE from User where uid = :id")
abstract fun foo(id: Int): ListenableFuture<Void>
@@ -1874,7 +1874,7 @@
@Test
fun maybe() {
- singleQueryMethodKotlin<ReadQueryMethod>(
+ singleQueryFunction<ReadQueryFunction>(
"""
@Query("SELECT * FROM book WHERE bookId = :bookId")
abstract fun getBookMaybe(bookId: String): io.reactivex.Maybe<Book>
@@ -1886,7 +1886,7 @@
@Test
fun single() {
- singleQueryMethodKotlin<ReadQueryMethod>(
+ singleQueryFunction<ReadQueryFunction>(
"""
@Query("SELECT * FROM book WHERE bookId = :bookId")
abstract fun getBookSingle(bookId: String): io.reactivex.Single<Book>
@@ -1901,7 +1901,7 @@
if (!enableVerification) {
return
}
- singleQueryMethod<ReadQueryMethod>(
+ singleQueryMethod<ReadQueryFunction>(
"""
@Query("select * from User")
abstract String[] stringArray();
@@ -1920,7 +1920,7 @@
if (!enableVerification) {
return
}
- singleQueryMethod<ReadQueryMethod>(
+ singleQueryMethod<ReadQueryFunction>(
"""
@Query("select * from User")
abstract long[] longArray();
diff --git a/room/room-compiler/src/test/kotlin/androidx/room/processor/RawQueryMethodProcessorTest.kt b/room/room-compiler/src/test/kotlin/androidx/room/processor/RawQueryFunctionProcessorTest.kt
similarity index 95%
rename from room/room-compiler/src/test/kotlin/androidx/room/processor/RawQueryMethodProcessorTest.kt
rename to room/room-compiler/src/test/kotlin/androidx/room/processor/RawQueryFunctionProcessorTest.kt
index 7bacb42..5a851a5 100644
--- a/room/room-compiler/src/test/kotlin/androidx/room/processor/RawQueryMethodProcessorTest.kt
+++ b/room/room-compiler/src/test/kotlin/androidx/room/processor/RawQueryFunctionProcessorTest.kt
@@ -37,13 +37,13 @@
import androidx.room.processor.ProcessorErrors.RAW_QUERY_STRING_PARAMETER_REMOVED
import androidx.room.runProcessorTestWithK1
import androidx.room.testing.context
-import androidx.room.vo.RawQueryMethod
+import androidx.room.vo.RawQueryFunction
import androidx.sqlite.db.SupportSQLiteQuery
import org.hamcrest.CoreMatchers.`is`
import org.hamcrest.MatcherAssert.assertThat
import org.junit.Test
-class RawQueryMethodProcessorTest {
+class RawQueryFunctionProcessorTest {
@Test
fun supportRawQuery() {
singleQueryMethod(
@@ -56,7 +56,7 @@
assertThat(
query.runtimeQueryParam,
`is`(
- RawQueryMethod.RuntimeQueryParameter(
+ RawQueryFunction.RuntimeQueryParameter(
paramName = "query",
typeName = SupportDbTypeNames.QUERY
)
@@ -95,7 +95,7 @@
assertThat(
query.runtimeQueryParam,
`is`(
- RawQueryMethod.RuntimeQueryParameter(
+ RawQueryFunction.RuntimeQueryParameter(
paramName = "query",
typeName = SupportDbTypeNames.QUERY
)
@@ -118,7 +118,7 @@
assertThat(
query.runtimeQueryParam,
`is`(
- RawQueryMethod.RuntimeQueryParameter(
+ RawQueryFunction.RuntimeQueryParameter(
paramName = "query",
typeName = SupportDbTypeNames.QUERY
)
@@ -190,7 +190,7 @@
assertThat(
query.runtimeQueryParam,
`is`(
- RawQueryMethod.RuntimeQueryParameter(
+ RawQueryFunction.RuntimeQueryParameter(
paramName = "query",
typeName = SupportDbTypeNames.QUERY
)
@@ -225,7 +225,7 @@
val daoElement =
invocation.processingEnv.requireTypeElement(RawQuerySuspendUnitDao::class)
val daoFunctionElement = daoElement.getDeclaredMethods().first()
- RawQueryMethodProcessor(
+ RawQueryFunctionProcessor(
baseContext = invocation.context,
containing = daoElement.type,
executableElement = daoFunctionElement
@@ -341,8 +341,8 @@
@RawQuery(observedEntities = MyDataClass.class)
abstract public int[] foo(SupportSQLiteQuery query);
"""
- ) { method, _ ->
- assertThat(method.observedTableNames, `is`(setOf("User")))
+ ) { function, _ ->
+ assertThat(function.observedTableNames, `is`(setOf("User")))
}
}
@@ -358,8 +358,8 @@
@RawQuery(observedEntities = MyDataClass.class)
abstract public int[] foo(SupportSQLiteQuery query);
"""
- ) { method, _ ->
- assertThat(method.observedTableNames, `is`(setOf("User")))
+ ) { function, _ ->
+ assertThat(function.observedTableNames, `is`(setOf("User")))
}
}
@@ -598,7 +598,7 @@
"${KotlinTypeNames.FLOW.canonicalName}<Int>"
)
.forEach { type ->
- singleQueryMethodKotlin(
+ singleQueryFunction(
"""
@RawQuery
abstract suspend fun foo(query: SupportSQLiteQuery): $type
@@ -614,7 +614,7 @@
@Test
fun nonNullVoidGuava() {
- singleQueryMethodKotlin(
+ singleQueryFunction(
"""
@RawQuery
abstract fun foo(query: SupportSQLiteQuery): ListenableFuture<Void>
@@ -626,7 +626,7 @@
private fun singleQueryMethod(
vararg input: String,
- handler: (RawQueryMethod, XTestInvocation) -> Unit
+ handler: (RawQueryFunction, XTestInvocation) -> Unit
) {
val inputSource =
Source.java("foo.bar.MyClass", DAO_PREFIX + input.joinToString("\n") + DAO_SUFFIX)
@@ -649,7 +649,7 @@
sources = commonSources + inputSource,
options = mapOf(Context.BooleanProcessorOptions.GENERATE_KOTLIN.argName to "false"),
) { invocation ->
- val (owner, methods) =
+ val (owner, functions) =
invocation.roundEnv
.getElementsAnnotatedWith(Dao::class.qualifiedName!!)
.filterIsInstance<XTypeElement>()
@@ -661,19 +661,19 @@
}
.first { it.second.isNotEmpty() }
val parser =
- RawQueryMethodProcessor(
+ RawQueryFunctionProcessor(
baseContext = invocation.context,
containing = owner.type,
- executableElement = methods.first()
+ executableElement = functions.first()
)
val parsedQuery = parser.process()
handler(parsedQuery, invocation)
}
}
- private fun singleQueryMethodKotlin(
+ private fun singleQueryFunction(
vararg input: String,
- handler: (RawQueryMethod, XTestInvocation) -> Unit
+ handler: (RawQueryFunction, XTestInvocation) -> Unit
) {
val inputSource =
Source.kotlin("MyClass.kt", DAO_PREFIX_KT + input.joinToString("\n") + DAO_SUFFIX)
@@ -700,7 +700,7 @@
COMMON.GUAVA_ROOM
)
runProcessorTestWithK1(sources = commonSources + inputSource) { invocation ->
- val (owner, methods) =
+ val (owner, functions) =
invocation.roundEnv
.getElementsAnnotatedWith(Dao::class.qualifiedName!!)
.filterIsInstance<XTypeElement>()
@@ -712,10 +712,10 @@
}
.first { it.second.isNotEmpty() }
val parser =
- RawQueryMethodProcessor(
+ RawQueryFunctionProcessor(
baseContext = invocation.context,
containing = owner.type,
- executableElement = methods.first()
+ executableElement = functions.first()
)
val parsedQuery = parser.process()
handler(parsedQuery, invocation)
diff --git a/room/room-compiler/src/test/kotlin/androidx/room/processor/TransactionMethodProcessorTest.kt b/room/room-compiler/src/test/kotlin/androidx/room/processor/TransactionFunctionProcessorTest.kt
similarity index 91%
rename from room/room-compiler/src/test/kotlin/androidx/room/processor/TransactionMethodProcessorTest.kt
rename to room/room-compiler/src/test/kotlin/androidx/room/processor/TransactionFunctionProcessorTest.kt
index 9354625..6edea0d 100644
--- a/room/room-compiler/src/test/kotlin/androidx/room/processor/TransactionMethodProcessorTest.kt
+++ b/room/room-compiler/src/test/kotlin/androidx/room/processor/TransactionFunctionProcessorTest.kt
@@ -32,7 +32,7 @@
import androidx.room.ext.RxJava3TypeNames
import androidx.room.runProcessorTestWithK1
import androidx.room.testing.context
-import androidx.room.vo.TransactionMethod
+import androidx.room.vo.TransactionFunction
import org.hamcrest.CoreMatchers.`is`
import org.hamcrest.MatcherAssert.assertThat
import org.junit.Test
@@ -41,7 +41,7 @@
@Suppress("PLATFORM_CLASS_MAPPED_TO_KOTLIN")
@RunWith(JUnit4::class)
-class TransactionMethodProcessorTest {
+class TransactionFunctionProcessorTest {
companion object {
const val DAO_PREFIX =
@@ -80,7 +80,7 @@
) { transaction, invocation ->
assertThat(transaction.jvmName, `is`("doInTransaction"))
invocation.assertCompilationResult {
- hasErrorContaining(ProcessorErrors.TRANSACTION_METHOD_MODIFIERS)
+ hasErrorContaining(ProcessorErrors.TRANSACTION_FUNCTION_MODIFIERS)
}
}
}
@@ -95,7 +95,7 @@
) { transaction, invocation ->
assertThat(transaction.jvmName, `is`("doInTransaction"))
invocation.assertCompilationResult {
- hasErrorContaining(ProcessorErrors.TRANSACTION_METHOD_MODIFIERS)
+ hasErrorContaining(ProcessorErrors.TRANSACTION_FUNCTION_MODIFIERS)
}
}
}
@@ -113,7 +113,7 @@
assertThat(transaction.jvmName, `is`("doInTransaction"))
invocation.assertCompilationResult {
hasErrorContaining(
- ProcessorErrors.transactionMethodAsync(
+ ProcessorErrors.transactionFunctionAsync(
FLOW.rawTypeName.toString(CodeLanguage.JAVA)
)
)
@@ -132,7 +132,7 @@
assertThat(transaction.jvmName, `is`("doInTransaction"))
invocation.assertCompilationResult {
hasErrorContaining(
- ProcessorErrors.transactionMethodAsync(
+ ProcessorErrors.transactionFunctionAsync(
LIVE_DATA.rawTypeName.toString(CodeLanguage.JAVA)
)
)
@@ -151,7 +151,7 @@
assertThat(transaction.jvmName, `is`("doInTransaction"))
invocation.assertCompilationResult {
hasErrorContaining(
- ProcessorErrors.transactionMethodAsync(
+ ProcessorErrors.transactionFunctionAsync(
COMPUTABLE_LIVE_DATA.rawTypeName.toString(CodeLanguage.JAVA)
)
)
@@ -170,7 +170,7 @@
assertThat(transaction.jvmName, `is`("doInTransaction"))
invocation.assertCompilationResult {
hasErrorContaining(
- ProcessorErrors.transactionMethodAsync(
+ ProcessorErrors.transactionFunctionAsync(
RxJava2TypeNames.FLOWABLE.rawTypeName.toString(CodeLanguage.JAVA)
)
)
@@ -191,7 +191,7 @@
assertThat(transaction.jvmName, `is`("doInTransaction"))
invocation.assertCompilationResult {
hasErrorContaining(
- ProcessorErrors.transactionMethodAsync(
+ ProcessorErrors.transactionFunctionAsync(
RxJava3TypeNames.FLOWABLE.rawTypeName.toString(CodeLanguage.JAVA)
)
)
@@ -210,7 +210,7 @@
assertThat(transaction.jvmName, `is`("doInTransaction"))
invocation.assertCompilationResult {
hasErrorContaining(
- ProcessorErrors.transactionMethodAsync(
+ ProcessorErrors.transactionFunctionAsync(
RxJava2TypeNames.COMPLETABLE.rawTypeName.toString(CodeLanguage.JAVA)
)
)
@@ -231,7 +231,7 @@
assertThat(transaction.jvmName, `is`("doInTransaction"))
invocation.assertCompilationResult {
hasErrorContaining(
- ProcessorErrors.transactionMethodAsync(
+ ProcessorErrors.transactionFunctionAsync(
RxJava3TypeNames.COMPLETABLE.rawTypeName.toString(CodeLanguage.JAVA)
)
)
@@ -250,7 +250,7 @@
assertThat(transaction.jvmName, `is`("doInTransaction"))
invocation.assertCompilationResult {
hasErrorContaining(
- ProcessorErrors.transactionMethodAsync(
+ ProcessorErrors.transactionFunctionAsync(
RxJava2TypeNames.SINGLE.rawTypeName.toString(CodeLanguage.JAVA)
)
)
@@ -271,7 +271,7 @@
assertThat(transaction.jvmName, `is`("doInTransaction"))
invocation.assertCompilationResult {
hasErrorContaining(
- ProcessorErrors.transactionMethodAsync(
+ ProcessorErrors.transactionFunctionAsync(
RxJava3TypeNames.SINGLE.rawTypeName.toString(CodeLanguage.JAVA)
)
)
@@ -290,7 +290,7 @@
assertThat(transaction.jvmName, `is`("doInTransaction"))
invocation.assertCompilationResult {
hasErrorContaining(
- ProcessorErrors.transactionMethodAsync(
+ ProcessorErrors.transactionFunctionAsync(
LISTENABLE_FUTURE.rawTypeName.toString(CodeLanguage.JAVA)
)
)
@@ -309,7 +309,7 @@
assertThat(transaction.jvmName, `is`("doInTransaction"))
invocation.assertCompilationResult {
hasErrorContaining(
- ProcessorErrors.transactionMethodAsync(
+ ProcessorErrors.transactionFunctionAsync(
PUBLISHER.rawTypeName.toString(CodeLanguage.JAVA)
)
)
@@ -317,12 +317,12 @@
}
}
- private val TransactionMethod.jvmName: String
+ private val TransactionFunction.jvmName: String
get() = element.jvmName
private fun singleTransactionMethod(
vararg input: String,
- handler: (TransactionMethod, XTestInvocation) -> Unit
+ handler: (TransactionFunction, XTestInvocation) -> Unit
) {
val inputSource =
listOf(
@@ -360,7 +360,7 @@
}
.first { it.second.isNotEmpty() }
val processor =
- TransactionMethodProcessor(
+ TransactionFunctionProcessor(
baseContext = invocation.context,
containingElement = owner,
containingType = owner.type,
diff --git a/room/room-compiler/src/test/kotlin/androidx/room/processor/UpdateMethodProcessorTest.kt b/room/room-compiler/src/test/kotlin/androidx/room/processor/UpdateFunctionProcessorTest.kt
similarity index 92%
rename from room/room-compiler/src/test/kotlin/androidx/room/processor/UpdateMethodProcessorTest.kt
rename to room/room-compiler/src/test/kotlin/androidx/room/processor/UpdateFunctionProcessorTest.kt
index f5a3a5a..b9b31bd 100644
--- a/room/room-compiler/src/test/kotlin/androidx/room/processor/UpdateMethodProcessorTest.kt
+++ b/room/room-compiler/src/test/kotlin/androidx/room/processor/UpdateFunctionProcessorTest.kt
@@ -22,7 +22,7 @@
import androidx.room.compiler.processing.util.Source
import androidx.room.processor.ProcessorErrors.CANNOT_FIND_UPDATE_RESULT_ADAPTER
import androidx.room.processor.ProcessorErrors.UPDATE_MISSING_PARAMS
-import androidx.room.vo.UpdateMethod
+import androidx.room.vo.UpdateFunction
import org.hamcrest.CoreMatchers.`is`
import org.hamcrest.MatcherAssert.assertThat
import org.junit.Test
@@ -31,8 +31,8 @@
@Suppress("PLATFORM_CLASS_MAPPED_TO_KOTLIN")
@RunWith(JUnit4::class)
-class UpdateMethodProcessorTest :
- DeleteOrUpdateShortcutMethodProcessorTest<UpdateMethod>(Update::class) {
+class UpdateFunctionProcessorTest :
+ DeleteOrUpdateShortcutFunctionProcessorTest<UpdateFunction>(Update::class) {
override fun invalidReturnTypeError(): String = CANNOT_FIND_UPDATE_RESULT_ADAPTER
override fun noParamsError(): String = UPDATE_MISSING_PARAMS
@@ -41,8 +41,8 @@
baseContext: Context,
containing: XType,
executableElement: XMethodElement
- ): UpdateMethod {
- return UpdateMethodProcessor(baseContext, containing, executableElement).process()
+ ): UpdateFunction {
+ return UpdateFunctionProcessor(baseContext, containing, executableElement).process()
}
@Test
diff --git a/room/room-compiler/src/test/kotlin/androidx/room/processor/UpsertMethodProcessorTest.kt b/room/room-compiler/src/test/kotlin/androidx/room/processor/UpsertFunctionProcessorTest.kt
similarity index 88%
rename from room/room-compiler/src/test/kotlin/androidx/room/processor/UpsertMethodProcessorTest.kt
rename to room/room-compiler/src/test/kotlin/androidx/room/processor/UpsertFunctionProcessorTest.kt
index 25f9a07..e36bf35 100644
--- a/room/room-compiler/src/test/kotlin/androidx/room/processor/UpsertMethodProcessorTest.kt
+++ b/room/room-compiler/src/test/kotlin/androidx/room/processor/UpsertFunctionProcessorTest.kt
@@ -23,14 +23,14 @@
import androidx.room.processor.ProcessorErrors.UPSERT_DOES_NOT_HAVE_ANY_PARAMETERS_TO_UPSERT
import androidx.room.processor.ProcessorErrors.UPSERT_MULTI_PARAM_SINGLE_RETURN_MISMATCH
import androidx.room.processor.ProcessorErrors.UPSERT_SINGLE_PARAM_MULTI_RETURN_MISMATCH
-import androidx.room.vo.UpsertMethod
+import androidx.room.vo.UpsertFunction
import org.junit.runner.RunWith
import org.junit.runners.JUnit4
@Suppress("PLATFORM_CLASS_MAPPED_TO_KOTLIN")
@RunWith(JUnit4::class)
-class UpsertMethodProcessorTest :
- InsertOrUpsertShortcutMethodProcessorTest<UpsertMethod>(Upsert::class) {
+class UpsertFunctionProcessorTest :
+ InsertOrUpsertShortcutFunctionProcessorTest<UpsertFunction>(Upsert::class) {
override fun noParamsError(): String = UPSERT_DOES_NOT_HAVE_ANY_PARAMETERS_TO_UPSERT
override fun missingPrimaryKey(
@@ -55,7 +55,7 @@
baseContext: Context,
containing: XType,
executableElement: XMethodElement
- ): UpsertMethod {
- return UpsertMethodProcessor(baseContext, containing, executableElement).process()
+ ): UpsertFunction {
+ return UpsertFunctionProcessor(baseContext, containing, executableElement).process()
}
}
diff --git a/room/room-compiler/src/test/kotlin/androidx/room/solver/TypeAdapterStoreTest.kt b/room/room-compiler/src/test/kotlin/androidx/room/solver/TypeAdapterStoreTest.kt
index bf39ada..19a60fa 100644
--- a/room/room-compiler/src/test/kotlin/androidx/room/solver/TypeAdapterStoreTest.kt
+++ b/room/room-compiler/src/test/kotlin/androidx/room/solver/TypeAdapterStoreTest.kt
@@ -61,10 +61,10 @@
import androidx.room.solver.query.parameter.CollectionQueryParameterAdapter
import androidx.room.solver.query.result.MultiTypedPagingSourceQueryResultBinder
import androidx.room.solver.query.result.Paging3PagingSourceQueryResultBinder
-import androidx.room.solver.shortcut.binderprovider.GuavaListenableFutureDeleteOrUpdateMethodBinderProvider
-import androidx.room.solver.shortcut.binderprovider.GuavaListenableFutureInsertOrUpsertMethodBinderProvider
-import androidx.room.solver.shortcut.binderprovider.RxCallableDeleteOrUpdateMethodBinderProvider
-import androidx.room.solver.shortcut.binderprovider.RxCallableInsertOrUpsertMethodBinderProvider
+import androidx.room.solver.shortcut.binderprovider.GuavaListenableFutureDeleteOrUpdateFunctionBinderProvider
+import androidx.room.solver.shortcut.binderprovider.GuavaListenableFutureInsertOrUpsertFunctionBinderProvider
+import androidx.room.solver.shortcut.binderprovider.RxCallableDeleteOrUpdateFunctionBinderProvider
+import androidx.room.solver.shortcut.binderprovider.RxCallableInsertOrUpsertFunctionBinderProvider
import androidx.room.solver.types.BoxedPrimitiveColumnTypeAdapter
import androidx.room.solver.types.ByteBufferColumnTypeAdapter
import androidx.room.solver.types.ColumnTypeAdapter
@@ -79,7 +79,7 @@
import androidx.room.solver.types.ValueClassConverterWrapper
import androidx.room.testing.context
import androidx.room.vo.BuiltInConverterFlags
-import androidx.room.vo.ReadQueryMethod
+import androidx.room.vo.ReadQueryFunction
import org.hamcrest.CoreMatchers.instanceOf
import org.hamcrest.CoreMatchers.`is`
import org.hamcrest.CoreMatchers.notNullValue
@@ -880,7 +880,7 @@
val single = invocation.processingEnv.requireTypeElement(rxTypeClassName)
assertThat(single, notNullValue())
assertThat(
- RxCallableInsertOrUpsertMethodBinderProvider.getAll(invocation.context)
+ RxCallableInsertOrUpsertFunctionBinderProvider.getAll(invocation.context)
.any { it.matches(single.type) },
`is`(true)
)
@@ -898,7 +898,7 @@
runProcessorTestWithK1(sources = listOf(rxTypeSrc)) { invocation ->
val maybe = invocation.processingEnv.requireTypeElement(rxTypeClassName)
assertThat(
- RxCallableInsertOrUpsertMethodBinderProvider.getAll(invocation.context)
+ RxCallableInsertOrUpsertFunctionBinderProvider.getAll(invocation.context)
.any { it.matches(maybe.type) },
`is`(true)
)
@@ -916,7 +916,7 @@
runProcessorTestWithK1(sources = listOf(rxTypeSrc)) { invocation ->
val completable = invocation.processingEnv.requireTypeElement(rxTypeClassName)
assertThat(
- RxCallableInsertOrUpsertMethodBinderProvider.getAll(invocation.context)
+ RxCallableInsertOrUpsertFunctionBinderProvider.getAll(invocation.context)
.any { it.matches(completable.type) },
`is`(true)
)
@@ -932,7 +932,7 @@
GuavaUtilConcurrentTypeNames.LISTENABLE_FUTURE
)
assertThat(
- GuavaListenableFutureInsertOrUpsertMethodBinderProvider(invocation.context)
+ GuavaListenableFutureInsertOrUpsertFunctionBinderProvider(invocation.context)
.matches(future.type),
`is`(true)
)
@@ -945,7 +945,7 @@
val single = invocation.processingEnv.requireTypeElement(RxJava2TypeNames.SINGLE)
assertThat(single, notNullValue())
assertThat(
- RxCallableDeleteOrUpdateMethodBinderProvider.getAll(invocation.context).any {
+ RxCallableDeleteOrUpdateFunctionBinderProvider.getAll(invocation.context).any {
it.matches(single.type)
},
`is`(true)
@@ -959,7 +959,7 @@
val maybe = invocation.processingEnv.requireTypeElement(RxJava2TypeNames.MAYBE)
assertThat(maybe, notNullValue())
assertThat(
- RxCallableDeleteOrUpdateMethodBinderProvider.getAll(invocation.context).any {
+ RxCallableDeleteOrUpdateFunctionBinderProvider.getAll(invocation.context).any {
it.matches(maybe.type)
},
`is`(true)
@@ -974,7 +974,7 @@
invocation.processingEnv.requireTypeElement(RxJava2TypeNames.COMPLETABLE)
assertThat(completable, notNullValue())
assertThat(
- RxCallableDeleteOrUpdateMethodBinderProvider.getAll(invocation.context).any {
+ RxCallableDeleteOrUpdateFunctionBinderProvider.getAll(invocation.context).any {
it.matches(completable.type)
},
`is`(true)
@@ -991,7 +991,7 @@
)
assertThat(future, notNullValue())
assertThat(
- GuavaListenableFutureDeleteOrUpdateMethodBinderProvider(invocation.context)
+ GuavaListenableFutureDeleteOrUpdateFunctionBinderProvider(invocation.context)
.matches(future.type),
`is`(true)
)
@@ -1009,7 +1009,9 @@
val single = invocation.processingEnv.requireTypeElement(rxTypeClassName)
assertThat(single).isNotNull()
assertThat(
- RxCallableInsertOrUpsertMethodBinderProvider.getAll(invocation.context)
+ RxCallableInsertOrUpsertFunctionBinderProvider.getAll(
+ invocation.context
+ )
.any { it.matches(single.type) }
)
.isTrue()
@@ -1027,7 +1029,9 @@
runProcessorTestWithK1(sources = listOf(rxTypeSrc)) { invocation ->
val maybe = invocation.processingEnv.requireTypeElement(rxTypeClassName)
assertThat(
- RxCallableInsertOrUpsertMethodBinderProvider.getAll(invocation.context)
+ RxCallableInsertOrUpsertFunctionBinderProvider.getAll(
+ invocation.context
+ )
.any { it.matches(maybe.type) }
)
.isTrue()
@@ -1045,7 +1049,9 @@
runProcessorTestWithK1(sources = listOf(rxTypeSrc)) { invocation ->
val completable = invocation.processingEnv.requireTypeElement(rxTypeClassName)
assertThat(
- RxCallableInsertOrUpsertMethodBinderProvider.getAll(invocation.context)
+ RxCallableInsertOrUpsertFunctionBinderProvider.getAll(
+ invocation.context
+ )
.any { it.matches(completable.type) }
)
.isTrue()
@@ -1061,7 +1067,7 @@
GuavaUtilConcurrentTypeNames.LISTENABLE_FUTURE
)
assertThat(
- GuavaListenableFutureInsertOrUpsertMethodBinderProvider(invocation.context)
+ GuavaListenableFutureInsertOrUpsertFunctionBinderProvider(invocation.context)
.matches(future.type)
)
.isTrue()
@@ -1427,7 +1433,10 @@
)
val parsedDao = parser.process()
val binder =
- parsedDao.queryMethods.filterIsInstance<ReadQueryMethod>().first().queryResultBinder
+ parsedDao.queryFunctions
+ .filterIsInstance<ReadQueryFunction>()
+ .first()
+ .queryResultBinder
assertThat(binder is Paging3PagingSourceQueryResultBinder).isTrue()
val pagingSourceXRawType: XRawType? =
@@ -1435,8 +1444,8 @@
.findType(PagingTypeNames.PAGING_SOURCE.canonicalName)
?.rawType
val returnedXRawType =
- parsedDao.queryMethods
- .filterIsInstance<ReadQueryMethod>()
+ parsedDao.queryFunctions
+ .filterIsInstance<ReadQueryFunction>()
.first()
.returnType
.rawType
@@ -1490,7 +1499,10 @@
)
val parsedDao = parser.process()
val binder =
- parsedDao.queryMethods.filterIsInstance<ReadQueryMethod>().first().queryResultBinder
+ parsedDao.queryFunctions
+ .filterIsInstance<ReadQueryFunction>()
+ .first()
+ .queryResultBinder
// assert that room correctly binds to ListenableFuturePagingSource instead of
// its supertype PagingSource. ListenableFuturePagingSourceBinderProvider
@@ -1502,8 +1514,8 @@
.findType(PagingTypeNames.LISTENABLE_FUTURE_PAGING_SOURCE.canonicalName)
?.rawType
val returnedXRawType =
- parsedDao.queryMethods
- .filterIsInstance<ReadQueryMethod>()
+ parsedDao.queryFunctions
+ .filterIsInstance<ReadQueryFunction>()
.first()
.returnType
.rawType
@@ -1550,7 +1562,10 @@
)
val parsedDao = parser.process()
val binder =
- parsedDao.queryMethods.filterIsInstance<ReadQueryMethod>().first().queryResultBinder
+ parsedDao.queryFunctions
+ .filterIsInstance<ReadQueryFunction>()
+ .first()
+ .queryResultBinder
assertThat(binder is MultiTypedPagingSourceQueryResultBinder).isTrue()
val rxPagingSourceXRawType: XRawType? =
@@ -1558,8 +1573,8 @@
.findType(PagingTypeNames.RX2_PAGING_SOURCE.canonicalName)
?.rawType
val returnedXRawType =
- parsedDao.queryMethods
- .filterIsInstance<ReadQueryMethod>()
+ parsedDao.queryFunctions
+ .filterIsInstance<ReadQueryFunction>()
.first()
.returnType
.rawType
@@ -1606,7 +1621,10 @@
)
val parsedDao = parser.process()
val binder =
- parsedDao.queryMethods.filterIsInstance<ReadQueryMethod>().first().queryResultBinder
+ parsedDao.queryFunctions
+ .filterIsInstance<ReadQueryFunction>()
+ .first()
+ .queryResultBinder
assertThat(binder is MultiTypedPagingSourceQueryResultBinder).isTrue()
val rxPagingSourceXRawType: XRawType? =
@@ -1614,8 +1632,8 @@
.findType(PagingTypeNames.RX3_PAGING_SOURCE.canonicalName)
?.rawType
val returnedXRawType =
- parsedDao.queryMethods
- .filterIsInstance<ReadQueryMethod>()
+ parsedDao.queryFunctions
+ .filterIsInstance<ReadQueryFunction>()
.first()
.returnType
.rawType
diff --git a/room/room-compiler/src/test/kotlin/androidx/room/solver/query/QueryWriterTest.kt b/room/room-compiler/src/test/kotlin/androidx/room/solver/query/QueryWriterTest.kt
index ad513ea..23c72a0 100644
--- a/room/room-compiler/src/test/kotlin/androidx/room/solver/query/QueryWriterTest.kt
+++ b/room/room-compiler/src/test/kotlin/androidx/room/solver/query/QueryWriterTest.kt
@@ -25,7 +25,7 @@
import androidx.room.compiler.processing.util.Source
import androidx.room.ext.RoomTypeNames.ROOM_SQL_QUERY
import androidx.room.ext.RoomTypeNames.STRING_UTIL
-import androidx.room.processor.QueryMethodProcessor
+import androidx.room.processor.QueryFunctionProcessor
import androidx.room.runProcessorTestWithK1
import androidx.room.testing.context
import androidx.room.writer.QueryWriter
@@ -375,7 +375,7 @@
}
.first { it.second.isNotEmpty() }
val parser =
- QueryMethodProcessor(
+ QueryFunctionProcessor(
baseContext = invocation.context,
containing = owner.type,
executableElement = methods.first()
diff --git a/room/room-compiler/src/test/kotlin/androidx/room/verifier/DatabaseVerifierTest.kt b/room/room-compiler/src/test/kotlin/androidx/room/verifier/DatabaseVerifierTest.kt
index 421fb25..a730267 100644
--- a/room/room-compiler/src/test/kotlin/androidx/room/verifier/DatabaseVerifierTest.kt
+++ b/room/room-compiler/src/test/kotlin/androidx/room/verifier/DatabaseVerifierTest.kt
@@ -399,7 +399,7 @@
type = mock(XType::class.java),
entities = entities,
views = views,
- daoMethods = emptyList(),
+ daoFunctions = emptyList(),
version = -1,
exportSchema = false,
enableForeignKeys = false,
diff --git a/room/room-compiler/src/test/kotlin/androidx/room/vo/DatabaseTest.kt b/room/room-compiler/src/test/kotlin/androidx/room/vo/DatabaseTest.kt
index 536bc08..cc50bc3 100644
--- a/room/room-compiler/src/test/kotlin/androidx/room/vo/DatabaseTest.kt
+++ b/room/room-compiler/src/test/kotlin/androidx/room/vo/DatabaseTest.kt
@@ -67,7 +67,7 @@
)
),
views = emptyList(),
- daoMethods = emptyList(),
+ daoFunctions = emptyList(),
version = 1,
exportSchema = false,
enableForeignKeys = false,
diff --git a/room/room-compiler/src/test/kotlin/androidx/room/writer/DaoKotlinCodeGenTest.kt b/room/room-compiler/src/test/kotlin/androidx/room/writer/DaoKotlinCodeGenTest.kt
index 47a2205..c6e6898 100644
--- a/room/room-compiler/src/test/kotlin/androidx/room/writer/DaoKotlinCodeGenTest.kt
+++ b/room/room-compiler/src/test/kotlin/androidx/room/writer/DaoKotlinCodeGenTest.kt
@@ -1108,7 +1108,7 @@
}
@Test
- fun transactionMethodAdapter_interface(
+ fun transactionFunctionAdapter_interface(
@TestParameter("disable", "all-compatibility", "all") jvmDefaultMode: String
) {
// For parametrized tests, use method name from reflection
@@ -1180,7 +1180,7 @@
}
@Test
- fun transactionMethodAdapter_abstractClass() {
+ fun transactionFunctionAdapter_abstractClass() {
val src =
Source.kotlin(
"MyDao.kt",
@@ -1235,7 +1235,7 @@
}
@Test
- fun deleteOrUpdateMethodAdapter() {
+ fun deleteOrUpdateFunctionAdapter() {
val src =
Source.kotlin(
"MyDao.kt",
@@ -1273,7 +1273,7 @@
}
@Test
- fun insertOrUpsertMethodAdapter() {
+ fun insertOrUpsertFunctionAdapter() {
val src =
Source.kotlin(
"MyDao.kt",
diff --git a/room/room-compiler/src/test/test-data/kotlinCodeGen/deleteOrUpdateMethodAdapter.kt b/room/room-compiler/src/test/test-data/kotlinCodeGen/deleteOrUpdateFunctionAdapter.kt
similarity index 100%
rename from room/room-compiler/src/test/test-data/kotlinCodeGen/deleteOrUpdateMethodAdapter.kt
rename to room/room-compiler/src/test/test-data/kotlinCodeGen/deleteOrUpdateFunctionAdapter.kt
diff --git a/room/room-compiler/src/test/test-data/kotlinCodeGen/insertOrUpsertMethodAdapter.kt b/room/room-compiler/src/test/test-data/kotlinCodeGen/insertOrUpsertFunctionAdapter.kt
similarity index 100%
rename from room/room-compiler/src/test/test-data/kotlinCodeGen/insertOrUpsertMethodAdapter.kt
rename to room/room-compiler/src/test/test-data/kotlinCodeGen/insertOrUpsertFunctionAdapter.kt
diff --git a/room/room-compiler/src/test/test-data/kotlinCodeGen/transactionMethodAdapter_abstractClass.kt b/room/room-compiler/src/test/test-data/kotlinCodeGen/transactionFunctionAdapter_abstractClass.kt
similarity index 100%
rename from room/room-compiler/src/test/test-data/kotlinCodeGen/transactionMethodAdapter_abstractClass.kt
rename to room/room-compiler/src/test/test-data/kotlinCodeGen/transactionFunctionAdapter_abstractClass.kt
diff --git a/room/room-compiler/src/test/test-data/kotlinCodeGen/transactionMethodAdapter_interface.kt b/room/room-compiler/src/test/test-data/kotlinCodeGen/transactionFunctionAdapter_interface.kt
similarity index 100%
rename from room/room-compiler/src/test/test-data/kotlinCodeGen/transactionMethodAdapter_interface.kt
rename to room/room-compiler/src/test/test-data/kotlinCodeGen/transactionFunctionAdapter_interface.kt