Skip to content

Commit

Permalink
Update plugin spotless to v6.8.0 (#3351)
Browse files Browse the repository at this point in the history
* Update plugin spotless to v6.8.0

* Fix all the things

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Alec Strong <astrong@squareup.com>
Co-authored-by: Alec Strong <AlecStrong@users.noreply.github.com>
  • Loading branch information
3 people committed Jul 11, 2022
1 parent ef4d594 commit 02edf13
Show file tree
Hide file tree
Showing 338 changed files with 2,505 additions and 1,905 deletions.
7 changes: 6 additions & 1 deletion build.gradle
Expand Up @@ -26,7 +26,12 @@ spotless {
kotlin {
target "**/*.kt"
targetExclude "**/gen/**/*.*", "**/generated/**/*.*", "sqldelight-compiler/integration-tests/src/test/kotlin/com/example/**/*.*", "sqldelight-compiler/src/test/migration-interface-fixtures/**/*.*"
ktlint(deps.versions.ktlint.get()).userData(["indent_size": "2"])
ktlint(deps.versions.ktlint.get()).editorConfigOverride([
"indent_size": "2",
"disabled_rules": "package-name",
"ij_kotlin_allow_trailing_comma": "true",
"ij_kotlin_allow_trailing_comma_on_call_site": "true",
])
trimTrailingWhitespace()
endWithNewline()
}
Expand Down
Expand Up @@ -16,7 +16,7 @@ import com.squareup.kotlinpoet.ClassName
class HsqlDialect : SqlDelightDialect {
override val runtimeTypes: RuntimeTypes = RuntimeTypes(
ClassName("app.cash.sqldelight.driver.jdbc", "JdbcCursor"),
ClassName("app.cash.sqldelight.driver.jdbc", "JdbcPreparedStatement")
ClassName("app.cash.sqldelight.driver.jdbc", "JdbcPreparedStatement"),
)

override val asyncRuntimeTypes: RuntimeTypes
Expand Down
Expand Up @@ -37,7 +37,7 @@ internal enum class HsqlType(override val javaType: TypeName) : DialectType {
.add(
when (this) {
TINY_INT, SMALL_INT, INTEGER, BIG_INT, BOOL -> "bindLong"
}
},
)
.add("($columnIndex, %L)\n", value)
.build()
Expand All @@ -47,7 +47,7 @@ internal enum class HsqlType(override val javaType: TypeName) : DialectType {
return CodeBlock.of(
when (this) {
TINY_INT, SMALL_INT, INTEGER, BIG_INT, BOOL -> "$cursorName.getLong($columnIndex)"
}
},
)
}
}
Expand Up @@ -12,7 +12,7 @@ class HSqlFixturesTest(name: String, fixtureRoot: File) : FixturesTest(name, fix
"TEXT" to "VARCHAR(8)",
"AUTOINCREMENT" to "AUTO_INCREMENT",
"?1" to ":one",
"?2" to ":two"
"?2" to ":two",
)

override fun setupDialect() {
Expand All @@ -22,9 +22,11 @@ class HSqlFixturesTest(name: String, fixtureRoot: File) : FixturesTest(name, fix
companion object {
private val fixtures = arrayOf("src/test/fixtures_hsql")

@Suppress("unused") // Used by Parameterized JUnit runner reflectively.
@Suppress("unused")
// Used by Parameterized JUnit runner reflectively.
@Parameters(name = "{0}")
@JvmStatic fun parameters() = fixtures.flatMap { fixtureFolder ->
@JvmStatic
fun parameters() = fixtures.flatMap { fixtureFolder ->
File(fixtureFolder).listFiles()!!
.filter { it.isDirectory }
.map { arrayOf(it.name, it) }
Expand Down
Expand Up @@ -20,7 +20,7 @@ import com.squareup.kotlinpoet.ClassName
class MySqlDialect : SqlDelightDialect {
override val runtimeTypes: RuntimeTypes = RuntimeTypes(
ClassName("app.cash.sqldelight.driver.jdbc", "JdbcCursor"),
ClassName("app.cash.sqldelight.driver.jdbc", "JdbcPreparedStatement")
ClassName("app.cash.sqldelight.driver.jdbc", "JdbcPreparedStatement"),
)

override val asyncRuntimeTypes: RuntimeTypes = RuntimeTypes(
Expand Down
Expand Up @@ -15,11 +15,11 @@ import com.intellij.refactoring.suggested.endOffset
import com.intellij.refactoring.suggested.startOffset

internal class MySqlMigrationSquasher(
private val parentSquasher: MigrationSquasher
private val parentSquasher: MigrationSquasher,
) : MigrationSquasher by parentSquasher {
override fun squish(
alterTableRule: SqlAlterTableRules,
into: SqlFileBase
into: SqlFileBase,
): String {
if (alterTableRule !is MySqlAlterTableRules) return parentSquasher.squish(alterTableRule, into)
return when {
Expand Down Expand Up @@ -76,7 +76,7 @@ internal class MySqlMigrationSquasher(
createTableStmt: SqlCreateTableStmt,
placementClause: MySqlPlacementClause?,
columnDef: SqlColumnDef?,
replace: SqlColumnName? = null
replace: SqlColumnName? = null,
): String {
val columnDefs = createTableStmt.columnDefList.toMutableList()

Expand All @@ -93,14 +93,14 @@ internal class MySqlMigrationSquasher(
val columnName = PsiTreeUtil.getChildOfType(placementClause, SqlColumnName::class.java)!!
columnDefs.add(
columnDefs.indexOfFirst { it.columnName.textMatches(columnName.text) } + 1,
columnDef
columnDef,
)
}
}

return this.replaceRange(
createTableStmt.columnDefList.first().startOffset until createTableStmt.columnDefList.last().endOffset,
columnDefs.joinToString(separator = ",\n ") { it.text }
columnDefs.joinToString(separator = ",\n ") { it.text },
)
}
}
Expand Up @@ -51,7 +51,7 @@ internal enum class MySqlType(override val javaType: TypeName) : DialectType {
TINY_INT, TINY_INT_BOOL, SMALL_INT, INTEGER, BIG_INT, BIT -> "bindLong"
DATE, TIME, DATETIME, TIMESTAMP -> "bindObject"
NUMERIC -> "bindBigDecimal"
}
},
)
.add("($columnIndex, %L)\n", value)
.build()
Expand All @@ -63,7 +63,7 @@ internal enum class MySqlType(override val javaType: TypeName) : DialectType {
TINY_INT, TINY_INT_BOOL, SMALL_INT, INTEGER, BIG_INT, BIT -> "$cursorName.getLong($columnIndex)"
DATE, TIME, DATETIME, TIMESTAMP -> "$cursorName.getObject($columnIndex)"
NUMERIC -> "$cursorName.getBigDecimal($columnIndex)"
}
},
)
}
}
Expand Up @@ -21,13 +21,16 @@ import com.intellij.psi.PsiElement
import com.intellij.psi.util.PsiTreeUtil

class MySqlTypeResolver(
private val parentResolver: TypeResolver
private val parentResolver: TypeResolver,
) : TypeResolver by parentResolver {
override fun resolvedType(expr: SqlExpr): IntermediateType {
return when (expr) {
is MySqlExtensionExpr -> encapsulatingType(
PsiTreeUtil.findChildrenOfType(expr.ifExpr, SqlExpr::class.java).drop(1),
INTEGER, REAL, TEXT, BLOB
INTEGER,
REAL,
TEXT,
BLOB,
)
else -> parentResolver.resolvedType(expr)
}
Expand All @@ -53,7 +56,7 @@ class MySqlTypeResolver(
"last_insert_id" -> IntermediateType(INTEGER)
"row_count" -> IntermediateType(INTEGER)
"microsecond", "second", "minute", "hour", "day", "week", "month", "year" -> IntermediateType(
INTEGER
INTEGER,
)
"sin", "cos", "tan" -> IntermediateType(REAL)
"coalesce", "ifnull" -> encapsulatingType(exprList, TINY_INT, SMALL_INT, MySqlType.INTEGER, INTEGER, BIG_INT, REAL, TEXT, BLOB)
Expand Down Expand Up @@ -97,7 +100,7 @@ class MySqlTypeResolver(
characterType != null -> TEXT
bitDataType != null -> MySqlType.BIT
else -> throw IllegalArgumentException("Unknown kotlin type for sql type ${this.text}")
}
},
)
}
}
Expand Up @@ -8,7 +8,7 @@ import com.alecstrong.sql.psi.core.psi.impl.SqlAlterTableAddColumnImpl
import com.intellij.lang.ASTNode

internal abstract class AlterTableAddColumnMixin(
node: ASTNode
node: ASTNode,
) : SqlAlterTableAddColumnImpl(node),
MySqlAlterTableAddColumn,
AlterTableApplier {
Expand All @@ -18,10 +18,10 @@ internal abstract class AlterTableAddColumnMixin(
query = {
val columns = placementClause.placeInQuery(
columns = lazyQuery.query.columns,
column = QueryElement.QueryColumn(columnDef.columnName)
column = QueryElement.QueryColumn(columnDef.columnName),
)
lazyQuery.query.copy(columns = columns)
}
},
)
}
}
Expand Up @@ -12,7 +12,7 @@ import com.alecstrong.sql.psi.core.psi.alterStmt
import com.intellij.lang.ASTNode

