This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import android.os.Looper | |
import android.view.ViewGroup | |
import androidx.recyclerview.widget.DiffUtil | |
import androidx.recyclerview.widget.RecyclerView | |
import androidx.recyclerview.widget.RecyclerView.Adapter | |
import androidx.recyclerview.widget.RecyclerView.NO_POSITION | |
import androidx.recyclerview.widget.RecyclerView.ViewHolder | |
class ComposableAdapter: Adapter<ViewHolder>() { | |
private val adapterForViewType = LinkedHashMap<Int, Adapter<ViewHolder>>() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class SqlDelightParserDefinition: SqliteParserDefinition() { | |
init { | |
setParserOverride(object : CustomSqliteParser() { | |
override fun columnDef(builder: PsiBuilder, level: Int, column_def: Parser): Boolean { | |
return SqlDelightParser.column_def(builder, level) | |
} | |
}) | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
column_def ::= <<column_name_real>> type_name [ 'AS' ('@' annotation) * java_type_name ] ( <<column_constraint_real>> ) * { | |
implements=[ | |
"com.alecstrong.sqlite.psi.core.psi.SqliteColumnDef"; | |
"com.squareup.sqldelight.core.lang.psi.TypedColumn" | |
] | |
extends="com.squareup.sqldelight.core.lang.psi.ColumnDefMixin" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public interface SqliteCreateTableStmt extends TableElement { | |
@NotNull | |
List<SqliteColumnDef> getColumnDefList(); | |
@Nullable | |
SqliteCompoundSelectStmt getCompoundSelectStmt(); | |
@Nullable | |
SqliteDatabaseName getDatabaseName(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
open class CustomSqliteParser { | |
open fun createElement(node: ASTNode): PsiElement = SqliteTypes.Factory.createElement(node) | |
open fun typeName( | |
builder: PsiBuilder, | |
level: Int, | |
type_name: GeneratedParserUtilBase.Parser | |
): Boolean = type_name.parse(builder, level) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
internal object SqliteParserUtil : ModuleParserUtil() { | |
internal var customSqliteParser: CustomSqliteParser = CustomSqliteParser() | |
@JvmStatic | |
fun typeNameExt( | |
builder: PsiBuilder, | |
level: Int, | |
type_name: Parser | |
): Boolean = customSqliteParser.typeName(builder, level, type_name) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fake column_def ::= column_name type_name ( column_constraint ) * | |
column_def_real ::= <<columnNameExt column_name_real>> <<typeNameExt type_name_real>> ( <<columnConstraintExt column_constraint_real>> ) * { | |
elementType = column_def | |
} | |
fake type_name ::= identifier [ '(' signed_number ')' | '(' signed_number ',' signed_number ')' ] | |
type_name_real ::= <<identifierExt identifier_real>> [ '(' <<signedNumberExt signed_number_real>> ')' | '(' <<signedNumberExt signed_number_real>> ',' <<signedNumberExt signed_number_real>> ')' ] { | |
elementType = type_name | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun BriteDatabase.createQuery(query: SqlDelightStatement) = createQuery(query.tables, query.statement, *query.args) | |
inline fun <T: SqlDelightCompiledStatement> BriteDatabase.bindAndExecute(compiledStatement: T, bind: T.() -> Unit): Long { | |
synchronized(compiledStatement) { | |
compiledStatement.bind() | |
return when (compiledStatement) { | |
is SqlDelightCompiledStatement.Insert -> { | |
executeInsert(compiledStatement.table, compiledStatement.program) | |
} | |
is SqlDelightCompiledStatement.Update -> { |