internal abstract class AlterTableChangeColumnMixin(
node: ASTNode
node: ASTNode,
) : SqlCompositeElementImpl(node),
MySqlAlterTableChangeColumn,
AlterTableApplier {
Expand All @@ -29,10 +29,10 @@ internal abstract class AlterTableChangeColumnMixin(
val columns = placementClause.placeInQuery(
columns = lazyQuery.query.columns,
column = QueryElement.QueryColumn(columnDef.columnName),
replace = lazyQuery.query.columns.singleOrNull { (it.element as SqlColumnName).textMatches(columnName) }
replace = lazyQuery.query.columns.singleOrNull { (it.element as SqlColumnName).textMatches(columnName) },
)
lazyQuery.query.copy(columns = columns)
}
},
)
}

Expand All @@ -46,7 +46,7 @@ internal abstract class AlterTableChangeColumnMixin(
) {
annotationHolder.createErrorAnnotation(
element = columnDef.columnName,
s = "No column found to modify with name ${columnDef.columnName.text}"
s = "No column found to modify with name ${columnDef.columnName.text}",
)
}
}
Expand Down
Expand Up @@ -8,7 +8,7 @@ import com.alecstrong.sql.psi.core.psi.SqlCompositeElementImpl
import com.intellij.lang.ASTNode

internal abstract class AlterTableDropColumnMixin(
node: ASTNode
node: ASTNode,
) : SqlCompositeElementImpl(node),
MySqlAlterTableDropColumn,
AlterTableApplier {
Expand All @@ -21,7 +21,7 @@ internal abstract class AlterTableDropColumnMixin(
query = {
val columns = lazyQuery.query.columns.filter { it.element.text != columnName.name }
lazyQuery.query.copy(columns = columns)
}
},
)
}
}
Expand Up @@ -12,7 +12,7 @@ import com.alecstrong.sql.psi.core.psi.alterStmt
import com.intellij.lang.ASTNode

internal abstract class AlterTableModifyColumnMixin(
node: ASTNode
node: ASTNode,
) : SqlCompositeElementImpl(node),
MySqlAlterTableModifyColumn,
AlterTableApplier {
Expand All @@ -26,10 +26,10 @@ internal abstract class AlterTableModifyColumnMixin(
val columns = placementClause.placeInQuery(
columns = lazyQuery.query.columns,
column = QueryElement.QueryColumn(columnDef.columnName),
replace = lazyQuery.query.columns.singleOrNull { (it.element as SqlColumnName).textMatches(columnDef.columnName) }
replace = lazyQuery.query.columns.singleOrNull { (it.element as SqlColumnName).textMatches(columnDef.columnName) },
)
lazyQuery.query.copy(columns = columns)
}
},
)
}

Expand All @@ -43,7 +43,7 @@ internal abstract class AlterTableModifyColumnMixin(
) {
annotationHolder.createErrorAnnotation(
element = columnDef.columnName,
s = "No column found to modify with name ${columnDef.columnName.text}"
s = "No column found to modify with name ${columnDef.columnName.text}",
)
}
}
Expand Down
Expand Up @@ -9,7 +9,7 @@ import com.intellij.psi.util.PsiTreeUtil
internal fun MySqlPlacementClause?.placeInQuery(
columns: List<QueryColumn>,
column: QueryColumn,
replace: QueryColumn? = null
replace: QueryColumn? = null,
): List<QueryColumn> {
if (this == null) {
return if (replace == null) columns + column
Expand All @@ -24,7 +24,7 @@ internal fun MySqlPlacementClause?.placeInQuery(
val index = indexOfFirst { (it.element as SqlColumnName).textMatches(columnName!!) }
if (index == -1) throw AnnotationException(
msg = "Unable to replace $replace with $column after $columnName in $columns",
element = this@placeInQuery
element = this@placeInQuery,
)
add(index + 1, column)
}
Expand Down
Expand Up @@ -31,7 +31,7 @@ internal class MySqlConnectionDialog(
row("Connection Name") {
textField(
getter = { connectionKey },
setter = { connectionName = it }
setter = { connectionName = it },
).withValidationOnApply(validateNonEmpty(connectionNameNonEmpty))
.growPolicy(MEDIUM_TEXT)
.applyToComponent {
Expand All @@ -41,35 +41,35 @@ internal class MySqlConnectionDialog(
row("Host") {
textField(
getter = { host },
setter = { host = it }
setter = { host = it },
).withValidationOnApply(validateNonEmpty(hostNonEmpty))
.growPolicy(MEDIUM_TEXT)
}
row("Port") {
textField(
getter = { port },
setter = { port = it }
setter = { port = it },
).withValidationOnApply(validateNonEmpty(portNonEmpty))
.growPolicy(MEDIUM_TEXT)
}
row("Database Name") {
textField(
getter = { databaseName },
setter = { databaseName = it }
setter = { databaseName = it },
)
.growPolicy(MEDIUM_TEXT)
}
row("Username") {
textField(
getter = { username },
setter = { username = it }
setter = { username = it },
)
.growPolicy(MEDIUM_TEXT)
}
row("Password") {
textField(
getter = { password },
setter = { password = it }
setter = { password = it },
)
.growPolicy(MEDIUM_TEXT)
}
Expand Down
Expand Up @@ -11,7 +11,7 @@ import java.sql.DriverManager
internal class MySqlConnectionManager : ConnectionManager {
override fun createNewConnectionProperties(
project: Project,
prefilledProperties: ConnectionProperties?
prefilledProperties: ConnectionProperties?,
): ConnectionProperties? {
val dialog =
if (prefilledProperties == null) MySqlConnectionDialog(project)
Expand All @@ -37,8 +37,8 @@ internal class MySqlConnectionManager : ConnectionManager {
databaseName = dialog.databaseName.ifEmpty { null },
username = dialog.username.ifEmpty { null },
password = dialog.password.ifEmpty { null },
)
)
),
),
)
}

Expand Down Expand Up @@ -71,7 +71,7 @@ internal class MySqlConnectionManager : ConnectionManager {
val port: String,
val databaseName: String?,
val username: String?,
val password: String?
val password: String?,
)

companion object {
Expand Down

0 comments on commit 02edf13

Please sign in to comment.