From 02edf13f390229d3eb8986b5c408fd795a085e0f Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 11 Jul 2022 18:22:02 -0400 Subject: [PATCH] Update plugin spotless to v6.8.0 (#3351) * 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 Co-authored-by: Alec Strong --- build.gradle | 7 +- .../sqldelight/dialects/hsql/HsqlDialect.kt | 2 +- .../cash/sqldelight/dialects/hsql/HsqlType.kt | 4 +- .../dialects/hsql/HSqlFixturesTest.kt | 8 +- .../sqldelight/dialects/mysql/MySqlDialect.kt | 2 +- .../dialects/mysql/MySqlMigrationSquasher.kt | 10 +- .../sqldelight/dialects/mysql/MySqlType.kt | 4 +- .../dialects/mysql/MySqlTypeResolver.kt | 11 +- .../mixins/AlterTableAddColumnMixin.kt | 6 +- .../mixins/AlterTableChangeColumnMixin.kt | 8 +- .../mixins/AlterTableDropColumnMixin.kt | 4 +- .../mixins/AlterTableModifyColumnMixin.kt | 8 +- .../{PlacementClause.kt => PlaceInQuery.kt} | 4 +- .../mysql/ide/MySqlConnectionDialog.kt | 12 +- .../mysql/ide/MySqlConnectionManager.kt | 8 +- .../dialects/mysql/ColumnOrderingTest.kt | 12 +- .../dialects/mysql/MySqlFixturesTest.kt | 6 +- .../postgresql/PostgreSqlMigrationSquasher.kt | 6 +- .../dialects/postgresql/PostgreSqlType.kt | 4 +- .../postgresql/PostgreSqlTypeResolver.kt | 18 +- .../mixins/AlterTableColumnAliasMixin.kt | 2 +- .../mixins/AlterTableDropColumnMixin.kt | 4 +- .../mixins/AlterTableRenameColumnMixin.kt | 8 +- .../grammar/mixins/ReturningClauseMixin.kt | 4 +- .../ide/PostgresConnectionDialog.kt | 12 +- .../ide/PostgresConnectionManager.kt | 8 +- .../postgres/PostgreSqlFixturesTest.kt | 6 +- .../sqlite_3_18/SelectConnectionTypeDialog.kt | 4 +- .../sqlite_3_18/SqliteConnectionManager.kt | 2 +- .../dialects/sqlite_3_18/SqliteDialect.kt | 2 +- .../sqlite_3_18/SqliteMigrationStrategy.kt | 4 +- .../grammar/mixins/AlterTableElementType.kt | 5 +- .../grammar/mixins/StatementValidatorMixin.kt | 2 +- .../dialects/sqlite_3_18/NullabilityTest.kt | 6 +- .../sqlite_3_18/Sqlite318FixturesTest.kt | 6 +- .../sqlite_3_24/SqliteTypeResolver.kt | 2 +- .../grammar/mixins/InsertStmtMixin.kt | 12 +- .../grammar/mixins/UpsertClauseMixin.kt | 7 +- .../sqlite_3_24/Sqlite324FixturesTest.kt | 8 +- .../sqlite_3_25/SqliteMigrationSquasher.kt | 4 +- .../mixins/AlterTableRenameColumnMixin.kt | 8 +- .../sqlite_3_25/Sqlite325FixturesTest.kt | 8 +- .../sqlite_3_30/Sqlite330FixturesTest.kt | 8 +- .../sqlite_3_35/SqliteMigrationSquasher.kt | 6 +- .../mixins/AlterTableDropColumnMixin.kt | 14 +- .../grammar/mixins/ReturningClauseMixin.kt | 6 +- .../sqlite_3_35/Sqlite335FixturesTest.kt | 8 +- .../sqlite_3_38/Sqlite338FixturesTest.kt | 8 +- .../{JsonFunctions.kt => JsonModule.kt} | 2 +- .../grammar/mixins/TableOrSubqueryMixin.kt | 6 +- .../sqlite/json/module/JsonModuleTest.kt | 6 +- .../driver/android/AndroidSqliteDriver.kt | 35 ++- .../sqldelight/android/AndroidDriverTest.kt | 18 +- .../android/AndroidTransacterTest.kt | 14 +- .../sqldelight/driver/test/DriverTest.kt | 14 +- .../sqldelight/driver/test/QueryTest.kt | 9 +- .../sqldelight/driver/test/TransacterTest.kt | 20 +- .../cash/sqldelight/driver/jdbc/JdbcDriver.kt | 14 +- ..._RECURSIVE.kt => PthreadMutexRecursive.kt} | 0 .../sqldelight/driver/native/util/PoolLock.kt | 5 +- ..._RECURSIVE.kt => PthreadMutexRecursive.kt} | 0 .../sqldelight/driver/native/util/PoolLock.kt | 5 +- .../driver/native/NativeSqlDatabase.kt | 38 +-- .../app/cash/sqldelight/driver/native/Pool.kt | 3 +- .../driver/native/SqliterStatement.kt | 4 +- .../driver/native/util/BasicMutableMap.kt | 5 +- .../util/{MemoryModel.kt => MaybeFreeze.kt} | 0 .../sqldelight/driver/native/util/PoolLock.kt | 2 +- .../drivers/native/LazyDriverBaseTest.kt | 14 +- .../connectionpool/BaseConcurrencyTest.kt | 23 +- .../connectionpool/WalConcurrencyTest.kt | 3 +- .../sqldelight/driver/r2dbc/R2dbcDriver.kt | 6 +- .../driver/jdbc/sqlite/JdbcSqliteDriver.kt | 4 +- .../driver/sqljs/{sqljs.kt => InitDb.kt} | 3 +- .../sqldelight/driver/sqljs/JsSqlDriver.kt | 4 +- .../driver/sqljs/{sqljs.SqlJs.kt => SqlJs.kt} | 0 .../driver/sqljs/worker/JsWorkerSqlDriver.kt | 6 +- .../sqldelight/drivers/sqljs/JsDriverTest.kt | 14 +- .../sqldelight/drivers/sqljs/JsQueryTest.kt | 7 +- .../drivers/sqljs/JsTransacterTest.kt | 2 +- .../drivers/sqljs/JsWorkerDriverTest.kt | 12 +- .../drivers/sqljs/JsWorkerTransacterTest.kt | 2 +- .../sqldelight/drivers/sqljs/SqlJsTest.kt | 6 +- .../paging3/OffsetQueryPagingSource.kt | 4 +- .../sqldelight/paging3/QueryPagingSource.kt | 2 +- .../paging3/KeyedQueryPagingSourceTest.kt | 16 +- .../paging3/OffsetQueryPagingSourceTest.kt | 35 ++- .../async/coroutines/DriverExtensions.kt | 4 +- .../sqldelight/coroutines/FlowExtensions.kt | 10 +- .../cash/sqldelight/coroutines/MappingTest.kt | 4 +- .../coroutines/{runTest.kt => RunTest.kt} | 0 .../app/cash/sqldelight/coroutines/TestDb.kt | 17 +- .../coroutines/{runTest.kt => RunTest.kt} | 0 .../coroutines/{TestDb.kt => TestDriver.kt} | 0 .../coroutines/{runTest.kt => RunTest.kt} | 0 .../coroutines/{TestDb.kt => TestDriver.kt} | 0 .../coroutines/{runTest.kt => RunTest.kt} | 0 .../coroutines/{TestDb.kt => TestDriver.kt} | 2 +- .../cash/sqldelight/rx2/RxJavaExtensions.kt | 4 +- .../app/cash/sqldelight/rx2/QueryTest.kt | 4 +- .../kotlin/app/cash/sqldelight/rx2/TestDb.kt | 17 +- .../cash/sqldelight/rx3/RxJavaExtensions.kt | 4 +- .../app/cash/sqldelight/rx3/QueryTest.kt | 4 +- .../kotlin/app/cash/sqldelight/rx3/TestDb.kt | 17 +- gradle/libs.versions.toml | 4 +- .../app/cash/sqldelight/EnumColumnAdapter.kt | 2 +- .../kotlin/app/cash/sqldelight/Query.kt | 17 +- .../kotlin/app/cash/sqldelight/Transacter.kt | 20 +- .../app/cash/sqldelight/db/QueryResult.kt | 2 +- .../app/cash/sqldelight/db/SqlDriver.kt | 4 +- .../app/cash/sqldelight/db/SqlSchema.kt | 4 +- .../cash/sqldelight/logs/LogSqliteDriver.kt | 16 +- .../sqldelight/logs/LogSqliteDriverTest.kt | 13 +- .../logs/SqlDriverMigrationCallbackTest.kt | 2 +- .../hockey/data/{Db.kt => GetInstance.kt} | 0 .../example/sqldelight/hockey/ui/PlayerRow.kt | 2 +- .../sqldelight/hockey/ui/PlayersActivity.kt | 2 +- .../example/sqldelight/hockey/ui/TeamRow.kt | 2 +- .../sqldelight/hockey/ui/TeamsActivity.kt | 2 +- .../example/sqldelight/hockey/data/Schema.kt | 13 +- .../sqldelight/hockey/IosSchemaTest.kt | 4 +- .../example/sqldelight/hockey/JsSchemaTest.kt | 4 +- .../sqldelight/hockey/JvmSchemaTest.kt | 4 +- .../sqldelight/hockey/{App.kt => Main.kt} | 0 .../data/{Extensions.kt => GetInstance.kt} | 0 .../dialect/api/ConnectionManager.kt | 4 +- .../app/cash/sqldelight/dialect/api/NoOp.kt | 2 +- .../sqldelight/dialect/api/PrimitiveType.kt | 4 +- .../sqldelight/dialect/api/RuntimeTypes.kt | 2 +- .../dialect/api/SqlGeneratorStrategy.kt | 2 +- .../sqldelight/dialect/api/TypeResolver.kt | 4 +- .../core/integration/IntegrationTest.kt | 116 ++++--- .../sqldelight/core/GradleCompatibility.kt | 4 +- .../sqldelight/core/SqlDelightEnvironment.kt | 19 +- .../core/compiler/DatabaseExposerGenerator.kt | 4 +- .../core/compiler/DatabaseGenerator.kt | 25 +- .../core/compiler/ExecuteQueryGenerator.kt | 8 +- .../core/compiler/QueryGenerator.kt | 19 +- .../core/compiler/QueryInterfaceGenerator.kt | 2 +- .../core/compiler/SelectQueryGenerator.kt | 44 +-- .../core/compiler/SqlDelightCompiler.kt | 8 +- .../core/compiler/TableInterfaceGenerator.kt | 12 +- .../{KotlinPoet.kt => ToCodeLiteral.kt} | 0 .../{JavadocIntegration.kt => JavadocText.kt} | 0 .../compiler/integration/TableIntegration.kt | 2 +- .../core/compiler/model/BindableQuery.kt | 24 +- .../core/compiler/model/NamedExecute.kt | 2 +- .../core/compiler/model/NamedMutator.kt | 8 +- .../core/compiler/model/NamedQuery.kt | 6 +- .../core/compiler/model/PragmaWithResults.kt | 4 +- ...insertStmt.kt => AcceptsTableInterface.kt} | 0 .../lang/DatabaseFileViewProviderFactory.kt | 6 +- .../sqldelight/core/lang/IntermediateType.kt | 12 +- .../sqldelight/core/lang/MigrationFile.kt | 2 +- .../sqldelight/core/lang/SqlDelightFile.kt | 7 +- .../core/lang/SqlDelightQueriesFile.kt | 8 +- .../core/lang/psi/ClojureStmtListMixin.kt | 2 +- .../core/lang/psi/ColumnTypeMixin.kt | 20 +- .../core/lang/psi/ImportStmtMixin.kt | 2 +- .../core/lang/psi/InsertStmtValuesMixin.kt | 8 +- .../sqldelight/core/lang/psi/JavaTypeMixin.kt | 2 +- .../sqldelight/core/lang/psi/SignatureData.kt | 4 +- .../core/lang/psi/StmtIdentifierMixin.kt | 13 +- .../util/{Columns.kt => ColumnDefSource.kt} | 0 .../sqldelight/core/lang/util/ExprUtil.kt | 16 +- .../core/lang/util/SelectStmtUtil.kt | 2 +- .../sqldelight/core/lang/util/TreeUtil.kt | 24 +- .../validation/OptimisticLockValidator.kt | 30 +- .../app/cash/sqldelight/core/BindArgsTest.kt | 23 +- .../app/cash/sqldelight/core/ImportTests.kt | 4 +- .../cash/sqldelight/core/NamedQueryTests.kt | 12 +- .../cash/sqldelight/core/QueriesTypeTest.kt | 50 +-- .../cash/sqldelight/core/QueryWrapperTest.kt | 53 ++-- .../core/async/AsyncQueriesTypeTest.kt | 8 +- .../core/async/AsyncQueryWrapperTest.kt | 19 +- .../core/errors/DuplicateSqlIdentifiers.kt | 5 +- .../cash/sqldelight/core/errors/ErrorTest.kt | 2 +- .../core/errors/InsertStmtErrors.kt | 10 +- .../sqldelight/core/errors/SyntaxErrors.kt | 22 +- .../core/migrations/MigrationQueryTest.kt | 2 +- .../core/queries/BindableQueryTest.kt | 70 +++-- .../sqldelight/core/queries/ExpressionTest.kt | 86 +++--- .../core/queries/InterfaceGeneration.kt | 186 ++++++----- .../sqldelight/core/queries/JavadocTest.kt | 83 +++-- .../core/queries/MutatorQueryFunctionTest.kt | 103 +++--- .../core/queries/MutatorQueryTypeTest.kt | 113 ++++--- .../core/queries/PgInsertOnConflictTest.kt | 21 +- .../core/queries/SelectQueryFunctionTest.kt | 214 +++++++------ .../core/queries/SelectQueryTypeTest.kt | 292 +++++++++++------- .../async/AsyncMutatorQueryTypeTest.kt | 24 +- .../queries/async/AsyncQueryFunctionTest.kt | 5 +- .../queries/async/AsyncSelectQueryTypeTest.kt | 40 ++- .../core/tables/InterfaceGeneration.kt | 91 ++++-- .../core/tables/OptimisticLockTest.kt | 24 +- .../core/triggers/TriggerNotificationTest.kt | 45 +-- .../cash/sqldelight/core/util/TreeUtilTest.kt | 38 +-- .../core/views/InterfaceGeneration.kt | 22 +- .../dialect/DialectIntegrationTests.kt | 2 +- .../gradle/GenerateMigrationOutputTask.kt | 12 +- .../sqldelight/gradle/GenerateSchemaTask.kt | 9 +- .../cash/sqldelight/gradle/PropertiesImpl.kt | 8 +- .../sqldelight/gradle/SqlDelightDatabase.kt | 6 +- .../sqldelight/gradle/SqlDelightExtension.kt | 2 +- .../sqldelight/gradle/SqlDelightPlugin.kt | 4 +- .../cash/sqldelight/gradle/SqlDelightTask.kt | 11 +- .../sqldelight/gradle/VerifyMigrationTask.kt | 15 +- .../sqldelight/gradle/android/PackageName.kt | 2 +- .../{Multiplatform.kt => LinkSqlite.kt} | 2 +- .../sqldelight/gradle/kotlin/SourceRoots.kt | 8 +- .../gradle/squash/AnsiSqlMigrationSquasher.kt | 8 +- .../gradle/squash/MigrationSquashTask.kt | 7 +- .../dialect/src/main/kotlin/foo/FooDialect.kt | 2 +- .../integration/IntegrationTests.kt | 18 +- .../sqldelight/hsql/integration/HsqlTest.kt | 4 +- .../integration/IntegrationTests.kt | 2 +- .../integration/{android.kt => Android.kt} | 0 .../integration/{common.kt => Common.kt} | 0 .../integration/IntegrationTests.kt | 50 +-- .../sqldelight/integration/{ios.kt => Ios.kt} | 2 +- .../sqldelight/mysql/integration/MySqlTest.kt | 14 +- .../sqldelight/mysql/integration/MySqlTest.kt | 12 +- .../sqldelight/mysql/integration/MySqlTest.kt | 22 +- .../postgresql/integration/PostgreSqlTest.kt | 6 +- .../postgresql/integration/PostgreSqlTest.kt | 32 +- .../integration/IntegrationTests.kt | 4 +- .../integration/IntegrationTests.kt | 2 +- .../integration/IntegrationTests.kt | 4 +- .../integration/IntegrationTests.kt | 33 +- .../{AndroidTestUtil.kt => AndroidHome.kt} | 2 +- .../app/cash/sqldelight/TemporaryFixture.kt | 8 +- .../kotlin/app/cash/sqldelight/TestUtil.kt | 6 +- ...leRunner.kt => WithCommonConfiguration.kt} | 2 +- .../cash/sqldelight/assertions/FileSubject.kt | 2 +- .../integrations/IntegrationTest.kt | 12 +- .../sqldelight/integrations/VariantTest.kt | 14 +- .../sqldelight/properties/MultiModuleTests.kt | 19 +- .../properties/PropertiesFileTest.kt | 8 +- .../sqldelight/tests/CompilationUnitTests.kt | 56 ++-- .../app/cash/sqldelight/tests/FailureTest.kt | 3 +- .../tests/GradlePluginCombinationTests.kt | 4 +- .../sqldelight/tests/MigrationSquashTest.kt | 4 +- .../cash/sqldelight/tests/MigrationTest.kt | 15 +- .../app/cash/sqldelight/tests/PluginTest.kt | 4 +- .../integration/IntegrationTests.kt | 12 +- .../integration/IntegrationTests.kt | 12 +- .../main/kotlin/com/example/db/DbHelper.kt | 2 +- .../com/example/db/{utils.kt => Utils.kt} | 0 .../app/cash/sqldelight/intellij/FileIndex.kt | 10 +- .../intellij/GradleSystemListener.kt | 2 +- .../cash/sqldelight/intellij/LoggerTree.kt | 2 +- .../sqldelight/intellij/ProjectService.kt | 4 +- .../SqlDelightClassCompletionContributor.kt | 6 +- .../SqlDelightClassNameElementAnnotator.kt | 2 +- .../intellij/SqlDelightColorSettingsPage.kt | 3 +- .../intellij/SqlDelightCopyPasteProcessor.kt | 8 +- .../intellij/SqlDelightErrorHandler.kt | 2 +- .../intellij/SqlDelightFileIndexImpl.kt | 4 +- .../SqlDelightFindUsagesHandlerFactory.kt | 10 +- .../intellij/SqlDelightFindUsagesProvider.kt | 2 +- .../SqlDelightGotoDeclarationHandler.kt | 10 +- .../SqlDelightParameterInfoHandler.kt | 8 +- .../SqlDelightReferenceContributor.kt | 4 +- .../intellij/SqlDelightRenameProcessor.kt | 4 +- .../actions/GenerateInsertIntoQueryAction.kt | 6 +- .../actions/GenerateSelectAllQueryAction.kt | 6 +- ...tionUtil.kt => InsertNewLineAndCleanup.kt} | 0 .../actions/QueryByPrimaryKeyHandler.kt | 6 +- .../file/SqlDelightCreateFileAction.kt | 10 +- .../intellij/gradle/FileIndexMap.kt | 17 +- .../intellij/inspections/InspectionExt.kt | 2 +- .../MismatchJoinColumnInspection.kt | 16 +- ...MixedNamedAndPositionalParamsInspection.kt | 2 +- .../inspections/NullEqualityInspection.kt | 2 +- .../RedundantNullCheckInspection.kt | 2 +- .../SchemaNeedsMigrationInspection.kt | 32 +- .../inspections/UnusedColumnInspection.kt | 13 +- .../inspections/UnusedImportInspection.kt | 11 +- .../inspections/UnusedQueryInspection.kt | 13 +- .../SqlDelightInspectionSuppressor.kt | 6 +- .../SqlDelightSuppressInspectionQuickFix.kt | 4 +- .../intellij/intentions/AddImportIntention.kt | 17 +- .../ExpandColumnNamesWildcardQuickFix.kt | 4 +- .../IntroduceTableAliasIntention.kt | 6 +- .../intentions/QualifyColumnNameIntention.kt | 4 +- .../lang/SqlDelightFileViewProviderFactory.kt | 15 +- .../intellij/lang/SqlDelightFoldingBuilder.kt | 2 +- .../lang/SqlDelightHighlightVisitor.kt | 18 +- .../intellij/lang/SqlDelightHighlighter.kt | 32 +- .../lang/SqlDelightImportOptimizer.kt | 3 +- .../lang/SqlDelightPairedBraceMatcher.kt | 2 +- .../lang/SqlDelightStructureViewFactory.kt | 6 +- .../SqlDelightKeywordCompletionContributor.kt | 4 +- .../intellij/macro/DbColumnsMacro.kt | 2 +- .../cash/sqldelight/intellij/macro/PkMacro.kt | 2 +- .../notifications/FileIndexingNotification.kt | 2 +- .../refactoring/SqlDelightSignatureBuilder.kt | 2 +- ...SqlDelightSuggestedRefactoringExecution.kt | 18 +- .../intellij/run/ArgumentsInputDialogImpl.kt | 4 +- .../intellij/run/ConnectionOptions.kt | 2 +- .../sqldelight/intellij/run/RunSqlAction.kt | 6 +- .../intellij/run/SqlDelightRunVisitor.kt | 2 +- .../run/SqlDelightStatementExecutor.kt | 4 +- .../sqldelight/intellij/run/SqlParameter.kt | 2 +- .../run/android/SqlDelightRunAnnotator.kt | 12 +- .../run/window/ConnectionListPanel.kt | 28 +- .../run/window/SqlDelightToolWindowFactory.kt | 12 +- .../intellij/util/GeneratedVirtualFile.kt | 2 +- .../{VirtualFileUtil.kt => IsAncestorOf.kt} | 0 .../cash/sqldelight/intellij/util/PsiUtil.kt | 2 +- .../sqldelight/intellij/FindUsagesTest.kt | 46 +-- .../intellij/ReferenceContrubutorTest.kt | 52 ++-- .../intellij/SqlDelightFixtureTestCase.kt | 4 +- ...lDelightInlayParameterHintsProviderTest.kt | 4 +- .../SqlDelightParameterInfoHandlerTest.kt | 2 +- .../intellij/SqlDelightProjectTestCase.kt | 14 +- .../annotations/ClassNameAnnotatorTest.kt | 12 +- .../OptimisticLockAnnotatorTest.kt | 28 +- .../autocomplete/AutocompleteTests.kt | 16 +- .../GoToDeclarationHandlerTest.kt | 12 +- .../gotodeclaration/GoToDeclarationTest.kt | 11 +- .../highlighting/HighlightingTests.kt | 2 +- .../SafeDeleteColumnQuickFixTest.kt | 12 +- .../SafeDeleteQueryQuickFixTest.kt | 4 +- .../ExpandColumnNamesWildcardQuickFixTest.kt | 19 +- .../QualifyColumnNameIntentionTest.kt | 27 +- .../intentions/TableAliasIntentionTest.kt | 27 +- .../intellij/lang/SqlDelightCommenterTest.kt | 10 +- .../lang/SqlDelightImportOptimizerTest.kt | 4 +- .../lang/SqlDelightPairedBraceMatcherTest.kt | 6 +- .../SqlDelightStructureViewFactoryTest.kt | 6 +- .../intellij/rename/SqlStmtIdentifierTests.kt | 26 +- .../intellij/rename/SqliteElementTests.kt | 28 +- .../cash/sqlite/migrations/CatalogDatabase.kt | 6 +- ...FilesCollector.kt => FindDatabaseFiles.kt} | 0 .../ObjectDifferDatabaseComparator.kt | 44 +-- .../migrations/ObjectDifferDatabaseDiff.kt | 5 +- .../sqldelight/test/util/FixtureCompiler.kt | 14 +- .../sqldelight/test/util/TestEnvironment.kt | 2 +- 338 files changed, 2505 insertions(+), 1905 deletions(-) rename dialects/mysql/src/main/kotlin/app/cash/sqldelight/dialects/mysql/grammar/mixins/{PlacementClause.kt => PlaceInQuery.kt} (94%) rename dialects/sqlite/json-module/src/main/kotlin/app/cash/sqldelight/dialects/sqlite/json/module/{JsonFunctions.kt => JsonModule.kt} (98%) rename drivers/native-driver/src/linuxMain/kotlin/app/cash/sqldelight/driver/native/util/{PTHREAD_MUTEX_RECURSIVE.kt => PthreadMutexRecursive.kt} (100%) rename drivers/native-driver/src/nativeDarwinMain/kotlin/app/cash/sqldelight/driver/native/util/{PTHREAD_MUTEX_RECURSIVE.kt => PthreadMutexRecursive.kt} (100%) rename drivers/native-driver/src/nativeMain/kotlin/app/cash/sqldelight/driver/native/util/{MemoryModel.kt => MaybeFreeze.kt} (100%) rename drivers/sqljs-driver/src/main/kotlin/app/cash/sqldelight/driver/sqljs/{sqljs.kt => InitDb.kt} (96%) rename drivers/sqljs-driver/src/main/kotlin/app/cash/sqldelight/driver/sqljs/{sqljs.SqlJs.kt => SqlJs.kt} (100%) rename extensions/coroutines-extensions/src/commonTest/kotlin/app/cash/sqldelight/coroutines/{runTest.kt => RunTest.kt} (100%) rename extensions/coroutines-extensions/src/jsTest/kotlin/app/cash/sqldelight/coroutines/{runTest.kt => RunTest.kt} (100%) rename extensions/coroutines-extensions/src/jsTest/kotlin/app/cash/sqldelight/coroutines/{TestDb.kt => TestDriver.kt} (100%) rename extensions/coroutines-extensions/src/jvmTest/kotlin/app/cash/sqldelight/coroutines/{runTest.kt => RunTest.kt} (100%) rename extensions/coroutines-extensions/src/jvmTest/kotlin/app/cash/sqldelight/coroutines/{TestDb.kt => TestDriver.kt} (100%) rename extensions/coroutines-extensions/src/nativeTest/kotlin/app/cash/sqldelight/coroutines/{runTest.kt => RunTest.kt} (100%) rename extensions/coroutines-extensions/src/nativeTest/kotlin/app/cash/sqldelight/coroutines/{TestDb.kt => TestDriver.kt} (98%) rename sample/android/src/main/java/com/example/sqldelight/hockey/data/{Db.kt => GetInstance.kt} (100%) rename sample/web/src/main/kotlin/com/example/sqldelight/hockey/{App.kt => Main.kt} (100%) rename sample/web/src/main/kotlin/com/example/sqldelight/hockey/data/{Extensions.kt => GetInstance.kt} (100%) rename sqldelight-compiler/src/main/kotlin/app/cash/sqldelight/core/compiler/{KotlinPoet.kt => ToCodeLiteral.kt} (100%) rename sqldelight-compiler/src/main/kotlin/app/cash/sqldelight/core/compiler/integration/{JavadocIntegration.kt => JavadocText.kt} (100%) rename sqldelight-compiler/src/main/kotlin/app/cash/sqldelight/core/lang/{insertStmt.kt => AcceptsTableInterface.kt} (100%) rename sqldelight-compiler/src/main/kotlin/app/cash/sqldelight/core/lang/util/{Columns.kt => ColumnDefSource.kt} (100%) rename sqldelight-gradle-plugin/src/main/kotlin/app/cash/sqldelight/gradle/kotlin/{Multiplatform.kt => LinkSqlite.kt} (93%) rename sqldelight-gradle-plugin/src/test/integration-multiplatform/src/androidMain/kotlin/app/cash/sqldelight/integration/{android.kt => Android.kt} (100%) rename sqldelight-gradle-plugin/src/test/integration-multiplatform/src/commonMain/kotlin/app/cash/sqldelight/integration/{common.kt => Common.kt} (100%) rename sqldelight-gradle-plugin/src/test/integration-multiplatform/src/iosMain/kotlin/app/cash/sqldelight/integration/{ios.kt => Ios.kt} (99%) rename sqldelight-gradle-plugin/src/test/kotlin/app/cash/sqldelight/{AndroidTestUtil.kt => AndroidHome.kt} (98%) rename sqldelight-gradle-plugin/src/test/kotlin/app/cash/sqldelight/{GradleRunner.kt => WithCommonConfiguration.kt} (95%) rename sqldelight-gradle-plugin/src/test/multithreaded-sqlite/src/main/kotlin/com/example/db/{utils.kt => Utils.kt} (100%) rename sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/actions/{GenerateActionUtil.kt => InsertNewLineAndCleanup.kt} (100%) rename sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/util/{VirtualFileUtil.kt => IsAncestorOf.kt} (100%) rename sqlite-migrations/src/main/kotlin/app/cash/sqlite/migrations/{DatabaseFilesCollector.kt => FindDatabaseFiles.kt} (100%) diff --git a/build.gradle b/build.gradle index 7ab6853c29b..48a23effd34 100644 --- a/build.gradle +++ b/build.gradle @@ -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() } diff --git a/dialects/hsql/src/main/kotlin/app/cash/sqldelight/dialects/hsql/HsqlDialect.kt b/dialects/hsql/src/main/kotlin/app/cash/sqldelight/dialects/hsql/HsqlDialect.kt index 2591151bb94..e79d13d9f2a 100644 --- a/dialects/hsql/src/main/kotlin/app/cash/sqldelight/dialects/hsql/HsqlDialect.kt +++ b/dialects/hsql/src/main/kotlin/app/cash/sqldelight/dialects/hsql/HsqlDialect.kt @@ -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 diff --git a/dialects/hsql/src/main/kotlin/app/cash/sqldelight/dialects/hsql/HsqlType.kt b/dialects/hsql/src/main/kotlin/app/cash/sqldelight/dialects/hsql/HsqlType.kt index 72e7a6a82d4..417b2dce0d4 100644 --- a/dialects/hsql/src/main/kotlin/app/cash/sqldelight/dialects/hsql/HsqlType.kt +++ b/dialects/hsql/src/main/kotlin/app/cash/sqldelight/dialects/hsql/HsqlType.kt @@ -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() @@ -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)" - } + }, ) } } diff --git a/dialects/hsql/src/test/kotlin/app/cash/sqldelight/dialects/hsql/HSqlFixturesTest.kt b/dialects/hsql/src/test/kotlin/app/cash/sqldelight/dialects/hsql/HSqlFixturesTest.kt index 9d827375909..e1c2bd5e6e8 100644 --- a/dialects/hsql/src/test/kotlin/app/cash/sqldelight/dialects/hsql/HSqlFixturesTest.kt +++ b/dialects/hsql/src/test/kotlin/app/cash/sqldelight/dialects/hsql/HSqlFixturesTest.kt @@ -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() { @@ -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) } diff --git a/dialects/mysql/src/main/kotlin/app/cash/sqldelight/dialects/mysql/MySqlDialect.kt b/dialects/mysql/src/main/kotlin/app/cash/sqldelight/dialects/mysql/MySqlDialect.kt index 3ac4dd427df..496a186e9e9 100644 --- a/dialects/mysql/src/main/kotlin/app/cash/sqldelight/dialects/mysql/MySqlDialect.kt +++ b/dialects/mysql/src/main/kotlin/app/cash/sqldelight/dialects/mysql/MySqlDialect.kt @@ -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( diff --git a/dialects/mysql/src/main/kotlin/app/cash/sqldelight/dialects/mysql/MySqlMigrationSquasher.kt b/dialects/mysql/src/main/kotlin/app/cash/sqldelight/dialects/mysql/MySqlMigrationSquasher.kt index da0519d2f99..6f0cf0d4e1d 100644 --- a/dialects/mysql/src/main/kotlin/app/cash/sqldelight/dialects/mysql/MySqlMigrationSquasher.kt +++ b/dialects/mysql/src/main/kotlin/app/cash/sqldelight/dialects/mysql/MySqlMigrationSquasher.kt @@ -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 { @@ -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() @@ -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 }, ) } } diff --git a/dialects/mysql/src/main/kotlin/app/cash/sqldelight/dialects/mysql/MySqlType.kt b/dialects/mysql/src/main/kotlin/app/cash/sqldelight/dialects/mysql/MySqlType.kt index f5828b9d0c2..15340b53f39 100644 --- a/dialects/mysql/src/main/kotlin/app/cash/sqldelight/dialects/mysql/MySqlType.kt +++ b/dialects/mysql/src/main/kotlin/app/cash/sqldelight/dialects/mysql/MySqlType.kt @@ -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() @@ -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)" - } + }, ) } } diff --git a/dialects/mysql/src/main/kotlin/app/cash/sqldelight/dialects/mysql/MySqlTypeResolver.kt b/dialects/mysql/src/main/kotlin/app/cash/sqldelight/dialects/mysql/MySqlTypeResolver.kt index 04094230873..be949af4125 100644 --- a/dialects/mysql/src/main/kotlin/app/cash/sqldelight/dialects/mysql/MySqlTypeResolver.kt +++ b/dialects/mysql/src/main/kotlin/app/cash/sqldelight/dialects/mysql/MySqlTypeResolver.kt @@ -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) } @@ -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) @@ -97,7 +100,7 @@ class MySqlTypeResolver( characterType != null -> TEXT bitDataType != null -> MySqlType.BIT else -> throw IllegalArgumentException("Unknown kotlin type for sql type ${this.text}") - } + }, ) } } diff --git a/dialects/mysql/src/main/kotlin/app/cash/sqldelight/dialects/mysql/grammar/mixins/AlterTableAddColumnMixin.kt b/dialects/mysql/src/main/kotlin/app/cash/sqldelight/dialects/mysql/grammar/mixins/AlterTableAddColumnMixin.kt index d4669dfe8a8..6f6ebcc0f2c 100644 --- a/dialects/mysql/src/main/kotlin/app/cash/sqldelight/dialects/mysql/grammar/mixins/AlterTableAddColumnMixin.kt +++ b/dialects/mysql/src/main/kotlin/app/cash/sqldelight/dialects/mysql/grammar/mixins/AlterTableAddColumnMixin.kt @@ -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 { @@ -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) - } + }, ) } } diff --git a/dialects/mysql/src/main/kotlin/app/cash/sqldelight/dialects/mysql/grammar/mixins/AlterTableChangeColumnMixin.kt b/dialects/mysql/src/main/kotlin/app/cash/sqldelight/dialects/mysql/grammar/mixins/AlterTableChangeColumnMixin.kt index f1541f4aa4a..8fb56b46cc6 100644 --- a/dialects/mysql/src/main/kotlin/app/cash/sqldelight/dialects/mysql/grammar/mixins/AlterTableChangeColumnMixin.kt +++ b/dialects/mysql/src/main/kotlin/app/cash/sqldelight/dialects/mysql/grammar/mixins/AlterTableChangeColumnMixin.kt @@ -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 { @@ -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) - } + }, ) } @@ -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}", ) } } diff --git a/dialects/mysql/src/main/kotlin/app/cash/sqldelight/dialects/mysql/grammar/mixins/AlterTableDropColumnMixin.kt b/dialects/mysql/src/main/kotlin/app/cash/sqldelight/dialects/mysql/grammar/mixins/AlterTableDropColumnMixin.kt index 5692a77c14a..5c0e7e794af 100644 --- a/dialects/mysql/src/main/kotlin/app/cash/sqldelight/dialects/mysql/grammar/mixins/AlterTableDropColumnMixin.kt +++ b/dialects/mysql/src/main/kotlin/app/cash/sqldelight/dialects/mysql/grammar/mixins/AlterTableDropColumnMixin.kt @@ -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 { @@ -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) - } + }, ) } } diff --git a/dialects/mysql/src/main/kotlin/app/cash/sqldelight/dialects/mysql/grammar/mixins/AlterTableModifyColumnMixin.kt b/dialects/mysql/src/main/kotlin/app/cash/sqldelight/dialects/mysql/grammar/mixins/AlterTableModifyColumnMixin.kt index 330c3f616cb..2e650e7a898 100644 --- a/dialects/mysql/src/main/kotlin/app/cash/sqldelight/dialects/mysql/grammar/mixins/AlterTableModifyColumnMixin.kt +++ b/dialects/mysql/src/main/kotlin/app/cash/sqldelight/dialects/mysql/grammar/mixins/AlterTableModifyColumnMixin.kt @@ -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 { @@ -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) - } + }, ) } @@ -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}", ) } } diff --git a/dialects/mysql/src/main/kotlin/app/cash/sqldelight/dialects/mysql/grammar/mixins/PlacementClause.kt b/dialects/mysql/src/main/kotlin/app/cash/sqldelight/dialects/mysql/grammar/mixins/PlaceInQuery.kt similarity index 94% rename from dialects/mysql/src/main/kotlin/app/cash/sqldelight/dialects/mysql/grammar/mixins/PlacementClause.kt rename to dialects/mysql/src/main/kotlin/app/cash/sqldelight/dialects/mysql/grammar/mixins/PlaceInQuery.kt index 93707fda7b6..e10bdfe24a9 100644 --- a/dialects/mysql/src/main/kotlin/app/cash/sqldelight/dialects/mysql/grammar/mixins/PlacementClause.kt +++ b/dialects/mysql/src/main/kotlin/app/cash/sqldelight/dialects/mysql/grammar/mixins/PlaceInQuery.kt @@ -9,7 +9,7 @@ import com.intellij.psi.util.PsiTreeUtil internal fun MySqlPlacementClause?.placeInQuery( columns: List, column: QueryColumn, - replace: QueryColumn? = null + replace: QueryColumn? = null, ): List { if (this == null) { return if (replace == null) columns + column @@ -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) } diff --git a/dialects/mysql/src/main/kotlin/app/cash/sqldelight/dialects/mysql/ide/MySqlConnectionDialog.kt b/dialects/mysql/src/main/kotlin/app/cash/sqldelight/dialects/mysql/ide/MySqlConnectionDialog.kt index 71d5a9a0fe6..6fc7f8a51e3 100644 --- a/dialects/mysql/src/main/kotlin/app/cash/sqldelight/dialects/mysql/ide/MySqlConnectionDialog.kt +++ b/dialects/mysql/src/main/kotlin/app/cash/sqldelight/dialects/mysql/ide/MySqlConnectionDialog.kt @@ -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 { @@ -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) } diff --git a/dialects/mysql/src/main/kotlin/app/cash/sqldelight/dialects/mysql/ide/MySqlConnectionManager.kt b/dialects/mysql/src/main/kotlin/app/cash/sqldelight/dialects/mysql/ide/MySqlConnectionManager.kt index fcb6bce74ea..de4983fe40e 100644 --- a/dialects/mysql/src/main/kotlin/app/cash/sqldelight/dialects/mysql/ide/MySqlConnectionManager.kt +++ b/dialects/mysql/src/main/kotlin/app/cash/sqldelight/dialects/mysql/ide/MySqlConnectionManager.kt @@ -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) @@ -37,8 +37,8 @@ internal class MySqlConnectionManager : ConnectionManager { databaseName = dialog.databaseName.ifEmpty { null }, username = dialog.username.ifEmpty { null }, password = dialog.password.ifEmpty { null }, - ) - ) + ), + ), ) } @@ -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 { diff --git a/dialects/mysql/src/test/kotlin/app/cash/sqldelight/dialects/mysql/ColumnOrderingTest.kt b/dialects/mysql/src/test/kotlin/app/cash/sqldelight/dialects/mysql/ColumnOrderingTest.kt index fde09869af1..bd1cff67b71 100644 --- a/dialects/mysql/src/test/kotlin/app/cash/sqldelight/dialects/mysql/ColumnOrderingTest.kt +++ b/dialects/mysql/src/test/kotlin/app/cash/sqldelight/dialects/mysql/ColumnOrderingTest.kt @@ -47,21 +47,21 @@ class ColumnOrderingTest { | MODIFY COLUMN id5 BIGINT FIRST, | MODIFY COLUMN id6 BIGINT AFTER id9, | MODIFY COLUMN id7 VARCHAR(8); - """.trimMargin(), - "1.s" + """.trimMargin(), + "1.s", ) val file = compileFile( """ |SELECT * |FROM test1; - """.trimMargin(), - "test.s" + """.trimMargin(), + "test.s", ) assertThat( file.sqlStmtList!!.stmtList.first().compoundSelectStmt!!.queryExposed() .flatMap { it.columns } - .map { it.element.text } + .map { it.element.text }, ).containsExactly( "id5", "new14", @@ -75,7 +75,7 @@ class ColumnOrderingTest { "id9", "id6", "id10", - "new13" + "new13", ).inOrder() } } diff --git a/dialects/mysql/src/test/kotlin/app/cash/sqldelight/dialects/mysql/MySqlFixturesTest.kt b/dialects/mysql/src/test/kotlin/app/cash/sqldelight/dialects/mysql/MySqlFixturesTest.kt index 1fffd5a985f..3614a4cb369 100644 --- a/dialects/mysql/src/test/kotlin/app/cash/sqldelight/dialects/mysql/MySqlFixturesTest.kt +++ b/dialects/mysql/src/test/kotlin/app/cash/sqldelight/dialects/mysql/MySqlFixturesTest.kt @@ -23,9 +23,11 @@ class MySqlFixturesTest(name: String, fixtureRoot: File) : FixturesTest(name, fi companion object { private val fixtures = arrayOf("src/test/fixtures_mysql") - @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) } diff --git a/dialects/postgresql/src/main/kotlin/app/cash/sqldelight/dialects/postgresql/PostgreSqlMigrationSquasher.kt b/dialects/postgresql/src/main/kotlin/app/cash/sqldelight/dialects/postgresql/PostgreSqlMigrationSquasher.kt index 33b6a091395..63abafff302 100644 --- a/dialects/postgresql/src/main/kotlin/app/cash/sqldelight/dialects/postgresql/PostgreSqlMigrationSquasher.kt +++ b/dialects/postgresql/src/main/kotlin/app/cash/sqldelight/dialects/postgresql/PostgreSqlMigrationSquasher.kt @@ -11,11 +11,11 @@ import com.intellij.refactoring.suggested.endOffset import com.intellij.refactoring.suggested.startOffset internal class PostgreSqlMigrationSquasher( - private val parentSquasher: MigrationSquasher + private val parentSquasher: MigrationSquasher, ) : MigrationSquasher by parentSquasher { override fun squish( alterTableRules: SqlAlterTableRules, - into: SqlFileBase + into: SqlFileBase, ): String { if (alterTableRules !is PostgreSqlAlterTableRules) return parentSquasher.squish(alterTableRules, into) return when { @@ -30,7 +30,7 @@ internal class PostgreSqlMigrationSquasher( into.text.replaceRange( createTable.columnDefList.first().startOffset until createTable.columnDefList.last().endOffset, createTable.columnDefList.filterNot { it.columnName.textMatches(columnName.text) } - .joinToString(separator = ",\n ") { it.text } + .joinToString(separator = ",\n ") { it.text }, ) } else -> parentSquasher.squish(alterTableRules, into) diff --git a/dialects/postgresql/src/main/kotlin/app/cash/sqldelight/dialects/postgresql/PostgreSqlType.kt b/dialects/postgresql/src/main/kotlin/app/cash/sqldelight/dialects/postgresql/PostgreSqlType.kt index efcb040b889..259f00bf307 100644 --- a/dialects/postgresql/src/main/kotlin/app/cash/sqldelight/dialects/postgresql/PostgreSqlType.kt +++ b/dialects/postgresql/src/main/kotlin/app/cash/sqldelight/dialects/postgresql/PostgreSqlType.kt @@ -36,7 +36,7 @@ internal enum class PostgreSqlType(override val javaType: TypeName) : DialectTyp SMALL_INT, INTEGER, BIG_INT -> "bindLong" DATE, TIME, TIMESTAMP, TIMESTAMP_TIMEZONE, INTERVAL, UUID -> "bindObject" NUMERIC -> "bindBigDecimal" - } + }, ) .add("($columnIndex, %L)\n", value) .build() @@ -48,7 +48,7 @@ internal enum class PostgreSqlType(override val javaType: TypeName) : DialectTyp SMALL_INT, INTEGER, BIG_INT -> "$cursorName.getLong($columnIndex)" DATE, TIME, TIMESTAMP, TIMESTAMP_TIMEZONE, INTERVAL, UUID -> "$cursorName.getObject($columnIndex)" NUMERIC -> "$cursorName.getBigDecimal($columnIndex)" - } + }, ) } } diff --git a/dialects/postgresql/src/main/kotlin/app/cash/sqldelight/dialects/postgresql/PostgreSqlTypeResolver.kt b/dialects/postgresql/src/main/kotlin/app/cash/sqldelight/dialects/postgresql/PostgreSqlTypeResolver.kt index 0abbc70d3fa..c69c35d7ef0 100644 --- a/dialects/postgresql/src/main/kotlin/app/cash/sqldelight/dialects/postgresql/PostgreSqlTypeResolver.kt +++ b/dialects/postgresql/src/main/kotlin/app/cash/sqldelight/dialects/postgresql/PostgreSqlTypeResolver.kt @@ -56,18 +56,20 @@ class PostgreSqlTypeResolver(private val parentResolver: TypeResolver) : TypeRes booleanDataType != null -> PrimitiveType.BOOLEAN blobDataType != null -> BLOB else -> throw IllegalArgumentException("Unknown kotlin type for sql type ${this.text}") - } + }, ) if (node.getChildren(null).map { it.text }.takeLast(2) == listOf("[", "]")) { - return IntermediateType(object : DialectType { - override val javaType = Array::class.asTypeName().parameterizedBy(type.javaType) + return IntermediateType( + object : DialectType { + override val javaType = Array::class.asTypeName().parameterizedBy(type.javaType) - override fun prepareStatementBinder(columnIndex: String, value: CodeBlock) = - CodeBlock.of("bindObject($columnIndex, %L)\n", value) + override fun prepareStatementBinder(columnIndex: String, value: CodeBlock) = + CodeBlock.of("bindObject($columnIndex, %L)\n", value) - override fun cursorGetter(columnIndex: Int, cursorName: String) = - CodeBlock.of("$cursorName.getArray($columnIndex)") - }) + override fun cursorGetter(columnIndex: Int, cursorName: String) = + CodeBlock.of("$cursorName.getArray($columnIndex)") + }, + ) } return type } diff --git a/dialects/postgresql/src/main/kotlin/app/cash/sqldelight/dialects/postgresql/grammar/mixins/AlterTableColumnAliasMixin.kt b/dialects/postgresql/src/main/kotlin/app/cash/sqldelight/dialects/postgresql/grammar/mixins/AlterTableColumnAliasMixin.kt index 64702dd66fd..eb02e3979db 100644 --- a/dialects/postgresql/src/main/kotlin/app/cash/sqldelight/dialects/postgresql/grammar/mixins/AlterTableColumnAliasMixin.kt +++ b/dialects/postgresql/src/main/kotlin/app/cash/sqldelight/dialects/postgresql/grammar/mixins/AlterTableColumnAliasMixin.kt @@ -10,7 +10,7 @@ import com.intellij.lang.PsiBuilder import com.intellij.psi.util.PsiTreeUtil internal abstract class AlterTableColumnAliasMixin( - node: ASTNode + node: ASTNode, ) : SqlColumnAliasImpl(node), SqlColumnAlias { override val parseRule: (PsiBuilder, Int) -> Boolean = PostgreSqlParser::alter_table_column_alias_real diff --git a/dialects/postgresql/src/main/kotlin/app/cash/sqldelight/dialects/postgresql/grammar/mixins/AlterTableDropColumnMixin.kt b/dialects/postgresql/src/main/kotlin/app/cash/sqldelight/dialects/postgresql/grammar/mixins/AlterTableDropColumnMixin.kt index ec19cb35103..52c14b2b2bd 100644 --- a/dialects/postgresql/src/main/kotlin/app/cash/sqldelight/dialects/postgresql/grammar/mixins/AlterTableDropColumnMixin.kt +++ b/dialects/postgresql/src/main/kotlin/app/cash/sqldelight/dialects/postgresql/grammar/mixins/AlterTableDropColumnMixin.kt @@ -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), PostgreSqlAlterTableDropColumn, AlterTableApplier { @@ -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) - } + }, ) } } diff --git a/dialects/postgresql/src/main/kotlin/app/cash/sqldelight/dialects/postgresql/grammar/mixins/AlterTableRenameColumnMixin.kt b/dialects/postgresql/src/main/kotlin/app/cash/sqldelight/dialects/postgresql/grammar/mixins/AlterTableRenameColumnMixin.kt index 838581a7018..476a9b90f14 100644 --- a/dialects/postgresql/src/main/kotlin/app/cash/sqldelight/dialects/postgresql/grammar/mixins/AlterTableRenameColumnMixin.kt +++ b/dialects/postgresql/src/main/kotlin/app/cash/sqldelight/dialects/postgresql/grammar/mixins/AlterTableRenameColumnMixin.kt @@ -12,7 +12,7 @@ import com.alecstrong.sql.psi.core.psi.alterStmt import com.intellij.lang.ASTNode internal abstract class AlterTableRenameColumnMixin( - node: ASTNode + node: ASTNode, ) : SqlCompositeElementImpl(node), PostgreSqlAlterTableRenameColumn, AlterTableApplier { @@ -32,9 +32,9 @@ internal abstract class AlterTableRenameColumnMixin( (it.element as SqlColumnName).textMatches(columnName) } lazyQuery.query.copy( - columns = lazyQuery.query.columns.map { if (it == replace) column else it } + columns = lazyQuery.query.columns.map { if (it == replace) column else it }, ) - } + }, ) } @@ -48,7 +48,7 @@ internal abstract class AlterTableRenameColumnMixin( ) { annotationHolder.createErrorAnnotation( element = columnName, - s = "No column found to modify with name ${columnName.text}" + s = "No column found to modify with name ${columnName.text}", ) } } diff --git a/dialects/postgresql/src/main/kotlin/app/cash/sqldelight/dialects/postgresql/grammar/mixins/ReturningClauseMixin.kt b/dialects/postgresql/src/main/kotlin/app/cash/sqldelight/dialects/postgresql/grammar/mixins/ReturningClauseMixin.kt index 9c700c94892..892a3dab661 100644 --- a/dialects/postgresql/src/main/kotlin/app/cash/sqldelight/dialects/postgresql/grammar/mixins/ReturningClauseMixin.kt +++ b/dialects/postgresql/src/main/kotlin/app/cash/sqldelight/dialects/postgresql/grammar/mixins/ReturningClauseMixin.kt @@ -23,8 +23,8 @@ internal abstract class ReturningClauseMixin(node: ASTNode) : QueryResult( null, PsiTreeUtil.findChildrenOfType(this, SqlResultColumn::class.java) - .flatMap { it.queryExposed().flatMap(QueryResult::columns) } - ) + .flatMap { it.queryExposed().flatMap(QueryResult::columns) }, + ), ) } diff --git a/dialects/postgresql/src/main/kotlin/app/cash/sqldelight/dialects/postgresql/ide/PostgresConnectionDialog.kt b/dialects/postgresql/src/main/kotlin/app/cash/sqldelight/dialects/postgresql/ide/PostgresConnectionDialog.kt index db28641ab99..512a04ae927 100644 --- a/dialects/postgresql/src/main/kotlin/app/cash/sqldelight/dialects/postgresql/ide/PostgresConnectionDialog.kt +++ b/dialects/postgresql/src/main/kotlin/app/cash/sqldelight/dialects/postgresql/ide/PostgresConnectionDialog.kt @@ -31,7 +31,7 @@ internal class PostgresConnectionDialog( row("Connection Name") { textField( getter = { connectionKey }, - setter = { connectionName = it } + setter = { connectionName = it }, ).withValidationOnApply(validateNonEmpty(connectionNameNonEmpty)) .growPolicy(MEDIUM_TEXT) .applyToComponent { @@ -41,35 +41,35 @@ internal class PostgresConnectionDialog( 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) } diff --git a/dialects/postgresql/src/main/kotlin/app/cash/sqldelight/dialects/postgresql/ide/PostgresConnectionManager.kt b/dialects/postgresql/src/main/kotlin/app/cash/sqldelight/dialects/postgresql/ide/PostgresConnectionManager.kt index 34a92a10fcd..ecf11ee2abf 100644 --- a/dialects/postgresql/src/main/kotlin/app/cash/sqldelight/dialects/postgresql/ide/PostgresConnectionManager.kt +++ b/dialects/postgresql/src/main/kotlin/app/cash/sqldelight/dialects/postgresql/ide/PostgresConnectionManager.kt @@ -11,7 +11,7 @@ import java.sql.DriverManager internal class PostgresConnectionManager : ConnectionManager { override fun createNewConnectionProperties( project: Project, - prefilledProperties: ConnectionProperties? + prefilledProperties: ConnectionProperties?, ): ConnectionProperties? { val dialog = if (prefilledProperties == null) PostgresConnectionDialog(project) @@ -37,8 +37,8 @@ internal class PostgresConnectionManager : ConnectionManager { databaseName = dialog.databaseName.ifEmpty { null }, username = dialog.username.ifEmpty { null }, password = dialog.password.ifEmpty { null }, - ) - ) + ), + ), ) } @@ -70,7 +70,7 @@ internal class PostgresConnectionManager : ConnectionManager { val port: String, val databaseName: String?, val username: String?, - val password: String? + val password: String?, ) companion object { diff --git a/dialects/postgresql/src/test/kotlin/app/cash/sqldelight/dialects/postgres/PostgreSqlFixturesTest.kt b/dialects/postgresql/src/test/kotlin/app/cash/sqldelight/dialects/postgres/PostgreSqlFixturesTest.kt index 4e13281c72c..3443e8b9e90 100644 --- a/dialects/postgresql/src/test/kotlin/app/cash/sqldelight/dialects/postgres/PostgreSqlFixturesTest.kt +++ b/dialects/postgresql/src/test/kotlin/app/cash/sqldelight/dialects/postgres/PostgreSqlFixturesTest.kt @@ -24,9 +24,11 @@ class PostgreSqlFixturesTest(name: String, fixtureRoot: File) : FixturesTest(nam companion object { private val fixtures = arrayOf("src/test/fixtures_postgresql") - @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) } diff --git a/dialects/sqlite-3-18/src/main/kotlin/app/cash/sqldelight/dialects/sqlite_3_18/SelectConnectionTypeDialog.kt b/dialects/sqlite-3-18/src/main/kotlin/app/cash/sqldelight/dialects/sqlite_3_18/SelectConnectionTypeDialog.kt index a41e7e7c370..7738fd35925 100644 --- a/dialects/sqlite-3-18/src/main/kotlin/app/cash/sqldelight/dialects/sqlite_3_18/SelectConnectionTypeDialog.kt +++ b/dialects/sqlite-3-18/src/main/kotlin/app/cash/sqldelight/dialects/sqlite_3_18/SelectConnectionTypeDialog.kt @@ -37,7 +37,7 @@ internal class SelectConnectionTypeDialog( row("Connection Name") { textField( getter = { connectionName }, - setter = { connectionName = it } + setter = { connectionName = it }, ).withValidationOnApply(validateKey()) .withValidationOnInput(validateKey()) } @@ -53,7 +53,7 @@ internal class SelectConnectionTypeDialog( filePath = path recentsManager.registerRecentEntry(RECENT_DB_PATH, path) } - } + }, ) .withValidationOnInput(validateFilePath()) .withValidationOnApply(validateFilePath()) diff --git a/dialects/sqlite-3-18/src/main/kotlin/app/cash/sqldelight/dialects/sqlite_3_18/SqliteConnectionManager.kt b/dialects/sqlite-3-18/src/main/kotlin/app/cash/sqldelight/dialects/sqlite_3_18/SqliteConnectionManager.kt index a2b397d0c52..bdd3e61029b 100644 --- a/dialects/sqlite-3-18/src/main/kotlin/app/cash/sqldelight/dialects/sqlite_3_18/SqliteConnectionManager.kt +++ b/dialects/sqlite-3-18/src/main/kotlin/app/cash/sqldelight/dialects/sqlite_3_18/SqliteConnectionManager.kt @@ -10,7 +10,7 @@ import java.sql.SQLException class SqliteConnectionManager : ConnectionManager { override fun createNewConnectionProperties( project: Project, - prefilledProperties: ConnectionProperties? + prefilledProperties: ConnectionProperties?, ): ConnectionProperties? { val dialog = SelectConnectionTypeDialog(project) if (!dialog.showAndGet()) return null diff --git a/dialects/sqlite-3-18/src/main/kotlin/app/cash/sqldelight/dialects/sqlite_3_18/SqliteDialect.kt b/dialects/sqlite-3-18/src/main/kotlin/app/cash/sqldelight/dialects/sqlite_3_18/SqliteDialect.kt index 9420b9893d3..9fc5d0263b1 100644 --- a/dialects/sqlite-3-18/src/main/kotlin/app/cash/sqldelight/dialects/sqlite_3_18/SqliteDialect.kt +++ b/dialects/sqlite-3-18/src/main/kotlin/app/cash/sqldelight/dialects/sqlite_3_18/SqliteDialect.kt @@ -54,7 +54,7 @@ open class SqliteDialect : SqlDelightDialect { holderClass = SqliteTypes::class.java.name }, PluginManagerCore.getPlugin(PluginId.getId("com.squareup.sqldelight"))!!, - this + this, ) Timber.i("Registered Stub extension point") } diff --git a/dialects/sqlite-3-18/src/main/kotlin/app/cash/sqldelight/dialects/sqlite_3_18/SqliteMigrationStrategy.kt b/dialects/sqlite-3-18/src/main/kotlin/app/cash/sqldelight/dialects/sqlite_3_18/SqliteMigrationStrategy.kt index db090847ea8..169f5aecb6b 100644 --- a/dialects/sqlite-3-18/src/main/kotlin/app/cash/sqldelight/dialects/sqlite_3_18/SqliteMigrationStrategy.kt +++ b/dialects/sqlite-3-18/src/main/kotlin/app/cash/sqldelight/dialects/sqlite_3_18/SqliteMigrationStrategy.kt @@ -15,7 +15,7 @@ class SqliteMigrationStrategy : SqlGeneratorStrategy { override fun columnRemoved( tableName: String, columnName: String, - columnDefList: List + columnDefList: List, ): String { val columnNames = columnDefList.filter { !it.startsWith(columnName) } .joinToString(", ") { columnDef -> columnDef.takeWhile { !Character.isWhitespace(it) } } @@ -34,7 +34,7 @@ class SqliteMigrationStrategy : SqlGeneratorStrategy { tableName: String, oldName: String, newName: String, - columnDefList: List + columnDefList: List, ): String { val newColumnDefList = columnDefList.toMutableList() val index = newColumnDefList.indexOfFirst { it.startsWith(oldName) } diff --git a/dialects/sqlite-3-18/src/main/kotlin/app/cash/sqldelight/dialects/sqlite_3_18/grammar/mixins/AlterTableElementType.kt b/dialects/sqlite-3-18/src/main/kotlin/app/cash/sqldelight/dialects/sqlite_3_18/grammar/mixins/AlterTableElementType.kt index 5de76c3ab65..34a6259ca54 100644 --- a/dialects/sqlite-3-18/src/main/kotlin/app/cash/sqldelight/dialects/sqlite_3_18/grammar/mixins/AlterTableElementType.kt +++ b/dialects/sqlite-3-18/src/main/kotlin/app/cash/sqldelight/dialects/sqlite_3_18/grammar/mixins/AlterTableElementType.kt @@ -6,9 +6,10 @@ import com.alecstrong.sql.psi.core.psi.mixins.AlterTableElementType import com.alecstrong.sql.psi.core.psi.mixins.AlterTableStmtStub internal class AlterTableElementType( - name: String + name: String, ) : AlterTableElementType("sqlite_3_18.$name") { override fun createPsi(stub: SchemaContributorStub) = SqliteAlterTableStmtImpl( - stub as AlterTableStmtStub, this + stub as AlterTableStmtStub, + this, ) } diff --git a/dialects/sqlite-3-18/src/main/kotlin/app/cash/sqldelight/dialects/sqlite_3_18/grammar/mixins/StatementValidatorMixin.kt b/dialects/sqlite-3-18/src/main/kotlin/app/cash/sqldelight/dialects/sqlite_3_18/grammar/mixins/StatementValidatorMixin.kt index a5976bb88f9..f66cc2fabe2 100644 --- a/dialects/sqlite-3-18/src/main/kotlin/app/cash/sqldelight/dialects/sqlite_3_18/grammar/mixins/StatementValidatorMixin.kt +++ b/dialects/sqlite-3-18/src/main/kotlin/app/cash/sqldelight/dialects/sqlite_3_18/grammar/mixins/StatementValidatorMixin.kt @@ -41,7 +41,7 @@ open class StatementValidatorMixin(node: ASTNode) : SqlStmtImpl(node) { "ELSE", "ESCAPE", "EXCEPT", "EXISTS", "FOREIGN", "FROM", "GROUP", "HAVING", "IN", "INDEX", "INSERT", "INTERSECT", "INTO", "IS", "ISNULL", "JOIN", "LIMIT", "NOT", "NOTNULL", "NULL", "OR", "ORDER", "PRIMARY", "REFERENCES", "SELECT", "SET", "TABLE", "THEN", "TO", - "TRANSACTION", "UNION", "UNIQUE", "UPDATE", "USING", "VALUES", "WHEN", "WHERE" + "TRANSACTION", "UNION", "UNIQUE", "UPDATE", "USING", "VALUES", "WHEN", "WHERE", ) } } diff --git a/dialects/sqlite-3-18/src/test/kotlin/app/cash/sqldelight/dialects/sqlite_3_18/NullabilityTest.kt b/dialects/sqlite-3-18/src/test/kotlin/app/cash/sqldelight/dialects/sqlite_3_18/NullabilityTest.kt index 591b687b4ba..08601b50035 100644 --- a/dialects/sqlite-3-18/src/test/kotlin/app/cash/sqldelight/dialects/sqlite_3_18/NullabilityTest.kt +++ b/dialects/sqlite-3-18/src/test/kotlin/app/cash/sqldelight/dialects/sqlite_3_18/NullabilityTest.kt @@ -41,7 +41,7 @@ class NullabilityTest { | FROM owner | LEFT OUTER JOIN car ON owner.carId = car.id) |WHERE carBrand = ?; - """.trimMargin() + """.trimMargin(), ) val select = file.sqlStmtList!!.stmtList.mapNotNull { it.compoundSelectStmt }.single() @@ -83,7 +83,7 @@ class NullabilityTest { | GROUP BY 1 | ORDER BY target.name COLLATE NOCASE ASC |; - """.trimMargin() + """.trimMargin(), ) val select = file.sqlStmtList!!.stmtList.mapNotNull { it.compoundSelectStmt }.single() @@ -106,7 +106,7 @@ class NullabilityTest { |SELECT name, name AS poop, thing AS poop2 |FROM target |WHERE name IS NOT NULL AND thing IS NOT NULL; - """.trimMargin() + """.trimMargin(), ) val select = file.sqlStmtList!!.stmtList.mapNotNull { it.compoundSelectStmt }.single() diff --git a/dialects/sqlite-3-18/src/test/kotlin/app/cash/sqldelight/dialects/sqlite_3_18/Sqlite318FixturesTest.kt b/dialects/sqlite-3-18/src/test/kotlin/app/cash/sqldelight/dialects/sqlite_3_18/Sqlite318FixturesTest.kt index 2df3c098859..1cc0c2bf2c0 100644 --- a/dialects/sqlite-3-18/src/test/kotlin/app/cash/sqldelight/dialects/sqlite_3_18/Sqlite318FixturesTest.kt +++ b/dialects/sqlite-3-18/src/test/kotlin/app/cash/sqldelight/dialects/sqlite_3_18/Sqlite318FixturesTest.kt @@ -15,9 +15,11 @@ class Sqlite318FixturesTest(name: String, fixtureRoot: File) : FixturesTest(name companion object { private val fixtures = arrayOf("src/test/fixtures_upsert_not_supported", "src/test/fixtures_sqlite_3_18") - @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) } diff --git a/dialects/sqlite-3-24/src/main/kotlin/app/cash/sqldelight/dialects/sqlite_3_24/SqliteTypeResolver.kt b/dialects/sqlite-3-24/src/main/kotlin/app/cash/sqldelight/dialects/sqlite_3_24/SqliteTypeResolver.kt index 139d30cb110..9751fa0aa94 100644 --- a/dialects/sqlite-3-24/src/main/kotlin/app/cash/sqldelight/dialects/sqlite_3_24/SqliteTypeResolver.kt +++ b/dialects/sqlite-3-24/src/main/kotlin/app/cash/sqldelight/dialects/sqlite_3_24/SqliteTypeResolver.kt @@ -11,7 +11,7 @@ import app.cash.sqldelight.dialects.sqlite_3_18.SqliteTypeResolver as Sqlite318T open class SqliteTypeResolver(parentResolver: TypeResolver) : Sqlite318TypeResolver(parentResolver) { override fun argumentType( parent: PsiElement, - argument: SqlExpr + argument: SqlExpr, ): IntermediateType { when (parent) { is SqlSetterExpression -> when (parent.parent!!) { diff --git a/dialects/sqlite-3-24/src/main/kotlin/app/cash/sqldelight/dialects/sqlite_3_24/grammar/mixins/InsertStmtMixin.kt b/dialects/sqlite-3-24/src/main/kotlin/app/cash/sqldelight/dialects/sqlite_3_24/grammar/mixins/InsertStmtMixin.kt index c3c9edf8fd4..fafdf234922 100644 --- a/dialects/sqlite-3-24/src/main/kotlin/app/cash/sqldelight/dialects/sqlite_3_24/grammar/mixins/InsertStmtMixin.kt +++ b/dialects/sqlite-3-24/src/main/kotlin/app/cash/sqldelight/dialects/sqlite_3_24/grammar/mixins/InsertStmtMixin.kt @@ -7,13 +7,13 @@ import com.alecstrong.sql.psi.core.psi.impl.SqlInsertStmtImpl import com.intellij.lang.ASTNode internal abstract class InsertStmtMixin( - node: ASTNode + node: ASTNode, ) : SqlInsertStmtImpl(node), SqliteInsertStmt { override fun annotate(annotationHolder: SqlAnnotationHolder) { super.annotate(annotationHolder) val insertDefaultValues = insertStmtValues?.node?.findChildByType( - SqlTypes.DEFAULT + SqlTypes.DEFAULT, ) != null upsertClause?.let { upsert -> @@ -23,10 +23,10 @@ internal abstract class InsertStmtMixin( } val insertOr = node.findChildByType( - SqlTypes.INSERT + SqlTypes.INSERT, )?.treeNext val replace = node.findChildByType( - SqlTypes.REPLACE + SqlTypes.REPLACE, ) val conflictResolution = when { replace != null -> SqlTypes.REPLACE @@ -34,7 +34,7 @@ internal abstract class InsertStmtMixin( val type = insertOr.treeNext.elementType check( type == SqlTypes.ROLLBACK || type == SqlTypes.ABORT || - type == SqlTypes.FAIL || type == SqlTypes.IGNORE + type == SqlTypes.FAIL || type == SqlTypes.IGNORE, ) type } @@ -45,7 +45,7 @@ internal abstract class InsertStmtMixin( annotationHolder.createErrorAnnotation( upsertDoUpdate, "Cannot use DO UPDATE while " + - "also specifying a conflict resolution algorithm ($conflictResolution)" + "also specifying a conflict resolution algorithm ($conflictResolution)", ) } } diff --git a/dialects/sqlite-3-24/src/main/kotlin/app/cash/sqldelight/dialects/sqlite_3_24/grammar/mixins/UpsertClauseMixin.kt b/dialects/sqlite-3-24/src/main/kotlin/app/cash/sqldelight/dialects/sqlite_3_24/grammar/mixins/UpsertClauseMixin.kt index 266e40ad0fe..ee0780547d8 100644 --- a/dialects/sqlite-3-24/src/main/kotlin/app/cash/sqldelight/dialects/sqlite_3_24/grammar/mixins/UpsertClauseMixin.kt +++ b/dialects/sqlite-3-24/src/main/kotlin/app/cash/sqldelight/dialects/sqlite_3_24/grammar/mixins/UpsertClauseMixin.kt @@ -11,7 +11,7 @@ import com.intellij.lang.ASTNode import com.intellij.psi.PsiElement internal abstract class UpsertClauseMixin( - node: ASTNode + node: ASTNode, ) : SqlCompositeElementImpl(node), SqliteUpsertClause { @@ -27,10 +27,11 @@ internal abstract class UpsertClauseMixin( if (child is SqliteUpsertDoUpdate) { val excludedTable = QueryElement.QueryResult( SingleRow( - tableName, "excluded" + tableName, + "excluded", ), table.columns, - synthesizedColumns = table.synthesizedColumns + synthesizedColumns = table.synthesizedColumns, ) val available = arrayListOf(excludedTable) diff --git a/dialects/sqlite-3-24/src/test/kotlin/app/cash/sqldelight/dialects/sqlite_3_24/Sqlite324FixturesTest.kt b/dialects/sqlite-3-24/src/test/kotlin/app/cash/sqldelight/dialects/sqlite_3_24/Sqlite324FixturesTest.kt index 0a6c175c828..c436d92f0a0 100644 --- a/dialects/sqlite-3-24/src/test/kotlin/app/cash/sqldelight/dialects/sqlite_3_24/Sqlite324FixturesTest.kt +++ b/dialects/sqlite-3-24/src/test/kotlin/app/cash/sqldelight/dialects/sqlite_3_24/Sqlite324FixturesTest.kt @@ -9,7 +9,7 @@ import java.io.File @RunWith(Parameterized::class) class Sqlite324FixturesTest(name: String, fixtureRoot: File) : FixturesTest(name, fixtureRoot) { override val replaceRules = arrayOf( - "ORDER or WHERE expected" to "ORDER, WHERE or WINDOW expected" + "ORDER or WHERE expected" to "ORDER, WHERE or WINDOW expected", ) override fun setupDialect() { @@ -19,9 +19,11 @@ class Sqlite324FixturesTest(name: String, fixtureRoot: File) : FixturesTest(name companion object { private val fixtures = arrayOf("../sqlite-3-18/src/test/fixtures_sqlite_3_18", "src/test/fixtures_sqlite_3_24") - @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) } diff --git a/dialects/sqlite-3-25/src/main/kotlin/app/cash/sqldelight/dialects/sqlite_3_25/SqliteMigrationSquasher.kt b/dialects/sqlite-3-25/src/main/kotlin/app/cash/sqldelight/dialects/sqlite_3_25/SqliteMigrationSquasher.kt index 04f72636005..82fceb6ced5 100644 --- a/dialects/sqlite-3-25/src/main/kotlin/app/cash/sqldelight/dialects/sqlite_3_25/SqliteMigrationSquasher.kt +++ b/dialects/sqlite-3-25/src/main/kotlin/app/cash/sqldelight/dialects/sqlite_3_25/SqliteMigrationSquasher.kt @@ -12,11 +12,11 @@ import com.intellij.refactoring.suggested.endOffset import com.intellij.refactoring.suggested.startOffset internal class SqliteMigrationSquasher( - private val parentSquasher: MigrationSquasher + private val parentSquasher: MigrationSquasher, ) : MigrationSquasher by parentSquasher { override fun squish( alterTableRules: SqlAlterTableRules, - into: SqlFileBase + into: SqlFileBase, ): String { if (alterTableRules !is SqliteAlterTableRules) return parentSquasher.squish(alterTableRules, into) return when { diff --git a/dialects/sqlite-3-25/src/main/kotlin/app/cash/sqldelight/dialects/sqlite_3_25/grammar/mixins/AlterTableRenameColumnMixin.kt b/dialects/sqlite-3-25/src/main/kotlin/app/cash/sqldelight/dialects/sqlite_3_25/grammar/mixins/AlterTableRenameColumnMixin.kt index cba441e20fc..00ba1d45712 100644 --- a/dialects/sqlite-3-25/src/main/kotlin/app/cash/sqldelight/dialects/sqlite_3_25/grammar/mixins/AlterTableRenameColumnMixin.kt +++ b/dialects/sqlite-3-25/src/main/kotlin/app/cash/sqldelight/dialects/sqlite_3_25/grammar/mixins/AlterTableRenameColumnMixin.kt @@ -12,7 +12,7 @@ import com.alecstrong.sql.psi.core.psi.alterStmt import com.intellij.lang.ASTNode internal abstract class AlterTableRenameColumnMixin( - node: ASTNode + node: ASTNode, ) : SqlCompositeElementImpl(node), SqliteAlterTableRenameColumn, AlterTableApplier { @@ -32,9 +32,9 @@ internal abstract class AlterTableRenameColumnMixin( (it.element as SqlColumnName).textMatches(columnName) } lazyQuery.query.copy( - columns = lazyQuery.query.columns.map { if (it == replace) column else it } + columns = lazyQuery.query.columns.map { if (it == replace) column else it }, ) - } + }, ) } @@ -48,7 +48,7 @@ internal abstract class AlterTableRenameColumnMixin( ) { annotationHolder.createErrorAnnotation( element = columnName, - s = "No column found to modify with name ${columnName.text}" + s = "No column found to modify with name ${columnName.text}", ) } } diff --git a/dialects/sqlite-3-25/src/test/kotlin/app/cash/sqldelight/dialects/sqlite_3_25/Sqlite325FixturesTest.kt b/dialects/sqlite-3-25/src/test/kotlin/app/cash/sqldelight/dialects/sqlite_3_25/Sqlite325FixturesTest.kt index 5d302a8b903..a962d45a965 100644 --- a/dialects/sqlite-3-25/src/test/kotlin/app/cash/sqldelight/dialects/sqlite_3_25/Sqlite325FixturesTest.kt +++ b/dialects/sqlite-3-25/src/test/kotlin/app/cash/sqldelight/dialects/sqlite_3_25/Sqlite325FixturesTest.kt @@ -9,7 +9,7 @@ import java.io.File @RunWith(Parameterized::class) class Sqlite325FixturesTest(name: String, fixtureRoot: File) : FixturesTest(name, fixtureRoot) { override val replaceRules = arrayOf( - "ORDER or WHERE expected" to "ORDER, WHERE or WINDOW expected" + "ORDER or WHERE expected" to "ORDER, WHERE or WINDOW expected", ) override fun setupDialect() { @@ -19,9 +19,11 @@ class Sqlite325FixturesTest(name: String, fixtureRoot: File) : FixturesTest(name companion object { private val fixtures = arrayOf("../sqlite-3-18/src/test/fixtures_sqlite_3_18", "../sqlite-3-24/src/test/fixtures_sqlite_3_24", "src/test/fixtures_sqlite_3_25") - @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) } diff --git a/dialects/sqlite-3-30/src/test/kotlin/app/cash/sqldelight/dialects/sqlite_3_30/Sqlite330FixturesTest.kt b/dialects/sqlite-3-30/src/test/kotlin/app/cash/sqldelight/dialects/sqlite_3_30/Sqlite330FixturesTest.kt index 093bbf33c1e..5b8ca7b3872 100644 --- a/dialects/sqlite-3-30/src/test/kotlin/app/cash/sqldelight/dialects/sqlite_3_30/Sqlite330FixturesTest.kt +++ b/dialects/sqlite-3-30/src/test/kotlin/app/cash/sqldelight/dialects/sqlite_3_30/Sqlite330FixturesTest.kt @@ -9,7 +9,7 @@ import java.io.File @RunWith(Parameterized::class) class Sqlite330FixturesTest(name: String, fixtureRoot: File) : FixturesTest(name, fixtureRoot) { override val replaceRules = arrayOf( - "ORDER or WHERE expected" to "ORDER, WHERE or WINDOW expected" + "ORDER or WHERE expected" to "ORDER, WHERE or WINDOW expected", ) override fun setupDialect() { @@ -19,9 +19,11 @@ class Sqlite330FixturesTest(name: String, fixtureRoot: File) : FixturesTest(name companion object { private val fixtures = arrayOf("../sqlite-3-18/src/test/fixtures_sqlite_3_18", "../sqlite-3-24/src/test/fixtures_sqlite_3_24", "../sqlite-3-25/src/test/fixtures_sqlite_3_25", "src/test/fixtures_sqlite_3_30") - @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) } diff --git a/dialects/sqlite-3-35/src/main/kotlin/app/cash/sqldelight/dialects/sqlite_3_35/SqliteMigrationSquasher.kt b/dialects/sqlite-3-35/src/main/kotlin/app/cash/sqldelight/dialects/sqlite_3_35/SqliteMigrationSquasher.kt index 1c7ef94b9dc..85efd18ff34 100644 --- a/dialects/sqlite-3-35/src/main/kotlin/app/cash/sqldelight/dialects/sqlite_3_35/SqliteMigrationSquasher.kt +++ b/dialects/sqlite-3-35/src/main/kotlin/app/cash/sqldelight/dialects/sqlite_3_35/SqliteMigrationSquasher.kt @@ -11,11 +11,11 @@ import com.intellij.refactoring.suggested.endOffset import com.intellij.refactoring.suggested.startOffset internal class SqliteMigrationSquasher( - private val parentSquasher: MigrationSquasher + private val parentSquasher: MigrationSquasher, ) : MigrationSquasher by parentSquasher { override fun squish( alterTableRules: SqlAlterTableRules, - into: SqlFileBase + into: SqlFileBase, ): String { if (alterTableRules !is SqliteAlterTableRules) return parentSquasher.squish(alterTableRules, into) return when { @@ -25,7 +25,7 @@ internal class SqliteMigrationSquasher( into.text.replaceRange( createTable.columnDefList.first().startOffset until createTable.columnDefList.last().endOffset, createTable.columnDefList.filterNot { it.columnName.textMatches(columnName.text) } - .joinToString(separator = ",\n ") { it.text } + .joinToString(separator = ",\n ") { it.text }, ) } else -> parentSquasher.squish(alterTableRules, into) diff --git a/dialects/sqlite-3-35/src/main/kotlin/app/cash/sqldelight/dialects/sqlite_3_35/grammar/mixins/AlterTableDropColumnMixin.kt b/dialects/sqlite-3-35/src/main/kotlin/app/cash/sqldelight/dialects/sqlite_3_35/grammar/mixins/AlterTableDropColumnMixin.kt index 4fb2cb0286c..0db877c3300 100644 --- a/dialects/sqlite-3-35/src/main/kotlin/app/cash/sqldelight/dialects/sqlite_3_35/grammar/mixins/AlterTableDropColumnMixin.kt +++ b/dialects/sqlite-3-35/src/main/kotlin/app/cash/sqldelight/dialects/sqlite_3_35/grammar/mixins/AlterTableDropColumnMixin.kt @@ -14,7 +14,7 @@ import com.alecstrong.sql.psi.core.psi.mixins.ColumnDefMixin import com.intellij.lang.ASTNode internal abstract class AlterTableDropColumnMixin( - node: ASTNode + node: ASTNode, ) : SqlCompositeElementImpl(node), SqliteAlterTableDropColumn, AlterTableApplier { @@ -26,9 +26,9 @@ internal abstract class AlterTableDropColumnMixin( tableName = lazyQuery.tableName, query = { lazyQuery.query.copy( - columns = lazyQuery.query.columns.filterNot { (it.element as SqlColumnName).textMatches(columnName) } + columns = lazyQuery.query.columns.filterNot { (it.element as SqlColumnName).textMatches(columnName) }, ) - } + }, ) } @@ -44,7 +44,7 @@ internal abstract class AlterTableDropColumnMixin( if (columns.size == 1) { annotationHolder.createErrorAnnotation( element = columnName, - s = "Cannot drop column \"${columnName.text}\": no other columns exist" + s = "Cannot drop column \"${columnName.text}\": no other columns exist", ) } else { val constraints = columnsToDrop @@ -54,12 +54,12 @@ internal abstract class AlterTableDropColumnMixin( if (constraints.any { it.hasPrimaryKey() }) { annotationHolder.createErrorAnnotation( element = columnName, - s = "Cannot drop PRIMARY KEY column \"${columnName.text}\"" + s = "Cannot drop PRIMARY KEY column \"${columnName.text}\"", ) } else if (constraints.any { it.isUnique() }) { annotationHolder.createErrorAnnotation( element = columnName, - s = "Cannot drop UNIQUE column \"${columnName.text}\"" + s = "Cannot drop UNIQUE column \"${columnName.text}\"", ) } else { containingFile @@ -73,7 +73,7 @@ internal abstract class AlterTableDropColumnMixin( ?.let { indexForColumnToDrop -> annotationHolder.createErrorAnnotation( element = columnName, - s = "Cannot drop indexed column \"${columnName.text}\" (\"${indexForColumnToDrop.indexName.text}\")" + s = "Cannot drop indexed column \"${columnName.text}\" (\"${indexForColumnToDrop.indexName.text}\")", ) } } diff --git a/dialects/sqlite-3-35/src/main/kotlin/app/cash/sqldelight/dialects/sqlite_3_35/grammar/mixins/ReturningClauseMixin.kt b/dialects/sqlite-3-35/src/main/kotlin/app/cash/sqldelight/dialects/sqlite_3_35/grammar/mixins/ReturningClauseMixin.kt index 29ded74498c..106e28654ee 100644 --- a/dialects/sqlite-3-35/src/main/kotlin/app/cash/sqldelight/dialects/sqlite_3_35/grammar/mixins/ReturningClauseMixin.kt +++ b/dialects/sqlite-3-35/src/main/kotlin/app/cash/sqldelight/dialects/sqlite_3_35/grammar/mixins/ReturningClauseMixin.kt @@ -16,7 +16,7 @@ import com.intellij.lang.ASTNode import com.intellij.psi.util.PsiTreeUtil internal abstract class ReturningClauseMixin( - node: ASTNode + node: ASTNode, ) : SqlCompositeElementImpl(node), SqliteReturningClause, FromQuery { @@ -25,8 +25,8 @@ internal abstract class ReturningClauseMixin( QueryElement.QueryResult( null, PsiTreeUtil.findChildrenOfType(this, SqlResultColumn::class.java) - .flatMap { it.queryExposed().flatMap(QueryElement.QueryResult::columns) } - ) + .flatMap { it.queryExposed().flatMap(QueryElement.QueryResult::columns) }, + ), ) } diff --git a/dialects/sqlite-3-35/src/test/kotlin/app/cash/sqldelight/dialect/sqlite_3_35/Sqlite335FixturesTest.kt b/dialects/sqlite-3-35/src/test/kotlin/app/cash/sqldelight/dialect/sqlite_3_35/Sqlite335FixturesTest.kt index cfc892bf383..3a01a018d46 100644 --- a/dialects/sqlite-3-35/src/test/kotlin/app/cash/sqldelight/dialect/sqlite_3_35/Sqlite335FixturesTest.kt +++ b/dialects/sqlite-3-35/src/test/kotlin/app/cash/sqldelight/dialect/sqlite_3_35/Sqlite335FixturesTest.kt @@ -10,7 +10,7 @@ import java.io.File @RunWith(Parameterized::class) class Sqlite335FixturesTest(name: String, fixtureRoot: File) : FixturesTest(name, fixtureRoot) { override val replaceRules = arrayOf( - "ORDER or WHERE expected" to "ORDER, WHERE or WINDOW expected" + "ORDER or WHERE expected" to "ORDER, WHERE or WINDOW expected", ) override fun setupDialect() { @@ -20,9 +20,11 @@ class Sqlite335FixturesTest(name: String, fixtureRoot: File) : FixturesTest(name companion object { private val fixtures = arrayOf("../sqlite-3-18/src/test/fixtures_sqlite_3_18", "../sqlite-3-24/src/test/fixtures_sqlite_3_24", "../sqlite-3-25/src/test/fixtures_sqlite_3_25", "../sqlite-3-30/src/test/fixtures_sqlite_3_30", "src/test/fixtures_sqlite_3_35") - @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) } diff --git a/dialects/sqlite-3-38/src/test/kotlin/app/cash/sqldelight/dialect/sqlite_3_38/Sqlite338FixturesTest.kt b/dialects/sqlite-3-38/src/test/kotlin/app/cash/sqldelight/dialect/sqlite_3_38/Sqlite338FixturesTest.kt index aa7e365a96f..b6ac2c5a53d 100644 --- a/dialects/sqlite-3-38/src/test/kotlin/app/cash/sqldelight/dialect/sqlite_3_38/Sqlite338FixturesTest.kt +++ b/dialects/sqlite-3-38/src/test/kotlin/app/cash/sqldelight/dialect/sqlite_3_38/Sqlite338FixturesTest.kt @@ -10,7 +10,7 @@ import java.io.File @RunWith(Parameterized::class) class Sqlite338FixturesTest(name: String, fixtureRoot: File) : FixturesTest(name, fixtureRoot) { override val replaceRules = arrayOf( - "ORDER or WHERE expected" to "ORDER, WHERE or WINDOW expected" + "ORDER or WHERE expected" to "ORDER, WHERE or WINDOW expected", ) override fun setupDialect() { @@ -20,9 +20,11 @@ class Sqlite338FixturesTest(name: String, fixtureRoot: File) : FixturesTest(name companion object { private val fixtures = arrayOf("../sqlite-3-18/src/test/fixtures_sqlite_3_18", "../sqlite-3-24/src/test/fixtures_sqlite_3_24", "../sqlite-3-25/src/test/fixtures_sqlite_3_25", "../sqlite-3-30/src/test/fixtures_sqlite_3_30", "../sqlite-3-35/src/test/fixtures_sqlite_3_35", "src/test/fixtures_sqlite_3_38") - @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) } diff --git a/dialects/sqlite/json-module/src/main/kotlin/app/cash/sqldelight/dialects/sqlite/json/module/JsonFunctions.kt b/dialects/sqlite/json-module/src/main/kotlin/app/cash/sqldelight/dialects/sqlite/json/module/JsonModule.kt similarity index 98% rename from dialects/sqlite/json-module/src/main/kotlin/app/cash/sqldelight/dialects/sqlite/json/module/JsonFunctions.kt rename to dialects/sqlite/json-module/src/main/kotlin/app/cash/sqldelight/dialects/sqlite/json/module/JsonModule.kt index 361f40043bb..bb8009961cb 100644 --- a/dialects/sqlite/json-module/src/main/kotlin/app/cash/sqldelight/dialects/sqlite/json/module/JsonFunctions.kt +++ b/dialects/sqlite/json-module/src/main/kotlin/app/cash/sqldelight/dialects/sqlite/json/module/JsonModule.kt @@ -22,7 +22,7 @@ private class JsonTypeResolver(private val parentResolver: TypeResolver) : override fun functionType(functionExpr: SqlFunctionExpr): IntermediateType? { when (functionExpr.functionName.text) { "json_array", "json", "json_insert", "json_replace", "json_set", "json_object", "json_patch", - "json_remove", "json_type", "json_quote", "json_group_array", "json_group_object" -> + "json_remove", "json_type", "json_quote", "json_group_array", "json_group_object", -> return IntermediateType(PrimitiveType.TEXT) "json_array_length" -> return IntermediateType(PrimitiveType.INTEGER) "json_extract" -> return IntermediateType(PrimitiveType.TEXT).asNullable() diff --git a/dialects/sqlite/json-module/src/main/kotlin/app/cash/sqldelight/dialects/sqlite/json/module/grammar/mixins/TableOrSubqueryMixin.kt b/dialects/sqlite/json-module/src/main/kotlin/app/cash/sqldelight/dialects/sqlite/json/module/grammar/mixins/TableOrSubqueryMixin.kt index d0395d4a16a..528d33c6b48 100644 --- a/dialects/sqlite/json-module/src/main/kotlin/app/cash/sqldelight/dialects/sqlite/json/module/grammar/mixins/TableOrSubqueryMixin.kt +++ b/dialects/sqlite/json-module/src/main/kotlin/app/cash/sqldelight/dialects/sqlite/json/module/grammar/mixins/TableOrSubqueryMixin.kt @@ -25,9 +25,9 @@ internal abstract class TableOrSubqueryMixin(node: ASTNode?) : SqlTableOrSubquer table = jsonFunctionName!!, columns = emptyList(), synthesizedColumns = listOf( - SynthesizedColumn(jsonFunctionName!!, acceptableValues = listOf("key", "value", "type", "atom", "id", "parent", "fullkey", "path", "json", "root")) - ) - ) + SynthesizedColumn(jsonFunctionName!!, acceptableValues = listOf("key", "value", "type", "atom", "id", "parent", "fullkey", "path", "json", "root")), + ), + ), ) } super.queryExposed() diff --git a/dialects/sqlite/json-module/src/test/kotlin/app/cash/sqldelight/dialects/sqlite/json/module/JsonModuleTest.kt b/dialects/sqlite/json-module/src/test/kotlin/app/cash/sqldelight/dialects/sqlite/json/module/JsonModuleTest.kt index 158941da8ec..d8e4ee15adf 100644 --- a/dialects/sqlite/json-module/src/test/kotlin/app/cash/sqldelight/dialects/sqlite/json/module/JsonModuleTest.kt +++ b/dialects/sqlite/json-module/src/test/kotlin/app/cash/sqldelight/dialects/sqlite/json/module/JsonModuleTest.kt @@ -17,9 +17,11 @@ class JsonModuleTest(name: String, fixtureRoot: File) : FixturesTest(name, fixtu companion object { private val fixtures = arrayOf("src/test/fixtures") - @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) } diff --git a/drivers/android-driver/src/main/java/app/cash/sqldelight/driver/android/AndroidSqliteDriver.kt b/drivers/android-driver/src/main/java/app/cash/sqldelight/driver/android/AndroidSqliteDriver.kt index 37961c03c34..26d044dc64f 100644 --- a/drivers/android-driver/src/main/java/app/cash/sqldelight/driver/android/AndroidSqliteDriver.kt +++ b/drivers/android-driver/src/main/java/app/cash/sqldelight/driver/android/AndroidSqliteDriver.kt @@ -24,7 +24,7 @@ private val DEFAULT_CACHE_SIZE = 20 class AndroidSqliteDriver private constructor( private val openHelper: SupportSQLiteOpenHelper? = null, database: SupportSQLiteDatabase? = null, - private val cacheSize: Int + private val cacheSize: Int, ) : SqlDriver { init { require((openHelper != null) xor (database != null)) @@ -36,7 +36,7 @@ class AndroidSqliteDriver private constructor( } constructor( - openHelper: SupportSQLiteOpenHelper + openHelper: SupportSQLiteOpenHelper, ) : this(openHelper = openHelper, database = null, cacheSize = DEFAULT_CACHE_SIZE) /** @@ -51,7 +51,7 @@ class AndroidSqliteDriver private constructor( factory: SupportSQLiteOpenHelper.Factory = FrameworkSQLiteOpenHelperFactory(), callback: SupportSQLiteOpenHelper.Callback = AndroidSqliteDriver.Callback(schema), cacheSize: Int = DEFAULT_CACHE_SIZE, - useNoBackupDirectory: Boolean = false + useNoBackupDirectory: Boolean = false, ) : this( database = null, openHelper = factory.create( @@ -59,14 +59,14 @@ class AndroidSqliteDriver private constructor( .callback(callback) .name(name) .noBackupDirectory(useNoBackupDirectory) - .build() + .build(), ), - cacheSize = cacheSize + cacheSize = cacheSize, ) @JvmOverloads constructor( database: SupportSQLiteDatabase, - cacheSize: Int = DEFAULT_CACHE_SIZE + cacheSize: Int = DEFAULT_CACHE_SIZE, ) : this(openHelper = null, database = database, cacheSize = cacheSize) private val statements = object : LruCache(cacheSize) { @@ -74,7 +74,7 @@ class AndroidSqliteDriver private constructor( evicted: Boolean, key: Int, oldValue: AndroidStatement, - newValue: AndroidStatement? + newValue: AndroidStatement?, ) { if (evicted) oldValue.close() } @@ -121,7 +121,7 @@ class AndroidSqliteDriver private constructor( override fun currentTransaction() = transactions.get() inner class Transaction( - override val enclosingTransaction: Transacter.Transaction? + override val enclosingTransaction: Transacter.Transaction?, ) : Transacter.Transaction() { override fun endTransaction(successful: Boolean): QueryResult { if (enclosingTransaction == null) { @@ -141,7 +141,7 @@ class AndroidSqliteDriver private constructor( identifier: Int?, createStatement: () -> AndroidStatement, binders: (SqlPreparedStatement.() -> Unit)?, - result: AndroidStatement.() -> T + result: AndroidStatement.() -> T, ): QueryResult { var statement: AndroidStatement? = null if (identifier != null) { @@ -166,7 +166,7 @@ class AndroidSqliteDriver private constructor( identifier: Int?, sql: String, parameters: Int, - binders: (SqlPreparedStatement.() -> Unit)? + binders: (SqlPreparedStatement.() -> Unit)?, ): QueryResult = execute(identifier, { AndroidPreparedStatement(database.compileStatement(sql)) }, binders, { execute() }) override fun executeQuery( @@ -174,7 +174,7 @@ class AndroidSqliteDriver private constructor( sql: String, mapper: (SqlCursor) -> R, parameters: Int, - binders: (SqlPreparedStatement.() -> Unit)? + binders: (SqlPreparedStatement.() -> Unit)?, ) = execute(identifier, { AndroidQuery(sql, database, parameters) }, binders) { executeQuery(mapper) } override fun close() { @@ -189,7 +189,7 @@ class AndroidSqliteDriver private constructor( private val callbacks = callbacks constructor( - schema: SqlSchema + schema: SqlSchema, ) : this(schema, *emptyArray()) override fun onCreate(db: SupportSQLiteDatabase) { @@ -199,14 +199,15 @@ class AndroidSqliteDriver private constructor( override fun onUpgrade( db: SupportSQLiteDatabase, oldVersion: Int, - newVersion: Int + newVersion: Int, ) { if (callbacks.isNotEmpty()) { schema.migrateWithCallbacks(AndroidSqliteDriver(openHelper = null, database = db, cacheSize = 1), oldVersion, newVersion, *callbacks) } else { schema.migrate( AndroidSqliteDriver(openHelper = null, database = db, cacheSize = 1), - oldVersion, newVersion + oldVersion, + newVersion, ) } } @@ -220,7 +221,7 @@ internal interface AndroidStatement : SqlPreparedStatement { } private class AndroidPreparedStatement( - private val statement: SupportSQLiteStatement + private val statement: SupportSQLiteStatement, ) : AndroidStatement { override fun bindBytes(index: Int, bytes: ByteArray?) { if (bytes == null) statement.bindNull(index + 1) else statement.bindBlob(index + 1, bytes) @@ -257,7 +258,7 @@ private class AndroidPreparedStatement( private class AndroidQuery( private val sql: String, private val database: SupportSQLiteDatabase, - private val argCount: Int + private val argCount: Int, ) : SupportSQLiteQuery, AndroidStatement { private val binds = MutableList<((SupportSQLiteProgram) -> Unit)?>(argCount) { null } @@ -307,7 +308,7 @@ private class AndroidQuery( } private class AndroidCursor( - private val cursor: Cursor + private val cursor: Cursor, ) : SqlCursor { override fun next() = cursor.moveToNext() override fun getString(index: Int) = if (cursor.isNull(index)) null else cursor.getString(index) diff --git a/drivers/android-driver/src/test/java/com/squareup/sqldelight/android/AndroidDriverTest.kt b/drivers/android-driver/src/test/java/com/squareup/sqldelight/android/AndroidDriverTest.kt index 6c4f29e11eb..c510dfc5004 100644 --- a/drivers/android-driver/src/test/java/com/squareup/sqldelight/android/AndroidDriverTest.kt +++ b/drivers/android-driver/src/test/java/com/squareup/sqldelight/android/AndroidDriverTest.kt @@ -28,10 +28,13 @@ class AndroidDriverTest : DriverTest() { driver.executeQuery(1, "SELECT * FROM test", {}, 0, { bindable = this }) driver.executeQuery( - 1, "SELECT * FROM test", {}, 0, + 1, + "SELECT * FROM test", + {}, + 0, { assertSame(bindable, this) - } + }, ) } @@ -44,10 +47,13 @@ class AndroidDriverTest : DriverTest() { driver.executeQuery(2, "SELECT * FROM test", {}, 0) driver.executeQuery( - 1, "SELECT * FROM test", {}, 0, + 1, + "SELECT * FROM test", + {}, + 0, { assertNotSame(bindable, this) - } + }, ) } @@ -74,7 +80,7 @@ class AndroidDriverTest : DriverTest() { context = getApplicationContext(), factory = factory, name = "name", - useNoBackupDirectory = true + useNoBackupDirectory = true, ) assertTrue(factory.lastConfiguration.useNoBackupDirectory) @@ -88,7 +94,7 @@ class AndroidDriverTest : DriverTest() { schema = schema, context = getApplicationContext(), factory = factory, - useNoBackupDirectory = false + useNoBackupDirectory = false, ) assertFalse(factory.lastConfiguration.useNoBackupDirectory) diff --git a/drivers/android-driver/src/test/java/com/squareup/sqldelight/android/AndroidTransacterTest.kt b/drivers/android-driver/src/test/java/com/squareup/sqldelight/android/AndroidTransacterTest.kt index 7932201d76b..0887965cc81 100644 --- a/drivers/android-driver/src/test/java/com/squareup/sqldelight/android/AndroidTransacterTest.kt +++ b/drivers/android-driver/src/test/java/com/squareup/sqldelight/android/AndroidTransacterTest.kt @@ -24,48 +24,48 @@ class AndroidTransacterTest : TransacterTest() { @Test fun `detect the afterRollback call has escaped the original transaction thread in transaction()`() { assertChecksThreadConfinement( scope = { transaction(false, it) }, - block = { afterRollback {} } + block = { afterRollback {} }, ) } @Test fun `detect the afterCommit call has escaped the original transaction thread in transaction()`() { assertChecksThreadConfinement( scope = { transaction(false, it) }, - block = { afterCommit {} } + block = { afterCommit {} }, ) } @Test fun `detect the rollback call has escaped the original transaction thread in transaction()`() { assertChecksThreadConfinement( scope = { transaction(false, it) }, - block = { rollback() } + block = { rollback() }, ) } @Test fun `detect the afterRollback call has escaped the original transaction thread in transactionWithReturn()`() { assertChecksThreadConfinement>( scope = { transactionWithResult(false, it) }, - block = { afterRollback {} } + block = { afterRollback {} }, ) } @Test fun `detect the afterCommit call has escaped the original transaction thread in transactionWithReturn()`() { assertChecksThreadConfinement>( scope = { transactionWithResult(false, it) }, - block = { afterCommit {} } + block = { afterCommit {} }, ) } @Test fun `detect the rollback call has escaped the original transaction thread in transactionWithReturn()`() { assertChecksThreadConfinement>( scope = { transactionWithResult(false, it) }, - block = { rollback(Unit) } + block = { rollback(Unit) }, ) } private inline fun assertChecksThreadConfinement( crossinline scope: Transacter.(T.() -> Unit) -> Unit, - crossinline block: T.() -> Unit + crossinline block: T.() -> Unit, ) { lateinit var thread: Thread var result: Result? = null diff --git a/drivers/driver-test/src/commonMain/kotlin/com/squareup/sqldelight/driver/test/DriverTest.kt b/drivers/driver-test/src/commonMain/kotlin/com/squareup/sqldelight/driver/test/DriverTest.kt index 33e141fa50c..d5da9eed896 100644 --- a/drivers/driver-test/src/commonMain/kotlin/com/squareup/sqldelight/driver/test/DriverTest.kt +++ b/drivers/driver-test/src/commonMain/kotlin/com/squareup/sqldelight/driver/test/DriverTest.kt @@ -31,8 +31,8 @@ abstract class DriverTest { | id INTEGER PRIMARY KEY, | value TEXT |); - """.trimMargin(), - 0 + """.trimMargin(), + 0, ) driver.execute( 1, @@ -44,8 +44,8 @@ abstract class DriverTest { | blob_value BLOB, | real_value REAL |); - """.trimMargin(), - 0 + """.trimMargin(), + 0, ) return QueryResult.Unit } @@ -53,7 +53,7 @@ abstract class DriverTest { override fun migrate( driver: SqlDriver, oldVersion: Int, - newVersion: Int + newVersion: Int, ) = QueryResult.Unit } private var transacter by Atomic(null) @@ -162,7 +162,7 @@ abstract class DriverTest { assertTrue(it.next()) assertEquals(2, it.getLong(0)) assertEquals("Jake", it.getString(1)) - } + }, ) // Second time running the query is fine @@ -174,7 +174,7 @@ abstract class DriverTest { assertTrue(it.next()) assertEquals(2, it.getLong(0)) assertEquals("Jake", it.getString(1)) - } + }, ) } diff --git a/drivers/driver-test/src/commonMain/kotlin/com/squareup/sqldelight/driver/test/QueryTest.kt b/drivers/driver-test/src/commonMain/kotlin/com/squareup/sqldelight/driver/test/QueryTest.kt index be92a47adbe..ed4a59fda03 100644 --- a/drivers/driver-test/src/commonMain/kotlin/com/squareup/sqldelight/driver/test/QueryTest.kt +++ b/drivers/driver-test/src/commonMain/kotlin/com/squareup/sqldelight/driver/test/QueryTest.kt @@ -16,7 +16,8 @@ import kotlin.test.assertTrue abstract class QueryTest { private val mapper = { cursor: SqlCursor -> TestData( - cursor.getLong(0)!!, cursor.getString(1)!! + cursor.getLong(0)!!, + cursor.getString(1)!!, ) } @@ -38,7 +39,7 @@ abstract class QueryTest { value TEXT NOT NULL ); """.trimIndent(), - 0 + 0, ) return QueryResult.Unit } @@ -46,12 +47,12 @@ abstract class QueryTest { override fun migrate( driver: SqlDriver, oldVersion: Int, - newVersion: Int + newVersion: Int, ): QueryResult { // No-op. return QueryResult.Unit } - } + }, ) } diff --git a/drivers/driver-test/src/commonMain/kotlin/com/squareup/sqldelight/driver/test/TransacterTest.kt b/drivers/driver-test/src/commonMain/kotlin/com/squareup/sqldelight/driver/test/TransacterTest.kt index b56a723a392..2af81293f33 100644 --- a/drivers/driver-test/src/commonMain/kotlin/com/squareup/sqldelight/driver/test/TransacterTest.kt +++ b/drivers/driver-test/src/commonMain/kotlin/com/squareup/sqldelight/driver/test/TransacterTest.kt @@ -18,15 +18,17 @@ abstract class TransacterTest { abstract fun setupDatabase(schema: SqlSchema): SqlDriver @BeforeTest fun setup() { - val driver = setupDatabase(object : SqlSchema { - override val version = 1 - override fun create(driver: SqlDriver): QueryResult = QueryResult.Unit - override fun migrate( - driver: SqlDriver, - oldVersion: Int, - newVersion: Int - ): QueryResult = QueryResult.Unit - }) + val driver = setupDatabase( + object : SqlSchema { + override val version = 1 + override fun create(driver: SqlDriver): QueryResult = QueryResult.Unit + override fun migrate( + driver: SqlDriver, + oldVersion: Int, + newVersion: Int, + ): QueryResult = QueryResult.Unit + }, + ) transacter = object : TransacterImpl(driver) {} this.driver = driver } diff --git a/drivers/jdbc-driver/src/main/kotlin/app/cash/sqldelight/driver/jdbc/JdbcDriver.kt b/drivers/jdbc-driver/src/main/kotlin/app/cash/sqldelight/driver/jdbc/JdbcDriver.kt index a8cdd4d9c3b..1a7f01e789e 100644 --- a/drivers/jdbc-driver/src/main/kotlin/app/cash/sqldelight/driver/jdbc/JdbcDriver.kt +++ b/drivers/jdbc-driver/src/main/kotlin/app/cash/sqldelight/driver/jdbc/JdbcDriver.kt @@ -1,4 +1,5 @@ @file:JvmName("JdbcDrivers") + package app.cash.sqldelight.driver.jdbc import app.cash.sqldelight.Query @@ -56,7 +57,7 @@ interface ConnectionManager { class Transaction( override val enclosingTransaction: Transaction?, private val connectionManager: ConnectionManager, - val connection: Connection + val connection: Connection, ) : Transacter.Transaction() { override fun endTransaction(successful: Boolean): QueryResult { if (enclosingTransaction == null) { @@ -118,7 +119,7 @@ abstract class JdbcDriver : SqlDriver, ConnectionManager { identifier: Int?, sql: String, parameters: Int, - binders: (SqlPreparedStatement.() -> Unit)? + binders: (SqlPreparedStatement.() -> Unit)?, ): QueryResult { val (connection, onClose) = connectionAndClose() try { @@ -127,7 +128,7 @@ abstract class JdbcDriver : SqlDriver, ConnectionManager { JdbcPreparedStatement(jdbcStatement) .apply { if (binders != null) this.binders() } .execute() - } + }, ) } finally { onClose() @@ -139,14 +140,14 @@ abstract class JdbcDriver : SqlDriver, ConnectionManager { sql: String, mapper: (SqlCursor) -> R, parameters: Int, - binders: (SqlPreparedStatement.() -> Unit)? + binders: (SqlPreparedStatement.() -> Unit)?, ): QueryResult { val (connection, onClose) = connectionAndClose() try { return QueryResult.Value( JdbcPreparedStatement(connection.prepareStatement(sql)) .apply { if (binders != null) this.binders() } - .executeQuery(mapper) + .executeQuery(mapper), ) } finally { onClose() @@ -174,7 +175,7 @@ abstract class JdbcDriver : SqlDriver, ConnectionManager { * After binding, [execute] executes the query without a result, while [executeQuery] returns [JdbcCursor]. */ class JdbcPreparedStatement( - private val preparedStatement: PreparedStatement + private val preparedStatement: PreparedStatement, ) : SqlPreparedStatement { override fun bindBytes(index: Int, bytes: ByteArray?) { if (bytes == null) { @@ -299,6 +300,7 @@ class JdbcCursor(val resultSet: ResultSet) : SqlCursor { override fun getDouble(index: Int): Double? = getAtIndex(index, resultSet::getDouble) fun getBigDecimal(index: Int): BigDecimal? = resultSet.getBigDecimal(index + 1) inline fun getObject(index: Int): T? = resultSet.getObject(index + 1, T::class.java) + @Suppress("UNCHECKED_CAST") fun getArray(index: Int) = getAtIndex(index, resultSet::getArray)?.array as Array? diff --git a/drivers/native-driver/src/linuxMain/kotlin/app/cash/sqldelight/driver/native/util/PTHREAD_MUTEX_RECURSIVE.kt b/drivers/native-driver/src/linuxMain/kotlin/app/cash/sqldelight/driver/native/util/PthreadMutexRecursive.kt similarity index 100% rename from drivers/native-driver/src/linuxMain/kotlin/app/cash/sqldelight/driver/native/util/PTHREAD_MUTEX_RECURSIVE.kt rename to drivers/native-driver/src/linuxMain/kotlin/app/cash/sqldelight/driver/native/util/PthreadMutexRecursive.kt diff --git a/drivers/native-driver/src/mingwMain/kotlin/app/cash/sqldelight/driver/native/util/PoolLock.kt b/drivers/native-driver/src/mingwMain/kotlin/app/cash/sqldelight/driver/native/util/PoolLock.kt index a114504e0b7..7839660ac06 100644 --- a/drivers/native-driver/src/mingwMain/kotlin/app/cash/sqldelight/driver/native/util/PoolLock.kt +++ b/drivers/native-driver/src/mingwMain/kotlin/app/cash/sqldelight/driver/native/util/PoolLock.kt @@ -26,8 +26,9 @@ internal actual class PoolLock actual constructor(reentrant: Boolean) { private val attr = nativeHeap.alloc() .apply { pthread_mutexattr_init(ptr) - if (reentrant) + if (reentrant) { pthread_mutexattr_settype(ptr, PTHREAD_MUTEX_RECURSIVE.toInt()) + } } private val mutex = nativeHeap.alloc() .apply { pthread_mutex_init(ptr, attr.ptr) } @@ -35,7 +36,7 @@ internal actual class PoolLock actual constructor(reentrant: Boolean) { .apply { pthread_cond_init(ptr, null) } actual fun withLock( - action: CriticalSection.() -> R + action: CriticalSection.() -> R, ): R { check(isActive.value) pthread_mutex_lock(mutex.ptr) diff --git a/drivers/native-driver/src/nativeDarwinMain/kotlin/app/cash/sqldelight/driver/native/util/PTHREAD_MUTEX_RECURSIVE.kt b/drivers/native-driver/src/nativeDarwinMain/kotlin/app/cash/sqldelight/driver/native/util/PthreadMutexRecursive.kt similarity index 100% rename from drivers/native-driver/src/nativeDarwinMain/kotlin/app/cash/sqldelight/driver/native/util/PTHREAD_MUTEX_RECURSIVE.kt rename to drivers/native-driver/src/nativeDarwinMain/kotlin/app/cash/sqldelight/driver/native/util/PthreadMutexRecursive.kt diff --git a/drivers/native-driver/src/nativeLinuxLikeMain/kotlin/app/cash/sqldelight/driver/native/util/PoolLock.kt b/drivers/native-driver/src/nativeLinuxLikeMain/kotlin/app/cash/sqldelight/driver/native/util/PoolLock.kt index 1db14a02bc9..c8c82f4792f 100644 --- a/drivers/native-driver/src/nativeLinuxLikeMain/kotlin/app/cash/sqldelight/driver/native/util/PoolLock.kt +++ b/drivers/native-driver/src/nativeLinuxLikeMain/kotlin/app/cash/sqldelight/driver/native/util/PoolLock.kt @@ -25,8 +25,9 @@ internal actual class PoolLock actual constructor(reentrant: Boolean) { private val attr = nativeHeap.alloc() .apply { pthread_mutexattr_init(ptr) - if (reentrant) + if (reentrant) { pthread_mutexattr_settype(ptr, pthread_mutex_recursive) + } } private val mutex = nativeHeap.alloc() .apply { pthread_mutex_init(ptr, attr.ptr) } @@ -34,7 +35,7 @@ internal actual class PoolLock actual constructor(reentrant: Boolean) { .apply { pthread_cond_init(ptr, null) } actual fun withLock( - action: CriticalSection.() -> R + action: CriticalSection.() -> R, ): R { check(isActive.value) pthread_mutex_lock(mutex.ptr) diff --git a/drivers/native-driver/src/nativeMain/kotlin/app/cash/sqldelight/driver/native/NativeSqlDatabase.kt b/drivers/native-driver/src/nativeMain/kotlin/app/cash/sqldelight/driver/native/NativeSqlDatabase.kt index 754d3c1c6bc..797b6931643 100644 --- a/drivers/native-driver/src/nativeMain/kotlin/app/cash/sqldelight/driver/native/NativeSqlDatabase.kt +++ b/drivers/native-driver/src/nativeMain/kotlin/app/cash/sqldelight/driver/native/NativeSqlDatabase.kt @@ -23,7 +23,7 @@ import kotlin.native.concurrent.ensureNeverFrozen sealed class ConnectionWrapper : SqlDriver { internal abstract fun accessConnection( readOnly: Boolean, - block: ThreadConnection.() -> R + block: ThreadConnection.() -> R, ): R private fun accessStatement( @@ -31,7 +31,7 @@ sealed class ConnectionWrapper : SqlDriver { identifier: Int?, sql: String, binders: (SqlPreparedStatement.() -> Unit)?, - block: (Statement) -> R + block: (Statement) -> R, ): R { return accessConnection(readOnly) { val statement = useStatement(identifier, sql) @@ -52,11 +52,11 @@ sealed class ConnectionWrapper : SqlDriver { identifier: Int?, sql: String, parameters: Int, - binders: (SqlPreparedStatement.() -> Unit)? + binders: (SqlPreparedStatement.() -> Unit)?, ): QueryResult = QueryResult.Value( accessStatement(false, identifier, sql, binders) { statement -> statement.executeUpdateDelete().toLong() - } + }, ) final override fun executeQuery( @@ -64,11 +64,11 @@ sealed class ConnectionWrapper : SqlDriver { sql: String, mapper: (SqlCursor) -> R, parameters: Int, - binders: (SqlPreparedStatement.() -> Unit)? + binders: (SqlPreparedStatement.() -> Unit)?, ): QueryResult = QueryResult.Value( accessStatement(true, identifier, sql, binders) { statement -> mapper(SqliterSqlCursor(statement.query())) - } + }, ) } @@ -106,16 +106,16 @@ class NativeSqliteDriver( ) : ConnectionWrapper(), SqlDriver { constructor( configuration: DatabaseConfiguration, - maxReaderConnections: Int = 1 + maxReaderConnections: Int = 1, ) : this( databaseManager = createDatabaseManager(configuration), - maxReaderConnections = maxReaderConnections + maxReaderConnections = maxReaderConnections, ) constructor( schema: SqlSchema, name: String, - maxReaderConnections: Int = 1 + maxReaderConnections: Int = 1, ) : this( configuration = DatabaseConfiguration( name = name, @@ -125,9 +125,9 @@ class NativeSqliteDriver( }, upgrade = { connection, oldVersion, newVersion -> wrapConnection(connection) { schema.migrate(it, oldVersion, newVersion) } - } + }, ), - maxReaderConnections = maxReaderConnections + maxReaderConnections = maxReaderConnections, ) // A pool of reader connections used by all operations not in a transaction @@ -222,7 +222,7 @@ class NativeSqliteDriver( */ override fun accessConnection( readOnly: Boolean, - block: ThreadConnection.() -> R + block: ThreadConnection.() -> R, ): R { val mine = borrowedConnectionThread.get() @@ -263,8 +263,8 @@ fun inMemoryDriver(schema: SqlSchema): NativeSqliteDriver = NativeSqliteDriver( }, upgrade = { connection, oldVersion, newVersion -> wrapConnection(connection) { schema.migrate(it, oldVersion, newVersion) } - } - ) + }, + ), ) /** @@ -277,7 +277,7 @@ fun inMemoryDriver(schema: SqlSchema): NativeSqliteDriver = NativeSqliteDriver( */ fun wrapConnection( connection: DatabaseConnection, - block: (SqlDriver) -> Unit + block: (SqlDriver) -> Unit, ) { val conn = SqliterWrappedConnection(ThreadConnection(connection) {}) try { @@ -292,7 +292,7 @@ fun wrapConnection( * don't want the polling. */ internal class SqliterWrappedConnection( - private val threadConnection: ThreadConnection + private val threadConnection: ThreadConnection, ) : ConnectionWrapper(), SqlDriver { override fun currentTransaction(): Transacter.Transaction? = threadConnection.transaction.value @@ -301,7 +301,7 @@ internal class SqliterWrappedConnection( override fun accessConnection( readOnly: Boolean, - block: ThreadConnection.() -> R + block: ThreadConnection.() -> R, ): R = threadConnection.block() override fun addListener(listener: Query.Listener, queryKeys: Array) { @@ -330,7 +330,7 @@ internal class SqliterWrappedConnection( */ internal class ThreadConnection( private val connection: DatabaseConnection, - private val onEndTransaction: (ThreadConnection) -> Unit + private val onEndTransaction: (ThreadConnection) -> Unit, ) : Closeable { internal val transaction = ThreadLocalRef() internal val closed: Boolean @@ -384,7 +384,7 @@ internal class ThreadConnection( } private inner class Transaction( - override val enclosingTransaction: Transacter.Transaction? + override val enclosingTransaction: Transacter.Transaction?, ) : Transacter.Transaction() { init { ensureNeverFrozen() diff --git a/drivers/native-driver/src/nativeMain/kotlin/app/cash/sqldelight/driver/native/Pool.kt b/drivers/native-driver/src/nativeMain/kotlin/app/cash/sqldelight/driver/native/Pool.kt index 3196003ffc6..d8008411c7e 100644 --- a/drivers/native-driver/src/nativeMain/kotlin/app/cash/sqldelight/driver/native/Pool.kt +++ b/drivers/native-driver/src/nativeMain/kotlin/app/cash/sqldelight/driver/native/Pool.kt @@ -70,8 +70,9 @@ internal class Pool(internal val capacity: Int, private val produ } fun close() { - if (!poolLock.close()) + if (!poolLock.close()) { return + } val entries = entriesRef.value val done = entriesRef.compareAndSet(entries, null) diff --git a/drivers/native-driver/src/nativeMain/kotlin/app/cash/sqldelight/driver/native/SqliterStatement.kt b/drivers/native-driver/src/nativeMain/kotlin/app/cash/sqldelight/driver/native/SqliterStatement.kt index 82b2ffa4df0..6252bf5075b 100644 --- a/drivers/native-driver/src/nativeMain/kotlin/app/cash/sqldelight/driver/native/SqliterStatement.kt +++ b/drivers/native-driver/src/nativeMain/kotlin/app/cash/sqldelight/driver/native/SqliterStatement.kt @@ -11,7 +11,7 @@ import co.touchlab.sqliter.bindString * @param [recycle] A function which recycles any resources this statement is backed by. */ internal class SqliterStatement( - private val statement: Statement + private val statement: Statement, ) : SqlPreparedStatement { override fun bindBytes(index: Int, bytes: ByteArray?) { statement.bindBlob(index + 1, bytes) @@ -36,7 +36,7 @@ internal class SqliterStatement( null -> null true -> 1L false -> 0L - } + }, ) } } diff --git a/drivers/native-driver/src/nativeMain/kotlin/app/cash/sqldelight/driver/native/util/BasicMutableMap.kt b/drivers/native-driver/src/nativeMain/kotlin/app/cash/sqldelight/driver/native/util/BasicMutableMap.kt index ea5f1cadd3b..9e4da7c88f1 100644 --- a/drivers/native-driver/src/nativeMain/kotlin/app/cash/sqldelight/driver/native/util/BasicMutableMap.kt +++ b/drivers/native-driver/src/nativeMain/kotlin/app/cash/sqldelight/driver/native/util/BasicMutableMap.kt @@ -89,7 +89,7 @@ private class BasicMutableMapStrict : BasicMutableMap { Pair(key, value), *mapReference.value.map { entry -> Pair(entry.key, entry.value) - }.toTypedArray() + }.toTypedArray(), ).freeze() } @@ -101,8 +101,9 @@ private class BasicMutableMapStrict : BasicMutableMap { val resultMap = mutableMapOf() sourceMap.keys.subtract(listOf(key)).forEach { key -> val value = sourceMap[key] - if (value != null) + if (value != null) { resultMap[key] = value + } } mapReference.value = resultMap.freeze() } diff --git a/drivers/native-driver/src/nativeMain/kotlin/app/cash/sqldelight/driver/native/util/MemoryModel.kt b/drivers/native-driver/src/nativeMain/kotlin/app/cash/sqldelight/driver/native/util/MaybeFreeze.kt similarity index 100% rename from drivers/native-driver/src/nativeMain/kotlin/app/cash/sqldelight/driver/native/util/MemoryModel.kt rename to drivers/native-driver/src/nativeMain/kotlin/app/cash/sqldelight/driver/native/util/MaybeFreeze.kt diff --git a/drivers/native-driver/src/nativeMain/kotlin/app/cash/sqldelight/driver/native/util/PoolLock.kt b/drivers/native-driver/src/nativeMain/kotlin/app/cash/sqldelight/driver/native/util/PoolLock.kt index 44ca1a7637d..0c718fcdabd 100644 --- a/drivers/native-driver/src/nativeMain/kotlin/app/cash/sqldelight/driver/native/util/PoolLock.kt +++ b/drivers/native-driver/src/nativeMain/kotlin/app/cash/sqldelight/driver/native/util/PoolLock.kt @@ -3,7 +3,7 @@ package app.cash.sqldelight.driver.native.util @Suppress("NO_ACTUAL_FOR_EXPECT") internal expect class PoolLock(reentrant: Boolean = false) { fun withLock( - action: CriticalSection.() -> R + action: CriticalSection.() -> R, ): R /** diff --git a/drivers/native-driver/src/nativeTest/kotlin/com/squareup/sqldelight/drivers/native/LazyDriverBaseTest.kt b/drivers/native-driver/src/nativeTest/kotlin/com/squareup/sqldelight/drivers/native/LazyDriverBaseTest.kt index 36e2a70c93d..34ef1c66a6f 100644 --- a/drivers/native-driver/src/nativeTest/kotlin/com/squareup/sqldelight/drivers/native/LazyDriverBaseTest.kt +++ b/drivers/native-driver/src/nativeTest/kotlin/com/squareup/sqldelight/drivers/native/LazyDriverBaseTest.kt @@ -51,8 +51,8 @@ abstract class LazyDriverBaseTest { | id INTEGER PRIMARY KEY, | value TEXT |); - """.trimMargin(), - 0 + """.trimMargin(), + 0, ) driver.execute( 30, @@ -64,8 +64,8 @@ abstract class LazyDriverBaseTest { | blob_value BLOB, | real_value REAL |); - """.trimMargin(), - 0 + """.trimMargin(), + 0, ) return QueryResult.Unit } @@ -73,7 +73,7 @@ abstract class LazyDriverBaseTest { override fun migrate( driver: SqlDriver, oldVersion: Int, - newVersion: Int + newVersion: Int, ) = QueryResult.Unit } } @@ -85,7 +85,7 @@ abstract class LazyDriverBaseTest { private fun setupDatabase( schema: SqlSchema, - config: DatabaseConfiguration = defaultConfiguration(schema) + config: DatabaseConfiguration = defaultConfiguration(schema), ): NativeSqliteDriver { deleteDatabase(config.name!!) // This isn't pretty, but just for test @@ -103,7 +103,7 @@ abstract class LazyDriverBaseTest { } }, extendedConfig = DatabaseConfiguration.Extended(busyTimeout = 20_000), - inMemory = true + inMemory = true, ) } } diff --git a/drivers/native-driver/src/nativeTest/kotlin/com/squareup/sqldelight/drivers/native/connectionpool/BaseConcurrencyTest.kt b/drivers/native-driver/src/nativeTest/kotlin/com/squareup/sqldelight/drivers/native/connectionpool/BaseConcurrencyTest.kt index 3384b97e31b..253d00e19e4 100644 --- a/drivers/native-driver/src/nativeTest/kotlin/com/squareup/sqldelight/drivers/native/connectionpool/BaseConcurrencyTest.kt +++ b/drivers/native-driver/src/nativeTest/kotlin/com/squareup/sqldelight/drivers/native/connectionpool/BaseConcurrencyTest.kt @@ -20,7 +20,7 @@ abstract class BaseConcurrencyTest { 0, "SELECT count(*) FROM test", { it.next(); it.getLong(0)!! }, - 0 + 0, ).value } @@ -55,7 +55,7 @@ abstract class BaseConcurrencyTest { schema: SqlSchema, dbType: DbType, configBase: DatabaseConfiguration, - maxReaderConnections: Int = 4 + maxReaderConnections: Int = 4, ): SqlDriver { // Some failing tests can leave the db in a weird state, so on each run we have a different db per test val name = "testdb_${globalDbCount.addAndGet(1)}" @@ -68,34 +68,34 @@ abstract class BaseConcurrencyTest { wrapConnection(conn) { driver -> schema.create(driver) } - } + }, ) return when (dbType) { DbType.RegularWal -> { NativeSqliteDriver( configCommon, - maxReaderConnections = maxReaderConnections + maxReaderConnections = maxReaderConnections, ) } DbType.RegularDelete -> { val config = configCommon.copy(journalMode = JournalMode.DELETE) NativeSqliteDriver( config, - maxReaderConnections = maxReaderConnections + maxReaderConnections = maxReaderConnections, ) } DbType.InMemoryShared -> { val config = configCommon.copy(inMemory = true) NativeSqliteDriver( config, - maxReaderConnections = maxReaderConnections + maxReaderConnections = maxReaderConnections, ) } DbType.InMemorySingle -> { val config = configCommon.copy(name = null, inMemory = true) NativeSqliteDriver( config, - maxReaderConnections = maxReaderConnections + maxReaderConnections = maxReaderConnections, ) } } @@ -122,7 +122,7 @@ abstract class BaseConcurrencyTest { value TEXT NOT NULL ); """.trimIndent(), - 0 + 0, ) return QueryResult.Unit } @@ -130,11 +130,11 @@ abstract class BaseConcurrencyTest { override fun migrate( driver: SqlDriver, oldVersion: Int, - newVersion: Int + newVersion: Int, ) = QueryResult.Unit }, dbType, - configBase + configBase, ) } @@ -147,8 +147,9 @@ abstract class BaseConcurrencyTest { wasTimeout = (currentTimeMillis() - start) > timeout } - if (wasTimeout) + if (wasTimeout) { throw IllegalStateException("Timeout $timeout exceeded") + } } fun initDriver(dbType: DbType) { diff --git a/drivers/native-driver/src/nativeTest/kotlin/com/squareup/sqldelight/drivers/native/connectionpool/WalConcurrencyTest.kt b/drivers/native-driver/src/nativeTest/kotlin/com/squareup/sqldelight/drivers/native/connectionpool/WalConcurrencyTest.kt index 08e8f26434c..9fafee441af 100644 --- a/drivers/native-driver/src/nativeTest/kotlin/com/squareup/sqldelight/drivers/native/connectionpool/WalConcurrencyTest.kt +++ b/drivers/native-driver/src/nativeTest/kotlin/com/squareup/sqldelight/drivers/native/connectionpool/WalConcurrencyTest.kt @@ -96,7 +96,8 @@ class WalConcurrencyTest : BaseConcurrencyTest() { private val mapper = { cursor: SqlCursor -> TestData( - cursor.getLong(0)!!, cursor.getString(1)!! + cursor.getLong(0)!!, + cursor.getString(1)!!, ) } diff --git a/drivers/r2dbc-driver/src/main/kotlin/app/cash/sqldelight/driver/r2dbc/R2dbcDriver.kt b/drivers/r2dbc-driver/src/main/kotlin/app/cash/sqldelight/driver/r2dbc/R2dbcDriver.kt index c0cbdd1cca4..848110c617b 100644 --- a/drivers/r2dbc-driver/src/main/kotlin/app/cash/sqldelight/driver/r2dbc/R2dbcDriver.kt +++ b/drivers/r2dbc-driver/src/main/kotlin/app/cash/sqldelight/driver/r2dbc/R2dbcDriver.kt @@ -17,7 +17,7 @@ class R2dbcDriver(private val connection: Connection) : SqlDriver { sql: String, mapper: (SqlCursor) -> R, parameters: Int, - binders: (SqlPreparedStatement.() -> Unit)? + binders: (SqlPreparedStatement.() -> Unit)?, ): QueryResult { val prepared = connection.createStatement(sql).also { statement -> R2dbcPreparedStatement(statement).apply { if (binders != null) this.binders() } @@ -39,7 +39,7 @@ class R2dbcDriver(private val connection: Connection) : SqlDriver { identifier: Int?, sql: String, parameters: Int, - binders: (SqlPreparedStatement.() -> Unit)? + binders: (SqlPreparedStatement.() -> Unit)?, ): QueryResult { val prepared = connection.createStatement(sql).also { statement -> R2dbcPreparedStatement(statement).apply { if (binders != null) this.binders() } @@ -83,7 +83,7 @@ class R2dbcDriver(private val connection: Connection) : SqlDriver { private inner class Transaction( override val enclosingTransaction: Transacter.Transaction?, - private val connection: Connection + private val connection: Connection, ) : Transacter.Transaction() { override fun endTransaction(successful: Boolean): QueryResult = QueryResult.AsyncValue { if (enclosingTransaction == null) { diff --git a/drivers/sqlite-driver/src/main/kotlin/app/cash/sqldelight/driver/jdbc/sqlite/JdbcSqliteDriver.kt b/drivers/sqlite-driver/src/main/kotlin/app/cash/sqldelight/driver/jdbc/sqlite/JdbcSqliteDriver.kt index 1da0b9619a4..5b6b3f7f99d 100644 --- a/drivers/sqlite-driver/src/main/kotlin/app/cash/sqldelight/driver/jdbc/sqlite/JdbcSqliteDriver.kt +++ b/drivers/sqlite-driver/src/main/kotlin/app/cash/sqldelight/driver/jdbc/sqlite/JdbcSqliteDriver.kt @@ -17,7 +17,7 @@ class JdbcSqliteDriver constructor( * (creating an in-memory database) or a path to a file. */ url: String, - properties: Properties = Properties() + properties: Properties = Properties(), ) : JdbcDriver(), ConnectionManager by connectionManager(url, properties) { private val listeners = linkedMapOf>() @@ -70,7 +70,7 @@ private abstract class JdbcSqliteDriverConnectionManager : ConnectionManager { } private class InMemoryConnectionManager( - properties: Properties + properties: Properties, ) : JdbcSqliteDriverConnectionManager() { override var transaction: Transaction? = null private val connection: Connection = DriverManager.getConnection(IN_MEMORY, properties) diff --git a/drivers/sqljs-driver/src/main/kotlin/app/cash/sqldelight/driver/sqljs/sqljs.kt b/drivers/sqljs-driver/src/main/kotlin/app/cash/sqldelight/driver/sqljs/InitDb.kt similarity index 96% rename from drivers/sqljs-driver/src/main/kotlin/app/cash/sqldelight/driver/sqljs/sqljs.kt rename to drivers/sqljs-driver/src/main/kotlin/app/cash/sqldelight/driver/sqljs/InitDb.kt index 9a65b78d646..96b047603ad 100644 --- a/drivers/sqljs-driver/src/main/kotlin/app/cash/sqldelight/driver/sqljs/sqljs.kt +++ b/drivers/sqljs-driver/src/main/kotlin/app/cash/sqldelight/driver/sqljs/InitDb.kt @@ -10,7 +10,8 @@ operator fun InitDatabaseJsStatic.invoke(data: Uint8Array): Database = createIns operator fun InitSqlJsStatic.invoke(): Promise = asDynamic()() operator fun InitSqlJsStatic.invoke(config: Config?): Promise = asDynamic()(config) -@JsNonModule @JsModule("sql.js") +@JsNonModule +@JsModule("sql.js") external val initSqlJs: InitSqlJsStatic @Suppress("UNUSED_VARIABLE", "UNUSED_PARAMETER") diff --git a/drivers/sqljs-driver/src/main/kotlin/app/cash/sqldelight/driver/sqljs/JsSqlDriver.kt b/drivers/sqljs-driver/src/main/kotlin/app/cash/sqldelight/driver/sqljs/JsSqlDriver.kt index 0a2215b8ce4..2756f432c3b 100644 --- a/drivers/sqljs-driver/src/main/kotlin/app/cash/sqldelight/driver/sqljs/JsSqlDriver.kt +++ b/drivers/sqljs-driver/src/main/kotlin/app/cash/sqldelight/driver/sqljs/JsSqlDriver.kt @@ -52,7 +52,7 @@ class JsSqlDriver(private val db: Database) : SqlDriver { sql: String, mapper: (SqlCursor) -> R, parameters: Int, - binders: (SqlPreparedStatement.() -> Unit)? + binders: (SqlPreparedStatement.() -> Unit)?, ): QueryResult { val cursor = createOrGetStatement(identifier, sql).run { bind(parameters, binders) @@ -103,7 +103,7 @@ class JsSqlDriver(private val db: Database) : SqlDriver { override fun close() = db.close() private inner class Transaction( - override val enclosingTransaction: Transacter.Transaction? + override val enclosingTransaction: Transacter.Transaction?, ) : Transacter.Transaction() { override fun endTransaction(successful: Boolean): QueryResult { if (enclosingTransaction == null) { diff --git a/drivers/sqljs-driver/src/main/kotlin/app/cash/sqldelight/driver/sqljs/sqljs.SqlJs.kt b/drivers/sqljs-driver/src/main/kotlin/app/cash/sqldelight/driver/sqljs/SqlJs.kt similarity index 100% rename from drivers/sqljs-driver/src/main/kotlin/app/cash/sqldelight/driver/sqljs/sqljs.SqlJs.kt rename to drivers/sqljs-driver/src/main/kotlin/app/cash/sqldelight/driver/sqljs/SqlJs.kt diff --git a/drivers/sqljs-driver/src/main/kotlin/app/cash/sqldelight/driver/sqljs/worker/JsWorkerSqlDriver.kt b/drivers/sqljs-driver/src/main/kotlin/app/cash/sqldelight/driver/sqljs/worker/JsWorkerSqlDriver.kt index 18ad78c378a..44bed3f3278 100644 --- a/drivers/sqljs-driver/src/main/kotlin/app/cash/sqldelight/driver/sqljs/worker/JsWorkerSqlDriver.kt +++ b/drivers/sqljs-driver/src/main/kotlin/app/cash/sqldelight/driver/sqljs/worker/JsWorkerSqlDriver.kt @@ -26,7 +26,7 @@ private fun jsObject(block: T.() -> Unit): T { suspend fun initAsyncSqlDriver( workerPath: String = "/worker.sql-wasm.js", - schema: SqlSchema? = null + schema: SqlSchema? = null, ): SqlDriver = JsWorkerSqlDriver(Worker(workerPath)).withSchema(schema) suspend fun SqlDriver.withSchema(schema: SqlSchema? = null): SqlDriver = this.also { schema?.create(it)?.await() } @@ -113,7 +113,7 @@ class JsWorkerSqlDriver(private val worker: Worker) : SqlDriver { override fun currentTransaction(): Transacter.Transaction? = transaction private inner class Transaction( - override val enclosingTransaction: Transacter.Transaction? + override val enclosingTransaction: Transacter.Transaction?, ) : Transacter.Transaction() { override fun endTransaction(successful: Boolean): QueryResult = QueryResult.AsyncValue { if (enclosingTransaction == null) { @@ -220,7 +220,7 @@ internal class JsWorkerSqlPreparedStatement : SqlPreparedStatement { null -> null true -> 1.0 false -> 0.0 - } + }, ) } } diff --git a/drivers/sqljs-driver/src/test/kotlin/com/squareup/sqldelight/drivers/sqljs/JsDriverTest.kt b/drivers/sqljs-driver/src/test/kotlin/com/squareup/sqldelight/drivers/sqljs/JsDriverTest.kt index d8b3cb464b9..b2b501f41dc 100644 --- a/drivers/sqljs-driver/src/test/kotlin/com/squareup/sqldelight/drivers/sqljs/JsDriverTest.kt +++ b/drivers/sqljs-driver/src/test/kotlin/com/squareup/sqldelight/drivers/sqljs/JsDriverTest.kt @@ -29,8 +29,8 @@ class JsDriverTest { | id INTEGER PRIMARY KEY, | value TEXT |); - """.trimMargin(), - 0 + """.trimMargin(), + 0, ) driver.execute( 1, @@ -42,8 +42,8 @@ class JsDriverTest { | blob_value BLOB, | real_value REAL |); - """.trimMargin(), - 0 + """.trimMargin(), + 0, ) return QueryResult.Unit } @@ -51,7 +51,7 @@ class JsDriverTest { override fun migrate( driver: SqlDriver, oldVersion: Int, - newVersion: Int + newVersion: Int, ): QueryResult { // No-op. return QueryResult.Unit @@ -159,7 +159,7 @@ class JsDriverTest { assertTrue(it.next()) assertEquals(2, it.getLong(0)) assertEquals("Jake", it.getString(1)) - } + }, ) // Second time running the query is fine @@ -171,7 +171,7 @@ class JsDriverTest { assertTrue(it.next()) assertEquals(2, it.getLong(0)) assertEquals("Jake", it.getString(1)) - } + }, ) } diff --git a/drivers/sqljs-driver/src/test/kotlin/com/squareup/sqldelight/drivers/sqljs/JsQueryTest.kt b/drivers/sqljs-driver/src/test/kotlin/com/squareup/sqldelight/drivers/sqljs/JsQueryTest.kt index 324f0013800..a724363d7d4 100644 --- a/drivers/sqljs-driver/src/test/kotlin/com/squareup/sqldelight/drivers/sqljs/JsQueryTest.kt +++ b/drivers/sqljs-driver/src/test/kotlin/com/squareup/sqldelight/drivers/sqljs/JsQueryTest.kt @@ -20,7 +20,8 @@ class JsQueryTest { private val mapper = { cursor: SqlCursor -> TestData( - cursor.getLong(0)!!, cursor.getString(1)!! + cursor.getLong(0)!!, + cursor.getString(1)!!, ) } @@ -36,7 +37,7 @@ class JsQueryTest { value TEXT NOT NULL ); """.trimIndent(), - 0 + 0, ) return QueryResult.Unit } @@ -44,7 +45,7 @@ class JsQueryTest { override fun migrate( driver: SqlDriver, oldVersion: Int, - newVersion: Int + newVersion: Int, ): QueryResult { // No-op. return QueryResult.Unit diff --git a/drivers/sqljs-driver/src/test/kotlin/com/squareup/sqldelight/drivers/sqljs/JsTransacterTest.kt b/drivers/sqljs-driver/src/test/kotlin/com/squareup/sqldelight/drivers/sqljs/JsTransacterTest.kt index 0950543fca3..2fcda8a5b5b 100644 --- a/drivers/sqljs-driver/src/test/kotlin/com/squareup/sqldelight/drivers/sqljs/JsTransacterTest.kt +++ b/drivers/sqljs-driver/src/test/kotlin/com/squareup/sqldelight/drivers/sqljs/JsTransacterTest.kt @@ -23,7 +23,7 @@ class JsTransacterTest { override fun migrate( driver: SqlDriver, oldVersion: Int, - newVersion: Int + newVersion: Int, ) = QueryResult.Unit } diff --git a/drivers/sqljs-driver/src/test/kotlin/com/squareup/sqldelight/drivers/sqljs/JsWorkerDriverTest.kt b/drivers/sqljs-driver/src/test/kotlin/com/squareup/sqldelight/drivers/sqljs/JsWorkerDriverTest.kt index 3407739f373..9b82f13c14d 100644 --- a/drivers/sqljs-driver/src/test/kotlin/com/squareup/sqldelight/drivers/sqljs/JsWorkerDriverTest.kt +++ b/drivers/sqljs-driver/src/test/kotlin/com/squareup/sqldelight/drivers/sqljs/JsWorkerDriverTest.kt @@ -32,8 +32,8 @@ class JsWorkerDriverTest { | id INTEGER PRIMARY KEY, | value TEXT |); - """.trimMargin(), - 0 + """.trimMargin(), + 0, ).await() driver.execute( 1, @@ -45,8 +45,8 @@ class JsWorkerDriverTest { | blob_value BLOB, | real_value REAL |); - """.trimMargin(), - 0 + """.trimMargin(), + 0, ).await() } @@ -152,7 +152,7 @@ class JsWorkerDriverTest { assertTrue(it.next()) assertEquals(2, it.getLong(0)) assertEquals("Jake", it.getString(1)) - } + }, ) // Second time running the query is fine @@ -164,7 +164,7 @@ class JsWorkerDriverTest { assertTrue(it.next()) assertEquals(2, it.getLong(0)) assertEquals("Jake", it.getString(1)) - } + }, ) } diff --git a/drivers/sqljs-driver/src/test/kotlin/com/squareup/sqldelight/drivers/sqljs/JsWorkerTransacterTest.kt b/drivers/sqljs-driver/src/test/kotlin/com/squareup/sqldelight/drivers/sqljs/JsWorkerTransacterTest.kt index da735e48178..c3f7df0a54e 100644 --- a/drivers/sqljs-driver/src/test/kotlin/com/squareup/sqldelight/drivers/sqljs/JsWorkerTransacterTest.kt +++ b/drivers/sqljs-driver/src/test/kotlin/com/squareup/sqldelight/drivers/sqljs/JsWorkerTransacterTest.kt @@ -19,7 +19,7 @@ class JsWorkerTransacterTest { override fun migrate( driver: SqlDriver, oldVersion: Int, - newVersion: Int + newVersion: Int, ): QueryResult = QueryResult.Unit } diff --git a/drivers/sqljs-driver/src/test/kotlin/com/squareup/sqldelight/drivers/sqljs/SqlJsTest.kt b/drivers/sqljs-driver/src/test/kotlin/com/squareup/sqldelight/drivers/sqljs/SqlJsTest.kt index 7abbd5711f0..99ab6fed692 100644 --- a/drivers/sqljs-driver/src/test/kotlin/com/squareup/sqldelight/drivers/sqljs/SqlJsTest.kt +++ b/drivers/sqljs-driver/src/test/kotlin/com/squareup/sqldelight/drivers/sqljs/SqlJsTest.kt @@ -24,7 +24,7 @@ class SqlJsTest { | id INTEGER PRIMARY KEY, | value TEXT |); - """.trimMargin() + """.trimMargin(), ) db.run( """ @@ -35,7 +35,7 @@ class SqlJsTest { | blob_value BLOB, | real_value REAL |); - """.trimMargin() + """.trimMargin(), ) } } @@ -133,7 +133,7 @@ class SqlJsTest { val params = listOf( dynamicArrayOf(1, "Alec"), - dynamicArrayOf(2, "Jake") + dynamicArrayOf(2, "Jake"), ) params.forEach { param -> diff --git a/extensions/android-paging3/src/main/java/app/cash/sqldelight/paging3/OffsetQueryPagingSource.kt b/extensions/android-paging3/src/main/java/app/cash/sqldelight/paging3/OffsetQueryPagingSource.kt index cd494034903..2b8d72233e4 100644 --- a/extensions/android-paging3/src/main/java/app/cash/sqldelight/paging3/OffsetQueryPagingSource.kt +++ b/extensions/android-paging3/src/main/java/app/cash/sqldelight/paging3/OffsetQueryPagingSource.kt @@ -31,7 +31,7 @@ internal class OffsetQueryPagingSource( override val jumpingSupported get() = true override suspend fun load( - params: LoadParams + params: LoadParams, ): LoadResult = withContext(dispatcher) { try { val key = params.key ?: 0L @@ -52,7 +52,7 @@ internal class OffsetQueryPagingSource( prevKey = if (key <= 0L) null else key - params.loadSize, nextKey = if (key + params.loadSize >= count) null else key + params.loadSize, itemsBefore = maxOf(0L, key).toInt(), - itemsAfter = maxOf(0, (count - (key + params.loadSize))).toInt() + itemsAfter = maxOf(0, (count - (key + params.loadSize))).toInt(), ) } } catch (e: Exception) { diff --git a/extensions/android-paging3/src/main/java/app/cash/sqldelight/paging3/QueryPagingSource.kt b/extensions/android-paging3/src/main/java/app/cash/sqldelight/paging3/QueryPagingSource.kt index b3f4b636703..b651c7be7de 100644 --- a/extensions/android-paging3/src/main/java/app/cash/sqldelight/paging3/QueryPagingSource.kt +++ b/extensions/android-paging3/src/main/java/app/cash/sqldelight/paging3/QueryPagingSource.kt @@ -67,7 +67,7 @@ fun QueryPagingSource( queryProvider, countQuery, transacter, - dispatcher + dispatcher, ) /** diff --git a/extensions/android-paging3/src/test/java/app/cash/sqldelight/paging3/KeyedQueryPagingSourceTest.kt b/extensions/android-paging3/src/test/java/app/cash/sqldelight/paging3/KeyedQueryPagingSourceTest.kt index 1fbd1fd0f2b..1dc927645f5 100644 --- a/extensions/android-paging3/src/test/java/app/cash/sqldelight/paging3/KeyedQueryPagingSourceTest.kt +++ b/extensions/android-paging3/src/test/java/app/cash/sqldelight/paging3/KeyedQueryPagingSourceTest.kt @@ -111,9 +111,9 @@ class KeyedQueryPagingSourceTest { emptyList(), null, PagingConfig(3), - 0 - ) - ) + 0, + ), + ), ) } @@ -131,8 +131,8 @@ class KeyedQueryPagingSourceTest { listOf(results as LoadResult.Page), null, PagingConfig(3), - 0 - ) + 0, + ), ) assertEquals(0L, refreshKey) @@ -152,8 +152,8 @@ class KeyedQueryPagingSourceTest { listOf(results as LoadResult.Page), null, PagingConfig(3), - 0 - ) + 0, + ), ) assertEquals(6L, refreshKey) @@ -195,7 +195,7 @@ class KeyedQueryPagingSourceTest { """.trimMargin() return object : Query( - { cursor -> cursor.getLong(0)!! } + { cursor -> cursor.getLong(0)!! }, ) { override fun execute(mapper: (SqlCursor) -> R) = driver.executeQuery(identifier = 2, sql = sql, mapper = mapper, parameters = 2) { bindLong(0, beginInclusive) diff --git a/extensions/android-paging3/src/test/java/app/cash/sqldelight/paging3/OffsetQueryPagingSourceTest.kt b/extensions/android-paging3/src/test/java/app/cash/sqldelight/paging3/OffsetQueryPagingSourceTest.kt index 679ffd811fb..f5c11f1f70c 100644 --- a/extensions/android-paging3/src/test/java/app/cash/sqldelight/paging3/OffsetQueryPagingSourceTest.kt +++ b/extensions/android-paging3/src/test/java/app/cash/sqldelight/paging3/OffsetQueryPagingSourceTest.kt @@ -52,7 +52,7 @@ class OffsetQueryPagingSourceTest { this::query, countQuery(), transacter, - TestCoroutineDispatcher() + TestCoroutineDispatcher(), ) val results = runBlocking { source.load(Refresh(null, 2, false)) } @@ -66,7 +66,7 @@ class OffsetQueryPagingSourceTest { this::query, countQuery(), transacter, - TestCoroutineDispatcher() + TestCoroutineDispatcher(), ) val results = runBlocking { source.load(Refresh(null, 2, false)) } @@ -80,7 +80,7 @@ class OffsetQueryPagingSourceTest { this::query, countQuery(), transacter, - TestCoroutineDispatcher() + TestCoroutineDispatcher(), ) val results = runBlocking { source.load(Refresh(8, 2, false)) } @@ -94,7 +94,7 @@ class OffsetQueryPagingSourceTest { this::query, countQuery(), transacter, - TestCoroutineDispatcher() + TestCoroutineDispatcher(), ) runBlocking { @@ -113,7 +113,7 @@ class OffsetQueryPagingSourceTest { this::query, countQuery(), transacter, - TestCoroutineDispatcher() + TestCoroutineDispatcher(), ) val results = runBlocking { source.load(Refresh(9, 2, false)) } @@ -127,7 +127,7 @@ class OffsetQueryPagingSourceTest { this::query, countQuery(), transacter, - TestCoroutineDispatcher() + TestCoroutineDispatcher(), ) val results = runBlocking { source.load(Refresh(1L, 2, false)) } @@ -141,7 +141,7 @@ class OffsetQueryPagingSourceTest { this::query, countQuery(), transacter, - TestCoroutineDispatcher() + TestCoroutineDispatcher(), ) val results = runBlocking { source.load(Refresh(null, 2, false)) } @@ -155,7 +155,7 @@ class OffsetQueryPagingSourceTest { this::query, countQuery(), transacter, - TestCoroutineDispatcher() + TestCoroutineDispatcher(), ) val results = runBlocking { source.load(Refresh(4, 2, false)) } @@ -169,7 +169,7 @@ class OffsetQueryPagingSourceTest { this::query, countQuery(), transacter, - TestCoroutineDispatcher() + TestCoroutineDispatcher(), ) val results = runBlocking { source.load(Refresh(8, 2, false)) } @@ -183,7 +183,7 @@ class OffsetQueryPagingSourceTest { this::query, countQuery(), transacter, - TestCoroutineDispatcher() + TestCoroutineDispatcher(), ) val results = runBlocking { source.load(Refresh(9, 2, false)) } @@ -197,7 +197,7 @@ class OffsetQueryPagingSourceTest { this::query, countQuery(), transacter, - TestCoroutineDispatcher() + TestCoroutineDispatcher(), ) val results = runBlocking { source.load(Refresh(1, 2, false)) } @@ -211,7 +211,7 @@ class OffsetQueryPagingSourceTest { this::query, countQuery(), transacter, - TestCoroutineDispatcher() + TestCoroutineDispatcher(), ) runBlocking { @@ -230,7 +230,7 @@ class OffsetQueryPagingSourceTest { this::query, countQuery(), transacter, - TestCoroutineDispatcher() + TestCoroutineDispatcher(), ) runBlocking { @@ -246,7 +246,7 @@ class OffsetQueryPagingSourceTest { { _, _ -> query }, countQuery(), transacter, - TestCoroutineDispatcher() + TestCoroutineDispatcher(), ) runBlocking { source.load(Refresh(null, 0, false)) } @@ -257,7 +257,7 @@ class OffsetQueryPagingSourceTest { } private fun query(limit: Long, offset: Long) = object : Query( - { cursor -> cursor.getLong(0)!! } + { cursor -> cursor.getLong(0)!! }, ) { override fun execute(mapper: (SqlCursor) -> R) = driver.executeQuery(1, "SELECT value FROM testTable LIMIT ? OFFSET ?", mapper, 2) { bindLong(0, limit) @@ -273,8 +273,9 @@ class OffsetQueryPagingSourceTest { arrayOf("testTable"), driver, "Test.sq", - "count", "SELECT count(*) FROM testTable", - { it.getLong(0)!! } + "count", + "SELECT count(*) FROM testTable", + { it.getLong(0)!! }, ) private fun insert(value: Long, db: SqlDriver = driver) { diff --git a/extensions/async-extensions/src/commonMain/kotlin/app/cash/sqldelight/async/coroutines/DriverExtensions.kt b/extensions/async-extensions/src/commonMain/kotlin/app/cash/sqldelight/async/coroutines/DriverExtensions.kt index 19bf3b533ae..37beb5da57c 100644 --- a/extensions/async-extensions/src/commonMain/kotlin/app/cash/sqldelight/async/coroutines/DriverExtensions.kt +++ b/extensions/async-extensions/src/commonMain/kotlin/app/cash/sqldelight/async/coroutines/DriverExtensions.kt @@ -10,14 +10,14 @@ suspend fun SqlDriver.awaitQuery( sql: String, mapper: (SqlCursor) -> R, parameters: Int, - binders: (SqlPreparedStatement.() -> Unit)? = null + binders: (SqlPreparedStatement.() -> Unit)? = null, ): R = executeQuery(identifier, sql, mapper, parameters, binders).await() suspend fun SqlDriver.await( identifier: Int?, sql: String, parameters: Int, - binders: (SqlPreparedStatement.() -> Unit)? = null + binders: (SqlPreparedStatement.() -> Unit)? = null, ): Long = execute(identifier, sql, parameters, binders).await() suspend fun SqlSchema.awaitCreate(driver: SqlDriver) = create(driver).await() diff --git a/extensions/coroutines-extensions/src/commonMain/kotlin/app/cash/sqldelight/coroutines/FlowExtensions.kt b/extensions/coroutines-extensions/src/commonMain/kotlin/app/cash/sqldelight/coroutines/FlowExtensions.kt index 978120dc236..4bf36c36eb9 100644 --- a/extensions/coroutines-extensions/src/commonMain/kotlin/app/cash/sqldelight/coroutines/FlowExtensions.kt +++ b/extensions/coroutines-extensions/src/commonMain/kotlin/app/cash/sqldelight/coroutines/FlowExtensions.kt @@ -58,7 +58,7 @@ fun Query.asFlow(): Flow> = flow { @JvmOverloads fun Flow>.mapToOne( - context: CoroutineContext = Dispatchers.Default + context: CoroutineContext = Dispatchers.Default, ): Flow = map { withContext(context) { it.awaitAsOne() @@ -68,7 +68,7 @@ fun Flow>.mapToOne( @JvmOverloads fun Flow>.mapToOneOrDefault( defaultValue: T, - context: CoroutineContext = Dispatchers.Default + context: CoroutineContext = Dispatchers.Default, ): Flow = map { withContext(context) { it.awaitAsOneOrNull() ?: defaultValue @@ -77,7 +77,7 @@ fun Flow>.mapToOneOrDefault( @JvmOverloads fun Flow>.mapToOneOrNull( - context: CoroutineContext = Dispatchers.Default + context: CoroutineContext = Dispatchers.Default, ): Flow = map { withContext(context) { it.awaitAsOneOrNull() @@ -86,7 +86,7 @@ fun Flow>.mapToOneOrNull( @JvmOverloads fun Flow>.mapToOneNotNull( - context: CoroutineContext = Dispatchers.Default + context: CoroutineContext = Dispatchers.Default, ): Flow = mapNotNull { withContext(context) { it.awaitAsOneOrNull() @@ -95,7 +95,7 @@ fun Flow>.mapToOneNotNull( @JvmOverloads fun Flow>.mapToList( - context: CoroutineContext = Dispatchers.Default + context: CoroutineContext = Dispatchers.Default, ): Flow> = map { withContext(context) { it.awaitAsList() diff --git a/extensions/coroutines-extensions/src/commonTest/kotlin/app/cash/sqldelight/coroutines/MappingTest.kt b/extensions/coroutines-extensions/src/commonTest/kotlin/app/cash/sqldelight/coroutines/MappingTest.kt index 6e6a2423b93..306a30ab2d7 100644 --- a/extensions/coroutines-extensions/src/commonTest/kotlin/app/cash/sqldelight/coroutines/MappingTest.kt +++ b/extensions/coroutines-extensions/src/commonTest/kotlin/app/cash/sqldelight/coroutines/MappingTest.kt @@ -147,9 +147,9 @@ class MappingTest : DbTest { listOf( Employee("alice", "Alice Allison"), // Employee("bob", "Bob Bobberson"), // - Employee("eve", "Eve Evenson") + Employee("eve", "Eve Evenson"), ), - awaitItem() + awaitItem(), ) cancel() } diff --git a/extensions/coroutines-extensions/src/commonTest/kotlin/app/cash/sqldelight/coroutines/runTest.kt b/extensions/coroutines-extensions/src/commonTest/kotlin/app/cash/sqldelight/coroutines/RunTest.kt similarity index 100% rename from extensions/coroutines-extensions/src/commonTest/kotlin/app/cash/sqldelight/coroutines/runTest.kt rename to extensions/coroutines-extensions/src/commonTest/kotlin/app/cash/sqldelight/coroutines/RunTest.kt diff --git a/extensions/coroutines-extensions/src/commonTest/kotlin/app/cash/sqldelight/coroutines/TestDb.kt b/extensions/coroutines-extensions/src/commonTest/kotlin/app/cash/sqldelight/coroutines/TestDb.kt index 835c3c5b00d..7ab50d385fe 100644 --- a/extensions/coroutines-extensions/src/commonTest/kotlin/app/cash/sqldelight/coroutines/TestDb.kt +++ b/extensions/coroutines-extensions/src/commonTest/kotlin/app/cash/sqldelight/coroutines/TestDb.kt @@ -14,7 +14,7 @@ import app.cash.sqldelight.internal.setValue expect suspend fun testDriver(): SqlDriver class TestDb( - val db: SqlDriver + val db: SqlDriver, ) : TransacterImpl(db) { var aliceId: Long by Atomic(0) var bobId: Long by Atomic(0) @@ -62,8 +62,9 @@ class TestDb( """ |INSERT OR FAIL INTO $TABLE_EMPLOYEE (${Employee.USERNAME}, ${Employee.NAME}) |VALUES (?, ?) - |""".trimMargin(), - 2 + | + """.trimMargin(), + 2, ) { bindString(0, employee.username) bindString(1, employee.name) @@ -81,15 +82,16 @@ class TestDb( fun manager( employeeId: Long, - managerId: Long + managerId: Long, ): Long { db.execute( 1, """ |INSERT OR FAIL INTO $TABLE_MANAGER (${Manager.EMPLOYEE_ID}, ${Manager.MANAGER_ID}) |VALUES (?, ?) - |""".trimMargin(), - 2 + | + """.trimMargin(), + 2, ) { bindLong(0, employeeId) bindLong(1, managerId) @@ -139,7 +141,8 @@ object Manager { |ON manager.$EMPLOYEE_ID = e.${Employee.ID} |JOIN $TABLE_EMPLOYEE AS m |ON manager.$MANAGER_ID = m.${Employee.ID} - |""".trimMargin() + | + """.trimMargin() } data class Employee(val username: String, val name: String) { diff --git a/extensions/coroutines-extensions/src/jsTest/kotlin/app/cash/sqldelight/coroutines/runTest.kt b/extensions/coroutines-extensions/src/jsTest/kotlin/app/cash/sqldelight/coroutines/RunTest.kt similarity index 100% rename from extensions/coroutines-extensions/src/jsTest/kotlin/app/cash/sqldelight/coroutines/runTest.kt rename to extensions/coroutines-extensions/src/jsTest/kotlin/app/cash/sqldelight/coroutines/RunTest.kt diff --git a/extensions/coroutines-extensions/src/jsTest/kotlin/app/cash/sqldelight/coroutines/TestDb.kt b/extensions/coroutines-extensions/src/jsTest/kotlin/app/cash/sqldelight/coroutines/TestDriver.kt similarity index 100% rename from extensions/coroutines-extensions/src/jsTest/kotlin/app/cash/sqldelight/coroutines/TestDb.kt rename to extensions/coroutines-extensions/src/jsTest/kotlin/app/cash/sqldelight/coroutines/TestDriver.kt diff --git a/extensions/coroutines-extensions/src/jvmTest/kotlin/app/cash/sqldelight/coroutines/runTest.kt b/extensions/coroutines-extensions/src/jvmTest/kotlin/app/cash/sqldelight/coroutines/RunTest.kt similarity index 100% rename from extensions/coroutines-extensions/src/jvmTest/kotlin/app/cash/sqldelight/coroutines/runTest.kt rename to extensions/coroutines-extensions/src/jvmTest/kotlin/app/cash/sqldelight/coroutines/RunTest.kt diff --git a/extensions/coroutines-extensions/src/jvmTest/kotlin/app/cash/sqldelight/coroutines/TestDb.kt b/extensions/coroutines-extensions/src/jvmTest/kotlin/app/cash/sqldelight/coroutines/TestDriver.kt similarity index 100% rename from extensions/coroutines-extensions/src/jvmTest/kotlin/app/cash/sqldelight/coroutines/TestDb.kt rename to extensions/coroutines-extensions/src/jvmTest/kotlin/app/cash/sqldelight/coroutines/TestDriver.kt diff --git a/extensions/coroutines-extensions/src/nativeTest/kotlin/app/cash/sqldelight/coroutines/runTest.kt b/extensions/coroutines-extensions/src/nativeTest/kotlin/app/cash/sqldelight/coroutines/RunTest.kt similarity index 100% rename from extensions/coroutines-extensions/src/nativeTest/kotlin/app/cash/sqldelight/coroutines/runTest.kt rename to extensions/coroutines-extensions/src/nativeTest/kotlin/app/cash/sqldelight/coroutines/RunTest.kt diff --git a/extensions/coroutines-extensions/src/nativeTest/kotlin/app/cash/sqldelight/coroutines/TestDb.kt b/extensions/coroutines-extensions/src/nativeTest/kotlin/app/cash/sqldelight/coroutines/TestDriver.kt similarity index 98% rename from extensions/coroutines-extensions/src/nativeTest/kotlin/app/cash/sqldelight/coroutines/TestDb.kt rename to extensions/coroutines-extensions/src/nativeTest/kotlin/app/cash/sqldelight/coroutines/TestDriver.kt index 64a2d4bec78..cfdeb701057 100644 --- a/extensions/coroutines-extensions/src/nativeTest/kotlin/app/cash/sqldelight/coroutines/TestDb.kt +++ b/extensions/coroutines-extensions/src/nativeTest/kotlin/app/cash/sqldelight/coroutines/TestDriver.kt @@ -29,7 +29,7 @@ private fun defaultSchema(): SqlSchema { override fun migrate( driver: SqlDriver, oldVersion: Int, - newVersion: Int + newVersion: Int, ) = QueryResult.Unit } } diff --git a/extensions/rxjava2-extensions/src/main/kotlin/app/cash/sqldelight/rx2/RxJavaExtensions.kt b/extensions/rxjava2-extensions/src/main/kotlin/app/cash/sqldelight/rx2/RxJavaExtensions.kt index b35bf8c59cb..85a1a5829b1 100644 --- a/extensions/rxjava2-extensions/src/main/kotlin/app/cash/sqldelight/rx2/RxJavaExtensions.kt +++ b/extensions/rxjava2-extensions/src/main/kotlin/app/cash/sqldelight/rx2/RxJavaExtensions.kt @@ -27,7 +27,7 @@ fun Query.asObservable(scheduler: Scheduler = Schedulers.io()): Obs } private class QueryOnSubscribe( - private val query: Query + private val query: Query, ) : ObservableOnSubscribe> { override fun subscribe(emitter: ObservableEmitter>) { val listenerAndDisposable = QueryListenerAndDisposable(emitter, query) @@ -39,7 +39,7 @@ private class QueryOnSubscribe( private class QueryListenerAndDisposable( private val emitter: ObservableEmitter>, - private val query: Query + private val query: Query, ) : AtomicBoolean(), Query.Listener, Disposable { override fun queryResultsChanged() { emitter.onNext(query) diff --git a/extensions/rxjava2-extensions/src/test/kotlin/app/cash/sqldelight/rx2/QueryTest.kt b/extensions/rxjava2-extensions/src/test/kotlin/app/cash/sqldelight/rx2/QueryTest.kt index 3128d40a1dc..78534c3496c 100644 --- a/extensions/rxjava2-extensions/src/test/kotlin/app/cash/sqldelight/rx2/QueryTest.kt +++ b/extensions/rxjava2-extensions/src/test/kotlin/app/cash/sqldelight/rx2/QueryTest.kt @@ -66,8 +66,8 @@ class QueryTest { listOf( Employee("alice", "Alice Allison"), // Employee("bob", "Bob Bobberson"), // - Employee("eve", "Eve Evenson") - ) + Employee("eve", "Eve Evenson"), + ), ) } diff --git a/extensions/rxjava2-extensions/src/test/kotlin/app/cash/sqldelight/rx2/TestDb.kt b/extensions/rxjava2-extensions/src/test/kotlin/app/cash/sqldelight/rx2/TestDb.kt index 4da69deed3a..88d7d37c244 100644 --- a/extensions/rxjava2-extensions/src/test/kotlin/app/cash/sqldelight/rx2/TestDb.kt +++ b/extensions/rxjava2-extensions/src/test/kotlin/app/cash/sqldelight/rx2/TestDb.kt @@ -12,7 +12,7 @@ import app.cash.sqldelight.rx2.TestDb.Companion.TABLE_EMPLOYEE import app.cash.sqldelight.rx2.TestDb.Companion.TABLE_MANAGER class TestDb( - val db: SqlDriver = JdbcSqliteDriver(IN_MEMORY) + val db: SqlDriver = JdbcSqliteDriver(IN_MEMORY), ) : TransacterImpl(db) { var aliceId: Long = 0 var bobId: Long = 0 @@ -60,8 +60,9 @@ class TestDb( """ |INSERT OR FAIL INTO $TABLE_EMPLOYEE (${app.cash.sqldelight.rx2.Employee.USERNAME}, ${app.cash.sqldelight.rx2.Employee.NAME}) |VALUES (?, ?) - |""".trimMargin(), - 2 + | + """.trimMargin(), + 2, ) { bindString(0, employee.username) bindString(1, employee.name) @@ -72,15 +73,16 @@ class TestDb( fun manager( employeeId: Long, - managerId: Long + managerId: Long, ): Long { db.execute( 1, """ |INSERT OR FAIL INTO $TABLE_MANAGER (${Manager.EMPLOYEE_ID}, ${Manager.MANAGER_ID}) |VALUES (?, ?) - |""".trimMargin(), - 2 + | + """.trimMargin(), + 2, ) { bindLong(0, employeeId) bindLong(1, managerId) @@ -123,7 +125,8 @@ object Manager { |ON manager.$EMPLOYEE_ID = e.${Companion.ID} |JOIN $TABLE_EMPLOYEE AS m |ON manager.$MANAGER_ID = m.${Companion.ID} - |""".trimMargin() + | + """.trimMargin() } data class Employee(val username: String, val name: String) { diff --git a/extensions/rxjava3-extensions/src/main/kotlin/app/cash/sqldelight/rx3/RxJavaExtensions.kt b/extensions/rxjava3-extensions/src/main/kotlin/app/cash/sqldelight/rx3/RxJavaExtensions.kt index 64890faa0b5..be2c77d839c 100644 --- a/extensions/rxjava3-extensions/src/main/kotlin/app/cash/sqldelight/rx3/RxJavaExtensions.kt +++ b/extensions/rxjava3-extensions/src/main/kotlin/app/cash/sqldelight/rx3/RxJavaExtensions.kt @@ -27,7 +27,7 @@ fun Query.asObservable(scheduler: Scheduler = Schedulers.io()): Obs } private class QueryOnSubscribe( - private val query: Query + private val query: Query, ) : ObservableOnSubscribe> { override fun subscribe(emitter: ObservableEmitter>) { val listenerAndDisposable = QueryListenerAndDisposable(emitter, query) @@ -39,7 +39,7 @@ private class QueryOnSubscribe( private class QueryListenerAndDisposable( private val emitter: ObservableEmitter>, - private val query: Query + private val query: Query, ) : AtomicBoolean(), Query.Listener, Disposable { override fun queryResultsChanged() { emitter.onNext(query) diff --git a/extensions/rxjava3-extensions/src/test/kotlin/app/cash/sqldelight/rx3/QueryTest.kt b/extensions/rxjava3-extensions/src/test/kotlin/app/cash/sqldelight/rx3/QueryTest.kt index 16d7aa3999a..dc94b4e447f 100644 --- a/extensions/rxjava3-extensions/src/test/kotlin/app/cash/sqldelight/rx3/QueryTest.kt +++ b/extensions/rxjava3-extensions/src/test/kotlin/app/cash/sqldelight/rx3/QueryTest.kt @@ -66,8 +66,8 @@ class QueryTest { listOf( Employee("alice", "Alice Allison"), // Employee("bob", "Bob Bobberson"), // - Employee("eve", "Eve Evenson") - ) + Employee("eve", "Eve Evenson"), + ), ) } diff --git a/extensions/rxjava3-extensions/src/test/kotlin/app/cash/sqldelight/rx3/TestDb.kt b/extensions/rxjava3-extensions/src/test/kotlin/app/cash/sqldelight/rx3/TestDb.kt index 413d97bc570..31f5574ff39 100644 --- a/extensions/rxjava3-extensions/src/test/kotlin/app/cash/sqldelight/rx3/TestDb.kt +++ b/extensions/rxjava3-extensions/src/test/kotlin/app/cash/sqldelight/rx3/TestDb.kt @@ -11,7 +11,7 @@ import app.cash.sqldelight.rx3.TestDb.Companion.TABLE_EMPLOYEE import app.cash.sqldelight.rx3.TestDb.Companion.TABLE_MANAGER class TestDb( - val db: SqlDriver = JdbcSqliteDriver(IN_MEMORY) + val db: SqlDriver = JdbcSqliteDriver(IN_MEMORY), ) : TransacterImpl(db) { var aliceId: Long = 0 var bobId: Long = 0 @@ -59,8 +59,9 @@ class TestDb( """ |INSERT OR FAIL INTO $TABLE_EMPLOYEE (${Employee.USERNAME}, ${Employee.NAME}) |VALUES (?, ?) - |""".trimMargin(), - 2 + | + """.trimMargin(), + 2, ) { bindString(0, employee.username) bindString(1, employee.name) @@ -71,15 +72,16 @@ class TestDb( fun manager( employeeId: Long, - managerId: Long + managerId: Long, ): Long { db.execute( 1, """ |INSERT OR FAIL INTO $TABLE_MANAGER (${Manager.EMPLOYEE_ID}, ${Manager.MANAGER_ID}) |VALUES (?, ?) - |""".trimMargin(), - 2 + | + """.trimMargin(), + 2, ) { bindLong(0, employeeId) bindLong(1, managerId) @@ -122,7 +124,8 @@ object Manager { |ON manager.$EMPLOYEE_ID = e.${Employee.ID} |JOIN $TABLE_EMPLOYEE AS m |ON manager.$MANAGER_ID = m.${Employee.ID} - |""".trimMargin() + | + """.trimMargin() } data class Employee(val username: String, val name: String) { diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 0bde22ced50..1a631900f84 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -10,7 +10,7 @@ sqliter = "1.2.0" testhelp = "0.6.3" sqljs = "1.6.2" paging3 = "3.1.1" -ktlint = "0.43.0" +ktlint = "0.46.1" test = "1.4.0" agp = "7.2.1" compileSdk = "31" @@ -89,7 +89,7 @@ dokka = { id = "org.jetbrains.dokka", version.ref = "dokka" } intellij = { id = "org.jetbrains.intellij", version = "1.6.0" } grammarKitComposer = { id = "com.alecstrong.grammar.kit.composer", version = "0.1.10" } publish = { id = "com.vanniktech.maven.publish", version = "0.21.0" } -spotless = { id = "com.diffplug.spotless", version = "6.7.2" } # When updating, check if we can remove base plugin from root build.gradle +spotless = { id = "com.diffplug.spotless", version = "6.8.0" } changelog = { id = "org.jetbrains.changelog", version = "1.3.1" } shadow = { id = "com.github.johnrengelman.shadow", version = "7.1.2" } ksp = { id = "com.google.devtools.ksp", version = "1.7.10-1.0.6" } diff --git a/runtime/src/commonMain/kotlin/app/cash/sqldelight/EnumColumnAdapter.kt b/runtime/src/commonMain/kotlin/app/cash/sqldelight/EnumColumnAdapter.kt index 5eb402e46f4..ef6f57d638b 100644 --- a/runtime/src/commonMain/kotlin/app/cash/sqldelight/EnumColumnAdapter.kt +++ b/runtime/src/commonMain/kotlin/app/cash/sqldelight/EnumColumnAdapter.kt @@ -17,7 +17,7 @@ package app.cash.sqldelight /** A [ColumnAdapter] which maps the enum class `T` to a string in the database. */ class EnumColumnAdapter> @PublishedApi internal constructor( - private val enumValues: Array + private val enumValues: Array, ) : ColumnAdapter { override fun decode(databaseValue: String): T = enumValues.first { it.name == databaseValue } diff --git a/runtime/src/commonMain/kotlin/app/cash/sqldelight/Query.kt b/runtime/src/commonMain/kotlin/app/cash/sqldelight/Query.kt index 2e718742d69..b9c8686a388 100644 --- a/runtime/src/commonMain/kotlin/app/cash/sqldelight/Query.kt +++ b/runtime/src/commonMain/kotlin/app/cash/sqldelight/Query.kt @@ -30,7 +30,7 @@ fun Query( queryKeys: Array, driver: SqlDriver, query: String, - mapper: (SqlCursor) -> RowType + mapper: (SqlCursor) -> RowType, ): Query { return Query(identifier, queryKeys, driver, "unknown", "unknown", query, mapper) } @@ -48,10 +48,11 @@ fun Query( fileName: String, label: String, query: String, - mapper: (SqlCursor) -> RowType + mapper: (SqlCursor) -> RowType, ): Query { return SimpleQuery(identifier, queryKeys, driver, fileName, label, query, mapper) } + /** * A listenable, typed query generated by SQLDelight. * @@ -62,7 +63,7 @@ fun Query( identifier: Int, driver: SqlDriver, query: String, - mapper: (SqlCursor) -> RowType + mapper: (SqlCursor) -> RowType, ): ExecutableQuery { return Query(identifier, driver, "unknown", "unknown", query, mapper) } @@ -79,7 +80,7 @@ fun Query( fileName: String, label: String, query: String, - mapper: (SqlCursor) -> RowType + mapper: (SqlCursor) -> RowType, ): ExecutableQuery { return SimpleExecutableQuery(identifier, driver, fileName, label, query, mapper) } @@ -91,7 +92,7 @@ private class SimpleQuery( private val fileName: String, private val label: String, private val query: String, - mapper: (SqlCursor) -> RowType + mapper: (SqlCursor) -> RowType, ) : Query(mapper) { override fun execute(mapper: (SqlCursor) -> R): QueryResult { return driver.executeQuery(identifier, query, mapper, 0, null) @@ -114,7 +115,7 @@ private class SimpleExecutableQuery( private val fileName: String, private val label: String, private val query: String, - mapper: (SqlCursor) -> RowType + mapper: (SqlCursor) -> RowType, ) : ExecutableQuery(mapper) { override fun execute(mapper: (SqlCursor) -> R): QueryResult { return driver.executeQuery(identifier, query, mapper, 0, null) @@ -132,7 +133,7 @@ private class SimpleExecutableQuery( * cursor returned by [execute] to [RowType]. */ abstract class Query( - mapper: (SqlCursor) -> RowType + mapper: (SqlCursor) -> RowType, ) : ExecutableQuery(mapper) { /** * Register a listener to be notified of future changes in the result set. @@ -158,7 +159,7 @@ abstract class Query( } abstract class ExecutableQuery( - val mapper: (SqlCursor) -> RowType + val mapper: (SqlCursor) -> RowType, ) { /** * Execute the underlying statement. The resulting cursor is passed to the given block. diff --git a/runtime/src/commonMain/kotlin/app/cash/sqldelight/Transacter.kt b/runtime/src/commonMain/kotlin/app/cash/sqldelight/Transacter.kt index 68a28ec0baa..ba632a129e1 100644 --- a/runtime/src/commonMain/kotlin/app/cash/sqldelight/Transacter.kt +++ b/runtime/src/commonMain/kotlin/app/cash/sqldelight/Transacter.kt @@ -82,7 +82,7 @@ interface Transacter : TransacterBase { */ fun transactionWithResult( noEnclosing: Boolean = false, - bodyWithReturn: TransactionWithReturn.() -> R + bodyWithReturn: TransactionWithReturn.() -> R, ): R /** @@ -93,7 +93,7 @@ interface Transacter : TransacterBase { */ fun transaction( noEnclosing: Boolean = false, - body: TransactionWithoutReturn.() -> Unit + body: TransactionWithoutReturn.() -> Unit, ) /** @@ -172,7 +172,7 @@ interface SuspendingTransacter : TransacterBase { */ suspend fun transactionWithResult( noEnclosing: Boolean = false, - bodyWithReturn: suspend SuspendingTransactionWithReturn.() -> R + bodyWithReturn: suspend SuspendingTransactionWithReturn.() -> R, ): R /** @@ -183,14 +183,14 @@ interface SuspendingTransacter : TransacterBase { */ suspend fun transaction( noEnclosing: Boolean = false, - body: suspend SuspendingTransactionWithoutReturn.() -> Unit + body: suspend SuspendingTransactionWithoutReturn.() -> Unit, ) } private class RollbackException(val value: Any? = null) : Throwable() private class TransactionWrapper( - val transaction: Transaction + val transaction: Transaction, ) : TransactionWithoutReturn, TransactionWithReturn { override fun rollback(): Nothing { transaction.checkThreadConfinement() @@ -225,7 +225,7 @@ private class TransactionWrapper( } private class SuspendingTransactionWrapper( - val transaction: Transaction + val transaction: Transaction, ) : SuspendingTransactionWithoutReturn, SuspendingTransactionWithReturn { override fun rollback(): Nothing { transaction.checkThreadConfinement() @@ -344,14 +344,14 @@ abstract class BaseTransacterImpl(protected val driver: SqlDriver) { abstract class TransacterImpl(driver: SqlDriver) : BaseTransacterImpl(driver), Transacter { override fun transaction( noEnclosing: Boolean, - body: TransactionWithoutReturn.() -> Unit + body: TransactionWithoutReturn.() -> Unit, ) { transactionWithWrapper(noEnclosing, body) } override fun transactionWithResult( noEnclosing: Boolean, - bodyWithReturn: TransactionWithReturn.() -> R + bodyWithReturn: TransactionWithReturn.() -> R, ): R { return transactionWithWrapper(noEnclosing, bodyWithReturn) } @@ -381,14 +381,14 @@ abstract class TransacterImpl(driver: SqlDriver) : BaseTransacterImpl(driver), T abstract class SuspendingTransacterImpl(driver: SqlDriver) : BaseTransacterImpl(driver), SuspendingTransacter { override suspend fun transactionWithResult( noEnclosing: Boolean, - bodyWithReturn: suspend SuspendingTransactionWithReturn.() -> R + bodyWithReturn: suspend SuspendingTransactionWithReturn.() -> R, ): R { return transactionWithWrapper(noEnclosing, bodyWithReturn) } override suspend fun transaction( noEnclosing: Boolean, - body: suspend SuspendingTransactionWithoutReturn.() -> Unit + body: suspend SuspendingTransactionWithoutReturn.() -> Unit, ) { return transactionWithWrapper(noEnclosing, body) } diff --git a/runtime/src/commonMain/kotlin/app/cash/sqldelight/db/QueryResult.kt b/runtime/src/commonMain/kotlin/app/cash/sqldelight/db/QueryResult.kt index 7c780b1e9fd..52d2b1d351b 100644 --- a/runtime/src/commonMain/kotlin/app/cash/sqldelight/db/QueryResult.kt +++ b/runtime/src/commonMain/kotlin/app/cash/sqldelight/db/QueryResult.kt @@ -11,7 +11,7 @@ sealed interface QueryResult { generateAsync = true } } - """.trimIndent() + """.trimIndent(), ) suspend fun await(): T diff --git a/runtime/src/commonMain/kotlin/app/cash/sqldelight/db/SqlDriver.kt b/runtime/src/commonMain/kotlin/app/cash/sqldelight/db/SqlDriver.kt index e31ee9a8bea..36a1e1b21ea 100644 --- a/runtime/src/commonMain/kotlin/app/cash/sqldelight/db/SqlDriver.kt +++ b/runtime/src/commonMain/kotlin/app/cash/sqldelight/db/SqlDriver.kt @@ -42,7 +42,7 @@ interface SqlDriver : Closeable { sql: String, mapper: (SqlCursor) -> R, parameters: Int, - binders: (SqlPreparedStatement.() -> Unit)? = null + binders: (SqlPreparedStatement.() -> Unit)? = null, ): QueryResult /** @@ -64,7 +64,7 @@ interface SqlDriver : Closeable { identifier: Int?, sql: String, parameters: Int, - binders: (SqlPreparedStatement.() -> Unit)? = null + binders: (SqlPreparedStatement.() -> Unit)? = null, ): QueryResult /** diff --git a/runtime/src/commonMain/kotlin/app/cash/sqldelight/db/SqlSchema.kt b/runtime/src/commonMain/kotlin/app/cash/sqldelight/db/SqlSchema.kt index 638919fee05..ef9e412688c 100644 --- a/runtime/src/commonMain/kotlin/app/cash/sqldelight/db/SqlSchema.kt +++ b/runtime/src/commonMain/kotlin/app/cash/sqldelight/db/SqlSchema.kt @@ -41,7 +41,7 @@ interface SqlSchema { */ class AfterVersion( internal val afterVersion: Int, - internal val block: (SqlDriver) -> Unit + internal val block: (SqlDriver) -> Unit, ) /** @@ -52,7 +52,7 @@ fun SqlSchema.migrateWithCallbacks( driver: SqlDriver, oldVersion: Int, newVersion: Int, - vararg callbacks: AfterVersion + vararg callbacks: AfterVersion, ) { var lastVersion = oldVersion diff --git a/runtime/src/commonMain/kotlin/app/cash/sqldelight/logs/LogSqliteDriver.kt b/runtime/src/commonMain/kotlin/app/cash/sqldelight/logs/LogSqliteDriver.kt index 4e36e2c8d8d..d838596cad0 100644 --- a/runtime/src/commonMain/kotlin/app/cash/sqldelight/logs/LogSqliteDriver.kt +++ b/runtime/src/commonMain/kotlin/app/cash/sqldelight/logs/LogSqliteDriver.kt @@ -24,7 +24,7 @@ import app.cash.sqldelight.db.SqlPreparedStatement class LogSqliteDriver( private val sqlDriver: SqlDriver, - private val logger: (String) -> Unit + private val logger: (String) -> Unit, ) : SqlDriver { override fun currentTransaction(): Transacter.Transaction? { @@ -35,7 +35,7 @@ class LogSqliteDriver( identifier: Int?, sql: String, parameters: Int, - binders: (SqlPreparedStatement.() -> Unit)? + binders: (SqlPreparedStatement.() -> Unit)?, ): QueryResult { logger("EXECUTE\n $sql") logParameters(binders) @@ -47,7 +47,7 @@ class LogSqliteDriver( sql: String, mapper: (SqlCursor) -> R, parameters: Int, - binders: (SqlPreparedStatement.() -> Unit)? + binders: (SqlPreparedStatement.() -> Unit)?, ): QueryResult { logger("QUERY\n $sql") logParameters(binders) @@ -97,35 +97,35 @@ class StatementParameterInterceptor : SqlPreparedStatement { override fun bindBytes( index: Int, - bytes: ByteArray? + bytes: ByteArray?, ) { values.add(bytes) } override fun bindDouble( index: Int, - double: Double? + double: Double?, ) { values.add(double) } override fun bindLong( index: Int, - long: Long? + long: Long?, ) { values.add(long) } override fun bindString( index: Int, - string: String? + string: String?, ) { values.add(string) } override fun bindBoolean( index: Int, - boolean: Boolean? + boolean: Boolean?, ) { values.add(boolean) } diff --git a/runtime/src/commonTest/kotlin/com/squareup/sqldelight/logs/LogSqliteDriverTest.kt b/runtime/src/commonTest/kotlin/com/squareup/sqldelight/logs/LogSqliteDriverTest.kt index 453048cc127..857a9194787 100644 --- a/runtime/src/commonTest/kotlin/com/squareup/sqldelight/logs/LogSqliteDriverTest.kt +++ b/runtime/src/commonTest/kotlin/com/squareup/sqldelight/logs/LogSqliteDriverTest.kt @@ -33,7 +33,8 @@ class LogSqliteDriverTest { } @JsName("insertLogsCorrect") - @Test fun `insert logs are correct`() { + @Test + fun `insert logs are correct`() { val insert = { binders: SqlPreparedStatement.() -> Unit -> driver.execute(2, "INSERT INTO test VALUES (?, ?);", 2, binders) } @@ -51,7 +52,8 @@ class LogSqliteDriverTest { } @JsName("queryLogsCorrect") - @Test fun `query logs are correct`() { + @Test + fun `query logs are correct`() { val query = { driver.executeQuery(3, "SELECT * FROM test", {}, 0) } @@ -62,7 +64,8 @@ class LogSqliteDriverTest { } @JsName("transactionLogsCorrect") - @Test fun `transaction logs are correct`() { + @Test + fun `transaction logs are correct`() { transacter.transaction {} transacter.transaction { rollback() } transacter.transaction { @@ -93,7 +96,7 @@ class FakeSqlDriver : SqlDriver { sql: String, mapper: (SqlCursor) -> R, parameters: Int, - binders: (SqlPreparedStatement.() -> Unit)? + binders: (SqlPreparedStatement.() -> Unit)?, ): QueryResult { return QueryResult.Value(mapper(FakeSqlCursor())) } @@ -102,7 +105,7 @@ class FakeSqlDriver : SqlDriver { identifier: Int?, sql: String, parameters: Int, - binders: (SqlPreparedStatement.() -> Unit)? + binders: (SqlPreparedStatement.() -> Unit)?, ): QueryResult { return QueryResult.Value(0) } diff --git a/runtime/src/commonTest/kotlin/com/squareup/sqldelight/logs/SqlDriverMigrationCallbackTest.kt b/runtime/src/commonTest/kotlin/com/squareup/sqldelight/logs/SqlDriverMigrationCallbackTest.kt index 09321db2a52..6ae771dc50d 100644 --- a/runtime/src/commonTest/kotlin/com/squareup/sqldelight/logs/SqlDriverMigrationCallbackTest.kt +++ b/runtime/src/commonTest/kotlin/com/squareup/sqldelight/logs/SqlDriverMigrationCallbackTest.kt @@ -20,7 +20,7 @@ class SqlDriverMigrationCallbackTest { driver = FakeSqlDriver(), oldVersion = 1, newVersion = 2, - AfterVersion(1) { callbackInvoked = true } + AfterVersion(1) { callbackInvoked = true }, ) assertTrue(callbackInvoked) diff --git a/sample/android/src/main/java/com/example/sqldelight/hockey/data/Db.kt b/sample/android/src/main/java/com/example/sqldelight/hockey/data/GetInstance.kt similarity index 100% rename from sample/android/src/main/java/com/example/sqldelight/hockey/data/Db.kt rename to sample/android/src/main/java/com/example/sqldelight/hockey/data/GetInstance.kt diff --git a/sample/android/src/main/java/com/example/sqldelight/hockey/ui/PlayerRow.kt b/sample/android/src/main/java/com/example/sqldelight/hockey/ui/PlayerRow.kt index e6faf36fb7d..26636319f42 100644 --- a/sample/android/src/main/java/com/example/sqldelight/hockey/ui/PlayerRow.kt +++ b/sample/android/src/main/java/com/example/sqldelight/hockey/ui/PlayerRow.kt @@ -9,7 +9,7 @@ import com.example.sqldelight.hockey.data.ForTeam class PlayerRow( context: Context, - attrs: AttributeSet + attrs: AttributeSet, ) : LinearLayout(context, attrs) { fun populate(row: ForTeam) { findViewById(R.id.player_name).text = "${row.first_name} ${row.last_name}" diff --git a/sample/android/src/main/java/com/example/sqldelight/hockey/ui/PlayersActivity.kt b/sample/android/src/main/java/com/example/sqldelight/hockey/ui/PlayersActivity.kt index a1ed28949be..592510ec9b7 100644 --- a/sample/android/src/main/java/com/example/sqldelight/hockey/ui/PlayersActivity.kt +++ b/sample/android/src/main/java/com/example/sqldelight/hockey/ui/PlayersActivity.kt @@ -23,7 +23,7 @@ class PlayersActivity : Activity() { } private inner class PlayersAdapter( - private val data: List + private val data: List, ) : RecyclerView.Adapter() { override fun getItemCount() = data.size diff --git a/sample/android/src/main/java/com/example/sqldelight/hockey/ui/TeamRow.kt b/sample/android/src/main/java/com/example/sqldelight/hockey/ui/TeamRow.kt index 4291a8cff6b..ac3749e543d 100644 --- a/sample/android/src/main/java/com/example/sqldelight/hockey/ui/TeamRow.kt +++ b/sample/android/src/main/java/com/example/sqldelight/hockey/ui/TeamRow.kt @@ -10,7 +10,7 @@ import com.example.sqldelight.hockey.platform.defaultFormatter class TeamRow( context: Context, - attrs: AttributeSet + attrs: AttributeSet, ) : LinearLayout(context, attrs) { fun populate(team: Team) { findViewById(R.id.team_name).text = team.name diff --git a/sample/android/src/main/java/com/example/sqldelight/hockey/ui/TeamsActivity.kt b/sample/android/src/main/java/com/example/sqldelight/hockey/ui/TeamsActivity.kt index 29e8b101127..df99c72482c 100644 --- a/sample/android/src/main/java/com/example/sqldelight/hockey/ui/TeamsActivity.kt +++ b/sample/android/src/main/java/com/example/sqldelight/hockey/ui/TeamsActivity.kt @@ -30,7 +30,7 @@ class TeamsActivity : Activity() { private inner class Adapter( private val data: List, - private val clickListener: (Team) -> Unit + private val clickListener: (Team) -> Unit, ) : RecyclerView.Adapter() { override fun getItemCount() = data.size diff --git a/sample/common/src/commonMain/kotlin/com/example/sqldelight/hockey/data/Schema.kt b/sample/common/src/commonMain/kotlin/com/example/sqldelight/hockey/data/Schema.kt index e63055c8012..9d4065428c6 100644 --- a/sample/common/src/commonMain/kotlin/com/example/sqldelight/hockey/data/Schema.kt +++ b/sample/common/src/commonMain/kotlin/com/example/sqldelight/hockey/data/Schema.kt @@ -23,7 +23,7 @@ fun createQueryWrapper(driver: SqlDriver): HockeyDb { numberAdapter = IntColumnAdapter, ageAdapter = IntColumnAdapter, weightAdapter = FloatColumnAdapter, - ) + ), ) } @@ -33,7 +33,6 @@ object Schema : SqlSchema by HockeyDb.Schema { // Seed data time! createQueryWrapper(driver).apply { - val ducks = "Anaheim Ducks" val pens = "Pittsburgh Penguins" val sharks = "San Jose Sharks" @@ -45,28 +44,28 @@ object Schema : SqlSchema by HockeyDb.Schema { playerQueries.insertPlayer( "Corey", "Perry", 10, ducks, 30, 210F, Date(1985, 5, 16), - Shoots.RIGHT, Position.RIGHT_WING + Shoots.RIGHT, Position.RIGHT_WING, ) playerQueries.insertPlayer( "Ryan", "Getzlaf", 15, ducks, 30, 221F, Date(1985, 5, 10), - Shoots.RIGHT, Position.CENTER + Shoots.RIGHT, Position.CENTER, ) teamQueries.setCaptain(15, ducks) playerQueries.insertPlayer( "Sidney", "Crosby", 87, pens, 28, 200F, Date(1987, 8, 7), - Shoots.LEFT, Position.CENTER + Shoots.LEFT, Position.CENTER, ) teamQueries.setCaptain(87, pens) playerQueries.insertPlayer( "Erik", "Karlsson", 65, sharks, 28, 190F, Date(1990, 5, 31), - Shoots.RIGHT, Position.DEFENSE + Shoots.RIGHT, Position.DEFENSE, ) playerQueries.insertPlayer( "Joe", "Pavelski", 8, sharks, 31, 194F, Date(1984, 7, 18), - Shoots.RIGHT, Position.CENTER + Shoots.RIGHT, Position.CENTER, ) teamQueries.setCaptain(8, sharks) } diff --git a/sample/common/src/iosTest/kotlin/com/example/sqldelight/hockey/IosSchemaTest.kt b/sample/common/src/iosTest/kotlin/com/example/sqldelight/hockey/IosSchemaTest.kt index 0af2224a6c4..b9fc2b9e049 100644 --- a/sample/common/src/iosTest/kotlin/com/example/sqldelight/hockey/IosSchemaTest.kt +++ b/sample/common/src/iosTest/kotlin/com/example/sqldelight/hockey/IosSchemaTest.kt @@ -11,7 +11,7 @@ class IosSchemaTest : BaseTest() { assertTrue( teams.any { it.name == "Anaheim Ducks" - } + }, ) } @@ -21,7 +21,7 @@ class IosSchemaTest : BaseTest() { assertTrue( players.any { it.last_name == "Karlsson" - } + }, ) } } diff --git a/sample/common/src/jsTest/kotlin/com/example/sqldelight/hockey/JsSchemaTest.kt b/sample/common/src/jsTest/kotlin/com/example/sqldelight/hockey/JsSchemaTest.kt index d0301558b83..0bd57407f90 100644 --- a/sample/common/src/jsTest/kotlin/com/example/sqldelight/hockey/JsSchemaTest.kt +++ b/sample/common/src/jsTest/kotlin/com/example/sqldelight/hockey/JsSchemaTest.kt @@ -11,7 +11,7 @@ class JsSchemaTest : BaseTest() { assertTrue( teams.any { it.name == "Anaheim Ducks" - } + }, ) } @@ -21,7 +21,7 @@ class JsSchemaTest : BaseTest() { assertTrue( players.any { it.last_name == "Karlsson" - } + }, ) } } diff --git a/sample/common/src/jvmTest/kotlin/com/example/sqldelight/hockey/JvmSchemaTest.kt b/sample/common/src/jvmTest/kotlin/com/example/sqldelight/hockey/JvmSchemaTest.kt index c140d3d4151..0c1bbc1e745 100644 --- a/sample/common/src/jvmTest/kotlin/com/example/sqldelight/hockey/JvmSchemaTest.kt +++ b/sample/common/src/jvmTest/kotlin/com/example/sqldelight/hockey/JvmSchemaTest.kt @@ -11,7 +11,7 @@ class JvmSchemaTest : BaseTest() { assertTrue( teams.any { it.name == "Anaheim Ducks" - } + }, ) } @@ -21,7 +21,7 @@ class JvmSchemaTest : BaseTest() { assertTrue( players.any { it.last_name == "Karlsson" - } + }, ) } } diff --git a/sample/web/src/main/kotlin/com/example/sqldelight/hockey/App.kt b/sample/web/src/main/kotlin/com/example/sqldelight/hockey/Main.kt similarity index 100% rename from sample/web/src/main/kotlin/com/example/sqldelight/hockey/App.kt rename to sample/web/src/main/kotlin/com/example/sqldelight/hockey/Main.kt diff --git a/sample/web/src/main/kotlin/com/example/sqldelight/hockey/data/Extensions.kt b/sample/web/src/main/kotlin/com/example/sqldelight/hockey/data/GetInstance.kt similarity index 100% rename from sample/web/src/main/kotlin/com/example/sqldelight/hockey/data/Extensions.kt rename to sample/web/src/main/kotlin/com/example/sqldelight/hockey/data/GetInstance.kt diff --git a/sqldelight-compiler/dialect/src/main/kotlin/app/cash/sqldelight/dialect/api/ConnectionManager.kt b/sqldelight-compiler/dialect/src/main/kotlin/app/cash/sqldelight/dialect/api/ConnectionManager.kt index f984bdee489..baba3028ebb 100644 --- a/sqldelight-compiler/dialect/src/main/kotlin/app/cash/sqldelight/dialect/api/ConnectionManager.kt +++ b/sqldelight-compiler/dialect/src/main/kotlin/app/cash/sqldelight/dialect/api/ConnectionManager.kt @@ -6,13 +6,13 @@ import java.sql.Connection interface ConnectionManager { fun createNewConnectionProperties( project: Project, - prefilledProperties: ConnectionProperties? = null + prefilledProperties: ConnectionProperties? = null, ): ConnectionProperties? fun getConnection(connectionProperties: ConnectionProperties): Connection data class ConnectionProperties( val key: String, - val serializedProperties: String + val serializedProperties: String, ) } diff --git a/sqldelight-compiler/dialect/src/main/kotlin/app/cash/sqldelight/dialect/api/NoOp.kt b/sqldelight-compiler/dialect/src/main/kotlin/app/cash/sqldelight/dialect/api/NoOp.kt index f76dde7f348..9098e4cb765 100644 --- a/sqldelight-compiler/dialect/src/main/kotlin/app/cash/sqldelight/dialect/api/NoOp.kt +++ b/sqldelight-compiler/dialect/src/main/kotlin/app/cash/sqldelight/dialect/api/NoOp.kt @@ -18,7 +18,7 @@ internal class NoOp : SqlGeneratorStrategy { tableName: String, oldName: String, newName: String, - columnDefList: List + columnDefList: List, ): String { return "" } diff --git a/sqldelight-compiler/dialect/src/main/kotlin/app/cash/sqldelight/dialect/api/PrimitiveType.kt b/sqldelight-compiler/dialect/src/main/kotlin/app/cash/sqldelight/dialect/api/PrimitiveType.kt index 8be86140e5f..4d88ed0a573 100644 --- a/sqldelight-compiler/dialect/src/main/kotlin/app/cash/sqldelight/dialect/api/PrimitiveType.kt +++ b/sqldelight-compiler/dialect/src/main/kotlin/app/cash/sqldelight/dialect/api/PrimitiveType.kt @@ -30,7 +30,7 @@ enum class PrimitiveType(override val javaType: TypeName) : DialectType { BLOB -> "bindBytes" BOOLEAN -> "bindBoolean" else -> throw IllegalArgumentException("Cannot bind unknown types or null") - } + }, ) .add("($columnIndex, %L)\n", value) .build() @@ -46,7 +46,7 @@ enum class PrimitiveType(override val javaType: TypeName) : DialectType { BLOB -> "$cursorName.getBytes($columnIndex)" BOOLEAN -> "$cursorName.getBoolean($columnIndex)" ARGUMENT -> throw IllegalArgumentException("Cannot retrieve argument from cursor") - } + }, ) } } diff --git a/sqldelight-compiler/dialect/src/main/kotlin/app/cash/sqldelight/dialect/api/RuntimeTypes.kt b/sqldelight-compiler/dialect/src/main/kotlin/app/cash/sqldelight/dialect/api/RuntimeTypes.kt index 5bd43987631..e3d47182c6e 100644 --- a/sqldelight-compiler/dialect/src/main/kotlin/app/cash/sqldelight/dialect/api/RuntimeTypes.kt +++ b/sqldelight-compiler/dialect/src/main/kotlin/app/cash/sqldelight/dialect/api/RuntimeTypes.kt @@ -7,5 +7,5 @@ import com.squareup.kotlinpoet.ClassName */ data class RuntimeTypes( val cursorType: ClassName, - val preparedStatementType: ClassName + val preparedStatementType: ClassName, ) diff --git a/sqldelight-compiler/dialect/src/main/kotlin/app/cash/sqldelight/dialect/api/SqlGeneratorStrategy.kt b/sqldelight-compiler/dialect/src/main/kotlin/app/cash/sqldelight/dialect/api/SqlGeneratorStrategy.kt index ba25e8e4e5e..c2eb1eaa2e8 100644 --- a/sqldelight-compiler/dialect/src/main/kotlin/app/cash/sqldelight/dialect/api/SqlGeneratorStrategy.kt +++ b/sqldelight-compiler/dialect/src/main/kotlin/app/cash/sqldelight/dialect/api/SqlGeneratorStrategy.kt @@ -8,6 +8,6 @@ interface SqlGeneratorStrategy { tableName: String, oldName: String, newName: String, - columnDefList: List + columnDefList: List, ): String } diff --git a/sqldelight-compiler/dialect/src/main/kotlin/app/cash/sqldelight/dialect/api/TypeResolver.kt b/sqldelight-compiler/dialect/src/main/kotlin/app/cash/sqldelight/dialect/api/TypeResolver.kt index 66244547684..65906757a59 100644 --- a/sqldelight-compiler/dialect/src/main/kotlin/app/cash/sqldelight/dialect/api/TypeResolver.kt +++ b/sqldelight-compiler/dialect/src/main/kotlin/app/cash/sqldelight/dialect/api/TypeResolver.kt @@ -43,7 +43,7 @@ interface TypeResolver { */ fun TypeResolver.encapsulatingType( exprList: List, - vararg typeOrder: DialectType + vararg typeOrder: DialectType, ) = encapsulatingType(exprList = exprList, nullableIfAny = false, typeOrder = typeOrder) /** @@ -52,7 +52,7 @@ fun TypeResolver.encapsulatingType( fun TypeResolver.encapsulatingType( exprList: List, nullableIfAny: Boolean, - vararg typeOrder: DialectType + vararg typeOrder: DialectType, ): IntermediateType { val types = exprList.map { resolvedType(it) } val sqlTypes = types.map { it.dialectType } diff --git a/sqldelight-compiler/integration-tests/src/test/kotlin/app/cash/sqldelight/core/integration/IntegrationTest.kt b/sqldelight-compiler/integration-tests/src/test/kotlin/app/cash/sqldelight/core/integration/IntegrationTest.kt index 216e598f1c1..f561f8ac928 100644 --- a/sqldelight-compiler/integration-tests/src/test/kotlin/app/cash/sqldelight/core/integration/IntegrationTest.kt +++ b/sqldelight-compiler/integration-tests/src/test/kotlin/app/cash/sqldelight/core/integration/IntegrationTest.kt @@ -90,8 +90,10 @@ class IntegrationTest { | FROM player | WHERE player.rowid = last_insert_rowid(); |} - |""".trimMargin(), - temporaryFolder, "Player.sq" + | + """.trimMargin(), + temporaryFolder, + "Player.sq", ) FixtureCompiler.writeSql( @@ -121,8 +123,10 @@ class IntegrationTest { | |selectStuff: |SELECT 1, 2; - |""".trimMargin(), - temporaryFolder, "Team.sq" + | + """.trimMargin(), + temporaryFolder, + "Team.sq", ) FixtureCompiler.writeSql( @@ -133,8 +137,10 @@ class IntegrationTest { | |selectAll: |SELECT `index` FROM `group`; - |""".trimMargin(), - temporaryFolder, "Group.sq" + | + """.trimMargin(), + temporaryFolder, + "Group.sq", ) val fileWriter: (String) -> Appendable = { fileName -> @@ -146,7 +152,7 @@ class IntegrationTest { val result = FixtureCompiler.compileFixture( fixtureRoot = temporaryFolder.fixtureRoot().path, writer = fileWriter, - outputDirectory = File("src/test/kotlin") + outputDirectory = File("src/test/kotlin"), ) temporaryFolder.delete() @@ -173,15 +179,17 @@ class IntegrationTest { val resultSetChanged = AtomicInteger(0) val allPlayers = queryWrapper.playerQueries.allPlayers() - allPlayers.addListener(object : Query.Listener { - override fun queryResultsChanged() { - resultSetChanged.incrementAndGet() - } - }) + allPlayers.addListener( + object : Query.Listener { + override fun queryResultsChanged() { + resultSetChanged.incrementAndGet() + } + }, + ) assertThat(allPlayers.executeAsList()).containsExactly( Player(Player.Name("Ryan Getzlaf"), 15, Team.Name("Anaheim Ducks"), RIGHT), - Player(Player.Name("Erik Karlsson"), 65, Team.Name("Ottawa Senators"), RIGHT) + Player(Player.Name("Erik Karlsson"), 65, Team.Name("Ottawa Senators"), RIGHT), ) queryWrapper.playerQueries.insertPlayer(Player.Name("Sidney Crosby"), 87, Team.Name("Pittsburgh Penguins"), LEFT) @@ -191,7 +199,7 @@ class IntegrationTest { assertThat(allPlayers.executeAsList()).containsExactly( Player(Player.Name("Ryan Getzlaf"), 15, Team.Name("Anaheim Ducks"), RIGHT), Player(Player.Name("Erik Karlsson"), 65, Team.Name("Ottawa Senators"), RIGHT), - Player(Player.Name("Sidney Crosby"), 87, Team.Name("Pittsburgh Penguins"), LEFT) + Player(Player.Name("Sidney Crosby"), 87, Team.Name("Pittsburgh Penguins"), LEFT), ) } @@ -199,14 +207,16 @@ class IntegrationTest { val resultSetChanged = AtomicInteger(0) val teamForCoach = queryWrapper.teamQueries.teamForCoach("Randy Carlyle") - teamForCoach.addListener(object : Query.Listener { - override fun queryResultsChanged() { - resultSetChanged.incrementAndGet() - } - }) + teamForCoach.addListener( + object : Query.Listener { + override fun queryResultsChanged() { + resultSetChanged.incrementAndGet() + } + }, + ) assertThat(teamForCoach.executeAsList()).containsExactly( - TeamForCoach(Team.Name("Anaheim Ducks"), 15) + TeamForCoach(Team.Name("Anaheim Ducks"), 15), ) queryWrapper.playerQueries.insertPlayer(Player.Name("Sidney Crosby"), 87, Team.Name("Pittsburgh Penguins"), LEFT) @@ -218,14 +228,16 @@ class IntegrationTest { val resultSetChanged = AtomicInteger(0) val playersForNumbers = queryWrapper.playerQueries.playersForNumbers(listOf(15, 87)) - playersForNumbers.addListener(object : Query.Listener { - override fun queryResultsChanged() { - resultSetChanged.incrementAndGet() - } - }) + playersForNumbers.addListener( + object : Query.Listener { + override fun queryResultsChanged() { + resultSetChanged.incrementAndGet() + } + }, + ) assertThat(playersForNumbers.executeAsList()).containsExactly( - Player(Player.Name("Ryan Getzlaf"), 15, Team.Name("Anaheim Ducks"), RIGHT) + Player(Player.Name("Ryan Getzlaf"), 15, Team.Name("Anaheim Ducks"), RIGHT), ) queryWrapper.playerQueries.insertPlayer(Player.Name("Sidney Crosby"), 87, Team.Name("Pittsburgh Penguins"), LEFT) @@ -234,7 +246,7 @@ class IntegrationTest { assertThat(playersForNumbers.executeAsList()).containsExactly( Player(Player.Name("Ryan Getzlaf"), 15, Team.Name("Anaheim Ducks"), RIGHT), - Player(Player.Name("Sidney Crosby"), 87, Team.Name("Pittsburgh Penguins"), LEFT) + Player(Player.Name("Sidney Crosby"), 87, Team.Name("Pittsburgh Penguins"), LEFT), ) } @@ -242,14 +254,16 @@ class IntegrationTest { val resultSetChanged = AtomicInteger(0) val playersForNumbers = queryWrapper.playerQueries.playersForNumbers(listOf(10, 87, 15)) - playersForNumbers.addListener(object : Query.Listener { - override fun queryResultsChanged() { - resultSetChanged.incrementAndGet() - } - }) + playersForNumbers.addListener( + object : Query.Listener { + override fun queryResultsChanged() { + resultSetChanged.incrementAndGet() + } + }, + ) assertThat(playersForNumbers.executeAsList()).containsExactly( - Player(Player.Name("Ryan Getzlaf"), 15, Team.Name("Anaheim Ducks"), RIGHT) + Player(Player.Name("Ryan Getzlaf"), 15, Team.Name("Anaheim Ducks"), RIGHT), ) queryWrapper.playerQueries.transaction { @@ -262,7 +276,7 @@ class IntegrationTest { assertThat(playersForNumbers.executeAsList()).containsExactly( Player(Player.Name("Ryan Getzlaf"), 15, Team.Name("Anaheim Ducks"), RIGHT), Player(Player.Name("Sidney Crosby"), 87, Team.Name("Pittsburgh Penguins"), LEFT), - Player(Player.Name("Corey Perry"), 10, Team.Name("Anaheim Ducks"), RIGHT) + Player(Player.Name("Corey Perry"), 10, Team.Name("Anaheim Ducks"), RIGHT), ) } @@ -270,14 +284,16 @@ class IntegrationTest { val resultSetChanged = AtomicInteger(0) val playersForTeam = queryWrapper.playerQueries.playersForTeam(Team.Name("Anaheim Ducks")) - playersForTeam.addListener(object : Query.Listener { - override fun queryResultsChanged() { - resultSetChanged.incrementAndGet() - } - }) + playersForTeam.addListener( + object : Query.Listener { + override fun queryResultsChanged() { + resultSetChanged.incrementAndGet() + } + }, + ) assertThat(playersForTeam.executeAsList()).containsExactly( - Player(Player.Name("Ryan Getzlaf"), 15, Team.Name("Anaheim Ducks"), RIGHT) + Player(Player.Name("Ryan Getzlaf"), 15, Team.Name("Anaheim Ducks"), RIGHT), ) queryWrapper.playerQueries.transaction { @@ -288,7 +304,7 @@ class IntegrationTest { assertThat(playersForTeam.executeAsList()).containsExactly( Player(Player.Name("Ryan Getzlaf"), 15, Team.Name("Anaheim Ducks"), RIGHT), - Player(Player.Name("Erik Karlsson"), 65, Team.Name("Anaheim Ducks"), RIGHT) + Player(Player.Name("Erik Karlsson"), 65, Team.Name("Anaheim Ducks"), RIGHT), ) } @@ -296,14 +312,16 @@ class IntegrationTest { val resultSetChanged = AtomicInteger(0) val playersForTeam = queryWrapper.playerQueries.playersForTeam(Team.Name("Anaheim Ducks")) - playersForTeam.addListener(object : Query.Listener { - override fun queryResultsChanged() { - resultSetChanged.incrementAndGet() - } - }) + playersForTeam.addListener( + object : Query.Listener { + override fun queryResultsChanged() { + resultSetChanged.incrementAndGet() + } + }, + ) assertThat(playersForTeam.executeAsList()).containsExactly( - Player(Player.Name("Ryan Getzlaf"), 15, Team.Name("Anaheim Ducks"), RIGHT) + Player(Player.Name("Ryan Getzlaf"), 15, Team.Name("Anaheim Ducks"), RIGHT), ) queryWrapper.playerQueries.transaction { @@ -316,7 +334,7 @@ class IntegrationTest { assertThat(playersForTeam.executeAsList()).containsExactly( Player(Player.Name("Ryan Getzlaf"), 15, Team.Name("Anaheim Ducks"), RIGHT), Player(Player.Name("Erik Karlsson"), 65, Team.Name("Anaheim Ducks"), RIGHT), - Player(Player.Name("Sidney Crosby"), 87, Team.Name("Anaheim Ducks"), LEFT) + Player(Player.Name("Sidney Crosby"), 87, Team.Name("Anaheim Ducks"), LEFT), ) } @@ -330,7 +348,7 @@ class IntegrationTest { @Test fun `inner type query`() { assertThat(queryWrapper.teamQueries.forInnerType(ONE).executeAsList()).containsExactly( - Team(Team.Name("Ottawa Senators"), 65, ONE, "Guy Boucher") + Team(Team.Name("Ottawa Senators"), 65, ONE, "Guy Boucher"), ) } diff --git a/sqldelight-compiler/src/main/kotlin/app/cash/sqldelight/core/GradleCompatibility.kt b/sqldelight-compiler/src/main/kotlin/app/cash/sqldelight/core/GradleCompatibility.kt index 56d6d3571a4..20a7a4f1c75 100644 --- a/sqldelight-compiler/src/main/kotlin/app/cash/sqldelight/core/GradleCompatibility.kt +++ b/sqldelight-compiler/src/main/kotlin/app/cash/sqldelight/core/GradleCompatibility.kt @@ -25,7 +25,7 @@ object GradleCompatibility { if (currentGradleVersion < minimumGradleVersion) { return CompatibilityReport.Incompatible( - reason = "Gradle plugin 'app.cash.sqldelight:gradle-plugin' is incompatible with the current SQLDelight IntelliJ Plugin version. Use version $minimumGradleVersion or later." + reason = "Gradle plugin 'app.cash.sqldelight:gradle-plugin' is incompatible with the current SQLDelight IntelliJ Plugin version. Use version $minimumGradleVersion or later.", ) } @@ -59,7 +59,7 @@ object GradleCompatibility { sealed class CompatibilityReport { object Compatible : CompatibilityReport() data class Incompatible( - val reason: String + val reason: String, ) : CompatibilityReport() } } diff --git a/sqldelight-compiler/src/main/kotlin/app/cash/sqldelight/core/SqlDelightEnvironment.kt b/sqldelight-compiler/src/main/kotlin/app/cash/sqldelight/core/SqlDelightEnvironment.kt index 1adee796d56..34fdd472e41 100644 --- a/sqldelight-compiler/src/main/kotlin/app/cash/sqldelight/core/SqlDelightEnvironment.kt +++ b/sqldelight-compiler/src/main/kotlin/app/cash/sqldelight/core/SqlDelightEnvironment.kt @@ -79,12 +79,14 @@ class SqlDelightEnvironment( init { (project.picoContainer as MutablePicoContainer).registerComponentInstance( - SqlDelightProjectService::class.java.name, this + SqlDelightProjectService::class.java.name, + this, ) CoreApplicationEnvironment.registerExtensionPoint( module.extensionArea, - ModuleExtension.EP_NAME, ModuleExtension::class.java + ModuleExtension.EP_NAME, + ModuleExtension::class.java, ) initializeApplication { @@ -134,7 +136,7 @@ class SqlDelightEnvironment( errors[key]!!.add(errorMessage(element, s)) } }, - extraAnnotators + extraAnnotators, ) if (errors.isNotEmpty()) return CompilationStatus.Failure(errors.values.flatten()) @@ -170,7 +172,7 @@ class SqlDelightEnvironment( SqlDelightCompiler.writeInterfaces( file = migrationFile, output = writer, - includeAll = true + includeAll = true, ) } logger("----- END ${migrationFile.name} in $timeTaken ms ------") @@ -178,8 +180,9 @@ class SqlDelightEnvironment( sourceFile?.let { SqlDelightCompiler.writeDatabaseInterface(module, it, moduleName, writer) - if (it is SqlDelightQueriesFile) + if (it is SqlDelightQueriesFile) { SqlDelightCompiler.writeImplementations(module, it, moduleName, writer) + } } return CompilationStatus.Success() @@ -205,7 +208,7 @@ class SqlDelightEnvironment( if (errorElements.isNotEmpty()) { throw SqlDelightException( "Error Reading ${it.name}:\n\n" + - errorElements.joinToString(separator = "\n") { errorMessage(it, it.errorDescription) } + errorElements.joinToString(separator = "\n") { errorMessage(it, it.errorDescription) }, ) } body(it) @@ -322,14 +325,14 @@ class SqlDelightEnvironment( val path = file.parent!!.relativePathUnder(sourceFolder) if (path != null) return path.joinToString(separator = ".") { SqlDelightFileIndex.sanitizeDirectoryName( - it + it, ) } } throw IllegalStateException( "Tried to find package name of file ${file.virtualFile!!.path} when" + - " it is not under any of the source folders $sourceFolders" + " it is not under any of the source folders $sourceFolders", ) } diff --git a/sqldelight-compiler/src/main/kotlin/app/cash/sqldelight/core/compiler/DatabaseExposerGenerator.kt b/sqldelight-compiler/src/main/kotlin/app/cash/sqldelight/core/compiler/DatabaseExposerGenerator.kt index d8bb1659338..81b5e2061df 100644 --- a/sqldelight-compiler/src/main/kotlin/app/cash/sqldelight/core/compiler/DatabaseExposerGenerator.kt +++ b/sqldelight-compiler/src/main/kotlin/app/cash/sqldelight/core/compiler/DatabaseExposerGenerator.kt @@ -16,7 +16,7 @@ import kotlin.reflect.KClass internal class DatabaseExposerGenerator( val implementation: TypeSpec, val fileIndex: SqlDelightFileIndex, - val generateAsync: Boolean + val generateAsync: Boolean, ) { private val interfaceType = ClassName(fileIndex.packageName, fileIndex.className) @@ -27,7 +27,7 @@ internal class DatabaseExposerGenerator( .getter( FunSpec.getterBuilder() .addStatement("return %N.Schema", implementation) - .build() + .build(), ) .build() } diff --git a/sqldelight-compiler/src/main/kotlin/app/cash/sqldelight/core/compiler/DatabaseGenerator.kt b/sqldelight-compiler/src/main/kotlin/app/cash/sqldelight/core/compiler/DatabaseGenerator.kt index 1abf4a85c77..c07e2354654 100644 --- a/sqldelight-compiler/src/main/kotlin/app/cash/sqldelight/core/compiler/DatabaseGenerator.kt +++ b/sqldelight-compiler/src/main/kotlin/app/cash/sqldelight/core/compiler/DatabaseGenerator.kt @@ -104,26 +104,26 @@ internal class DatabaseGenerator( .getter( FunSpec.getterBuilder() .addStatement("return %T::class.schema", type) - .build() + .build(), ) - .build() + .build(), ) .addFunction( invoke .addCode( invokeReturn .add(")") - .build() + .build(), ) - .build() + .build(), ) - .build() + .build(), ) .build() } private fun forAdapters( - block: (PropertySpec) -> Unit + block: (PropertySpec) -> Unit, ) { sourceFolders .flatMap { it.queryFiles() } @@ -174,7 +174,7 @@ internal class DatabaseGenerator( if (file.requiredAdapters.isNotEmpty()) { adapters = file.requiredAdapters.joinToString( prefix = ", ", - transform = { it.name } + transform = { it.name }, ) } // queries property added to QueryWrapper type: @@ -183,7 +183,7 @@ internal class DatabaseGenerator( PropertySpec.builder(file.queriesName, file.queriesType) .addModifiers(OVERRIDE) .initializer("%T($DRIVER_NAME$adapters)", file.queriesType) - .build() + .build(), ) } @@ -225,12 +225,13 @@ internal class DatabaseGenerator( } migrateFunction.beginControlFlow( "if (%N <= ${migrationFile.version} && %N > ${migrationFile.version})", - oldVersion, newVersion + oldVersion, + newVersion, ) migrationFile.sqlStatements().forEach { migrateFunction.addStatement( if (generateAsync) "$DRIVER_NAME.execute(null, %S, 0).await()" else "$DRIVER_NAME.execute(null, %S, 0)", - it.rawSqlText() + it.rawSqlText(), ) } migrateFunction.endControlFlow() @@ -253,9 +254,9 @@ internal class DatabaseGenerator( .addProperty( PropertySpec.builder("version", INT, OVERRIDE) .getter(FunSpec.getterBuilder().addStatement("return $maxVersion").build()) - .build() + .build(), ) - .build() + .build(), ) .addSuperinterface(ClassName(fileIndex.packageName, fileIndex.className)) .primaryConstructor(constructor.build()) diff --git a/sqldelight-compiler/src/main/kotlin/app/cash/sqldelight/core/compiler/ExecuteQueryGenerator.kt b/sqldelight-compiler/src/main/kotlin/app/cash/sqldelight/core/compiler/ExecuteQueryGenerator.kt index 348b9be1bda..aa5537a2bf8 100644 --- a/sqldelight-compiler/src/main/kotlin/app/cash/sqldelight/core/compiler/ExecuteQueryGenerator.kt +++ b/sqldelight-compiler/src/main/kotlin/app/cash/sqldelight/core/compiler/ExecuteQueryGenerator.kt @@ -27,7 +27,7 @@ open class ExecuteQueryGenerator( query.statement, SqlUpdateStmtLimited::class.java, SqlDeleteStmtLimited::class.java, - SqlInsertStmt::class.java + SqlInsertStmt::class.java, ).flatMap { MutatorQueryGenerator( when (it) { @@ -35,7 +35,7 @@ open class ExecuteQueryGenerator( is SqlDeleteStmtLimited -> NamedMutator.Delete(it, query.identifier as StmtIdentifierMixin) is SqlInsertStmt -> NamedMutator.Insert(it, query.identifier as StmtIdentifierMixin) else -> throw IllegalArgumentException("Unexpected statement $it") - } + }, ).tablesUpdated() }.distinctBy { it.name } } @@ -61,7 +61,7 @@ open class ExecuteQueryGenerator( } } .endControlFlow() - .build() + .build(), ) return this @@ -84,7 +84,7 @@ open class ExecuteQueryGenerator( .addParameters( query.parameters.map { ParameterSpec.builder(it.name, it.argumentType()).build() - } + }, ) } diff --git a/sqldelight-compiler/src/main/kotlin/app/cash/sqldelight/core/compiler/QueryGenerator.kt b/sqldelight-compiler/src/main/kotlin/app/cash/sqldelight/core/compiler/QueryGenerator.kt index 2e6f7812c51..df8d1802aa4 100644 --- a/sqldelight-compiler/src/main/kotlin/app/cash/sqldelight/core/compiler/QueryGenerator.kt +++ b/sqldelight-compiler/src/main/kotlin/app/cash/sqldelight/core/compiler/QueryGenerator.kt @@ -75,7 +75,7 @@ abstract class QueryGenerator( private fun executeBlock( statement: PsiElement, - id: Int + id: Int, ): CodeBlock { val dialectPreparedStatementType = if (generateAsync) dialect.asyncRuntimeTypes.preparedStatementType else dialect.runtimeTypes.preparedStatementType @@ -144,7 +144,7 @@ abstract class QueryGenerator( result.addStatement( """ |val ${type.name}Indexes = createArguments(count = ${type.name}.size) - """.trimMargin() + """.trimMargin(), ) } @@ -162,8 +162,9 @@ abstract class QueryGenerator( """ |${type.name}.forEachIndexed { index, $elementName -> | %L} - |""".trimMargin(), - type.copy(name = elementName).preparedStatementBinder(indexCalculator) + | + """.trimMargin(), + type.copy(name = elementName).preparedStatementBinder(indexCalculator), ) precedingArrays.add(type.name) @@ -223,7 +224,7 @@ abstract class QueryGenerator( } val arguments = mutableListOf( statement.rawSqlText(replacements), - argumentCounts.ifEmpty { listOf(0) }.joinToString(" + ") + argumentCounts.ifEmpty { listOf(0) }.joinToString(" + "), ) var binder: String @@ -269,17 +270,17 @@ abstract class QueryGenerator( } result.addStatement( "$execute($statementId, %P, $MAPPER_NAME, %L)$binder", - *arguments.toTypedArray() + *arguments.toTypedArray(), ) } else if (optimisticLock != null) { result.addStatement( "val result = $DRIVER_NAME.execute($statementId, %P, %L)$binder", - *arguments.toTypedArray() + *arguments.toTypedArray(), ) } else { result.addStatement( "$DRIVER_NAME.execute($statementId, %P, %L)$binder", - *arguments.toTypedArray() + *arguments.toTypedArray(), ) } @@ -290,7 +291,7 @@ abstract class QueryGenerator( """.trimIndent(), if (generateAsync) ".await()" else ".value", ClassName("app.cash.sqldelight.db", "OptimisticLockException"), - "UPDATE on ${query.tablesAffected.single().name} failed because optimistic lock ${optimisticLock.name} did not match" + "UPDATE on ${query.tablesAffected.single().name} failed because optimistic lock ${optimisticLock.name} did not match", ) } diff --git a/sqldelight-compiler/src/main/kotlin/app/cash/sqldelight/core/compiler/QueryInterfaceGenerator.kt b/sqldelight-compiler/src/main/kotlin/app/cash/sqldelight/core/compiler/QueryInterfaceGenerator.kt index 020af2709e9..40440af3052 100644 --- a/sqldelight-compiler/src/main/kotlin/app/cash/sqldelight/core/compiler/QueryInterfaceGenerator.kt +++ b/sqldelight-compiler/src/main/kotlin/app/cash/sqldelight/core/compiler/QueryInterfaceGenerator.kt @@ -35,7 +35,7 @@ class QueryInterfaceGenerator(val query: NamedQuery) { PropertySpec.builder(it.name, typeWithoutAnnotations) .initializer(it.name) .addAnnotations(javaType.annotations) - .build() + .build(), ) constructor.addParameter(it.name, typeWithoutAnnotations) } diff --git a/sqldelight-compiler/src/main/kotlin/app/cash/sqldelight/core/compiler/SelectQueryGenerator.kt b/sqldelight-compiler/src/main/kotlin/app/cash/sqldelight/core/compiler/SelectQueryGenerator.kt index 85900597dc5..0370d87d810 100644 --- a/sqldelight-compiler/src/main/kotlin/app/cash/sqldelight/core/compiler/SelectQueryGenerator.kt +++ b/sqldelight-compiler/src/main/kotlin/app/cash/sqldelight/core/compiler/SelectQueryGenerator.kt @@ -97,10 +97,10 @@ class SelectQueryGenerator( CodeBlock.of(query.name) } else { params.joinToCode(", ", "${query.name}(", ")") - } + }, ) .add(trailingLambda) - .build() + .build(), ) .build() } @@ -143,9 +143,9 @@ class SelectQueryGenerator( ParameterSpec.builder(it.name, it.javaType.copy(annotations = emptyList())) .build() }, - returnType = typeVariable - ) - ).build() + returnType = typeVariable, + ), + ).build(), ) // Specify the return type for the mapper: @@ -184,7 +184,7 @@ class SelectQueryGenerator( """%M(%M(%L).size == 1) { "Adapter·types·are·expected·to·be·identical." }""", MemberName("kotlin", "check"), MemberName("kotlin.collections", "setOf"), - adapterNames.joinToString() + adapterNames.joinToString(), ) } } @@ -232,24 +232,32 @@ class SelectQueryGenerator( if (query.tablesObserved != null) { function.addCode( "return %T(${query.id}, %L, $DRIVER_NAME, %S, %S, %S)%L", - QUERY_TYPE, queryKeys(query.tablesObserved!!), query.statement.containingFile.name, query.name, - query.statement.rawSqlText(), mapperLambda.build() + QUERY_TYPE, + queryKeys(query.tablesObserved!!), + query.statement.containingFile.name, + query.name, + query.statement.rawSqlText(), + mapperLambda.build(), ) } else { function.addCode( "return %T(${query.id}, $DRIVER_NAME, %S, %S, %S)%L", - QUERY_TYPE, query.statement.containingFile.name, query.name, - query.statement.rawSqlText(), mapperLambda.build() + QUERY_TYPE, + query.statement.containingFile.name, + query.name, + query.statement.rawSqlText(), + mapperLambda.build(), ) } } else { // Custom type is needed to handle dirtying events, return an instance of custom type: // return SelectForId(id) { resultSet -> ... } function.addCode( - "return %N(%L)%L", query.customQuerySubtype, + "return %N(%L)%L", + query.customQuerySubtype, query.arguments.sortedBy { it.index } .joinToString { (_, parameter) -> parameter.name }, - mapperLambda.build() + mapperLambda.build(), ) } @@ -311,7 +319,7 @@ class SelectQueryGenerator( queryType.addProperty( PropertySpec.builder(parameter.name, parameter.argumentType()) .initializer(parameter.name) - .build() + .build(), ) constructor.addParameter(parameter.name, parameter.argumentType()) } @@ -321,8 +329,8 @@ class SelectQueryGenerator( MAPPER_NAME, LambdaTypeName.get( parameters = arrayOf(CURSOR_TYPE), - returnType = returnType - ) + returnType = returnType, + ), ) queryType.addSuperclassConstructorParameter(MAPPER_NAME) @@ -333,14 +341,14 @@ class SelectQueryGenerator( .addModifiers(OVERRIDE) .addParameter("listener", QUERY_LISTENER_TYPE) .addStatement("driver.addListener(listener, arrayOf(${query.tablesObserved!!.joinToString { "\"${it.name}\"" }}))") - .build() + .build(), ) .addFunction( FunSpec.builder("removeListener") .addModifiers(OVERRIDE) .addParameter("listener", QUERY_LISTENER_TYPE) .addStatement("driver.removeListener(listener, arrayOf(${query.tablesObserved!!.joinToString { "\"${it.name}\"" }}))") - .build() + .build(), ) } @@ -352,7 +360,7 @@ class SelectQueryGenerator( .addModifiers(OVERRIDE) .returns(String::class) .addStatement("return %S", "${query.statement.containingFile.name}:${query.name}") - .build() + .build(), ) .build() } diff --git a/sqldelight-compiler/src/main/kotlin/app/cash/sqldelight/core/compiler/SqlDelightCompiler.kt b/sqldelight-compiler/src/main/kotlin/app/cash/sqldelight/core/compiler/SqlDelightCompiler.kt index 53d4dadac92..96f5c092646 100644 --- a/sqldelight-compiler/src/main/kotlin/app/cash/sqldelight/core/compiler/SqlDelightCompiler.kt +++ b/sqldelight-compiler/src/main/kotlin/app/cash/sqldelight/core/compiler/SqlDelightCompiler.kt @@ -56,7 +56,7 @@ object SqlDelightCompiler { fun writeInterfaces( file: MigrationFile, output: FileAppender, - includeAll: Boolean = false + includeAll: Boolean = false, ) { writeTableInterfaces(file, output, includeAll) } @@ -123,7 +123,7 @@ object SqlDelightCompiler { internal fun writeTableInterfaces( file: SqlDelightFile, output: FileAppender, - includeAll: Boolean = false + includeAll: Boolean = false, ) { val packageName = file.packageName ?: return file.tables(includeAll).forEach { query -> @@ -152,7 +152,7 @@ object SqlDelightCompiler { internal fun writeQueryInterfaces( file: SqlDelightQueriesFile, - output: FileAppender + output: FileAppender, ) { file.namedQueries.writeQueryInterfaces(file, output) } @@ -217,7 +217,7 @@ object SqlDelightCompiler { internal fun tryWithElement( element: PsiElement, - block: () -> T + block: () -> T, ): T? { try { return block() diff --git a/sqldelight-compiler/src/main/kotlin/app/cash/sqldelight/core/compiler/TableInterfaceGenerator.kt b/sqldelight-compiler/src/main/kotlin/app/cash/sqldelight/core/compiler/TableInterfaceGenerator.kt index be3cc8a1aa6..7339af4988c 100644 --- a/sqldelight-compiler/src/main/kotlin/app/cash/sqldelight/core/compiler/TableInterfaceGenerator.kt +++ b/sqldelight-compiler/src/main/kotlin/app/cash/sqldelight/core/compiler/TableInterfaceGenerator.kt @@ -42,7 +42,7 @@ internal class TableInterfaceGenerator(private val table: LazyQuery) { val identifier = PsiTreeUtil.getPrevSiblingOfType( PsiTreeUtil.getParentOfType(table.tableName, SqlStmt::class.java), - SqlDelightStmtIdentifier::class.java + SqlDelightStmtIdentifier::class.java, ) identifier?.childOfType(SqlTypes.JAVADOC)?.let { javadoc -> javadocText(javadoc)?.let { typeSpec.addKdoc(it) } @@ -60,7 +60,7 @@ internal class TableInterfaceGenerator(private val table: LazyQuery) { PropertySpec.builder(columnName, typeWithoutAnnotations) .initializer(columnName) .addAnnotations(javaType.annotations) - .build() + .build(), ) val param = ParameterSpec.builder(columnName, typeWithoutAnnotations) columnDef.javadoc?.let(::javadocText)?.let { param.addKdoc(it) } @@ -79,18 +79,18 @@ internal class TableInterfaceGenerator(private val table: LazyQuery) { .addParameters( adapters.map { ParameterSpec.builder(it.name, it.type, *it.modifiers.toTypedArray()).build() - } + }, ) - .build() + .build(), ) .addProperties( adapters.map { PropertySpec.builder(it.name, it.type, *it.modifiers.toTypedArray()) .initializer(it.name) .build() - } + }, ) - .build() + .build(), ) } diff --git a/sqldelight-compiler/src/main/kotlin/app/cash/sqldelight/core/compiler/KotlinPoet.kt b/sqldelight-compiler/src/main/kotlin/app/cash/sqldelight/core/compiler/ToCodeLiteral.kt similarity index 100% rename from sqldelight-compiler/src/main/kotlin/app/cash/sqldelight/core/compiler/KotlinPoet.kt rename to sqldelight-compiler/src/main/kotlin/app/cash/sqldelight/core/compiler/ToCodeLiteral.kt diff --git a/sqldelight-compiler/src/main/kotlin/app/cash/sqldelight/core/compiler/integration/JavadocIntegration.kt b/sqldelight-compiler/src/main/kotlin/app/cash/sqldelight/core/compiler/integration/JavadocText.kt similarity index 100% rename from sqldelight-compiler/src/main/kotlin/app/cash/sqldelight/core/compiler/integration/JavadocIntegration.kt rename to sqldelight-compiler/src/main/kotlin/app/cash/sqldelight/core/compiler/integration/JavadocText.kt diff --git a/sqldelight-compiler/src/main/kotlin/app/cash/sqldelight/core/compiler/integration/TableIntegration.kt b/sqldelight-compiler/src/main/kotlin/app/cash/sqldelight/core/compiler/integration/TableIntegration.kt index de221ec6e1b..3a557afca0c 100644 --- a/sqldelight-compiler/src/main/kotlin/app/cash/sqldelight/core/compiler/integration/TableIntegration.kt +++ b/sqldelight-compiler/src/main/kotlin/app/cash/sqldelight/core/compiler/integration/TableIntegration.kt @@ -22,7 +22,7 @@ internal fun LazyQuery.adapterProperty(): PropertySpec { val adapterType = ClassName( (tableName.containingFile as SqlDelightFile).packageName!!, SqlDelightCompiler.allocateName(tableName).capitalize(), - ADAPTER_NAME + ADAPTER_NAME, ) return PropertySpec.builder(adapterName, adapterType, KModifier.PRIVATE) .initializer(adapterName) diff --git a/sqldelight-compiler/src/main/kotlin/app/cash/sqldelight/core/compiler/model/BindableQuery.kt b/sqldelight-compiler/src/main/kotlin/app/cash/sqldelight/core/compiler/model/BindableQuery.kt index a35000ddaf9..b7de29ff05e 100644 --- a/sqldelight-compiler/src/main/kotlin/app/cash/sqldelight/core/compiler/model/BindableQuery.kt +++ b/sqldelight-compiler/src/main/kotlin/app/cash/sqldelight/core/compiler/model/BindableQuery.kt @@ -43,7 +43,7 @@ import java.util.concurrent.ConcurrentHashMap abstract class BindableQuery( internal val identifier: StmtIdentifierMixin?, - internal val statement: SqlAnnotatedElement + internal val statement: SqlAnnotatedElement, ) { protected val typeResolver = statement.typeResolver @@ -61,8 +61,8 @@ abstract class BindableQuery( IntermediateType( ARGUMENT, javaType = ClassName(table.sqFile().packageName!!, allocateName(statement.tableName).capitalize()), - name = allocateName(statement.tableName) - ) + name = allocateName(statement.tableName), + ), ) } return@lazy arguments.sortedBy { it.index }.map { it.type } @@ -78,9 +78,9 @@ abstract class BindableQuery( index + 1, column.type().let { it.copy( - name = "${allocateName(statement.tableName)}.${it.name}" + name = "${allocateName(statement.tableName)}.${it.name}", ) - } + }, ) } } @@ -144,7 +144,7 @@ abstract class BindableQuery( private fun MutableList.findAndReplace( bindArg: SqlBindExpr, index: Int? = null, - condition: (Argument) -> Boolean + condition: (Argument) -> Boolean, ) { val current = first(condition) current.bindArgs.add(bindArg) @@ -174,10 +174,10 @@ abstract class BindableQuery( type = newArgumentType.run { copy( javaType = javaType.copy(nullable = current.type.javaType.isNullable || newType.javaType.isNullable), - name = bindArg.bindParameter.identifier?.text ?: name + name = bindArg.bindParameter.identifier?.text ?: name, ) - } - ) + }, + ), ) } } @@ -187,7 +187,7 @@ abstract class BindableQuery( return getUniqueQueryIdentifier( statement.sqFile().let { "${it.packageName}:${it.name}:${identifier?.name ?: ""}$postFix" - } + }, ) } @@ -197,7 +197,7 @@ abstract class BindableQuery( data class Argument( val index: Int, val type: IntermediateType, - val bindArgs: MutableList = mutableListOf() + val bindArgs: MutableList = mutableListOf(), ) companion object { @@ -222,7 +222,7 @@ abstract class BindableQuery( // to give a different query than adding logic to generate deterministic identifier throw RuntimeException( "HashCode collision happened when generating unique identifier for $qualifiedQueryName." + - "Please give a different name" + "Please give a different name", ) } queryIdMap[qualifiedQueryName] = queryId diff --git a/sqldelight-compiler/src/main/kotlin/app/cash/sqldelight/core/compiler/model/NamedExecute.kt b/sqldelight-compiler/src/main/kotlin/app/cash/sqldelight/core/compiler/model/NamedExecute.kt index b5281f47aa9..ec71f99acac 100644 --- a/sqldelight-compiler/src/main/kotlin/app/cash/sqldelight/core/compiler/model/NamedExecute.kt +++ b/sqldelight-compiler/src/main/kotlin/app/cash/sqldelight/core/compiler/model/NamedExecute.kt @@ -5,7 +5,7 @@ import com.alecstrong.sql.psi.core.psi.SqlAnnotatedElement open class NamedExecute( identifier: StmtIdentifierMixin, - statement: SqlAnnotatedElement + statement: SqlAnnotatedElement, ) : BindableQuery(identifier, statement) { val name = identifier.name!! diff --git a/sqldelight-compiler/src/main/kotlin/app/cash/sqldelight/core/compiler/model/NamedMutator.kt b/sqldelight-compiler/src/main/kotlin/app/cash/sqldelight/core/compiler/model/NamedMutator.kt index 9d550b5b3ff..e71fd084084 100644 --- a/sqldelight-compiler/src/main/kotlin/app/cash/sqldelight/core/compiler/model/NamedMutator.kt +++ b/sqldelight-compiler/src/main/kotlin/app/cash/sqldelight/core/compiler/model/NamedMutator.kt @@ -31,7 +31,7 @@ import com.alecstrong.sql.psi.core.psi.SqlUpdateStmtLimited sealed class NamedMutator( statement: SqlAnnotatedElement, identifier: StmtIdentifierMixin, - tableName: SqlTableName + tableName: SqlTableName, ) : NamedExecute(identifier, statement) { val containingFile = statement.sqFile() as SqlDelightQueriesFile @@ -41,18 +41,18 @@ sealed class NamedMutator( class Insert( insert: SqlInsertStmt, - identifier: StmtIdentifierMixin + identifier: StmtIdentifierMixin, ) : NamedMutator(insert, identifier, insert.tableName) { val hasUpsertClause get() = statement.node.findChildRecursive(SqlTypes.UPDATE) != null } class Delete( delete: SqlDeleteStmtLimited, - identifier: StmtIdentifierMixin + identifier: StmtIdentifierMixin, ) : NamedMutator(delete, identifier, delete.qualifiedTableName!!.tableName) class Update( internal val update: SqlUpdateStmtLimited, - identifier: StmtIdentifierMixin + identifier: StmtIdentifierMixin, ) : NamedMutator(update, identifier, update.qualifiedTableName.tableName) } diff --git a/sqldelight-compiler/src/main/kotlin/app/cash/sqldelight/core/compiler/model/NamedQuery.kt b/sqldelight-compiler/src/main/kotlin/app/cash/sqldelight/core/compiler/model/NamedQuery.kt index 8196cb4239e..d8c5cce8ab5 100644 --- a/sqldelight-compiler/src/main/kotlin/app/cash/sqldelight/core/compiler/model/NamedQuery.kt +++ b/sqldelight-compiler/src/main/kotlin/app/cash/sqldelight/core/compiler/model/NamedQuery.kt @@ -47,7 +47,7 @@ import com.squareup.kotlinpoet.PropertySpec data class NamedQuery( val name: String, val queryable: QueryWithResults, - private val statementIdentifier: StmtIdentifierMixin? = null + private val statementIdentifier: StmtIdentifierMixin? = null, ) : BindableQuery(statementIdentifier, queryable.statement) { internal val select get() = queryable.statement internal val pureTable get() = queryable.pureTable @@ -141,7 +141,7 @@ data class NamedQuery( val exposedTypes = values.exprList.map { it.type() } if (results.isEmpty()) return@fold exposedTypes return@fold results.zip(exposedTypes, this::superType) - } + }, ) } @@ -193,7 +193,7 @@ data class NamedQuery( } private fun QueryElement.typesExposed( - namesUsed: LinkedHashSet + namesUsed: LinkedHashSet, ): List { return queryExposed().flatMap { val table = it.table?.name diff --git a/sqldelight-compiler/src/main/kotlin/app/cash/sqldelight/core/compiler/model/PragmaWithResults.kt b/sqldelight-compiler/src/main/kotlin/app/cash/sqldelight/core/compiler/model/PragmaWithResults.kt index e201cca247d..71d73785baf 100644 --- a/sqldelight-compiler/src/main/kotlin/app/cash/sqldelight/core/compiler/model/PragmaWithResults.kt +++ b/sqldelight-compiler/src/main/kotlin/app/cash/sqldelight/core/compiler/model/PragmaWithResults.kt @@ -18,7 +18,7 @@ class PragmaWithResults(private val pragmaStmt: SqlPragmaStmt) : QueryWithResult internal class SqlDelightPragmaName(node: ASTNode?) : SqlPragmaNameImpl(node), QueryElement { override fun queryExposed() = listOf( QueryResult( - column = this - ) + column = this, + ), ) } diff --git a/sqldelight-compiler/src/main/kotlin/app/cash/sqldelight/core/lang/insertStmt.kt b/sqldelight-compiler/src/main/kotlin/app/cash/sqldelight/core/lang/AcceptsTableInterface.kt similarity index 100% rename from sqldelight-compiler/src/main/kotlin/app/cash/sqldelight/core/lang/insertStmt.kt rename to sqldelight-compiler/src/main/kotlin/app/cash/sqldelight/core/lang/AcceptsTableInterface.kt diff --git a/sqldelight-compiler/src/main/kotlin/app/cash/sqldelight/core/lang/DatabaseFileViewProviderFactory.kt b/sqldelight-compiler/src/main/kotlin/app/cash/sqldelight/core/lang/DatabaseFileViewProviderFactory.kt index 4fd3a4a75ce..720c587a9ee 100644 --- a/sqldelight-compiler/src/main/kotlin/app/cash/sqldelight/core/lang/DatabaseFileViewProviderFactory.kt +++ b/sqldelight-compiler/src/main/kotlin/app/cash/sqldelight/core/lang/DatabaseFileViewProviderFactory.kt @@ -17,7 +17,7 @@ class DatabaseFileViewProviderFactory : FileViewProviderFactory { vFile: VirtualFile, language: Language?, psiManager: PsiManager, - eventSystemEnabled: Boolean + eventSystemEnabled: Boolean, ): FileViewProvider { fun default() = SingleRootFileViewProvider(psiManager, vFile, eventSystemEnabled) @@ -54,7 +54,7 @@ class DatabaseFileViewProviderFactory : FileViewProviderFactory { internal class DatabaseFileViewProvider( manager: PsiManager, virtualFile: VirtualFile, - eventSystemEnabled: Boolean + eventSystemEnabled: Boolean, ) : SingleRootFileViewProvider(manager, virtualFile, eventSystemEnabled, DatabaseFileType) { private var schemaFile: VirtualFile? = null @@ -80,7 +80,7 @@ internal class DatabaseFileViewProvider( return LightVirtualFile( "${virtualFile.version!! - 1}.db", MigrationFileType, - statements.joinToString(separator = "\n") + statements.joinToString(separator = "\n"), ).also { schemaFile = it } } catch (e: Exception) { return null diff --git a/sqldelight-compiler/src/main/kotlin/app/cash/sqldelight/core/lang/IntermediateType.kt b/sqldelight-compiler/src/main/kotlin/app/cash/sqldelight/core/lang/IntermediateType.kt index 04384f3d1c1..b3607c75259 100644 --- a/sqldelight-compiler/src/main/kotlin/app/cash/sqldelight/core/lang/IntermediateType.kt +++ b/sqldelight-compiler/src/main/kotlin/app/cash/sqldelight/core/lang/IntermediateType.kt @@ -40,7 +40,7 @@ internal fun IntermediateType.argumentType() = if (bindArg?.isArrayParameter() = */ internal fun IntermediateType.preparedStatementBinder( columnIndex: String, - extractedVariable: String? = null + extractedVariable: String? = null, ): CodeBlock { val codeBlock = extractedVariable?.let { CodeBlock.of(it) } ?: encodedJavaType() if (codeBlock != null) { @@ -57,7 +57,7 @@ internal fun IntermediateType.preparedStatementBinder( decodedType == encodedType -> CodeBlock.of(this.name) javaType.isNullable -> encodedType.wrapInLet(this) else -> encodedType - } + }, ) } @@ -67,7 +67,7 @@ internal fun IntermediateType.encodedJavaType(): CodeBlock? { val parent = PsiTreeUtil.getParentOfType(column, Queryable::class.java) val adapterName = parent!!.tableExposed().adapterName val value = dialectType.encode( - CodeBlock.of("$adapterName.%N.encode($name)", adapter) + CodeBlock.of("$adapterName.%N.encode($name)", adapter), ) if (javaType.isNullable) { value.wrapInLet(this) @@ -97,8 +97,10 @@ internal fun IntermediateType.cursorGetter(columnIndex: Int): CodeBlock { PsiTreeUtil.getParentOfType(column, Queryable::class.java)!!.tableExposed().adapterName if (javaType.isNullable) { CodeBlock.of( - "%L?.let { $adapterName.%N.decode(%L) }", cursorGetter, adapter, - dialectType.decode(CodeBlock.of("it")) + "%L?.let { $adapterName.%N.decode(%L) }", + cursorGetter, + adapter, + dialectType.decode(CodeBlock.of("it")), ) } else { CodeBlock.of("$adapterName.%N.decode(%L)", adapter, dialectType.decode(cursorGetter)) diff --git a/sqldelight-compiler/src/main/kotlin/app/cash/sqldelight/core/lang/MigrationFile.kt b/sqldelight-compiler/src/main/kotlin/app/cash/sqldelight/core/lang/MigrationFile.kt index 342b8ae708e..0398f5cddbf 100644 --- a/sqldelight-compiler/src/main/kotlin/app/cash/sqldelight/core/lang/MigrationFile.kt +++ b/sqldelight-compiler/src/main/kotlin/app/cash/sqldelight/core/lang/MigrationFile.kt @@ -5,7 +5,7 @@ import com.alecstrong.sql.psi.core.SqlFileBase import com.intellij.psi.FileViewProvider class MigrationFile( - viewProvider: FileViewProvider + viewProvider: FileViewProvider, ) : SqlDelightFile(viewProvider, MigrationLanguage) { val version: Int by lazy { name.substringBeforeLast(".${MigrationFileType.EXTENSION}") diff --git a/sqldelight-compiler/src/main/kotlin/app/cash/sqldelight/core/lang/SqlDelightFile.kt b/sqldelight-compiler/src/main/kotlin/app/cash/sqldelight/core/lang/SqlDelightFile.kt index 82a3784af05..9dc92d6b579 100644 --- a/sqldelight-compiler/src/main/kotlin/app/cash/sqldelight/core/lang/SqlDelightFile.kt +++ b/sqldelight-compiler/src/main/kotlin/app/cash/sqldelight/core/lang/SqlDelightFile.kt @@ -18,7 +18,7 @@ import java.util.ServiceLoader abstract class SqlDelightFile( viewProvider: FileViewProvider, - language: Language + language: Language, ) : SqlFileBase(viewProvider, language) { val module: Module? get() = virtualFile?.let { SqlDelightProjectService.getInstance(project).module(it) } @@ -82,7 +82,8 @@ abstract class SqlDelightFile( val folders = SqlDelightFileIndex.getInstance(module).sourceFolders(virtualFile ?: return null) folders.forEach { dir -> VfsUtilCore.iterateChildrenRecursively( - dir, { it.isDirectory || it.fileType == DatabaseFileType }, + dir, + { it.isDirectory || it.fileType == DatabaseFileType }, { file -> if (file.isDirectory) return@iterateChildrenRecursively true @@ -97,7 +98,7 @@ abstract class SqlDelightFile( } return@iterateChildrenRecursively true - } + }, ) } return result diff --git a/sqldelight-compiler/src/main/kotlin/app/cash/sqldelight/core/lang/SqlDelightQueriesFile.kt b/sqldelight-compiler/src/main/kotlin/app/cash/sqldelight/core/lang/SqlDelightQueriesFile.kt index a65f1f8b14a..9b11916c73d 100644 --- a/sqldelight-compiler/src/main/kotlin/app/cash/sqldelight/core/lang/SqlDelightQueriesFile.kt +++ b/sqldelight-compiler/src/main/kotlin/app/cash/sqldelight/core/lang/SqlDelightQueriesFile.kt @@ -40,7 +40,7 @@ import com.intellij.psi.search.GlobalSearchScope import com.intellij.psi.util.PsiTreeUtil class SqlDelightQueriesFile( - viewProvider: FileViewProvider + viewProvider: FileViewProvider, ) : SqlDelightFile(viewProvider, SqlDelightLanguage), SqlAnnotatedElement { override val packageName by lazy { @@ -56,7 +56,7 @@ class SqlDelightQueriesFile( NamedQuery( name = it.identifier.name!!, queryable = typeResolver.queryWithResults(it.statement)!!, - statementIdentifier = it.identifier + statementIdentifier = it.identifier, ) } } @@ -83,12 +83,12 @@ class SqlDelightQueriesFile( return@map NamedQuery( statementIdentifier = it.stmtIdentifierClojure as StmtIdentifierMixin, queryable = lastQuery, - name = it.stmtIdentifierClojure.name!! + name = it.stmtIdentifierClojure.name!!, ) } else { return@map NamedExecute( identifier = it.stmtIdentifierClojure as StmtIdentifierMixin, - statement = it.stmtClojureStmtList!! + statement = it.stmtClojureStmtList!!, ) } } diff --git a/sqldelight-compiler/src/main/kotlin/app/cash/sqldelight/core/lang/psi/ClojureStmtListMixin.kt b/sqldelight-compiler/src/main/kotlin/app/cash/sqldelight/core/lang/psi/ClojureStmtListMixin.kt index 7d6d1678e4f..a1226828827 100644 --- a/sqldelight-compiler/src/main/kotlin/app/cash/sqldelight/core/lang/psi/ClojureStmtListMixin.kt +++ b/sqldelight-compiler/src/main/kotlin/app/cash/sqldelight/core/lang/psi/ClojureStmtListMixin.kt @@ -8,7 +8,7 @@ import com.intellij.lang.ASTNode import com.intellij.psi.PsiElement abstract class ClojureStmtListMixin( - node: ASTNode + node: ASTNode, ) : SqlCompositeElementImpl(node), SqlDelightStmtClojureStmtList { override fun tablesAvailable(child: PsiElement): Collection { diff --git a/sqldelight-compiler/src/main/kotlin/app/cash/sqldelight/core/lang/psi/ColumnTypeMixin.kt b/sqldelight-compiler/src/main/kotlin/app/cash/sqldelight/core/lang/psi/ColumnTypeMixin.kt index d6378ceef0d..2de1f80245b 100644 --- a/sqldelight-compiler/src/main/kotlin/app/cash/sqldelight/core/lang/psi/ColumnTypeMixin.kt +++ b/sqldelight-compiler/src/main/kotlin/app/cash/sqldelight/core/lang/psi/ColumnTypeMixin.kt @@ -54,7 +54,7 @@ import com.squareup.kotlinpoet.joinToCode import com.squareup.kotlinpoet.jvm.jvmInline internal abstract class ColumnTypeMixin( - node: ASTNode + node: ASTNode, ) : SqlColumnTypeImpl(node), TypedColumn, SqlDelightColumnType { @@ -75,7 +75,7 @@ internal abstract class ColumnTypeMixin( ?.type()?.dialectType?.castSafelyTo() ?: return@let // SqlDelight type type = type.copy( dialectType = dialectType, - javaType = dialectType.javaType + javaType = dialectType.javaType, ) } @@ -83,7 +83,7 @@ internal abstract class ColumnTypeMixin( val newDialectType = ValueTypeDialectType(valueType.name!!, type.dialectType) type = type.copy( dialectType = newDialectType, - javaType = newDialectType.javaType + javaType = newDialectType.javaType, ) } if (columnConstraintList.none { @@ -96,7 +96,7 @@ internal abstract class ColumnTypeMixin( if (annotationList.isNotEmpty()) { type = type.copy( javaType = type.javaType - .copy(annotations = type.javaType.annotations + annotationList.map { it.spec() }) + .copy(annotations = type.javaType.annotations + annotationList.map { it.spec() }), ) } return typeResolver.simplifyType(type) @@ -115,7 +115,7 @@ internal abstract class ColumnTypeMixin( return PropertySpec .builder( name = "${allocateName(columnName)}Adapter", - type = columnAdapterType.parameterizedBy(customType, typeResolver.definitionType(typeName).dialectType.javaType) + type = columnAdapterType.parameterizedBy(customType, typeResolver.definitionType(typeName).dialectType.javaType), ) .build() } @@ -131,12 +131,12 @@ internal abstract class ColumnTypeMixin( .primaryConstructor( FunSpec.constructorBuilder() .addParameter(columnName, type) - .build() + .build(), ) .addProperty( PropertySpec.builder(columnName, type) .initializer(columnName) - .build() + .build(), ) .addModifiers(KModifier.VALUE) .jvmInline() @@ -190,9 +190,9 @@ internal abstract class ColumnTypeMixin( CodeBlock.builder() .add("${identifier.text} = ") .add(annotation_value.value()) - .build() + .build(), ) - } + }, ) return annotation.build() } @@ -225,7 +225,7 @@ internal abstract class ColumnTypeMixin( internal inner class ValueTypeDialectType( name: String, - val wrappedType: DialectType + val wrappedType: DialectType, ) : DialectType by wrappedType { override val javaType: TypeName by lazy { val tableName = PsiTreeUtil.getParentOfType(this@ColumnTypeMixin, Queryable::class.java)!!.tableExposed().tableName diff --git a/sqldelight-compiler/src/main/kotlin/app/cash/sqldelight/core/lang/psi/ImportStmtMixin.kt b/sqldelight-compiler/src/main/kotlin/app/cash/sqldelight/core/lang/psi/ImportStmtMixin.kt index 11849c54551..85b228f4880 100644 --- a/sqldelight-compiler/src/main/kotlin/app/cash/sqldelight/core/lang/psi/ImportStmtMixin.kt +++ b/sqldelight-compiler/src/main/kotlin/app/cash/sqldelight/core/lang/psi/ImportStmtMixin.kt @@ -8,7 +8,7 @@ import com.alecstrong.sql.psi.core.psi.SqlCompositeElementImpl import com.intellij.lang.ASTNode abstract class ImportStmtMixin( - node: ASTNode + node: ASTNode, ) : SqlCompositeElementImpl(node), SqlDelightImportStmt, SqlAnnotatedElement { diff --git a/sqldelight-compiler/src/main/kotlin/app/cash/sqldelight/core/lang/psi/InsertStmtValuesMixin.kt b/sqldelight-compiler/src/main/kotlin/app/cash/sqldelight/core/lang/psi/InsertStmtValuesMixin.kt index 507bb217370..18aea9fc33c 100644 --- a/sqldelight-compiler/src/main/kotlin/app/cash/sqldelight/core/lang/psi/InsertStmtValuesMixin.kt +++ b/sqldelight-compiler/src/main/kotlin/app/cash/sqldelight/core/lang/psi/InsertStmtValuesMixin.kt @@ -11,7 +11,7 @@ import com.intellij.lang.ASTNode import com.intellij.psi.util.parentOfType open class InsertStmtValuesMixin( - node: ASTNode + node: ASTNode, ) : SqlInsertStmtValuesImpl(node), SqlDelightInsertStmtValues { override fun annotate(annotationHolder: SqlAnnotationHolder) { @@ -20,7 +20,7 @@ open class InsertStmtValuesMixin( if (parentOfType(withSelf = false) != null) { annotationHolder.createErrorAnnotation( this, - "Table parameters are not usable in a grouped statement." + "Table parameters are not usable in a grouped statement.", ) } @@ -44,13 +44,13 @@ open class InsertStmtValuesMixin( annotationHolder.createErrorAnnotation( parent, "Cannot populate default value for column " + - "${needsDefaultValue.first().name}, it must be specified in insert statement." + "${needsDefaultValue.first().name}, it must be specified in insert statement.", ) } else if (needsDefaultValue.size > 1) { annotationHolder.createErrorAnnotation( parent, "Cannot populate default values for columns " + - "(${needsDefaultValue.joinToString { it.name }}), they must be specified in insert statement." + "(${needsDefaultValue.joinToString { it.name }}), they must be specified in insert statement.", ) } diff --git a/sqldelight-compiler/src/main/kotlin/app/cash/sqldelight/core/lang/psi/JavaTypeMixin.kt b/sqldelight-compiler/src/main/kotlin/app/cash/sqldelight/core/lang/psi/JavaTypeMixin.kt index d2be48424e3..1f53aef25ee 100644 --- a/sqldelight-compiler/src/main/kotlin/app/cash/sqldelight/core/lang/psi/JavaTypeMixin.kt +++ b/sqldelight-compiler/src/main/kotlin/app/cash/sqldelight/core/lang/psi/JavaTypeMixin.kt @@ -11,7 +11,7 @@ import com.intellij.psi.impl.source.resolve.reference.ReferenceProvidersRegistry import com.intellij.psi.impl.source.resolve.reference.impl.PsiMultiReference abstract class JavaTypeMixin( - node: ASTNode + node: ASTNode, ) : SqlNamedElementImpl(node) { override val parseRule: (PsiBuilder, Int) -> Boolean = SqldelightParser::java_type_real diff --git a/sqldelight-compiler/src/main/kotlin/app/cash/sqldelight/core/lang/psi/SignatureData.kt b/sqldelight-compiler/src/main/kotlin/app/cash/sqldelight/core/lang/psi/SignatureData.kt index 44e9e8748eb..9db5e1b79ba 100644 --- a/sqldelight-compiler/src/main/kotlin/app/cash/sqldelight/core/lang/psi/SignatureData.kt +++ b/sqldelight-compiler/src/main/kotlin/app/cash/sqldelight/core/lang/psi/SignatureData.kt @@ -14,7 +14,7 @@ fun QueryColumn.parameterValue(): SuggestedRefactoringSupport.Parameter? = eleme type = column.columnType.typeName.text, additionalData = column.columnConstraintList.takeIf { it.isNotEmpty() }?.let { list -> ColumnConstraints((list.filter { it.text.isNotBlank() }.joinToString(" ") { it.text.trim() })) - } + }, ) } @@ -24,7 +24,7 @@ fun SqlColumnDef.asParameter() = SuggestedRefactoringSupport.Parameter( type = columnType.typeName.text, additionalData = columnConstraintList.takeIf { it.isNotEmpty() }?.let { list -> ColumnConstraints((list.filter { it.text.isNotBlank() }.joinToString(" ") { it.text.trim() })) - } + }, ) data class ColumnConstraints(val constraints: String) : ParameterAdditionalData { diff --git a/sqldelight-compiler/src/main/kotlin/app/cash/sqldelight/core/lang/psi/StmtIdentifierMixin.kt b/sqldelight-compiler/src/main/kotlin/app/cash/sqldelight/core/lang/psi/StmtIdentifierMixin.kt index 631440f7d6b..0a654b10dbd 100644 --- a/sqldelight-compiler/src/main/kotlin/app/cash/sqldelight/core/lang/psi/StmtIdentifierMixin.kt +++ b/sqldelight-compiler/src/main/kotlin/app/cash/sqldelight/core/lang/psi/StmtIdentifierMixin.kt @@ -19,7 +19,7 @@ import com.intellij.psi.impl.GeneratedMarkerVisitor import com.intellij.psi.impl.source.tree.TreeElement abstract class StmtIdentifierMixin( - node: ASTNode + node: ASTNode, ) : ASTWrapperPsiElement(node), SqlDelightStmtIdentifier, SqlDelightStmtIdentifierClojure, @@ -29,10 +29,17 @@ abstract class StmtIdentifierMixin( override fun setName(name: String): PsiElement { val parserDefinition = LanguageParserDefinitions.INSTANCE.forLanguage(language) as SqlParserDefinition var builder = PsiBuilderFactory.getInstance().createBuilder( - project, node, parserDefinition.createLexer(project), language, name + project, + node, + parserDefinition.createLexer(project), + language, + name, ) builder = GeneratedParserUtilBase.adapt_builder_( - SqlTypes.IDENTIFIER, builder, SqlParser(), SqlParser.EXTENDS_SETS_ + SqlTypes.IDENTIFIER, + builder, + SqlParser(), + SqlParser.EXTENDS_SETS_, ) GeneratedParserUtilBase.ErrorState.get(builder).currentFrame = GeneratedParserUtilBase.Frame() diff --git a/sqldelight-compiler/src/main/kotlin/app/cash/sqldelight/core/lang/util/Columns.kt b/sqldelight-compiler/src/main/kotlin/app/cash/sqldelight/core/lang/util/ColumnDefSource.kt similarity index 100% rename from sqldelight-compiler/src/main/kotlin/app/cash/sqldelight/core/lang/util/Columns.kt rename to sqldelight-compiler/src/main/kotlin/app/cash/sqldelight/core/lang/util/ColumnDefSource.kt diff --git a/sqldelight-compiler/src/main/kotlin/app/cash/sqldelight/core/lang/util/ExprUtil.kt b/sqldelight-compiler/src/main/kotlin/app/cash/sqldelight/core/lang/util/ExprUtil.kt index 506d59bb3ed..3149d1b213e 100644 --- a/sqldelight-compiler/src/main/kotlin/app/cash/sqldelight/core/lang/util/ExprUtil.kt +++ b/sqldelight-compiler/src/main/kotlin/app/cash/sqldelight/core/lang/util/ExprUtil.kt @@ -81,7 +81,7 @@ internal object AnsiSqlTypeResolver : TypeResolver { override fun argumentType( parent: PsiElement, - argument: SqlExpr + argument: SqlExpr, ): IntermediateType { return when (parent) { is SqlExpr -> parent.argumentType(argument) @@ -223,8 +223,8 @@ private fun SqlExpr.ansiType(): IntermediateType = when (this) { TokenSet.create( SqlTypes.EQ, SqlTypes.EQ2, SqlTypes.NEQ, SqlTypes.NEQ2, SqlTypes.AND, SqlTypes.OR, SqlTypes.GT, SqlTypes.GTE, - SqlTypes.LT, SqlTypes.LTE - ) + SqlTypes.LT, SqlTypes.LTE, + ), ) != null ) { IntermediateType(PrimitiveType.BOOLEAN) @@ -235,7 +235,10 @@ private fun SqlExpr.ansiType(): IntermediateType = when (this) { this is SqlBinaryAddExpr || this is SqlBinaryMultExpr || this is SqlBinaryPipeExpr ), - INTEGER, REAL, TEXT, BLOB + INTEGER, + REAL, + TEXT, + BLOB, ) } } @@ -258,8 +261,9 @@ private fun SqlExpr.ansiType(): IntermediateType = when (this) { literalValue.childOfType( TokenSet.create( SqlTypes.CURRENT_TIMESTAMP, - SqlTypes.CURRENT_TIME, SqlTypes.CURRENT_DATE - ) + SqlTypes.CURRENT_TIME, + SqlTypes.CURRENT_DATE, + ), ) != null ) -> IntermediateType(TEXT) (literalValue.childOfType(SqlTypes.NULL) != null) -> IntermediateType(NULL) diff --git a/sqldelight-compiler/src/main/kotlin/app/cash/sqldelight/core/lang/util/SelectStmtUtil.kt b/sqldelight-compiler/src/main/kotlin/app/cash/sqldelight/core/lang/util/SelectStmtUtil.kt index a6e85d61eb2..13e0f5c4268 100644 --- a/sqldelight-compiler/src/main/kotlin/app/cash/sqldelight/core/lang/util/SelectStmtUtil.kt +++ b/sqldelight-compiler/src/main/kotlin/app/cash/sqldelight/core/lang/util/SelectStmtUtil.kt @@ -32,7 +32,7 @@ internal fun SqlCompoundSelectStmt.tablesObserved() = findChildrenOfType = when (this) { is SqlCompoundSelectStmt -> tablesObserved() is SqlTableAlias -> source().referencedTables() diff --git a/sqldelight-compiler/src/main/kotlin/app/cash/sqldelight/core/lang/util/TreeUtil.kt b/sqldelight-compiler/src/main/kotlin/app/cash/sqldelight/core/lang/util/TreeUtil.kt index 0682a48124c..2b776817611 100644 --- a/sqldelight-compiler/src/main/kotlin/app/cash/sqldelight/core/lang/util/TreeUtil.kt +++ b/sqldelight-compiler/src/main/kotlin/app/cash/sqldelight/core/lang/util/TreeUtil.kt @@ -75,7 +75,7 @@ internal fun PsiElement.type(): IntermediateType = when (this) { null -> IntermediateType(PrimitiveType.NULL) // Synthesized columns refer directly to the table is SqlCreateTableStmt, - is SqlCreateVirtualTableStmt -> synthesizedColumnType(this.name) + is SqlCreateVirtualTableStmt, -> synthesizedColumnType(this.name) else -> { val columnSelected = queryAvailable(this).flatMap { it.columns } .firstOrNull { it.element == resolvedReference } @@ -157,16 +157,16 @@ private fun PsiElement.rangesToReplace(): List> { Pair( first = (typeName.node.startOffset + typeName.node.textLength) until (javaTypeName!!.node.startOffset + javaTypeName!!.node.textLength), - second = "" - ) + second = "", + ), ) } else if (this is ColumnTypeMixin && node.getChildren(null).any { it.text == "VALUE" || it.text == "LOCK" }) { listOf( Pair( first = (typeName.node.startOffset + typeName.node.textLength) until (node.getChildren(null).single { it.text == "VALUE" || it.text == "LOCK" }.let { it.startOffset + it.textLength }), - second = "" - ) + second = "", + ), ) } else if (this is SqlModuleArgument && moduleArgumentDef?.columnDef != null && (parent as SqlCreateVirtualTableStmt).moduleName?.text?.toLowerCase() == "fts5") { val columnDef = moduleArgumentDef!!.columnDef!! @@ -176,15 +176,15 @@ private fun PsiElement.rangesToReplace(): List> { Pair( first = (columnDef.columnName.node.startOffset + columnDef.columnName.node.textLength) until (columnDef.columnName.node.startOffset + columnDef.node.textLength - lengthModifier), - second = "" - ) + second = "", + ), ) } else if (this is InsertStmtValuesMixin && parent?.acceptsTableInterface() == true) { listOf( Pair( first = childOfType(SqlTypes.BIND_EXPR)!!.range, - second = parent!!.columns.joinToString(separator = ", ", prefix = "(", postfix = ")") { "?" } - ) + second = parent!!.columns.joinToString(separator = ", ", prefix = "(", postfix = ")") { "?" }, + ), ) } else { children.flatMap { it.rangesToReplace() } @@ -199,7 +199,7 @@ private val IntRange.length: Int get() = endInclusive - start + 1 fun PsiElement.rawSqlText( - replacements: List> = emptyList() + replacements: List> = emptyList(), ): String { return (replacements + rangesToReplace()) .sortedBy { it.first.first } @@ -208,7 +208,7 @@ fun PsiElement.rawSqlText( 0 to text, { (totalRemoved, sqlText), (range, replacement) -> (totalRemoved + (range.length - replacement.length)) to sqlText.replaceRange(range - totalRemoved, replacement) - } + }, ).second } @@ -217,7 +217,7 @@ val PsiElement.range: IntRange fun Collection.forInitializationStatements( allowReferenceCycles: Boolean, - body: (sqlText: String) -> Unit + body: (sqlText: String) -> Unit, ) { val views = ArrayList() val tables = ArrayList() diff --git a/sqldelight-compiler/src/main/kotlin/app/cash/sqldelight/core/lang/validation/OptimisticLockValidator.kt b/sqldelight-compiler/src/main/kotlin/app/cash/sqldelight/core/lang/validation/OptimisticLockValidator.kt index cde791044a2..34a41bfd07c 100644 --- a/sqldelight-compiler/src/main/kotlin/app/cash/sqldelight/core/lang/validation/OptimisticLockValidator.kt +++ b/sqldelight-compiler/src/main/kotlin/app/cash/sqldelight/core/lang/validation/OptimisticLockValidator.kt @@ -35,7 +35,7 @@ open class OptimisticLockValidator : Annotator, SqlCompilerAnnotator { fun annotate( element: PsiElement, holder: AnnotationHolder?, - sqlAnnotationHolder: SqlAnnotationHolder? + sqlAnnotationHolder: SqlAnnotationHolder?, ) { val tableName = when (element) { is SqlUpdateStmt -> element.qualifiedTableName.tableName @@ -70,10 +70,13 @@ open class OptimisticLockValidator : Annotator, SqlCompilerAnnotator { if (column == null || setter == null) { displayError( - element, lock, holder, sqlAnnotationHolder, + element, + lock, + holder, + sqlAnnotationHolder, """ This statement is missing the optimistic lock in its SET clause. - """.trimIndent() + """.trimIndent(), ) return } @@ -87,10 +90,13 @@ open class OptimisticLockValidator : Annotator, SqlCompilerAnnotator { ) ) { displayError( - element, lock, holder, sqlAnnotationHolder, + element, + lock, + holder, + sqlAnnotationHolder, """ The optimistic lock must be set exactly like "${lock.columnName.name} = :${lock.columnName.name} + 1". - """.trimIndent() + """.trimIndent(), ) return } @@ -103,10 +109,13 @@ open class OptimisticLockValidator : Annotator, SqlCompilerAnnotator { if (whereExpression == null || whereExpression.node.treePrev.treePrev.text != "WHERE") { displayError( - element, lock, holder, sqlAnnotationHolder, + element, + lock, + holder, + sqlAnnotationHolder, """ This statement is missing a WHERE clause to check the optimistic lock. - """.trimIndent() + """.trimIndent(), ) return } @@ -119,10 +128,13 @@ open class OptimisticLockValidator : Annotator, SqlCompilerAnnotator { } ) { displayError( - element, lock, holder, sqlAnnotationHolder, + element, + lock, + holder, + sqlAnnotationHolder, """ The optimistic lock must be queried exactly like "${lock.columnName.name} == :${lock.columnName.name}". - """.trimIndent() + """.trimIndent(), ) return } diff --git a/sqldelight-compiler/src/test/kotlin/app/cash/sqldelight/core/BindArgsTest.kt b/sqldelight-compiler/src/test/kotlin/app/cash/sqldelight/core/BindArgsTest.kt index c3b52505e05..ea83424366e 100644 --- a/sqldelight-compiler/src/test/kotlin/app/cash/sqldelight/core/BindArgsTest.kt +++ b/sqldelight-compiler/src/test/kotlin/app/cash/sqldelight/core/BindArgsTest.kt @@ -30,7 +30,7 @@ class BindArgsTest { |FROM data |WHERE data.id = ?; """.trimMargin(), - tempFolder + tempFolder, ) val column = file.findChildrenOfType().first() @@ -57,7 +57,7 @@ class BindArgsTest { |FROM data_aliased |WHERE data_id = ?; """.trimMargin(), - tempFolder + tempFolder, ) val column = file.findChildrenOfType().first() @@ -79,7 +79,7 @@ class BindArgsTest { |INSERT INTO data (id) |VALUES (?), (?); """.trimMargin(), - tempFolder + tempFolder, ) val column = file.findChildrenOfType().first() @@ -102,7 +102,7 @@ class BindArgsTest { |INSERT INTO data |VALUES (?), (?); """.trimMargin(), - tempFolder + tempFolder, ) val column = file.findChildrenOfType().first() @@ -127,7 +127,7 @@ class BindArgsTest { |UNION |VALUES (?); """.trimMargin(), - tempFolder + tempFolder, ) val column = file.findChildrenOfType().first() @@ -152,7 +152,7 @@ class BindArgsTest { |UNION |VALUES (((?))); """.trimMargin(), - tempFolder + tempFolder, ) file.findChildrenOfType().map { it.argumentType() }.forEach { @@ -175,7 +175,7 @@ class BindArgsTest { |SET id = ? |WHERE id = ?; """.trimMargin(), - tempFolder + tempFolder, ) val column = file.findChildrenOfType().first() @@ -208,7 +208,8 @@ class BindArgsTest { |DO UPDATE SET | list = :list; """.trimMargin(), - tempFolder, dialect = SqliteDialect() + tempFolder, + dialect = SqliteDialect(), ) val (idColumn, listColumn) = file.findChildrenOfType().toList() @@ -246,7 +247,7 @@ class BindArgsTest { |) |WHERE some_alias = ?; """.trimMargin(), - tempFolder + tempFolder, ) val column = file.findChildrenOfType().first() @@ -270,7 +271,7 @@ class BindArgsTest { |FROM data |WHERE id IN ?; """.trimMargin(), - tempFolder + tempFolder, ) val column = file.findChildrenOfType().first() @@ -299,7 +300,7 @@ class BindArgsTest { | AND first_name LIKE ? | AND last_name LIKE ?; """.trimMargin(), - tempFolder + tempFolder, ) val columns = file.findChildrenOfType().toTypedArray() diff --git a/sqldelight-compiler/src/test/kotlin/app/cash/sqldelight/core/ImportTests.kt b/sqldelight-compiler/src/test/kotlin/app/cash/sqldelight/core/ImportTests.kt index 70a03acae50..708e138f618 100644 --- a/sqldelight-compiler/src/test/kotlin/app/cash/sqldelight/core/ImportTests.kt +++ b/sqldelight-compiler/src/test/kotlin/app/cash/sqldelight/core/ImportTests.kt @@ -19,12 +19,12 @@ class ImportTests { | _id INTEGER NOT NULL PRIMARY KEY |); """.trimMargin(), - tempFolder + tempFolder, ) assertThat(result.errors).containsExactly( "Test.sq: (1, 0): Multiple imports for type Thing", - "Test.sq: (2, 0): Multiple imports for type Thing" + "Test.sq: (2, 0): Multiple imports for type Thing", ) } } diff --git a/sqldelight-compiler/src/test/kotlin/app/cash/sqldelight/core/NamedQueryTests.kt b/sqldelight-compiler/src/test/kotlin/app/cash/sqldelight/core/NamedQueryTests.kt index a42844f0746..995255e70f9 100644 --- a/sqldelight-compiler/src/test/kotlin/app/cash/sqldelight/core/NamedQueryTests.kt +++ b/sqldelight-compiler/src/test/kotlin/app/cash/sqldelight/core/NamedQueryTests.kt @@ -24,7 +24,7 @@ class NamedQueryTests { |FROM data |WHERE id = ?; """.trimMargin(), - tempFolder + tempFolder, ) val query = file.namedQueries.first() @@ -46,7 +46,7 @@ class NamedQueryTests { |FROM data AS data2 |WHERE data2.id = ?; """.trimMargin(), - tempFolder + tempFolder, ) val query = file.namedQueries.first() @@ -71,7 +71,7 @@ class NamedQueryTests { |SELECT * |FROM some_view; """.trimMargin(), - tempFolder + tempFolder, ) val query = file.namedQueries.first() @@ -96,7 +96,7 @@ class NamedQueryTests { |SELECT * |FROM common_table; """.trimMargin(), - tempFolder + tempFolder, ) val query = file.namedQueries.first() @@ -118,7 +118,7 @@ class NamedQueryTests { | cnt(x) AS (SELECT id FROM data UNION ALL SELECT x+1 FROM cnt WHERE x<1000000) |SELECT x FROM cnt; """.trimMargin(), - tempFolder + tempFolder, ) val query = file.namedQueries.first() @@ -131,7 +131,7 @@ class NamedQueryTests { val result = FixtureCompiler.compileFixture( fixtureRoot = "src/test/migration-interface-fixtures/alter-table", generateDb = false, - deriveSchemaFromMigrations = true + deriveSchemaFromMigrations = true, ) val query = result.compiledFile.namedQueries.first() diff --git a/sqldelight-compiler/src/test/kotlin/app/cash/sqldelight/core/QueriesTypeTest.kt b/sqldelight-compiler/src/test/kotlin/app/cash/sqldelight/core/QueriesTypeTest.kt index fb9bce3757a..d42b6ba0e47 100644 --- a/sqldelight-compiler/src/test/kotlin/app/cash/sqldelight/core/QueriesTypeTest.kt +++ b/sqldelight-compiler/src/test/kotlin/app/cash/sqldelight/core/QueriesTypeTest.kt @@ -36,8 +36,9 @@ class QueriesTypeTest { |SELECT id, value FROM data |UNION |SELECT id, value FROM other; - """.trimMargin(), - temporaryFolder, fileName = "Data.sq" + """.trimMargin(), + temporaryFolder, + fileName = "Data.sq", ) val select = result.compiledFile.namedQueries.first() @@ -105,7 +106,8 @@ class QueriesTypeTest { | ): QueryResult = QueryResult.Unit | } |} - |""".trimMargin() + | + """.trimMargin(), ) val dataQueries = File(result.outputDirectory, "com/example/DataQueries.kt") @@ -206,7 +208,8 @@ class QueriesTypeTest { | public override fun toString(): String = "Data.sq:selectForId" | } |} - |""".trimMargin() + | + """.trimMargin(), ) } @@ -225,7 +228,8 @@ class QueriesTypeTest { |INSERT INTO data |VALUES ?; """.trimMargin(), - temporaryFolder, fileName = "Data.sq" + temporaryFolder, + fileName = "Data.sq", ) val insert = result.compiledFile.namedMutators.first() assertThat(result.errors).isEmpty() @@ -280,7 +284,8 @@ class QueriesTypeTest { | ): QueryResult = QueryResult.Unit | } |} - |""".trimMargin() + | + """.trimMargin(), ) val dataQueries = File(result.outputDirectory, "com/example/DataQueries.kt") @@ -310,7 +315,8 @@ class QueriesTypeTest { | } | } |} - |""".trimMargin() + | + """.trimMargin(), ) } @@ -323,8 +329,9 @@ class QueriesTypeTest { | id TEXT PRIMARY KEY, | value INTEGER AS Int NOT NULL |); - """.trimMargin(), - temporaryFolder, fileName = "Data.sq" + """.trimMargin(), + temporaryFolder, + fileName = "Data.sq", ) val database = File(result.outputDirectory, "com/example/testmodule/TestDatabaseImpl.kt") @@ -372,7 +379,8 @@ class QueriesTypeTest { | ): QueryResult = QueryResult.Unit | } |} - |""".trimMargin() + | + """.trimMargin(), ) } @@ -392,8 +400,9 @@ class QueriesTypeTest { |SELECT * |FROM data |WHERE id = ?; - """.trimMargin(), - temporaryFolder, fileName = "Data.sq" + """.trimMargin(), + temporaryFolder, + fileName = "Data.sq", ) val select = result.compiledFile.namedQueries.first() @@ -450,7 +459,8 @@ class QueriesTypeTest { | ): QueryResult = QueryResult.Unit | } |} - |""".trimMargin() + | + """.trimMargin(), ) val dataQueries = File(result.outputDirectory, "com/example/DataQueries.kt") @@ -526,7 +536,8 @@ class QueriesTypeTest { | public override fun toString(): String = "Data.sq:selectForId" | } |} - |""".trimMargin() + | + """.trimMargin(), ) } @@ -546,8 +557,9 @@ class QueriesTypeTest { |SELECT id, offsets(search) |FROM search |WHERE search MATCH ?; - """.trimMargin(), - temporaryFolder, fileName = "Search.sq" + """.trimMargin(), + temporaryFolder, + fileName = "Search.sq", ) val offsets = result.compiledFile.namedQueries.first() @@ -602,7 +614,8 @@ class QueriesTypeTest { | ): QueryResult = QueryResult.Unit | } |} - |""".trimMargin() + | + """.trimMargin(), ) val dataQueries = File(result.outputDirectory, "com/example/SearchQueries.kt") @@ -677,7 +690,8 @@ class QueriesTypeTest { | public override fun toString(): String = "Search.sq:selectOffsets" | } |} - |""".trimMargin() + | + """.trimMargin(), ) } } diff --git a/sqldelight-compiler/src/test/kotlin/app/cash/sqldelight/core/QueryWrapperTest.kt b/sqldelight-compiler/src/test/kotlin/app/cash/sqldelight/core/QueryWrapperTest.kt index 05fb0857a06..55f56c6bb2d 100644 --- a/sqldelight-compiler/src/test/kotlin/app/cash/sqldelight/core/QueryWrapperTest.kt +++ b/sqldelight-compiler/src/test/kotlin/app/cash/sqldelight/core/QueryWrapperTest.kt @@ -23,7 +23,7 @@ class QueryWrapperTest { |INSERT INTO test_table |VALUES (1, 'test'); """.trimMargin(), - tempFolder + tempFolder, ) assertThat(result.errors).isEmpty() @@ -78,7 +78,7 @@ class QueryWrapperTest { | } |} | - """.trimMargin() + """.trimMargin(), ) } @@ -101,7 +101,7 @@ class QueryWrapperTest { |UNION ALL |SELECT value FROM test_table2; """.trimMargin(), - tempFolder + tempFolder, ) assertThat(result.errors).isEmpty() @@ -169,7 +169,7 @@ class QueryWrapperTest { | } |} | - """.trimMargin() + """.trimMargin(), ) } @@ -241,7 +241,7 @@ class QueryWrapperTest { | } |} | - """.trimMargin() + """.trimMargin(), ) } @@ -277,7 +277,7 @@ class QueryWrapperTest { | id INTEGER PRIMARY KEY, | parent_id INTEGER REFERENCES parent(id) |); - """.trimMargin(), + """.trimMargin(), temporaryFolder = tempFolder, ) @@ -335,7 +335,7 @@ class QueryWrapperTest { | } |} | - """.trimMargin() + """.trimMargin(), ) } @@ -360,7 +360,7 @@ class QueryWrapperTest { | id INTEGER PRIMARY KEY, | parent_id INTEGER REFERENCES parent(id) |); - """.trimMargin(), + """.trimMargin(), overrideDialect = PostgreSqlDialect(), temporaryFolder = tempFolder, ) @@ -430,7 +430,7 @@ class QueryWrapperTest { | } |} | - """.trimMargin() + """.trimMargin(), ) } @@ -444,7 +444,7 @@ class QueryWrapperTest { |CREATE VIEW A AS |SELECT 1; """.trimMargin(), - tempFolder + tempFolder, ) assertThat(result.errors).isEmpty() @@ -498,7 +498,7 @@ class QueryWrapperTest { | } |} | - """.trimMargin() + """.trimMargin(), ) } @@ -517,7 +517,7 @@ class QueryWrapperTest { | value TEXT |); """.trimMargin(), - tempFolder + tempFolder, ) assertThat(result.errors).isEmpty() @@ -575,7 +575,7 @@ class QueryWrapperTest { | } |} | - """.trimMargin() + """.trimMargin(), ) } @@ -585,20 +585,23 @@ class QueryWrapperTest { |CREATE TABLE test ( | value1 TEXT |); - """.trimMargin(), - tempFolder, "0.sqm" + """.trimMargin(), + tempFolder, + "0.sqm", ) FixtureCompiler.writeSql( """ |ALTER TABLE test ADD COLUMN value2 TEXT; - """.trimMargin(), - tempFolder, "1.sqm" + """.trimMargin(), + tempFolder, + "1.sqm", ) FixtureCompiler.writeSql( """ |ALTER TABLE test ADD COLUMN value3 REAL; - """.trimMargin(), - tempFolder, "2.sqm" + """.trimMargin(), + tempFolder, + "2.sqm", ) val result = FixtureCompiler.compileSql( """ @@ -608,7 +611,7 @@ class QueryWrapperTest { | value3 REAL |); """.trimMargin(), - tempFolder + tempFolder, ) assertThat(result.errors).isEmpty() @@ -675,7 +678,7 @@ class QueryWrapperTest { | } |} | - """.trimMargin() + """.trimMargin(), ) } @@ -694,7 +697,7 @@ class QueryWrapperTest { | |INSERT INTO class_ability_test(id, class_id, name, level_id, special, url) |VALUES - """.trimMargin() + """.trimMargin(), ) repeat(500) { if (it > 0) append(',') @@ -751,13 +754,13 @@ class QueryWrapperTest { | |INSERT INTO class_ability_test(id, class_id, name, level_id, special, url) | |VALUES | | ('class_01_ability_0', 'class_01', 'aaaaaaaaaaaaaaa', 1, NULL, 'https://stuff.example.com/this/is/a/bunch/of/path/data/class_01_ability_0.png') - """.trimMargin() + """.trimMargin(), ) contains( """ | ""${'"'}.trimMargin()) | append(""${'"'} - """.trimMargin() + """.trimMargin(), ) endsWith( """ @@ -775,7 +778,7 @@ class QueryWrapperTest { | } |} | - """.trimMargin() + """.trimMargin(), ) } } diff --git a/sqldelight-compiler/src/test/kotlin/app/cash/sqldelight/core/async/AsyncQueriesTypeTest.kt b/sqldelight-compiler/src/test/kotlin/app/cash/sqldelight/core/async/AsyncQueriesTypeTest.kt index 93d67c13540..62b66f5b241 100644 --- a/sqldelight-compiler/src/test/kotlin/app/cash/sqldelight/core/async/AsyncQueriesTypeTest.kt +++ b/sqldelight-compiler/src/test/kotlin/app/cash/sqldelight/core/async/AsyncQueriesTypeTest.kt @@ -37,7 +37,7 @@ class AsyncQueriesTypeTest { |SELECT id, value FROM data |UNION |SELECT id, value FROM other; - """.trimMargin(), + """.trimMargin(), temporaryFolder, fileName = "Data.sq", generateAsync = true, @@ -108,7 +108,8 @@ class AsyncQueriesTypeTest { | } | } |} - |""".trimMargin() + | + """.trimMargin(), ) val dataQueries = File(result.outputDirectory, "com/example/DataQueries.kt") @@ -209,7 +210,8 @@ class AsyncQueriesTypeTest { | public override fun toString(): String = "Data.sq:selectForId" | } |} - |""".trimMargin() + | + """.trimMargin(), ) } } diff --git a/sqldelight-compiler/src/test/kotlin/app/cash/sqldelight/core/async/AsyncQueryWrapperTest.kt b/sqldelight-compiler/src/test/kotlin/app/cash/sqldelight/core/async/AsyncQueryWrapperTest.kt index 962e7cd7134..f9ef042e1ad 100644 --- a/sqldelight-compiler/src/test/kotlin/app/cash/sqldelight/core/async/AsyncQueryWrapperTest.kt +++ b/sqldelight-compiler/src/test/kotlin/app/cash/sqldelight/core/async/AsyncQueryWrapperTest.kt @@ -17,20 +17,23 @@ class AsyncQueryWrapperTest { |CREATE TABLE test ( | value1 TEXT |); - """.trimMargin(), - tempFolder, "0.sqm" + """.trimMargin(), + tempFolder, + "0.sqm", ) FixtureCompiler.writeSql( """ |ALTER TABLE test ADD COLUMN value2 TEXT; - """.trimMargin(), - tempFolder, "1.sqm" + """.trimMargin(), + tempFolder, + "1.sqm", ) FixtureCompiler.writeSql( """ |ALTER TABLE test ADD COLUMN value3 REAL; - """.trimMargin(), - tempFolder, "2.sqm" + """.trimMargin(), + tempFolder, + "2.sqm", ) val result = FixtureCompiler.compileSql( """ @@ -41,7 +44,7 @@ class AsyncQueryWrapperTest { |); """.trimMargin(), tempFolder, - generateAsync = true + generateAsync = true, ) Truth.assertThat(result.errors).isEmpty() @@ -106,7 +109,7 @@ class AsyncQueryWrapperTest { | } |} | - """.trimMargin() + """.trimMargin(), ) } } diff --git a/sqldelight-compiler/src/test/kotlin/app/cash/sqldelight/core/errors/DuplicateSqlIdentifiers.kt b/sqldelight-compiler/src/test/kotlin/app/cash/sqldelight/core/errors/DuplicateSqlIdentifiers.kt index 50c31e434a5..687ad2bbdbe 100644 --- a/sqldelight-compiler/src/test/kotlin/app/cash/sqldelight/core/errors/DuplicateSqlIdentifiers.kt +++ b/sqldelight-compiler/src/test/kotlin/app/cash/sqldelight/core/errors/DuplicateSqlIdentifiers.kt @@ -33,8 +33,9 @@ class DuplicateSqlIdentifiers { | |some_select: |SELECT 1; - |""".trimMargin(), - tempFolder + | + """.trimMargin(), + tempFolder, ) assertThat(result.errors).contains("Test.sq: (1, 0): Duplicate SQL identifier") diff --git a/sqldelight-compiler/src/test/kotlin/app/cash/sqldelight/core/errors/ErrorTest.kt b/sqldelight-compiler/src/test/kotlin/app/cash/sqldelight/core/errors/ErrorTest.kt index 777ceb13d92..b02192a1c38 100644 --- a/sqldelight-compiler/src/test/kotlin/app/cash/sqldelight/core/errors/ErrorTest.kt +++ b/sqldelight-compiler/src/test/kotlin/app/cash/sqldelight/core/errors/ErrorTest.kt @@ -17,7 +17,7 @@ class ErrorTest { val expectedFailure = File("src/test/errors/$fixtureRoot", "failure.txt") if (expectedFailure.exists()) { assertWithMessage(result.sourceFiles).that(result.errors).containsExactlyElementsIn( - expectedFailure.readText().splitLines().filter { it.isNotEmpty() } + expectedFailure.readText().splitLines().filter { it.isNotEmpty() }, ) } else { assertWithMessage(result.sourceFiles).that(result.errors).isEmpty() diff --git a/sqldelight-compiler/src/test/kotlin/app/cash/sqldelight/core/errors/InsertStmtErrors.kt b/sqldelight-compiler/src/test/kotlin/app/cash/sqldelight/core/errors/InsertStmtErrors.kt index 73ef53fa4cc..d2f18c2cbca 100644 --- a/sqldelight-compiler/src/test/kotlin/app/cash/sqldelight/core/errors/InsertStmtErrors.kt +++ b/sqldelight-compiler/src/test/kotlin/app/cash/sqldelight/core/errors/InsertStmtErrors.kt @@ -22,8 +22,9 @@ class InsertStmtErrors { |insert: |INSERT INTO test (value1, value2) |VALUES ?; - |""".trimMargin(), - tempFolder + | + """.trimMargin(), + tempFolder, ) assertThat(result.errors).hasSize(1) @@ -43,8 +44,9 @@ class InsertStmtErrors { |insert: |INSERT INTO test (value1, value2) |VALUES ?; - |""".trimMargin(), - tempFolder + | + """.trimMargin(), + tempFolder, ) assertThat(result.errors).hasSize(1) diff --git a/sqldelight-compiler/src/test/kotlin/app/cash/sqldelight/core/errors/SyntaxErrors.kt b/sqldelight-compiler/src/test/kotlin/app/cash/sqldelight/core/errors/SyntaxErrors.kt index d6eb3c15073..0997ba443fe 100644 --- a/sqldelight-compiler/src/test/kotlin/app/cash/sqldelight/core/errors/SyntaxErrors.kt +++ b/sqldelight-compiler/src/test/kotlin/app/cash/sqldelight/core/errors/SyntaxErrors.kt @@ -15,8 +15,9 @@ class SyntaxErrors { |CREATE TABLE my_table ( | col INTEGER AS long |); - |""".trimMargin(), - tempFolder + | + """.trimMargin(), + tempFolder, ) assertThat(result.errors).containsExactly("Test.sq: (2, 19): Unknown type long") @@ -27,8 +28,9 @@ class SyntaxErrors { """ |selectScoob: |SELECT scoobyDoo(); - |""".trimMargin(), - tempFolder + | + """.trimMargin(), + tempFolder, ) assertThat(result.errors).containsExactly("Test.sq: (2, 7): Unknown function scoobyDoo") @@ -40,8 +42,9 @@ class SyntaxErrors { |CREATE TABLE my_table ( | col INTEGER AS team |); - |""".trimMargin(), - tempFolder + | + """.trimMargin(), + tempFolder, ) assertThat(result.errors).containsExactly("Test.sq: (2, 19): Unknown type team") @@ -53,13 +56,14 @@ class SyntaxErrors { |CREATE TABLE my_table ( | col INTEGER as Boolean |); - |""".trimMargin(), - tempFolder + | + """.trimMargin(), + tempFolder, ) assertThat(result.errors).containsExactly( "Test.sq: (2, 8): Reserved keyword in sqlite", - "Test.sq: (2, 16): Expected 'AS', got 'as'" + "Test.sq: (2, 16): Expected 'AS', got 'as'", ) } } diff --git a/sqldelight-compiler/src/test/kotlin/app/cash/sqldelight/core/migrations/MigrationQueryTest.kt b/sqldelight-compiler/src/test/kotlin/app/cash/sqldelight/core/migrations/MigrationQueryTest.kt index eb1b2f96eba..18f970d6bcd 100644 --- a/sqldelight-compiler/src/test/kotlin/app/cash/sqldelight/core/migrations/MigrationQueryTest.kt +++ b/sqldelight-compiler/src/test/kotlin/app/cash/sqldelight/core/migrations/MigrationQueryTest.kt @@ -26,7 +26,7 @@ class MigrationQueryTest { overrideDialect = dialect, fixtureRoot = "src/test/migration-interface-fixtures/$fixtureRoot", generateDb = false, - deriveSchemaFromMigrations = true + deriveSchemaFromMigrations = true, ) for ((expectedFile, actualOutput) in result.compilerOutput) { assertWithMessage("No file with name $expectedFile").that(expectedFile.exists()).isTrue() diff --git a/sqldelight-compiler/src/test/kotlin/app/cash/sqldelight/core/queries/BindableQueryTest.kt b/sqldelight-compiler/src/test/kotlin/app/cash/sqldelight/core/queries/BindableQueryTest.kt index 275eb570f9d..7cbe9d4e61c 100644 --- a/sqldelight-compiler/src/test/kotlin/app/cash/sqldelight/core/queries/BindableQueryTest.kt +++ b/sqldelight-compiler/src/test/kotlin/app/cash/sqldelight/core/queries/BindableQueryTest.kt @@ -29,7 +29,7 @@ class BindableQueryTest { |FROM data |WHERE _id = ?1 AND _id = ?1; """.trimMargin(), - tempFolder + tempFolder, ) val createTable = file.sqlStatements().mapNotNull { it.statement.createTableStmt }.first() @@ -37,7 +37,7 @@ class BindableQueryTest { val arg = PsiTreeUtil.findChildrenOfType(file, SqlBindExpr::class.java).first() assertThat(select.arguments.map { it.index to it.type }).containsExactly( - 1 to IntermediateType(INTEGER, LONG, createTable.columnDefList[0], "_id", arg) + 1 to IntermediateType(INTEGER, LONG, createTable.columnDefList[0], "_id", arg), ) } @@ -54,7 +54,7 @@ class BindableQueryTest { |FROM data |WHERE _id = ? AND _id = ?1; """.trimMargin(), - tempFolder + tempFolder, ) val createTable = file.sqlStatements().mapNotNull { it.statement.createTableStmt }.first() @@ -62,7 +62,7 @@ class BindableQueryTest { val arg = PsiTreeUtil.findChildrenOfType(file, SqlBindExpr::class.java).first() assertThat(select.arguments.map { it.index to it.type }).containsExactly( - 1 to IntermediateType(INTEGER, LONG, createTable.columnDefList[0], "_id", arg) + 1 to IntermediateType(INTEGER, LONG, createTable.columnDefList[0], "_id", arg), ) } @@ -79,7 +79,7 @@ class BindableQueryTest { |FROM data |WHERE _id = ?20 AND value = ?; """.trimMargin(), - tempFolder + tempFolder, ) val createTable = file.sqlStatements().mapNotNull { it.statement.createTableStmt }.first() @@ -89,9 +89,12 @@ class BindableQueryTest { assertThat(select.arguments.map { it.index to it.type }).containsExactly( 20 to IntermediateType(INTEGER, LONG, createTable.columnDefList[0], "_id", args[0]), 21 to IntermediateType( - TEXT, List::class.asClassName().copy(nullable = true), - createTable.columnDefList[1], "value_", args[1] - ) + TEXT, + List::class.asClassName().copy(nullable = true), + createTable.columnDefList[1], + "value_", + args[1], + ), ) } @@ -108,7 +111,7 @@ class BindableQueryTest { |FROM data |WHERE _id = :value AND value = ?; """.trimMargin(), - tempFolder + tempFolder, ) val createTable = file.sqlStatements().mapNotNull { it.statement.createTableStmt }.first() @@ -118,9 +121,12 @@ class BindableQueryTest { assertThat(select.arguments.map { it.index to it.type }).containsExactly( 1 to IntermediateType(INTEGER, LONG, createTable.columnDefList[0], "value", args[0]), 2 to IntermediateType( - TEXT, List::class.asClassName().copy(nullable = true), - createTable.columnDefList[1], "value_", args[1] - ) + TEXT, + List::class.asClassName().copy(nullable = true), + createTable.columnDefList[1], + "value_", + args[1], + ), ) } @@ -137,7 +143,7 @@ class BindableQueryTest { |SET value = ? |WHERE value = :value; """.trimMargin(), - tempFolder + tempFolder, ) val createTable = file.sqlStatements().mapNotNull { it.statement.createTableStmt }.first() @@ -146,13 +152,19 @@ class BindableQueryTest { assertThat(update.arguments.map { it.index to it.type }).containsExactly( 1 to IntermediateType( - TEXT, List::class.asClassName().copy(nullable = true), - createTable.columnDefList[1], "value_", args[0] + TEXT, + List::class.asClassName().copy(nullable = true), + createTable.columnDefList[1], + "value_", + args[0], ), 2 to IntermediateType( - TEXT, List::class.asClassName().copy(nullable = true), - createTable.columnDefList[1], "value", args[1] - ) + TEXT, + List::class.asClassName().copy(nullable = true), + createTable.columnDefList[1], + "value", + args[1], + ), ) } @@ -178,7 +190,7 @@ class BindableQueryTest { | DESC LIMIT 1 |) t; """.trimMargin(), - tempFolder + tempFolder, ) val createTable = file.sqlStatements().mapNotNull { it.statement.createTableStmt }.first() @@ -188,15 +200,21 @@ class BindableQueryTest { assertThat(select.arguments.map { it.index to it.type }).containsExactly( 1 to IntermediateType(TEXT, String::class.asClassName().copy(nullable = true), null, "defaultValue", args[0]), 2 to IntermediateType( - INTEGER, Long::class.asClassName().copy(nullable = true), - createTable.columnDefList[1], "bufferId", args[1], - simplified = true + INTEGER, + Long::class.asClassName().copy(nullable = true), + createTable.columnDefList[1], + "bufferId", + args[1], + simplified = true, ), 3 to IntermediateType( - INTEGER, Long::class.asClassName().copy(nullable = true), - createTable.columnDefList[2], "accountId", args[2], - simplified = true - ) + INTEGER, + Long::class.asClassName().copy(nullable = true), + createTable.columnDefList[2], + "accountId", + args[2], + simplified = true, + ), ) } } diff --git a/sqldelight-compiler/src/test/kotlin/app/cash/sqldelight/core/queries/ExpressionTest.kt b/sqldelight-compiler/src/test/kotlin/app/cash/sqldelight/core/queries/ExpressionTest.kt index a49ea9b4330..1dce21f1bef 100644 --- a/sqldelight-compiler/src/test/kotlin/app/cash/sqldelight/core/queries/ExpressionTest.kt +++ b/sqldelight-compiler/src/test/kotlin/app/cash/sqldelight/core/queries/ExpressionTest.kt @@ -39,7 +39,7 @@ class ExpressionTest { |FROM test |WHERE SecondId = ? AND TestText LIKE ? ESCAPE '\' COLLATE NOCASE; """.trimMargin(), - tempFolder + tempFolder, ) val generator = SelectQueryGenerator(file.namedQueries.first()) @@ -52,7 +52,8 @@ class ExpressionTest { | SecondId_ | ) |} - |""".trimMargin() + | + """.trimMargin(), ) } @@ -68,7 +69,7 @@ class ExpressionTest { |SELECT CASE id WHEN 0 THEN some_text ELSE some_text + id END AS indexed_text |FROM test; """.trimMargin(), - tempFolder + tempFolder, ) val query = file.namedQueries.first() @@ -86,12 +87,13 @@ class ExpressionTest { |SELECT id, CAST (id AS TEXT) |FROM test; """.trimMargin(), - tempFolder + tempFolder, ) val query = file.namedQueries.first() assertThat(query.resultColumns.map { it.javaType }).containsExactly( - LONG, String::class.asClassName() + LONG, + String::class.asClassName(), ).inOrder() } @@ -117,13 +119,15 @@ class ExpressionTest { |) |ORDER BY department; """.trimMargin(), - tempFolder + tempFolder, ) val query = file.namedQueries.first() assertThat(query.arguments.map { it.type.javaType }).containsExactly( - String::class.asClassName(), String::class.asClassName(), String::class.asClassName(), - String::class.asClassName() + String::class.asClassName(), + String::class.asClassName(), + String::class.asClassName(), + String::class.asClassName(), ).inOrder() } @@ -133,12 +137,13 @@ class ExpressionTest { |someSelect: |SELECT round(1.123123), round(1.12312, 3); """.trimMargin(), - tempFolder + tempFolder, ) val query = file.namedQueries.first() assertThat(query.resultColumns.map { it.javaType }).containsExactly( - LONG, DOUBLE + LONG, + DOUBLE, ).inOrder() } @@ -153,7 +158,7 @@ class ExpressionTest { |SELECT sum(value) |FROM test; """.trimMargin(), - tempFolder + tempFolder, ) val query = file.namedQueries.first() @@ -171,7 +176,7 @@ class ExpressionTest { |SELECT sum(value) |FROM test; """.trimMargin(), - tempFolder + tempFolder, ) val query = file.namedQueries.first() @@ -190,12 +195,13 @@ class ExpressionTest { |SELECT lower(value1), lower(value2) |FROM test; """.trimMargin(), - tempFolder + tempFolder, ) val query = file.namedQueries.first() assertThat(query.resultColumns.map { it.javaType }).containsExactly( - String::class.asClassName().copy(nullable = true), String::class.asClassName() + String::class.asClassName().copy(nullable = true), + String::class.asClassName(), ).inOrder() } @@ -205,7 +211,7 @@ class ExpressionTest { |someSelect: |SELECT date('now'); """.trimMargin(), - tempFolder + tempFolder, ) val query = file.namedQueries.first() @@ -223,7 +229,7 @@ class ExpressionTest { |SELECT count(*) |FROM test; """.trimMargin(), - tempFolder + tempFolder, ) val query = file.namedQueries.first() @@ -242,12 +248,14 @@ class ExpressionTest { |SELECT instr(value1, value2), instr(value2, value1), instr(value2, value2) |FROM test; """.trimMargin(), - tempFolder + tempFolder, ) val query = file.namedQueries.first() assertThat(query.resultColumns.map { it.javaType }).containsExactly( - LONG.copy(nullable = true), LONG.copy(nullable = true), LONG + LONG.copy(nullable = true), + LONG.copy(nullable = true), + LONG, ).inOrder() } @@ -257,12 +265,13 @@ class ExpressionTest { |someSelect: |SELECT randomblob(), zeroblob(10); """.trimMargin(), - tempFolder + tempFolder, ) val query = file.namedQueries.first() assertThat(query.resultColumns.map { it.javaType }).containsExactly( - ByteArray::class.asClassName(), ByteArray::class.asClassName() + ByteArray::class.asClassName(), + ByteArray::class.asClassName(), ).inOrder() } @@ -277,12 +286,12 @@ class ExpressionTest { |SELECT total(value) |FROM test; """.trimMargin(), - tempFolder + tempFolder, ) val query = file.namedQueries.first() assertThat(query.resultColumns.map { it.javaType }).containsExactly( - DOUBLE + DOUBLE, ).inOrder() } @@ -303,13 +312,13 @@ class ExpressionTest { |someSelect: |SELECT avg(value) |FROM test; - """.trimMargin(), - tempFolder + """.trimMargin(), + tempFolder, ) val query = file.namedQueries.first() assertThat(query.resultColumns.map { it.javaType }).containsExactly( - DOUBLE.copy(nullable = true) + DOUBLE.copy(nullable = true), ).inOrder() } @@ -325,12 +334,13 @@ class ExpressionTest { |SELECT abs(value), abs(value2) |FROM test; """.trimMargin(), - tempFolder + tempFolder, ) val query = file.namedQueries.first() assertThat(query.resultColumns.map { it.javaType }).containsExactly( - LONG.copy(nullable = true), DOUBLE + LONG.copy(nullable = true), + DOUBLE, ).inOrder() } @@ -353,7 +363,7 @@ class ExpressionTest { | coalesce(integerVal) |FROM test; """.trimMargin(), - tempFolder + tempFolder, ) val query = file.namedQueries.first() @@ -362,7 +372,7 @@ class ExpressionTest { ByteArray::class.asClassName(), String::class.asClassName(), DOUBLE.copy(nullable = true), - LONG + LONG, ).inOrder() } @@ -400,7 +410,7 @@ class ExpressionTest { ByteArray::class.asClassName().copy(nullable = true), String::class.asClassName().copy(nullable = true), DOUBLE.copy(nullable = true), - integerKotlinType.copy(nullable = true) + integerKotlinType.copy(nullable = true), ).inOrder() } @@ -420,7 +430,7 @@ class ExpressionTest { | END |; """.trimMargin(), - tempFolder + tempFolder, ) val query = file.namedQueries.first() @@ -449,7 +459,7 @@ class ExpressionTest { | min(blobVal) |FROM test; """.trimMargin(), - tempFolder + tempFolder, ) val query = file.namedQueries.first() @@ -458,7 +468,7 @@ class ExpressionTest { DOUBLE.copy(nullable = true), DOUBLE.copy(nullable = true), String::class.asClassName().copy(nullable = true), - ByteArray::class.asClassName().copy(nullable = true) + ByteArray::class.asClassName().copy(nullable = true), ).inOrder() } @@ -473,7 +483,7 @@ class ExpressionTest { |selectTimestamp: |SELECT MIN(timestamp) - 1 FROM Test; """.trimMargin(), - tempFolder + tempFolder, ) val query = file.namedQueries.first() @@ -492,7 +502,7 @@ class ExpressionTest { |SELECT nullif(value1, value2) |FROM test; """.trimMargin(), - tempFolder + tempFolder, ) val query = file.namedQueries.first() @@ -512,7 +522,7 @@ class ExpressionTest { |SELECT ?, value2 |FROM test; """.trimMargin(), - tempFolder + tempFolder, ) val query = file.namedMutators.first() @@ -532,7 +542,7 @@ class ExpressionTest { |SELECT (SELECT ?), value2 |FROM test; """.trimMargin(), - tempFolder + tempFolder, ) val query = file.namedMutators.first() @@ -552,7 +562,7 @@ class ExpressionTest { |FROM test; """.trimMargin(), tempFolder, - dialect = dialect.dialect + dialect = dialect.dialect, ) val query = file.namedQueries.first() diff --git a/sqldelight-compiler/src/test/kotlin/app/cash/sqldelight/core/queries/InterfaceGeneration.kt b/sqldelight-compiler/src/test/kotlin/app/cash/sqldelight/core/queries/InterfaceGeneration.kt index 38b5875b268..1530a664f03 100644 --- a/sqldelight-compiler/src/test/kotlin/app/cash/sqldelight/core/queries/InterfaceGeneration.kt +++ b/sqldelight-compiler/src/test/kotlin/app/cash/sqldelight/core/queries/InterfaceGeneration.kt @@ -39,8 +39,8 @@ class InterfaceGeneration { |leftJoin: |SELECT * |FROM A LEFT OUTER JOIN B; - """.trimMargin(), - temporaryFolder + """.trimMargin(), + temporaryFolder, ) val query = file.namedQueries.first() @@ -50,7 +50,8 @@ class InterfaceGeneration { | public val val1: kotlin.String, | public val val2: kotlin.String?, |) - |""".trimMargin() + | + """.trimMargin(), ) } @@ -68,8 +69,8 @@ class InterfaceGeneration { |leftJoin: |SELECT * |FROM A JOIN B; - """.trimMargin(), - temporaryFolder + """.trimMargin(), + temporaryFolder, ) val query = file.namedQueries.first() @@ -79,7 +80,8 @@ class InterfaceGeneration { | public val value_: kotlin.String, | public val value__: kotlin.String, |) - |""".trimMargin() + | + """.trimMargin(), ) } @@ -100,8 +102,8 @@ class InterfaceGeneration { |UNION |SELECT value, value |FROM B; - """.trimMargin(), - temporaryFolder + """.trimMargin(), + temporaryFolder, ) val query = file.namedQueries.first() @@ -111,7 +113,8 @@ class InterfaceGeneration { | public val value_: kotlin.String?, | public val value__: kotlin.String?, |) - |""".trimMargin() + | + """.trimMargin(), ) } @@ -128,8 +131,8 @@ class InterfaceGeneration { |UNION |SELECT value, nullif(value, 1 == 1) |FROM A; - """.trimMargin(), - temporaryFolder + """.trimMargin(), + temporaryFolder, ) val query = file.namedQueries.first() @@ -139,7 +142,8 @@ class InterfaceGeneration { | public val value_: kotlin.collections.List, | public val value__: kotlin.collections.List?, |) - |""".trimMargin() + | + """.trimMargin(), ) } @@ -160,8 +164,8 @@ class InterfaceGeneration { |UNION |SELECT value, nullif(value, 1 == 1) |FROM B; - """.trimMargin(), - temporaryFolder + """.trimMargin(), + temporaryFolder, ) val query = file.namedQueries.first() @@ -171,7 +175,8 @@ class InterfaceGeneration { | public val value_: kotlin.collections.List, | public val value__: kotlin.collections.List?, |) - |""".trimMargin() + | + """.trimMargin(), ) } @@ -188,8 +193,8 @@ class InterfaceGeneration { |UNION |SELECT NULL, value |FROM A; - """.trimMargin(), - temporaryFolder + """.trimMargin(), + temporaryFolder, ) val query = file.namedQueries.first() @@ -199,7 +204,8 @@ class InterfaceGeneration { | public val value_: kotlin.collections.List?, | public val expr: kotlin.collections.List?, |) - |""".trimMargin() + | + """.trimMargin(), ) } @@ -216,8 +222,8 @@ class InterfaceGeneration { |UNION |SELECT value, value |FROM A; - """.trimMargin(), - temporaryFolder + """.trimMargin(), + temporaryFolder, ) val query = file.namedQueries.first() @@ -227,7 +233,8 @@ class InterfaceGeneration { | public val value_: kotlin.collections.List, | public val expr: kotlin.collections.List, |) - |""".trimMargin() + | + """.trimMargin(), ) } @@ -256,8 +263,8 @@ class InterfaceGeneration { |SELECT * |FROM TestAModel |JOIN TestBModel ON TestAModel.address = TestBModel.address; - """.trimMargin(), - temporaryFolder + """.trimMargin(), + temporaryFolder, ) val query = file.namedQueries.first() @@ -272,7 +279,8 @@ class InterfaceGeneration { | public val name_: kotlin.String, | public val address_: kotlin.String, |) - |""".trimMargin() + | + """.trimMargin(), ) } @@ -300,8 +308,8 @@ class InterfaceGeneration { |selectFromView: |SELECT name, nameB |FROM joined; - """.trimMargin(), - temporaryFolder + """.trimMargin(), + temporaryFolder, ) val query = file.namedQueries.first() @@ -311,7 +319,8 @@ class InterfaceGeneration { | public val name: kotlin.String?, | public val nameB: kotlin.String?, |) - |""".trimMargin() + | + """.trimMargin(), ) } @@ -320,13 +329,14 @@ class InterfaceGeneration { """ |someSelect: |SELECT '1' AS is_cool, '2' AS get_cheese, '3' AS stuff; - |""".trimMargin(), - temporaryFolder + | + """.trimMargin(), + temporaryFolder, ) assertThat(result.errors).isEmpty() val generatedInterface = result.compilerOutput.get( - File(result.outputDirectory, "com/example/SomeSelect.kt") + File(result.outputDirectory, "com/example/SomeSelect.kt"), ) assertThat(generatedInterface).isNotNull() assertThat(generatedInterface.toString()).isEqualTo( @@ -340,7 +350,8 @@ class InterfaceGeneration { | public val get_cheese: String, | public val stuff: String, |) - |""".trimMargin() + | + """.trimMargin(), ) } @@ -368,13 +379,14 @@ class InterfaceGeneration { | FROM testA | WHERE testA.attr IS NULL |); - |""".trimMargin(), - temporaryFolder + | + """.trimMargin(), + temporaryFolder, ) assertThat(result.errors).isEmpty() val generatedInterface = result.compilerOutput.get( - File(result.outputDirectory, "com/example/SomeSelect.kt") + File(result.outputDirectory, "com/example/SomeSelect.kt"), ) assertThat(generatedInterface).isNotNull() assertThat(generatedInterface.toString()).isEqualTo( @@ -390,7 +402,8 @@ class InterfaceGeneration { | public val attr: String?, | public val ordering: Long, |) - |""".trimMargin() + | + """.trimMargin(), ) } @@ -405,13 +418,14 @@ class InterfaceGeneration { |someSelect: |SELECT text_content, 1 |FROM entity_fts; - |""".trimMargin(), - temporaryFolder + | + """.trimMargin(), + temporaryFolder, ) assertThat(result.errors).isEmpty() val generatedInterface = result.compilerOutput.get( - File(result.outputDirectory, "com/example/SomeSelect.kt") + File(result.outputDirectory, "com/example/SomeSelect.kt"), ) assertThat(generatedInterface).isNotNull() assertThat(generatedInterface.toString()).isEqualTo( @@ -425,7 +439,8 @@ class InterfaceGeneration { | public val text_content: String?, | public val expr: Long, |) - |""".trimMargin() + | + """.trimMargin(), ) } @@ -441,13 +456,14 @@ class InterfaceGeneration { |someSelect: |SELECT text_content, 1 |FROM entity_fts; - |""".trimMargin(), - temporaryFolder + | + """.trimMargin(), + temporaryFolder, ) assertThat(result.errors).isEmpty() val generatedInterface = result.compilerOutput.get( - File(result.outputDirectory, "com/example/SomeSelect.kt") + File(result.outputDirectory, "com/example/SomeSelect.kt"), ) assertThat(generatedInterface).isNotNull() assertThat(generatedInterface.toString()).isEqualTo( @@ -461,7 +477,8 @@ class InterfaceGeneration { | public val text_content: String?, | public val expr: Long, |) - |""".trimMargin() + | + """.trimMargin(), ) } @@ -490,12 +507,12 @@ class InterfaceGeneration { |JOIN testB AS childJoined ON child_id = childJoined._id |WHERE parent_id = ? AND child_id = ?; """.trimMargin(), - temporaryFolder + temporaryFolder, ) assertThat(result.errors).isEmpty() val generatedInterface = result.compilerOutput.get( - File(result.outputDirectory, "com/example/Exact_match.kt") + File(result.outputDirectory, "com/example/Exact_match.kt"), ) assertThat(generatedInterface).isNotNull() assertThat(generatedInterface.toString()).isEqualTo( @@ -519,7 +536,8 @@ class InterfaceGeneration { | public val type_: List, | public val name_: String, |) - |""".trimMargin() + | + """.trimMargin(), ) } @@ -538,13 +556,14 @@ class InterfaceGeneration { | avg(real_value) AS avg_real_value, | avg(nullable_real_value) AS avg_nullable_real_value |FROM test; - |""".trimMargin(), - temporaryFolder + | + """.trimMargin(), + temporaryFolder, ) assertThat(result.errors).isEmpty() val generatedInterface = result.compilerOutput.get( - File(result.outputDirectory, "com/example/Average.kt") + File(result.outputDirectory, "com/example/Average.kt"), ) assertThat(generatedInterface).isNotNull() assertThat(generatedInterface.toString()).isEqualTo( @@ -558,7 +577,8 @@ class InterfaceGeneration { | public val avg_real_value: Double?, | public val avg_nullable_real_value: Double?, |) - |""".trimMargin() + | + """.trimMargin(), ) } @@ -593,13 +613,13 @@ class InterfaceGeneration { | GROUP BY 1 | ORDER BY target.name COLLATE NOCASE ASC |; - """.trimMargin(), - temporaryFolder + """.trimMargin(), + temporaryFolder, ) assertThat(result.errors).isEmpty() val generatedInterface = result.compilerOutput.get( - File(result.outputDirectory, "com/example/TargetWithEmojis.kt") + File(result.outputDirectory, "com/example/TargetWithEmojis.kt"), ) assertThat(generatedInterface).isNotNull() assertThat(generatedInterface.toString()).isEqualTo( @@ -614,7 +634,8 @@ class InterfaceGeneration { | public val name: String, | public val emojis: String?, |) - |""".trimMargin() + | + """.trimMargin(), ) } @@ -649,13 +670,13 @@ class InterfaceGeneration { | GROUP BY 1 | ORDER BY target.name COLLATE NOCASE ASC |; - """.trimMargin(), - temporaryFolder + """.trimMargin(), + temporaryFolder, ) assertThat(result.errors).isEmpty() val generatedInterface = result.compilerOutput.get( - File(result.outputDirectory, "com/example/TargetWithEmojis.kt") + File(result.outputDirectory, "com/example/TargetWithEmojis.kt"), ) assertThat(generatedInterface).isNotNull() assertThat(generatedInterface.toString()).isEqualTo( @@ -670,7 +691,8 @@ class InterfaceGeneration { | public val name: String, | public val emojis: String?, |) - |""".trimMargin() + | + """.trimMargin(), ) } @@ -686,8 +708,8 @@ class InterfaceGeneration { | foo, | CAST(foo AS BLOB) AS bar |FROM example; - """.trimMargin(), - temporaryFolder + """.trimMargin(), + temporaryFolder, ) val query = file.namedQueries.first() @@ -697,7 +719,8 @@ class InterfaceGeneration { | public val foo: kotlin.String?, | public val bar: kotlin.ByteArray?, |) - |""".trimMargin() + | + """.trimMargin(), ) } @@ -712,7 +735,8 @@ class InterfaceGeneration { | other_thing TEXT AS @Deprecated String NOT NULL |); """.trimMargin(), - temporaryFolder, dialect = TestDialect.MYSQL.dialect + temporaryFolder, + dialect = TestDialect.MYSQL.dialect, ) val query = file.tables(false).single() @@ -726,7 +750,8 @@ class InterfaceGeneration { | @java.lang.Deprecated | public val other_thing: kotlin.String, |) - |""".trimMargin() + | + """.trimMargin(), ) } @@ -744,13 +769,14 @@ class InterfaceGeneration { | |selectSongsByAlbumId: |SELECT * FROM song WHERE album_id = ?; - """.trimMargin(), - temporaryFolder, fileName = "song.sq" + """.trimMargin(), + temporaryFolder, + fileName = "song.sq", ) assertThat(result.errors).isEmpty() val generatedInterface = result.compilerOutput.get( - File(result.outputDirectory, "com/example/SongQueries.kt") + File(result.outputDirectory, "com/example/SongQueries.kt"), ) assertThat(generatedInterface).isNotNull() assertThat(generatedInterface.toString()).isEqualTo( @@ -813,7 +839,8 @@ class InterfaceGeneration { | public override fun toString(): String = "song.sq:selectSongsByAlbumId" | } |} - |""".trimMargin() + | + """.trimMargin(), ) } @@ -840,13 +867,15 @@ class InterfaceGeneration { | VALUES (?) | RETURNING user_id AS insert_id |) SELECT insert_id FROM inserted_ids; - """.trimMargin(), - temporaryFolder, fileName = "Subscription.sq", overrideDialect = PostgreSqlDialect() + """.trimMargin(), + temporaryFolder, + fileName = "Subscription.sq", + overrideDialect = PostgreSqlDialect(), ) assertThat(result.errors).isEmpty() val generatedInterface = result.compilerOutput.get( - File(result.outputDirectory, "com/example/SubscriptionQueries.kt") + File(result.outputDirectory, "com/example/SubscriptionQueries.kt"), ) assertThat(generatedInterface).isNotNull() assertThat(generatedInterface.toString()).isEqualTo( @@ -914,7 +943,8 @@ class InterfaceGeneration { | public override fun toString(): String = "Subscription.sq:insertUser" | } |} - |""".trimMargin() + | + """.trimMargin(), ) } @@ -940,8 +970,10 @@ class InterfaceGeneration { |) |SELECT descendants.id, descendants.parent_id |FROM descendants; - |""".trimMargin(), - temporaryFolder, fileName = "Recursive.sq" + | + """.trimMargin(), + temporaryFolder, + fileName = "Recursive.sq", ) val query = result.compiledFile.namedQueries[0] @@ -959,7 +991,8 @@ class InterfaceGeneration { | public val id: Long, | public val parent_id: Long?, |) - |""".trimMargin() + | + """.trimMargin(), ) val generatedQueries = result.compilerOutput.get(File(result.outputDirectory, "com/example/RecursiveQueries.kt")) @@ -1030,7 +1063,8 @@ class InterfaceGeneration { | public override fun toString(): String = "Recursive.sq:recursiveQuery" | } |} - |""".trimMargin() + | + """.trimMargin(), ) } @@ -1040,7 +1074,7 @@ class InterfaceGeneration { compilationMethod = { _, _, file, output -> SqlDelightCompiler.writeQueryInterfaces(file, output) }, - generateDb = false + generateDb = false, ) for ((expectedFile, actualOutput) in result.compilerOutput) { assertWithMessage("No file with name $expectedFile").that(expectedFile.exists()).isTrue() diff --git a/sqldelight-compiler/src/test/kotlin/app/cash/sqldelight/core/queries/JavadocTest.kt b/sqldelight-compiler/src/test/kotlin/app/cash/sqldelight/core/queries/JavadocTest.kt index 8fc0e4e898e..a185b5a27be 100644 --- a/sqldelight-compiler/src/test/kotlin/app/cash/sqldelight/core/queries/JavadocTest.kt +++ b/sqldelight-compiler/src/test/kotlin/app/cash/sqldelight/core/queries/JavadocTest.kt @@ -27,8 +27,10 @@ class JavadocTest { |selectAll: |SELECT * |FROM test; - |""".trimMargin(), - tempFolder, dialect = testDialect.dialect + | + """.trimMargin(), + tempFolder, + dialect = testDialect.dialect, ) val selectGenerator = SelectQueryGenerator(file.namedQueries.first()) @@ -43,7 +45,8 @@ class JavadocTest { | value_ | ) |} - |""".trimMargin() + | + """.trimMargin(), ) } @@ -63,8 +66,10 @@ class JavadocTest { |selectAll2: |SELECT * |FROM test; - |""".trimMargin(), - tempFolder, dialect = testDialect.dialect + | + """.trimMargin(), + tempFolder, + dialect = testDialect.dialect, ) val selectGenerator = SelectQueryGenerator(file.namedQueries.first()) @@ -79,7 +84,8 @@ class JavadocTest { | value_ | ) |} - |""".trimMargin() + | + """.trimMargin(), ) } @@ -95,8 +101,10 @@ class JavadocTest { |selectAll: |SELECT * |FROM test; - |""".trimMargin(), - tempFolder, dialect = testDialect.dialect + | + """.trimMargin(), + tempFolder, + dialect = testDialect.dialect, ) val selectGenerator = SelectQueryGenerator(file.namedQueries.first()) @@ -114,7 +122,8 @@ class JavadocTest { | value_ | ) |} - |""".trimMargin() + | + """.trimMargin(), ) } @@ -130,8 +139,10 @@ class JavadocTest { |selectAll: |SELECT * |FROM test; - |""".trimMargin(), - tempFolder, dialect = testDialect.dialect + | + """.trimMargin(), + tempFolder, + dialect = testDialect.dialect, ) val selectGenerator = SelectQueryGenerator(file.namedQueries.first()) @@ -149,7 +160,8 @@ class JavadocTest { | value_ | ) |} - |""".trimMargin() + | + """.trimMargin(), ) } @@ -160,8 +172,10 @@ class JavadocTest { |selectAll: |SELECT * |FROM test; - |""".trimMargin(), - tempFolder, dialect = testDialect.dialect + | + """.trimMargin(), + tempFolder, + dialect = testDialect.dialect, ) val selectGenerator = SelectQueryGenerator(file.namedQueries.first()) @@ -176,7 +190,8 @@ class JavadocTest { | value_ | ) |} - |""".trimMargin() + | + """.trimMargin(), ) } @@ -189,8 +204,10 @@ class JavadocTest { |selectAll: |SELECT * |FROM test; - |""".trimMargin(), - tempFolder, dialect = testDialect.dialect + | + """.trimMargin(), + tempFolder, + dialect = testDialect.dialect, ) val selectGenerator = SelectQueryGenerator(file.namedQueries.first()) @@ -205,7 +222,8 @@ class JavadocTest { | value_ | ) |} - |""".trimMargin() + | + """.trimMargin(), ) } @@ -218,8 +236,10 @@ class JavadocTest { |insertValue: |INSERT INTO test(value) |VALUES (?); - |""".trimMargin(), - tempFolder, dialect = testDialect.dialect + | + """.trimMargin(), + tempFolder, + dialect = testDialect.dialect, ) val insert = file.namedMutators.first() @@ -241,7 +261,8 @@ class JavadocTest { | emit("test") | } |} - |""".trimMargin() + | + """.trimMargin(), ) } @@ -255,8 +276,9 @@ class JavadocTest { |UPDATE test |SET value = ? |WHERE _id = ?; - |""".trimMargin(), - tempFolder + | + """.trimMargin(), + tempFolder, ) val update = file.namedMutators.first() @@ -280,7 +302,8 @@ class JavadocTest { | emit("test") | } |} - |""".trimMargin() + | + """.trimMargin(), ) } @@ -292,8 +315,10 @@ class JavadocTest { | */ |deleteAll: |DELETE FROM test; - |""".trimMargin(), - tempFolder, dialect = testDialect.dialect + | + """.trimMargin(), + tempFolder, + dialect = testDialect.dialect, ) val delete = file.namedMutators.first() @@ -310,7 +335,8 @@ class JavadocTest { | emit("test") | } |} - |""".trimMargin() + | + """.trimMargin(), ) } @@ -320,6 +346,7 @@ class JavadocTest { | _id INTEGER NOT NULL PRIMARY KEY DEFAULT 0, | value ${testDialect.textType} NOT NULL |); - |""".trimMargin() + | + """.trimMargin() } } diff --git a/sqldelight-compiler/src/test/kotlin/app/cash/sqldelight/core/queries/MutatorQueryFunctionTest.kt b/sqldelight-compiler/src/test/kotlin/app/cash/sqldelight/core/queries/MutatorQueryFunctionTest.kt index 9ef775e1ecb..19677da36e9 100644 --- a/sqldelight-compiler/src/test/kotlin/app/cash/sqldelight/core/queries/MutatorQueryFunctionTest.kt +++ b/sqldelight-compiler/src/test/kotlin/app/cash/sqldelight/core/queries/MutatorQueryFunctionTest.kt @@ -29,7 +29,8 @@ class MutatorQueryFunctionTest { |INSERT INTO data |VALUES (:customTextValue); """.trimMargin(), - tempFolder, dialect = dialect.dialect + tempFolder, + dialect = dialect.dialect, ) val insert = file.namedMutators.first() @@ -48,7 +49,8 @@ class MutatorQueryFunctionTest { | emit("data") | } |} - |""".trimMargin() + | + """.trimMargin(), ) } @@ -64,7 +66,7 @@ class MutatorQueryFunctionTest { |INSERT INTO data |VALUES (?, ?); """.trimMargin(), - tempFolder + tempFolder, ) val mutator = file.namedMutators.first() @@ -84,7 +86,8 @@ class MutatorQueryFunctionTest { | emit("data") | } |} - |""".trimMargin() + | + """.trimMargin(), ) } @@ -99,7 +102,8 @@ class MutatorQueryFunctionTest { |deleteData: |DELETE FROM data; """.trimMargin(), - tempFolder, fileName = "Data.sq" + tempFolder, + fileName = "Data.sq", ) val mutator = file.namedMutators.first() @@ -113,7 +117,8 @@ class MutatorQueryFunctionTest { | emit("data") | } |} - |""".trimMargin() + | + """.trimMargin(), ) } @@ -129,7 +134,7 @@ class MutatorQueryFunctionTest { |INSERT INTO data |VALUES ?; """.trimMargin(), - tempFolder + tempFolder, ) val mutator = file.namedMutators.first() @@ -149,7 +154,8 @@ class MutatorQueryFunctionTest { | emit("data") | } |} - |""".trimMargin() + | + """.trimMargin(), ) } @@ -166,7 +172,7 @@ class MutatorQueryFunctionTest { |SET value = :newValue |WHERE value = :oldValue; """.trimMargin(), - tempFolder + tempFolder, ) val update = file.namedMutators.first() @@ -187,7 +193,8 @@ class MutatorQueryFunctionTest { | emit("data") | } |} - |""".trimMargin() + | + """.trimMargin(), ) val nullAsUnknownFile = FixtureCompiler.parseSql( @@ -203,7 +210,7 @@ class MutatorQueryFunctionTest { |WHERE value = :oldValue; """.trimMargin(), tempFolder, - treatNullAsUnknownForEquality = true + treatNullAsUnknownForEquality = true, ) val nullAsUnknownUpdate = nullAsUnknownFile.namedMutators.first() @@ -224,7 +231,8 @@ class MutatorQueryFunctionTest { | emit("data") | } |} - |""".trimMargin() + | + """.trimMargin(), ) } @@ -240,7 +248,7 @@ class MutatorQueryFunctionTest { |INSERT INTO data |VALUES ?; """.trimMargin(), - tempFolder + tempFolder, ) val mutator = file.namedMutators.first() @@ -260,7 +268,8 @@ class MutatorQueryFunctionTest { | emit("data") | } |} - |""".trimMargin() + | + """.trimMargin(), ) } @@ -276,7 +285,7 @@ class MutatorQueryFunctionTest { |INSERT INTO data (id) |VALUES ?; """.trimMargin(), - tempFolder + tempFolder, ) val mutator = file.namedMutators.first() @@ -295,7 +304,8 @@ class MutatorQueryFunctionTest { | emit("data") | } |} - |""".trimMargin() + | + """.trimMargin(), ) } @@ -311,7 +321,7 @@ class MutatorQueryFunctionTest { |INSERT INTO data (id) |VALUES (?); """.trimMargin(), - tempFolder + tempFolder, ) val mutator = file.namedMutators.first() @@ -330,7 +340,8 @@ class MutatorQueryFunctionTest { | emit("data") | } |} - |""".trimMargin() + | + """.trimMargin(), ) } @@ -347,7 +358,7 @@ class MutatorQueryFunctionTest { |SET value = ? |WHERE id IN ?; """.trimMargin(), - tempFolder + tempFolder, ) val update = file.namedMutators.first() @@ -371,7 +382,8 @@ class MutatorQueryFunctionTest { | emit("data") | } |} - |""".trimMargin() + | + """.trimMargin(), ) } @@ -389,7 +401,7 @@ class MutatorQueryFunctionTest { | FROM some_table |); """.trimMargin(), - tempFolder + tempFolder, ) val update = file.namedMutators.first() @@ -412,7 +424,8 @@ class MutatorQueryFunctionTest { | emit("some_table") | } |} - |""".trimMargin() + | + """.trimMargin(), ) } @@ -436,7 +449,7 @@ class MutatorQueryFunctionTest { | c = ?, | d = ?; """.trimMargin(), - tempFolder + tempFolder, ) val mutator = file.namedMutators.first() @@ -465,7 +478,8 @@ class MutatorQueryFunctionTest { | emit("paymentHistoryConfig") | } |} - |""".trimMargin() + | + """.trimMargin(), ) } @@ -486,7 +500,7 @@ class MutatorQueryFunctionTest { |UPDATE paymentHistoryConfig |SET (a, b, c, d) = (?, ?, ?, ?); """.trimMargin(), - tempFolder + tempFolder, ) val mutator = file.namedMutators.first() @@ -512,7 +526,8 @@ class MutatorQueryFunctionTest { | emit("paymentHistoryConfig") | } |} - |""".trimMargin() + | + """.trimMargin(), ) } @@ -528,7 +543,7 @@ class MutatorQueryFunctionTest { |INSERT INTO nullableTypes |VALUES ?; """.trimMargin(), - tempFolder + tempFolder, ) val insert = file.namedMutators.first() @@ -548,7 +563,8 @@ class MutatorQueryFunctionTest { | emit("nullableTypes") | } |} - |""".trimMargin() + | + """.trimMargin(), ) } @@ -566,7 +582,7 @@ class MutatorQueryFunctionTest { |INTO category (rowid, id, name, description) |VALUES (COALESCE((SELECT rowid FROM category c2 WHERE id = ?1), NULL), ?1, ?2, ?3); """.trimMargin(), - tempFolder + tempFolder, ) val insert = file.namedMutators.first() @@ -593,7 +609,8 @@ class MutatorQueryFunctionTest { | emit("category") | } |} - |""".trimMargin() + | + """.trimMargin(), ) } @@ -609,8 +626,10 @@ class MutatorQueryFunctionTest { | |upsert: |INSERT INTO example(id, data) VALUES(:id, :data) ON CONFLICT(id) DO UPDATE SET data = :data; - """.trimMargin(), - tempFolder, fileName = "Data.sq", dialect = SqliteDialect() + """.trimMargin(), + tempFolder, + fileName = "Data.sq", + dialect = SqliteDialect(), ) val mutator = file.namedMutators.first() @@ -629,7 +648,8 @@ class MutatorQueryFunctionTest { | emit("example") | } |} - |""".trimMargin() + | + """.trimMargin(), ) } @@ -644,8 +664,9 @@ class MutatorQueryFunctionTest { |insertAnnotation: |INSERT INTO annotation |VALUES ?; - """.trimMargin(), - tempFolder, fileName = "Data.sq" + """.trimMargin(), + tempFolder, + fileName = "Data.sq", ) val mutator = file.namedMutators.first() @@ -665,7 +686,8 @@ class MutatorQueryFunctionTest { | emit("annotation") | } |} - |""".trimMargin() + | + """.trimMargin(), ) } @@ -685,12 +707,13 @@ class MutatorQueryFunctionTest { | WHERE id = :id; | INSERT OR IGNORE INTO myTable VALUES ?; |} - """.trimMargin(), - tempFolder, fileName = "Data.sq" + """.trimMargin(), + tempFolder, + fileName = "Data.sq", ) assertThat(result.errors).containsExactly( - "Data.sq: (12, 32): Table parameters are not usable in a grouped statement." + "Data.sq: (12, 32): Table parameters are not usable in a grouped statement.", ) } @@ -707,7 +730,7 @@ class MutatorQueryFunctionTest { |update2: |UPDATE BasketRowEntity SET subtotal = IIF(TRUE, :subtotal, :subtotal); """.trimMargin(), - tempFolder + tempFolder, ) file.namedMutators.forEach { diff --git a/sqldelight-compiler/src/test/kotlin/app/cash/sqldelight/core/queries/MutatorQueryTypeTest.kt b/sqldelight-compiler/src/test/kotlin/app/cash/sqldelight/core/queries/MutatorQueryTypeTest.kt index 4684e4eec92..d60b2e52739 100644 --- a/sqldelight-compiler/src/test/kotlin/app/cash/sqldelight/core/queries/MutatorQueryTypeTest.kt +++ b/sqldelight-compiler/src/test/kotlin/app/cash/sqldelight/core/queries/MutatorQueryTypeTest.kt @@ -28,7 +28,7 @@ class MutatorQueryTypeTest { |INSERT INTO data |VALUES (?, ?); """.trimMargin(), - tempFolder + tempFolder, ) val mutator = file.namedMutators.first() @@ -48,7 +48,8 @@ class MutatorQueryTypeTest { | emit("data") | } |} - |""".trimMargin() + | + """.trimMargin(), ) } @@ -65,8 +66,8 @@ class MutatorQueryTypeTest { |insertData: |INSERT INTO data |VALUES ?; - """.trimMargin(), - tempFolder + """.trimMargin(), + tempFolder, ) val mutator = file.namedMutators.first() @@ -86,7 +87,8 @@ class MutatorQueryTypeTest { | emit("data") | } |} - |""".trimMargin() + | + """.trimMargin(), ) } @@ -111,7 +113,7 @@ class MutatorQueryTypeTest { | AND className = ?2 |; """.trimMargin(), - tempFolder + tempFolder, ) val mutator = file.namedMutators.first() @@ -141,7 +143,8 @@ class MutatorQueryTypeTest { | emit("item") | } |} - |""".trimMargin() + | + """.trimMargin(), ) } @@ -162,7 +165,8 @@ class MutatorQueryTypeTest { |INSERT INTO data |VALUES (?, ?); """.trimMargin(), - tempFolder, fileName = "Data.sq" + tempFolder, + fileName = "Data.sq", ) val mutator = file.namedMutators.first() @@ -182,7 +186,8 @@ class MutatorQueryTypeTest { | emit("data") | } |} - |""".trimMargin() + | + """.trimMargin(), ) } @@ -194,7 +199,8 @@ class MutatorQueryTypeTest { |FROM data |WHERE id = ?; """.trimMargin(), - tempFolder, fileName = "OtherData.sq" + tempFolder, + fileName = "OtherData.sq", ) val file = FixtureCompiler.parseSql( @@ -208,7 +214,8 @@ class MutatorQueryTypeTest { |INSERT INTO data |VALUES (?, ?); """.trimMargin(), - tempFolder, fileName = "Data.sq" + tempFolder, + fileName = "Data.sq", ) val mutator = file.namedMutators.first() @@ -228,7 +235,8 @@ class MutatorQueryTypeTest { | emit("data") | } |} - |""".trimMargin() + | + """.trimMargin(), ) } @@ -244,7 +252,8 @@ class MutatorQueryTypeTest { |FROM other_data |WHERE id = ?; """.trimMargin(), - tempFolder, fileName = "OtherData.sq" + tempFolder, + fileName = "OtherData.sq", ) val file = FixtureCompiler.parseSql( @@ -263,7 +272,8 @@ class MutatorQueryTypeTest { |INSERT INTO data |VALUES (?, ?); """.trimMargin(), - tempFolder, fileName = "Data.sq" + tempFolder, + fileName = "Data.sq", ) val mutator = file.namedMutators.first() @@ -283,7 +293,8 @@ class MutatorQueryTypeTest { | emit("data") | } |} - |""".trimMargin() + | + """.trimMargin(), ) } @@ -299,7 +310,8 @@ class MutatorQueryTypeTest { |INSERT INTO data |VALUES (?, ?); """.trimMargin(), - tempFolder, fileName = "Data.sq" + tempFolder, + fileName = "Data.sq", ) val mutator = file.namedMutators.first() @@ -319,7 +331,8 @@ class MutatorQueryTypeTest { | emit("data") | } |} - |""".trimMargin() + | + """.trimMargin(), ) } @@ -346,7 +359,8 @@ class MutatorQueryTypeTest { | ON data.id = data2.id |); """.trimMargin(), - tempFolder, fileName = "Data.sq" + tempFolder, + fileName = "Data.sq", ) val mutator = file.namedMutators.first() @@ -369,7 +383,8 @@ class MutatorQueryTypeTest { | emit("data") | } |} - |""".trimMargin() + | + """.trimMargin(), ) } @@ -385,7 +400,8 @@ class MutatorQueryTypeTest { |INSERT INTO data (value) |VALUES (?); """.trimMargin(), - tempFolder, fileName = "Data.sq" + tempFolder, + fileName = "Data.sq", ) val mutator = file.namedMutators.first() @@ -404,7 +420,8 @@ class MutatorQueryTypeTest { | emit("data") | } |} - |""".trimMargin() + | + """.trimMargin(), ) } @@ -420,7 +437,8 @@ class MutatorQueryTypeTest { |INSERT INTO data (value) |VALUES (?); """.trimMargin(), - tempFolder, fileName = "Data.sq" + tempFolder, + fileName = "Data.sq", ) val mutator = file.namedMutators.first() @@ -439,7 +457,8 @@ class MutatorQueryTypeTest { | emit("data") | } |} - |""".trimMargin() + | + """.trimMargin(), ) } @@ -475,7 +494,9 @@ class MutatorQueryTypeTest { |INSERT INTO data |VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?); """.trimMargin(), - tempFolder, fileName = "Data.sq", dialect.dialect + tempFolder, + fileName = "Data.sq", + dialect.dialect, ) val mutator = file.namedMutators.first() @@ -535,7 +556,8 @@ class MutatorQueryTypeTest { | emit("data") | } |} - |""".trimMargin() + | + """.trimMargin(), ) } @@ -571,7 +593,9 @@ class MutatorQueryTypeTest { |INSERT INTO data |VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?); """.trimMargin(), - tempFolder, fileName = "Data.sq", dialect.dialect + tempFolder, + fileName = "Data.sq", + dialect.dialect, ) val mutator = file.namedMutators.first() @@ -631,7 +655,8 @@ class MutatorQueryTypeTest { | emit("data") | } |} - |""".trimMargin() + | + """.trimMargin(), ) } @@ -659,7 +684,9 @@ class MutatorQueryTypeTest { |INSERT INTO data |VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?); """.trimMargin(), - tempFolder, fileName = "Data.sq", dialect.dialect + tempFolder, + fileName = "Data.sq", + dialect.dialect, ) val mutator = file.namedMutators.first() @@ -703,7 +730,8 @@ class MutatorQueryTypeTest { | emit("data") | } |} - |""".trimMargin() + | + """.trimMargin(), ) } @@ -732,8 +760,10 @@ class MutatorQueryTypeTest { |JOIN item ON (docid = item.id) |WHERE content LIKE '%' || ? || '%' ESCAPE '\' |; - |""".trimMargin(), - tempFolder, fileName = "Data.sq" + | + """.trimMargin(), + tempFolder, + fileName = "Data.sq", ) val mutator = file.namedMutators.first() @@ -757,7 +787,8 @@ class MutatorQueryTypeTest { | emit("item") | } |} - |""".trimMargin() + | + """.trimMargin(), ) } @@ -785,8 +816,10 @@ class MutatorQueryTypeTest { |JOIN item ON (docid = item.id) |WHERE content MATCH '"one ' || ? || '" * '; | - |""".trimMargin(), - tempFolder, fileName = "Data.sq" + | + """.trimMargin(), + tempFolder, + fileName = "Data.sq", ) val mutator = file.namedMutators.first() @@ -802,7 +835,8 @@ class MutatorQueryTypeTest { | emit("item_index") | } |} - |""".trimMargin() + | + """.trimMargin(), ) } @@ -836,8 +870,10 @@ class MutatorQueryTypeTest { | |updateFoobarSelected: |UPDATE OR IGNORE foobar SET selected = ? WHERE id = ?; - |""".trimMargin(), - tempFolder, fileName = "Data.sq" + | + """.trimMargin(), + tempFolder, + fileName = "Data.sq", ) val mutator = file.namedMutators.first() @@ -855,7 +891,8 @@ class MutatorQueryTypeTest { | emit("foo") | } |} - |""".trimMargin() + | + """.trimMargin(), ) } } diff --git a/sqldelight-compiler/src/test/kotlin/app/cash/sqldelight/core/queries/PgInsertOnConflictTest.kt b/sqldelight-compiler/src/test/kotlin/app/cash/sqldelight/core/queries/PgInsertOnConflictTest.kt index 5496f7926cb..2bfe1b4cdcc 100644 --- a/sqldelight-compiler/src/test/kotlin/app/cash/sqldelight/core/queries/PgInsertOnConflictTest.kt +++ b/sqldelight-compiler/src/test/kotlin/app/cash/sqldelight/core/queries/PgInsertOnConflictTest.kt @@ -24,8 +24,9 @@ class PgInsertOnConflictTest { |INSERT INTO data |VALUES (:id, :c1) |ON CONFLICT (id) DO UPDATE SET col1 = :c1; - """.trimMargin(), - tempFolder, dialect = PostgreSqlDialect() + """.trimMargin(), + tempFolder, + dialect = PostgreSqlDialect(), ) val insert = file.namedMutators.first() @@ -49,7 +50,7 @@ class PgInsertOnConflictTest { | } |} | - """.trimMargin() + """.trimMargin(), ) } @@ -68,8 +69,9 @@ class PgInsertOnConflictTest { |INSERT INTO data |VALUES (:id, :c1, :c2, :c3) |ON CONFLICT (id) DO UPDATE SET col1 = :c1, col2 = :c2; - """.trimMargin(), - tempFolder, dialect = PostgreSqlDialect() + """.trimMargin(), + tempFolder, + dialect = PostgreSqlDialect(), ) val insert = file.namedMutators.first() @@ -101,7 +103,7 @@ class PgInsertOnConflictTest { | } |} | - """.trimMargin() + """.trimMargin(), ) } @@ -120,8 +122,9 @@ class PgInsertOnConflictTest { |INSERT INTO data |VALUES (:id, :c1, :c2, :c3) |ON CONFLICT (id) DO UPDATE SET col1 = :c1, col2 = :c2, col3 = :c3; - """.trimMargin(), - tempFolder, dialect = PostgreSqlDialect() + """.trimMargin(), + tempFolder, + dialect = PostgreSqlDialect(), ) val insert = file.namedMutators.first() @@ -154,7 +157,7 @@ class PgInsertOnConflictTest { | } |} | - """.trimMargin() + """.trimMargin(), ) } } diff --git a/sqldelight-compiler/src/test/kotlin/app/cash/sqldelight/core/queries/SelectQueryFunctionTest.kt b/sqldelight-compiler/src/test/kotlin/app/cash/sqldelight/core/queries/SelectQueryFunctionTest.kt index e14265c808f..08e0383ed27 100644 --- a/sqldelight-compiler/src/test/kotlin/app/cash/sqldelight/core/queries/SelectQueryFunctionTest.kt +++ b/sqldelight-compiler/src/test/kotlin/app/cash/sqldelight/core/queries/SelectQueryFunctionTest.kt @@ -31,7 +31,7 @@ class SelectQueryFunctionTest { |FROM data |WHERE id = ?; """.trimMargin(), - tempFolder + tempFolder, ) val generator = SelectQueryGenerator(file.namedQueries.first()) @@ -43,7 +43,8 @@ class SelectQueryFunctionTest { | value_ | ) |} - |""".trimMargin() + | + """.trimMargin(), ) } @@ -71,8 +72,9 @@ class SelectQueryFunctionTest { | OR | :to BETWEEN startTime AND endTime |); - |""".trimMargin(), - tempFolder + | + """.trimMargin(), + tempFolder, ) val generator = SelectQueryGenerator(file.namedQueries.first()) @@ -89,7 +91,8 @@ class SelectQueryFunctionTest { | endTime | ) |} - |""".trimMargin() + | + """.trimMargin(), ) } @@ -107,7 +110,7 @@ class SelectQueryFunctionTest { |WHERE id = ?2 |AND value = ?1; """.trimMargin(), - tempFolder + tempFolder, ) val generator = SelectQueryGenerator(file.namedQueries.first()) @@ -119,7 +122,8 @@ class SelectQueryFunctionTest { | value__ | ) |} - |""".trimMargin() + | + """.trimMargin(), ) } @@ -136,7 +140,7 @@ class SelectQueryFunctionTest { |FROM data |WHERE id = ?; """.trimMargin(), - tempFolder + tempFolder, ) val generator = SelectQueryGenerator(file.namedQueries.first()) @@ -149,7 +153,7 @@ class SelectQueryFunctionTest { | ) |} | - """.trimMargin() + """.trimMargin(), ) } @@ -168,7 +172,7 @@ class SelectQueryFunctionTest { |FROM data |WHERE id = ?; """.trimMargin(), - tempFolder + tempFolder, ) val generator = SelectQueryGenerator(file.namedQueries.first()) @@ -181,7 +185,7 @@ class SelectQueryFunctionTest { | ) |} | - """.trimMargin() + """.trimMargin(), ) } @@ -191,14 +195,14 @@ class SelectQueryFunctionTest { |selectValues: |VALUES (1), ('sup'); """.trimMargin(), - tempFolder + tempFolder, ) val generator = SelectQueryGenerator(file.namedQueries.first()) assertThat(generator.customResultTypeFunction().toString()).contains( """ |public fun selectValues(): app.cash.sqldelight.Query - """.trimMargin() + """.trimMargin(), ) } @@ -216,7 +220,7 @@ class SelectQueryFunctionTest { |SELECT * |FROM data; """.trimMargin(), - tempFolder + tempFolder, ) val query = file.namedQueries.first() @@ -233,7 +237,8 @@ class SelectQueryFunctionTest { | data_Adapter.value_Adapter.decode(cursor.getString(1)!!) | ) |} - |""".trimMargin() + | + """.trimMargin(), ) } @@ -248,7 +253,7 @@ class SelectQueryFunctionTest { |SELECT * |FROM data; """.trimMargin(), - tempFolder + tempFolder, ) val query = file.namedQueries.first() @@ -263,7 +268,7 @@ class SelectQueryFunctionTest { | cursor.getLong(0)!! |} | - """.trimMargin() + """.trimMargin(), ) } @@ -279,7 +284,7 @@ class SelectQueryFunctionTest { |FROM data |WHERE id IN :good AND id NOT IN :bad; """.trimMargin(), - tempFolder + tempFolder, ) val generator = SelectQueryGenerator(file.namedQueries.first()) @@ -318,7 +323,7 @@ class SelectQueryFunctionTest { | public override fun toString(): kotlin.String = "Test.sq:selectForId" |} | - """.trimMargin() + """.trimMargin(), ) } @@ -336,7 +341,7 @@ class SelectQueryFunctionTest { |WHERE EXISTS (SELECT * FROM data LIMIT :minimum OFFSET :offset) |LIMIT :minimum; """.trimMargin(), - tempFolder + tempFolder, ) val generator = SelectQueryGenerator(file.namedQueries.first()) @@ -348,7 +353,8 @@ class SelectQueryFunctionTest { | some_column2 | ) |} - |""".trimMargin() + | + """.trimMargin(), ) } @@ -366,7 +372,7 @@ class SelectQueryFunctionTest { |FROM person |WHERE first_name = :name AND last_name = :name; """.trimMargin(), - tempFolder + tempFolder, ) val query = file.namedQueries.first() @@ -398,7 +404,7 @@ class SelectQueryFunctionTest { | public override fun toString(): kotlin.String = "Test.sq:equivalentNamesNamed" |} | - """.trimMargin() + """.trimMargin(), ) } @@ -413,7 +419,7 @@ class SelectQueryFunctionTest { |SELECT * |FROM data; """.trimMargin(), - tempFolder + tempFolder, ) val query = file.namedQueries.first() @@ -428,7 +434,7 @@ class SelectQueryFunctionTest { | cursor.getDouble(0)!! |} | - """.trimMargin() + """.trimMargin(), ) } @@ -443,7 +449,7 @@ class SelectQueryFunctionTest { |SELECT * |FROM data; """.trimMargin(), - tempFolder + tempFolder, ) val query = file.namedQueries.first() @@ -458,7 +464,7 @@ class SelectQueryFunctionTest { | cursor.getBytes(0)!! |} | - """.trimMargin() + """.trimMargin(), ) } @@ -468,7 +474,7 @@ class SelectQueryFunctionTest { |selectData: |SELECT NULL; """.trimMargin(), - tempFolder + tempFolder, ) val query = file.namedQueries.first() @@ -482,7 +488,7 @@ class SelectQueryFunctionTest { | ) |} | - """.trimMargin() + """.trimMargin(), ) } @@ -518,7 +524,8 @@ class SelectQueryFunctionTest { |SELECT * |FROM data; """.trimMargin(), - tempFolder, dialect = dialect.dialect + tempFolder, + dialect = dialect.dialect, ) val query = file.namedQueries.first() @@ -576,7 +583,7 @@ class SelectQueryFunctionTest { | ) |} | - """.trimMargin() + """.trimMargin(), ) } @@ -616,7 +623,8 @@ class SelectQueryFunctionTest { |SELECT * |FROM data; """.trimMargin(), - tempFolder, dialect = dialect.dialect + tempFolder, + dialect = dialect.dialect, ) val query = file.namedQueries.first() @@ -682,7 +690,7 @@ class SelectQueryFunctionTest { | ) |} | - """.trimMargin() + """.trimMargin(), ) } @@ -712,7 +720,8 @@ class SelectQueryFunctionTest { |SELECT * |FROM data; """.trimMargin(), - tempFolder, dialect = dialect.dialect + tempFolder, + dialect = dialect.dialect, ) val query = file.namedQueries.first() @@ -758,7 +767,7 @@ class SelectQueryFunctionTest { | ) |} | - """.trimMargin() + """.trimMargin(), ) } @@ -774,7 +783,7 @@ class SelectQueryFunctionTest { |SELECT coalesce(value, value2), value, value2 |FROM data; """.trimMargin(), - tempFolder + tempFolder, ) val generator = SelectQueryGenerator(file.namedQueries.first()) @@ -787,7 +796,8 @@ class SelectQueryFunctionTest { | value2 | ) |} - |""".trimMargin() + | + """.trimMargin(), ) } @@ -809,7 +819,7 @@ class SelectQueryFunctionTest { | ELSE name | END; """.trimMargin(), - tempFolder + tempFolder, ) val generator = SelectQueryGenerator(file.namedQueries.first()) @@ -819,7 +829,7 @@ class SelectQueryFunctionTest { | cursor.getString(0)!! |} | - """.trimMargin() + """.trimMargin(), ) } @@ -863,7 +873,7 @@ class SelectQueryFunctionTest { |SELECT * |FROM bigTable; """.trimMargin(), - tempFolder + tempFolder, ) val query = file.namedQueries.first() @@ -939,7 +949,8 @@ class SelectQueryFunctionTest { | cursor.getLong(29) | ) |} - |""".trimMargin() + | + """.trimMargin(), ) } @@ -988,7 +999,7 @@ class SelectQueryFunctionTest { |LIMIT 50 |; """.trimMargin(), - tempFolder + tempFolder, ) val generator = SelectQueryGenerator(file.namedQueries.first()) @@ -1010,7 +1021,7 @@ class SelectQueryFunctionTest { | ) |} | - """.trimMargin() + """.trimMargin(), ) } @@ -1036,7 +1047,7 @@ class SelectQueryFunctionTest { |WHERE place_fts MATCH ?1 |ORDER BY rank(matchinfo(place_fts)), place.name; """.trimMargin(), - tempFolder + tempFolder, ) val generator = SelectQueryGenerator(file.namedQueries.first()) @@ -1056,7 +1067,7 @@ class SelectQueryFunctionTest { | ) |} | - """.trimMargin() + """.trimMargin(), ) } @@ -1083,7 +1094,7 @@ class SelectQueryFunctionTest { | WHERE testA.attr IS NULL |); """.trimMargin(), - tempFolder + tempFolder, ) val query = file.namedQueries.first() @@ -1117,7 +1128,8 @@ class SelectQueryFunctionTest { | cursor.getLong(3)!! | ) |} - |""".trimMargin() + | + """.trimMargin(), ) } @@ -1146,7 +1158,7 @@ class SelectQueryFunctionTest { |JOIN testB AS childJoined ON child_id = childJoined._id |WHERE parent_id = ? AND child_id = ?; """.trimMargin(), - tempFolder + tempFolder, ) val generator = SelectQueryGenerator(file.namedQueries.first()) @@ -1184,7 +1196,7 @@ class SelectQueryFunctionTest { | ) |} | - """.trimMargin() + """.trimMargin(), ) } @@ -1199,8 +1211,9 @@ class SelectQueryFunctionTest { |SELECT stuff |FROM test |WHERE stuff IS NOT NULL; - |""".trimMargin(), - tempFolder + | + """.trimMargin(), + tempFolder, ) val query = file.namedQueries.first() @@ -1214,7 +1227,8 @@ class SelectQueryFunctionTest { |""${'"'}.trimMargin()) { cursor -> | cursor.getLong(0)!! |} - |""".trimMargin() + | + """.trimMargin(), ) } @@ -1228,8 +1242,9 @@ class SelectQueryFunctionTest { |someSelect: |SELECT SUM(stuff) / 3.0 |FROM test; - |""".trimMargin(), - tempFolder + | + """.trimMargin(), + tempFolder, ) val query = file.namedQueries.first() @@ -1244,7 +1259,8 @@ class SelectQueryFunctionTest { | cursor.getDouble(0) | ) |} - |""".trimMargin() + | + """.trimMargin(), ) } @@ -1261,7 +1277,7 @@ class SelectQueryFunctionTest { |queryTwo: |SELECT * FROM exit WHERE :wingsuit = 1 AND wingsuit = :wingsuit; """.trimMargin(), - tempFolder + tempFolder, ) val queryOne = file.namedQueries.first() @@ -1287,7 +1303,8 @@ class SelectQueryFunctionTest { |searchDescription: |SELECT model_id, model_description FROM models WHERE INSTR(model_description, ?) > 0; """.trimMargin(), - tempFolder, dialect = TestDialect.MYSQL.dialect + tempFolder, + dialect = TestDialect.MYSQL.dialect, ) val query = file.namedQueries.first() @@ -1302,7 +1319,8 @@ class SelectQueryFunctionTest { | cursor.getString(1)!! | ) |} - |""".trimMargin() + | + """.trimMargin(), ) } @@ -1313,7 +1331,7 @@ class SelectQueryFunctionTest { |SELECT 1, 2 |WHERE IFNULL(:param, 1) > 0; """.trimMargin(), - tempFolder + tempFolder, ) val query = file.namedQueries.first() @@ -1322,7 +1340,7 @@ class SelectQueryFunctionTest { val param = ParameterSpec.builder( "param_", Long::class.asTypeName() - .copy(nullable = true) + .copy(nullable = true), ) .build() assertThat(generator.defaultResultTypeFunction().parameters).containsExactly(param) @@ -1342,7 +1360,8 @@ class SelectQueryFunctionTest { |selectAll: |SELECT * FROM category; """.trimMargin(), - tempFolder, dialect = TestDialect.MYSQL.dialect + tempFolder, + dialect = TestDialect.MYSQL.dialect, ) val query = file.namedQueries.first() @@ -1357,7 +1376,8 @@ class SelectQueryFunctionTest { | cursor.getString(1) | ) |} - |""".trimMargin() + | + """.trimMargin(), ) } @@ -1381,7 +1401,8 @@ class SelectQueryFunctionTest { |SELECT * |FROM supView; """.trimMargin(), - tempFolder, dialect = TestDialect.MYSQL.dialect + tempFolder, + dialect = TestDialect.MYSQL.dialect, ) val query = file.namedQueries.first() @@ -1395,7 +1416,8 @@ class SelectQueryFunctionTest { | value2 | ) |} - |""".trimMargin() + | + """.trimMargin(), ) } @@ -1419,7 +1441,8 @@ class SelectQueryFunctionTest { |SELECT * |FROM sup2; """.trimMargin(), - tempFolder, dialect = TestDialect.MYSQL.dialect + tempFolder, + dialect = TestDialect.MYSQL.dialect, ) val query = file.namedQueries.first() @@ -1432,7 +1455,8 @@ class SelectQueryFunctionTest { | value_ | ) |} - |""".trimMargin() + | + """.trimMargin(), ) } @@ -1452,7 +1476,8 @@ class SelectQueryFunctionTest { |SELECT * |FROM sup; """.trimMargin(), - tempFolder, dialect = TestDialect.MYSQL.dialect + tempFolder, + dialect = TestDialect.MYSQL.dialect, ) val query = file.namedQueries.first() @@ -1465,7 +1490,8 @@ class SelectQueryFunctionTest { | value_ | ) |} - |""".trimMargin() + | + """.trimMargin(), ) } @@ -1496,7 +1522,8 @@ class SelectQueryFunctionTest { |findAll: |SELECT * FROM TestView; """.trimMargin(), - tempFolder, dialect = TestDialect.MYSQL.dialect + tempFolder, + dialect = TestDialect.MYSQL.dialect, ) val query = file.namedQueries.first() @@ -1510,7 +1537,8 @@ class SelectQueryFunctionTest { | name | ) |} - |""".trimMargin() + | + """.trimMargin(), ) } @@ -1520,7 +1548,8 @@ class SelectQueryFunctionTest { |selectIf: |SELECT IF(1 = 1, 'yes', 'no'); """.trimMargin(), - tempFolder, dialect = TestDialect.MYSQL.dialect + tempFolder, + dialect = TestDialect.MYSQL.dialect, ) val query = file.namedQueries.first() @@ -1532,7 +1561,8 @@ class SelectQueryFunctionTest { | check(cursor is app.cash.sqldelight.driver.jdbc.JdbcCursor) | cursor.getString(0)!! |} - |""".trimMargin() + | + """.trimMargin(), ) } @@ -1550,7 +1580,7 @@ class SelectQueryFunctionTest { |FROM Player |WHERE username LIKE ('%' || ?1 || '%') OR email LIKE ('%' || ?1 || '%'); """.trimMargin(), - tempFolder + tempFolder, ) val generator = SelectQueryGenerator(file.namedQueries.first()) @@ -1563,7 +1593,8 @@ class SelectQueryFunctionTest { | email | ) |} - |""".trimMargin() + | + """.trimMargin(), ) } @@ -1612,8 +1643,9 @@ class SelectQueryFunctionTest { |ORDER BY store.name ASC |LIMIT ? |OFFSET ?; - """.trimMargin(), - tempFolder, dialect = TestDialect.MYSQL.dialect + """.trimMargin(), + tempFolder, + dialect = TestDialect.MYSQL.dialect, ) val generator = SelectQueryGenerator(file.namedQueries.first()) @@ -1629,7 +1661,8 @@ class SelectQueryFunctionTest { | name | ) |} - |""".trimMargin() + | + """.trimMargin(), ) } @@ -1648,8 +1681,9 @@ class SelectQueryFunctionTest { | (:someInteger IS NULL) OR ( | (string = :someString) AND (integer >= :someInteger) | ); - |""".trimMargin(), - tempFolder + | + """.trimMargin(), + tempFolder, ) val query = file.namedQueries.first() @@ -1672,7 +1706,8 @@ class SelectQueryFunctionTest { | cursor.getLong(2) | ) |} - |""".trimMargin() + | + """.trimMargin(), ) } @@ -1688,8 +1723,9 @@ class SelectQueryFunctionTest { | |test2: |SELECT * FROM Users WHERE initialized = :initialized AND initialized = 1; - |""".trimMargin(), - tempFolder + | + """.trimMargin(), + tempFolder, ) val query1 = file.namedQueries[0] @@ -1702,7 +1738,8 @@ class SelectQueryFunctionTest { | initialized_ | ) |} - |""".trimMargin() + | + """.trimMargin(), ) val query2 = file.namedQueries[1] @@ -1715,7 +1752,8 @@ class SelectQueryFunctionTest { | initialized_ | ) |} - |""".trimMargin() + | + """.trimMargin(), ) } @@ -1726,8 +1764,9 @@ class SelectQueryFunctionTest { |SELECT 'foo' |UNION |SELECT ?; - |""".trimMargin(), - tempFolder + | + """.trimMargin(), + tempFolder, ) val query = file.namedQueries.first() @@ -1738,7 +1777,8 @@ class SelectQueryFunctionTest { |public fun query(expr: kotlin.String): app.cash.sqldelight.Query = QueryQuery(expr) { cursor -> | cursor.getString(0)!! |} - |""".trimMargin() + | + """.trimMargin(), ) } } diff --git a/sqldelight-compiler/src/test/kotlin/app/cash/sqldelight/core/queries/SelectQueryTypeTest.kt b/sqldelight-compiler/src/test/kotlin/app/cash/sqldelight/core/queries/SelectQueryTypeTest.kt index 89f09926152..105cec73de0 100644 --- a/sqldelight-compiler/src/test/kotlin/app/cash/sqldelight/core/queries/SelectQueryTypeTest.kt +++ b/sqldelight-compiler/src/test/kotlin/app/cash/sqldelight/core/queries/SelectQueryTypeTest.kt @@ -35,9 +35,10 @@ class SelectQueryTypeTest { |INSERT INTO data |VALUES ('sup', 'dude') |RETURNING *; - |""".trimMargin(), + | + """.trimMargin(), tempFolder, - dialect = PostgreSqlDialect() + dialect = PostgreSqlDialect(), ) val query = file.namedQueries.first() @@ -56,7 +57,8 @@ class SelectQueryTypeTest { | cursor.getString(1) | ) |} - |""".trimMargin() + | + """.trimMargin(), ) } @@ -76,9 +78,10 @@ class SelectQueryTypeTest { | lastname = :lastname |WHERE id = :id |RETURNING id, firstname, lastname; - |""".trimMargin(), + | + """.trimMargin(), tempFolder, - dialect = PostgreSqlDialect() + dialect = PostgreSqlDialect(), ) val query = file.namedQueries.first() @@ -103,7 +106,8 @@ class SelectQueryTypeTest { | cursor.getString(2)!! | ) |} - |""".trimMargin() + | + """.trimMargin(), ) } @@ -118,8 +122,9 @@ class SelectQueryTypeTest { |SELECT * |FROM data |WHERE id = ?; - |""".trimMargin(), - tempFolder + | + """.trimMargin(), + tempFolder, ) val query = file.namedQueries.first() @@ -149,7 +154,8 @@ class SelectQueryTypeTest { | | public override fun toString(): kotlin.String = "Test.sq:selectForId" |} - |""".trimMargin() + | + """.trimMargin(), ) } @@ -167,7 +173,7 @@ class SelectQueryTypeTest { |WHERE id = ?2 |AND value = ?1; """.trimMargin(), - tempFolder + tempFolder, ) val query = file.namedQueries.first() @@ -200,7 +206,8 @@ class SelectQueryTypeTest { | | public override fun toString(): kotlin.String = "Test.sq:select" |} - |""".trimMargin() + | + """.trimMargin(), ) } @@ -215,8 +222,9 @@ class SelectQueryTypeTest { |SELECT * |FROM data |WHERE id IN ?; - |""".trimMargin(), - tempFolder + | + """.trimMargin(), + tempFolder, ) val generator = SelectQueryGenerator(file.namedQueries.first()) @@ -250,7 +258,8 @@ class SelectQueryTypeTest { | | public override fun toString(): kotlin.String = "Test.sq:selectForId" |} - |""".trimMargin() + | + """.trimMargin(), ) } @@ -266,8 +275,9 @@ class SelectQueryTypeTest { |SELECT * |FROM data |WHERE id IN ?1 AND message != ?2 AND id IN ?1; - |""".trimMargin(), - tempFolder + | + """.trimMargin(), + tempFolder, ) val generator = SelectQueryGenerator(file.namedQueries.first()) @@ -306,7 +316,8 @@ class SelectQueryTypeTest { | | public override fun toString(): kotlin.String = "Test.sq:selectForId" |} - |""".trimMargin() + | + """.trimMargin(), ) } @@ -321,8 +332,9 @@ class SelectQueryTypeTest { | |select_news_list: |SELECT * FROM socialFeedItem WHERE message IS NOT NULL AND userId = ? ORDER BY datetime(creation_time) DESC; - |""".trimMargin(), - tempFolder + | + """.trimMargin(), + tempFolder, ) val query = file.namedQueries.first() @@ -348,7 +360,8 @@ class SelectQueryTypeTest { | | public override fun toString(): kotlin.String = "Test.sq:select_news_list" |} - |""".trimMargin() + | + """.trimMargin(), ) val treatNullAsUnknownFile = FixtureCompiler.parseSql( @@ -361,9 +374,10 @@ class SelectQueryTypeTest { | |select_news_list: |SELECT * FROM socialFeedItem WHERE message IS NOT NULL AND userId = ? ORDER BY datetime(creation_time) DESC; - |""".trimMargin(), + | + """.trimMargin(), tempFolder, - treatNullAsUnknownForEquality = true + treatNullAsUnknownForEquality = true, ) val treatNullAsUnknownQuery = treatNullAsUnknownFile.namedQueries.first() @@ -389,7 +403,8 @@ class SelectQueryTypeTest { | | public override fun toString(): kotlin.String = "Test.sq:select_news_list" |} - |""".trimMargin() + | + """.trimMargin(), ) } @@ -406,8 +421,9 @@ class SelectQueryTypeTest { |SELECT _id, username |FROM Friend |WHERE userId=? OR username=? LIMIT 2; - |""".trimMargin(), - tempFolder + | + """.trimMargin(), + tempFolder, ) val query = file.namedQueries.first() @@ -440,7 +456,8 @@ class SelectQueryTypeTest { | | public override fun toString(): kotlin.String = "Test.sq:selectData" |} - |""".trimMargin() + | + """.trimMargin(), ) val nullAsUnknownFile = FixtureCompiler.parseSql( @@ -455,9 +472,10 @@ class SelectQueryTypeTest { |SELECT _id, username |FROM Friend |WHERE userId=? OR username=? LIMIT 2; - |""".trimMargin(), + | + """.trimMargin(), tempFolder, - treatNullAsUnknownForEquality = true + treatNullAsUnknownForEquality = true, ) val nullAsUnknownQuery = nullAsUnknownFile.namedQueries.first() @@ -489,7 +507,8 @@ class SelectQueryTypeTest { | | public override fun toString(): kotlin.String = "Test.sq:selectData" |} - |""".trimMargin() + | + """.trimMargin(), ) } @@ -510,8 +529,9 @@ class SelectQueryTypeTest { |AND val != ? |AND val IS ? |AND val IS NOT ?; - |""".trimMargin(), - tempFolder + | + """.trimMargin(), + tempFolder, ) val query = file.namedQueries.first() @@ -556,7 +576,8 @@ class SelectQueryTypeTest { | | public override fun toString(): kotlin.String = "Test.sq:selectForId" |} - |""".trimMargin() + | + """.trimMargin(), ) val nullAsUnknownFile = FixtureCompiler.parseSql( @@ -575,9 +596,10 @@ class SelectQueryTypeTest { |AND val != ? |AND val IS ? |AND val IS NOT ?; - |""".trimMargin(), + | + """.trimMargin(), tempFolder, - treatNullAsUnknownForEquality = true + treatNullAsUnknownForEquality = true, ) val nullAsUnknownQuery = nullAsUnknownFile.namedQueries.first() @@ -622,7 +644,8 @@ class SelectQueryTypeTest { | | public override fun toString(): kotlin.String = "Test.sq:selectForId" |} - |""".trimMargin() + | + """.trimMargin(), ) } @@ -637,8 +660,9 @@ class SelectQueryTypeTest { |SELECT * |FROM data |WHERE data MATCH ? AND rowid = ?; - |""".trimMargin(), - tempFolder + | + """.trimMargin(), + tempFolder, ) val query = file.namedQueries.first() @@ -670,7 +694,8 @@ class SelectQueryTypeTest { | | public override fun toString(): kotlin.String = "Test.sq:selectMatching" |} - |""".trimMargin() + | + """.trimMargin(), ) } @@ -687,8 +712,9 @@ class SelectQueryTypeTest { |SELECT * |FROM data |WHERE data MATCH '"one ' || ? || '" * '; - |""".trimMargin(), - tempFolder + | + """.trimMargin(), + tempFolder, ) val query = file.namedQueries.first() @@ -718,7 +744,8 @@ class SelectQueryTypeTest { | | public override fun toString(): kotlin.String = "Test.sq:selectMatching" |} - |""".trimMargin() + | + """.trimMargin(), ) } @@ -738,8 +765,9 @@ class SelectQueryTypeTest { | AND id IN ? | AND (token != :token OR (name = :name OR :name = 'foo')) | AND token IN ?; - |""".trimMargin(), - tempFolder + | + """.trimMargin(), + tempFolder, ) val generator = SelectQueryGenerator(file.namedQueries.first()) @@ -787,7 +815,8 @@ class SelectQueryTypeTest { | | public override fun toString(): kotlin.String = "Test.sq:selectForId" |} - |""".trimMargin() + | + """.trimMargin(), ) } @@ -805,8 +834,9 @@ class SelectQueryTypeTest { |WHERE id = ?1 OR id IN child_ids |LIMIT :limit |OFFSET :offset; - |""".trimMargin(), - tempFolder + | + """.trimMargin(), + tempFolder, ) val query = file.namedQueries.first() @@ -844,7 +874,8 @@ class SelectQueryTypeTest { | | public override fun toString(): kotlin.String = "Test.sq:selectForId" |} - |""".trimMargin() + | + """.trimMargin(), ) val nullAsUnknownFile = FixtureCompiler.parseSql( @@ -860,9 +891,10 @@ class SelectQueryTypeTest { |WHERE id = ?1 OR id IN child_ids |LIMIT :limit |OFFSET :offset; - |""".trimMargin(), + | + """.trimMargin(), tempFolder, - treatNullAsUnknownForEquality = true + treatNullAsUnknownForEquality = true, ) val nullAsUnknownQuery = nullAsUnknownFile.namedQueries.first() @@ -900,7 +932,8 @@ class SelectQueryTypeTest { | | public override fun toString(): kotlin.String = "Test.sq:selectForId" |} - |""".trimMargin() + | + """.trimMargin(), ) } @@ -917,8 +950,9 @@ class SelectQueryTypeTest { |SELECT * |FROM data |WHERE id IN ?; - |""".trimMargin(), - tempFolder + | + """.trimMargin(), + tempFolder, ) val generator = SelectQueryGenerator(file.namedQueries.first()) @@ -952,7 +986,8 @@ class SelectQueryTypeTest { | | public override fun toString(): kotlin.String = "Test.sq:selectForIds" |} - |""".trimMargin() + | + """.trimMargin(), ) } @@ -968,8 +1003,10 @@ class SelectQueryTypeTest { |SELECT * |FROM data |WHERE token = :token OR :token IS NULL; - |""".trimMargin(), - tempFolder, dialect = dialect.dialect + | + """.trimMargin(), + tempFolder, + dialect = dialect.dialect, ) val query = file.namedQueries.first() @@ -1013,7 +1050,8 @@ class SelectQueryTypeTest { | | public override fun toString(): kotlin.String = "Test.sq:selectByTokenOrAll" |} - |""".trimMargin() + | + """.trimMargin(), ) val nullAsUnknownFile = FixtureCompiler.parseSql( @@ -1026,9 +1064,11 @@ class SelectQueryTypeTest { |SELECT * |FROM data |WHERE token = :token OR :token IS NULL; - |""".trimMargin(), - tempFolder, dialect = dialect.dialect, - treatNullAsUnknownForEquality = true + | + """.trimMargin(), + tempFolder, + dialect = dialect.dialect, + treatNullAsUnknownForEquality = true, ) val nullAsUnknownQuery = nullAsUnknownFile.namedQueries.first() @@ -1059,7 +1099,8 @@ class SelectQueryTypeTest { | | public override fun toString(): kotlin.String = "Test.sq:selectByTokenOrAll" |} - |""".trimMargin() + | + """.trimMargin(), ) } @@ -1076,8 +1117,10 @@ class SelectQueryTypeTest { |selectGreatest: |SELECT greatest(token, value) |FROM data; - |""".trimMargin(), - tempFolder, dialect = dialect.dialect + | + """.trimMargin(), + tempFolder, + dialect = dialect.dialect, ) val query = file.namedQueries.first() @@ -1092,7 +1135,8 @@ class SelectQueryTypeTest { | check(cursor is ${dialect.dialect.runtimeTypes.cursorType}) | cursor.getString(0)!! |} - |""".trimMargin() + | + """.trimMargin(), ) } @@ -1109,8 +1153,10 @@ class SelectQueryTypeTest { |selectFullNames: |SELECT CONCAT(first_name, last_name) |FROM people; - |""".trimMargin(), - tempFolder, dialect = dialect.dialect + | + """.trimMargin(), + tempFolder, + dialect = dialect.dialect, ) val query = file.namedQueries.first() @@ -1125,7 +1171,8 @@ class SelectQueryTypeTest { | check(cursor is ${dialect.dialect.runtimeTypes.cursorType}) | cursor.getString(0)!! |} - |""".trimMargin() + | + """.trimMargin(), ) } @@ -1157,8 +1204,10 @@ class SelectQueryTypeTest { |UNION |SELECT birthday, age |FROM adults; - |""".trimMargin(), - tempFolder, dialect = dialect.dialect + | + """.trimMargin(), + tempFolder, + dialect = dialect.dialect, ) val query = file.namedQueries.first() @@ -1184,7 +1233,8 @@ class SelectQueryTypeTest { | ) | } |} - |""".trimMargin() + | + """.trimMargin(), ) } @@ -1216,9 +1266,10 @@ class SelectQueryTypeTest { |UNION |SELECT birthday, age |FROM adults; - |""".trimMargin(), + | + """.trimMargin(), tempFolder, - overrideDialect = dialect.dialect + overrideDialect = dialect.dialect, ) val requiredAdapters = file.compiledFile.requiredAdapters.joinToString { it.type.toString() } @@ -1237,8 +1288,10 @@ class SelectQueryTypeTest { |selectBirthMonthAndYear: |SELECT MONTH(born_at) AS birthMonth, YEAR(born_at) AS birthYear |FROM people; - |""".trimMargin(), - tempFolder, dialect = dialect.dialect + | + """.trimMargin(), + tempFolder, + dialect = dialect.dialect, ) val query = file.namedQueries.first() @@ -1256,7 +1309,8 @@ class SelectQueryTypeTest { | cursor.getLong(1)!! | ) |} - |""".trimMargin() + | + """.trimMargin(), ) } @@ -1272,8 +1326,10 @@ class SelectQueryTypeTest { |selectSomeTrigValues: |SELECT SIN(angle) AS sin, COS(angle) AS cos, TAN(angle) AS tan |FROM math; - |""".trimMargin(), - tempFolder, dialect = dialect.dialect + | + """.trimMargin(), + tempFolder, + dialect = dialect.dialect, ) val query = file.namedQueries.first() @@ -1296,7 +1352,8 @@ class SelectQueryTypeTest { | cursor.getDouble(2)!! | ) |} - |""".trimMargin() + | + """.trimMargin(), ) } @@ -1317,8 +1374,9 @@ class SelectQueryTypeTest { | VALUES (:value) | ; |} - |""".trimMargin(), - tempFolder + | + """.trimMargin(), + tempFolder, ) val query = file.namedExecutes.first() @@ -1345,7 +1403,8 @@ class SelectQueryTypeTest { | emit("data") | } |} - |""".trimMargin() + | + """.trimMargin(), ) } @@ -1366,8 +1425,9 @@ class SelectQueryTypeTest { | VALUES (?) | ; |} - |""".trimMargin(), - tempFolder + | + """.trimMargin(), + tempFolder, ) val query = file.namedExecutes.first() @@ -1394,7 +1454,8 @@ class SelectQueryTypeTest { | emit("data") | } |} - |""".trimMargin() + | + """.trimMargin(), ) } @@ -1415,8 +1476,9 @@ class SelectQueryTypeTest { | VALUES (?1) | ; |} - |""".trimMargin(), - tempFolder + | + """.trimMargin(), + tempFolder, ) val query = file.namedExecutes.first() @@ -1443,7 +1505,8 @@ class SelectQueryTypeTest { | emit("data") | } |} - |""".trimMargin() + | + """.trimMargin(), ) } @@ -1464,8 +1527,9 @@ class SelectQueryTypeTest { | VALUES (?2) | ; |} - |""".trimMargin(), - tempFolder + | + """.trimMargin(), + tempFolder, ) val query = file.namedExecutes.first() @@ -1492,7 +1556,8 @@ class SelectQueryTypeTest { | emit("data") | } |} - |""".trimMargin() + | + """.trimMargin(), ) } @@ -1517,8 +1582,9 @@ class SelectQueryTypeTest { | VALUES (?2) | ; |} - |""".trimMargin(), - tempFolder + | + """.trimMargin(), + tempFolder, ) val query = file.namedExecutes.first() @@ -1545,7 +1611,8 @@ class SelectQueryTypeTest { | emit("data") | } |} - |""".trimMargin() + | + """.trimMargin(), ) } @@ -1563,8 +1630,9 @@ class SelectQueryTypeTest { |SELECT CASE :param1 WHEN 'test' THEN r1 WHEN 'test1' THEN r2 ELSE r3 END, | CASE WHEN :param2='test' THEN r1 WHEN :param2='test1' THEN r2 ELSE r3 END |FROM data; - |""".trimMargin(), - tempFolder + | + """.trimMargin(), + tempFolder, ) val query = file.namedQueries.first() @@ -1582,7 +1650,8 @@ class SelectQueryTypeTest { | cursor.getString(1) | ) |} - |""".trimMargin() + | + """.trimMargin(), ) } @@ -1600,8 +1669,10 @@ class SelectQueryTypeTest { |countRecords: |SELECT (SELECT count(*) FROM ComboData WHERE value IN :values) + |(SELECT count(*) FROM ComboData2 WHERE value IN :values); - |""".trimMargin(), - tempFolder, fileName = "Data.sq" + | + """.trimMargin(), + tempFolder, + fileName = "Data.sq", ) val query = file.namedQueries.first() @@ -1638,7 +1709,8 @@ class SelectQueryTypeTest { | | public override fun toString(): kotlin.String = "Data.sq:countRecords" |} - |""".trimMargin() + | + """.trimMargin(), ) } @@ -1659,8 +1731,9 @@ class SelectQueryTypeTest { | FROM data | WHERE id = last_insert_rowid(); |} - |""".trimMargin(), - tempFolder + | + """.trimMargin(), + tempFolder, ) val query = file.namedQueries.first() @@ -1688,7 +1761,8 @@ class SelectQueryTypeTest { | | public override fun toString(): kotlin.String = "Test.sq:insertAndReturn" |} - |""".trimMargin() + | + """.trimMargin(), ) } @@ -1698,8 +1772,9 @@ class SelectQueryTypeTest { """ |getVersion: |PRAGMA user_version; - |""".trimMargin(), - tempFolder + | + """.trimMargin(), + tempFolder, ) val query = file.namedQueries.first() @@ -1710,7 +1785,8 @@ class SelectQueryTypeTest { |public fun getVersion(): app.cash.sqldelight.ExecutableQuery = app.cash.sqldelight.Query(${query.id}, driver, "Test.sq", "getVersion", "PRAGMA user_version") { cursor -> | cursor.getString(0)!! |} - |""".trimMargin() + | + """.trimMargin(), ) } @@ -1744,8 +1820,9 @@ class SelectQueryTypeTest { | ON tag.id = placeTag.tag | WHERE place.id = ? |; - |""".trimMargin(), - tempFolder + | + """.trimMargin(), + tempFolder, ) val query = file.namedQueries.first() @@ -1759,7 +1836,8 @@ class SelectQueryTypeTest { | cursor.getString(1) | ) |} - |""".trimMargin() + | + """.trimMargin(), ) } } diff --git a/sqldelight-compiler/src/test/kotlin/app/cash/sqldelight/core/queries/async/AsyncMutatorQueryTypeTest.kt b/sqldelight-compiler/src/test/kotlin/app/cash/sqldelight/core/queries/async/AsyncMutatorQueryTypeTest.kt index de9476b208a..293f26dc6ca 100644 --- a/sqldelight-compiler/src/test/kotlin/app/cash/sqldelight/core/queries/async/AsyncMutatorQueryTypeTest.kt +++ b/sqldelight-compiler/src/test/kotlin/app/cash/sqldelight/core/queries/async/AsyncMutatorQueryTypeTest.kt @@ -23,7 +23,7 @@ class AsyncMutatorQueryTypeTest { |VALUES (?, ?); """.trimMargin(), tempFolder, - generateAsync = true + generateAsync = true, ) val mutator = file.namedMutators.first() @@ -43,7 +43,8 @@ class AsyncMutatorQueryTypeTest { | emit("data") | } |} - |""".trimMargin() + | + """.trimMargin(), ) } @@ -64,8 +65,9 @@ class AsyncMutatorQueryTypeTest { |INSERT INTO data |VALUES (?, ?); """.trimMargin(), - tempFolder, fileName = "Data.sq", - generateAsync = true + tempFolder, + fileName = "Data.sq", + generateAsync = true, ) val mutator = file.namedMutators.first() @@ -85,7 +87,8 @@ class AsyncMutatorQueryTypeTest { | emit("data") | } |} - |""".trimMargin() + | + """.trimMargin(), ) } @@ -97,7 +100,8 @@ class AsyncMutatorQueryTypeTest { |FROM data |WHERE id = ?; """.trimMargin(), - tempFolder, fileName = "OtherData.sq", + tempFolder, + fileName = "OtherData.sq", ) val file = FixtureCompiler.parseSql( @@ -111,8 +115,9 @@ class AsyncMutatorQueryTypeTest { |INSERT INTO data |VALUES (?, ?); """.trimMargin(), - tempFolder, fileName = "Data.sq", - generateAsync = true + tempFolder, + fileName = "Data.sq", + generateAsync = true, ) val mutator = file.namedMutators.first() @@ -132,7 +137,8 @@ class AsyncMutatorQueryTypeTest { | emit("data") | } |} - |""".trimMargin() + | + """.trimMargin(), ) } } diff --git a/sqldelight-compiler/src/test/kotlin/app/cash/sqldelight/core/queries/async/AsyncQueryFunctionTest.kt b/sqldelight-compiler/src/test/kotlin/app/cash/sqldelight/core/queries/async/AsyncQueryFunctionTest.kt index 3627c89028f..a3a58a39c0a 100644 --- a/sqldelight-compiler/src/test/kotlin/app/cash/sqldelight/core/queries/async/AsyncQueryFunctionTest.kt +++ b/sqldelight-compiler/src/test/kotlin/app/cash/sqldelight/core/queries/async/AsyncQueryFunctionTest.kt @@ -29,7 +29,7 @@ class AsyncQueryFunctionTest { |WHERE id = ?; """.trimMargin(), tempFolder, - generateAsync = true + generateAsync = true, ) val generator = SelectQueryGenerator(file.namedQueries.first()) @@ -41,7 +41,8 @@ class AsyncQueryFunctionTest { | value_ | ) |} - |""".trimMargin() + | + """.trimMargin(), ) } } diff --git a/sqldelight-compiler/src/test/kotlin/app/cash/sqldelight/core/queries/async/AsyncSelectQueryTypeTest.kt b/sqldelight-compiler/src/test/kotlin/app/cash/sqldelight/core/queries/async/AsyncSelectQueryTypeTest.kt index f017caaf8a6..72a77aa6321 100644 --- a/sqldelight-compiler/src/test/kotlin/app/cash/sqldelight/core/queries/async/AsyncSelectQueryTypeTest.kt +++ b/sqldelight-compiler/src/test/kotlin/app/cash/sqldelight/core/queries/async/AsyncSelectQueryTypeTest.kt @@ -27,10 +27,11 @@ class AsyncSelectQueryTypeTest { |INSERT INTO data |VALUES ('sup', 'dude') |RETURNING *; - |""".trimMargin(), + | + """.trimMargin(), tempFolder, dialect = PostgreSqlDialect(), - generateAsync = true + generateAsync = true, ) val query = file.namedQueries.first() @@ -49,7 +50,8 @@ class AsyncSelectQueryTypeTest { | cursor.getString(1) | ) |} - |""".trimMargin() + | + """.trimMargin(), ) } @@ -69,10 +71,11 @@ class AsyncSelectQueryTypeTest { | lastname = :lastname |WHERE id = :id |RETURNING id, firstname, lastname; - |""".trimMargin(), + | + """.trimMargin(), tempFolder, dialect = PostgreSqlDialect(), - generateAsync = true + generateAsync = true, ) val query = file.namedQueries.first() @@ -97,7 +100,8 @@ class AsyncSelectQueryTypeTest { | cursor.getString(2)!! | ) |} - |""".trimMargin() + | + """.trimMargin(), ) } @@ -112,9 +116,10 @@ class AsyncSelectQueryTypeTest { |SELECT * |FROM data |WHERE id = ?; - |""".trimMargin(), + | + """.trimMargin(), tempFolder, - generateAsync = true + generateAsync = true, ) val query = file.namedQueries.first() @@ -144,7 +149,8 @@ class AsyncSelectQueryTypeTest { | | public override fun toString(): kotlin.String = "Test.sq:selectForId" |} - |""".trimMargin() + | + """.trimMargin(), ) } @@ -165,9 +171,10 @@ class AsyncSelectQueryTypeTest { | VALUES (:value) | ; |} - |""".trimMargin(), + | + """.trimMargin(), tempFolder, - generateAsync = true + generateAsync = true, ) val query = file.namedExecutes.first() @@ -194,7 +201,8 @@ class AsyncSelectQueryTypeTest { | emit("data") | } |} - |""".trimMargin() + | + """.trimMargin(), ) } @@ -215,9 +223,10 @@ class AsyncSelectQueryTypeTest { | FROM data | WHERE id = last_insert_rowid(); |} - |""".trimMargin(), + | + """.trimMargin(), tempFolder, - generateAsync = true + generateAsync = true, ) val query = file.namedQueries.first() @@ -245,7 +254,8 @@ class AsyncSelectQueryTypeTest { | | public override fun toString(): kotlin.String = "Test.sq:insertAndReturn" |} - |""".trimMargin() + | + """.trimMargin(), ) } } diff --git a/sqldelight-compiler/src/test/kotlin/app/cash/sqldelight/core/tables/InterfaceGeneration.kt b/sqldelight-compiler/src/test/kotlin/app/cash/sqldelight/core/tables/InterfaceGeneration.kt index 6d931a0ba91..7fd695f5eb4 100644 --- a/sqldelight-compiler/src/test/kotlin/app/cash/sqldelight/core/tables/InterfaceGeneration.kt +++ b/sqldelight-compiler/src/test/kotlin/app/cash/sqldelight/core/tables/InterfaceGeneration.kt @@ -37,8 +37,9 @@ class InterfaceGeneration { | otherAnnotation = SomeOtherAnnotation("value") | ) Int |); - |""".trimMargin(), - tempFolder + | + """.trimMargin(), + tempFolder, ) assertThat(result.errors).isEmpty() @@ -68,7 +69,8 @@ class InterfaceGeneration { | public val annotatedAdapter: ColumnAdapter, | ) |} - |""".trimMargin() + | + """.trimMargin(), ) } @@ -81,8 +83,9 @@ class InterfaceGeneration { | isle TEXT, | stuff TEXT |); - |""".trimMargin(), - tempFolder + | + """.trimMargin(), + tempFolder, ) assertThat(result.errors).isEmpty() @@ -100,7 +103,8 @@ class InterfaceGeneration { | public val isle: String?, | public val stuff: String?, |) - |""".trimMargin() + | + """.trimMargin(), ) } @@ -110,8 +114,9 @@ class InterfaceGeneration { |CREATE TABLE test ( | mapValue INTEGER AS kotlin.collections.Map>, kotlin.collections.List>> |); - |""".trimMargin(), - tempFolder + | + """.trimMargin(), + tempFolder, ) val generator = TableInterfaceGenerator(result.sqlStatements().first().statement.createTableStmt!!.tableExposed()) @@ -124,7 +129,8 @@ class InterfaceGeneration { | public val mapValueAdapter: app.cash.sqldelight.ColumnAdapter>, kotlin.collections.List>>, kotlin.Long>, | ) |} - |""".trimMargin() + | + """.trimMargin(), ) } @@ -140,8 +146,9 @@ class InterfaceGeneration { | enabledDays TEXT AS Set, | enabledWeeks TEXT AS Set |); - |""".trimMargin(), - tempFolder + | + """.trimMargin(), + tempFolder, ) val generator = TableInterfaceGenerator(result.sqlStatements().first().statement.createTableStmt!!.tableExposed()) @@ -157,7 +164,8 @@ class InterfaceGeneration { | public val enabledWeeksAdapter: app.cash.sqldelight.ColumnAdapter, kotlin.String>, | ) |} - |""".trimMargin() + | + """.trimMargin(), ) } @@ -170,8 +178,9 @@ class InterfaceGeneration { | "index3" TEXT, | [index4] TEXT |); - |""".trimMargin(), - tempFolder + | + """.trimMargin(), + tempFolder, ) val generator = TableInterfaceGenerator(result.sqlStatements().first().statement.createTableStmt!!.tableExposed()) @@ -183,7 +192,8 @@ class InterfaceGeneration { | public val index3: kotlin.String?, | public val index4: kotlin.String?, |) - |""".trimMargin() + | + """.trimMargin(), ) } @@ -199,8 +209,10 @@ class InterfaceGeneration { | bigIntValue BIGINT AS kotlin.Any NOT NULL, | bitValue BIT AS kotlin.Any NOT NULL |); - |""".trimMargin(), - tempFolder, dialect = MySqlDialect() + | + """.trimMargin(), + tempFolder, + dialect = MySqlDialect(), ) val generator = TableInterfaceGenerator(result.sqlStatements().first().statement.createTableStmt!!.tableExposed()) @@ -225,7 +237,8 @@ class InterfaceGeneration { | public val bitValueAdapter: app.cash.sqldelight.ColumnAdapter, | ) |} - |""".trimMargin() + | + """.trimMargin(), ) } @@ -240,8 +253,10 @@ class InterfaceGeneration { | serialValue SERIAL AS kotlin.Any NOT NULL, | bigSerialValue BIGSERIAL AS kotlin.Any NOT NULL |); - |""".trimMargin(), - tempFolder, dialect = PostgreSqlDialect() + | + """.trimMargin(), + tempFolder, + dialect = PostgreSqlDialect(), ) val generator = TableInterfaceGenerator(result.sqlStatements().first().statement.createTableStmt!!.tableExposed()) @@ -264,7 +279,8 @@ class InterfaceGeneration { | public val bigSerialValueAdapter: app.cash.sqldelight.ColumnAdapter, | ) |} - |""".trimMargin() + | + """.trimMargin(), ) } @@ -278,8 +294,10 @@ class InterfaceGeneration { | bigIntValue BIGINT AS kotlin.Any NOT NULL, | booleanValue BOOLEAN AS kotlin.Any NOT NULL |); - |""".trimMargin(), - tempFolder, dialect = HsqlDialect() + | + """.trimMargin(), + tempFolder, + dialect = HsqlDialect(), ) val generator = TableInterfaceGenerator(result.sqlStatements().first().statement.createTableStmt!!.tableExposed()) @@ -300,7 +318,8 @@ class InterfaceGeneration { | public val booleanValueAdapter: app.cash.sqldelight.ColumnAdapter, | ) |} - |""".trimMargin() + | + """.trimMargin(), ) } @@ -315,7 +334,7 @@ class InterfaceGeneration { | endDate INTEGER AS @Deprecated Date NOT NULL |); """.trimMargin(), - tempFolder + tempFolder, ) val generator = TableInterfaceGenerator(result.sqlStatements().first().statement.createTableStmt!!.tableExposed()) @@ -332,7 +351,8 @@ class InterfaceGeneration { | public val endDateAdapter: app.cash.sqldelight.ColumnAdapter, | ) |} - |""".trimMargin() + | + """.trimMargin(), ) } @@ -342,8 +362,9 @@ class InterfaceGeneration { |CREATE TABLE test ( | id INTEGER AS VALUE NOT NULL |); - |""".trimMargin(), - tempFolder + | + """.trimMargin(), + tempFolder, ) assertThat(result.errors).isEmpty() @@ -364,7 +385,8 @@ class InterfaceGeneration { | public val id: Long, | ) |} - |""".trimMargin() + | + """.trimMargin(), ) } @@ -377,8 +399,10 @@ class InterfaceGeneration { | score INTEGER NOT NULL, | PRIMARY KEY(bioguide_id, score_year) |); - |""".trimMargin(), - tempFolder, overrideDialect = PostgreSqlDialect() + | + """.trimMargin(), + tempFolder, + overrideDialect = PostgreSqlDialect(), ) assertThat(result.errors).isEmpty() @@ -396,7 +420,8 @@ class InterfaceGeneration { | public val score_year: Int, | public val score: Int, |) - |""".trimMargin() + | + """.trimMargin(), ) } @@ -406,7 +431,7 @@ class InterfaceGeneration { compilationMethod = { _, _, sqlDelightQueriesFile, writer -> SqlDelightCompiler.writeTableInterfaces(sqlDelightQueriesFile, writer) }, - generateDb = false + generateDb = false, ) for ((expectedFile, actualOutput) in result.compilerOutput) { assertWithMessage("No file with name $expectedFile").that(expectedFile.exists()).isTrue() diff --git a/sqldelight-compiler/src/test/kotlin/app/cash/sqldelight/core/tables/OptimisticLockTest.kt b/sqldelight-compiler/src/test/kotlin/app/cash/sqldelight/core/tables/OptimisticLockTest.kt index 12b9ec27a10..cbff4c8ea52 100644 --- a/sqldelight-compiler/src/test/kotlin/app/cash/sqldelight/core/tables/OptimisticLockTest.kt +++ b/sqldelight-compiler/src/test/kotlin/app/cash/sqldelight/core/tables/OptimisticLockTest.kt @@ -25,12 +25,13 @@ class OptimisticLockTest { |UPDATE test |SET text = :text |WHERE id = :id; - |""".trimMargin(), - tempFolder + | + """.trimMargin(), + tempFolder, ) assertThat(result.errors).containsExactly( - "Test.sq: (8, 0): This statement is missing the optimistic lock in its SET clause." + "Test.sq: (8, 0): This statement is missing the optimistic lock in its SET clause.", ) } @@ -40,8 +41,9 @@ class OptimisticLockTest { |CREATE TABLE test ( | id INTEGER AS LOCK NOT NULL |); - |""".trimMargin(), - tempFolder + | + """.trimMargin(), + tempFolder, ) assertThat(result.errors).isEmpty() @@ -62,7 +64,8 @@ class OptimisticLockTest { | public val id: Long, | ) |} - |""".trimMargin() + | + """.trimMargin(), ) } @@ -84,8 +87,10 @@ class OptimisticLockTest { | id = :id AND | version = :version |; - |""".trimMargin(), - tempFolder, dialect = PostgreSqlDialect() + | + """.trimMargin(), + tempFolder, + dialect = PostgreSqlDialect(), ) val mutator = file.namedMutators.first() @@ -117,7 +122,8 @@ class OptimisticLockTest { | emit("test") | } |} - |""".trimMargin() + | + """.trimMargin(), ) } } diff --git a/sqldelight-compiler/src/test/kotlin/app/cash/sqldelight/core/triggers/TriggerNotificationTest.kt b/sqldelight-compiler/src/test/kotlin/app/cash/sqldelight/core/triggers/TriggerNotificationTest.kt index 5ee14eabac8..1af10dda4ea 100644 --- a/sqldelight-compiler/src/test/kotlin/app/cash/sqldelight/core/triggers/TriggerNotificationTest.kt +++ b/sqldelight-compiler/src/test/kotlin/app/cash/sqldelight/core/triggers/TriggerNotificationTest.kt @@ -38,7 +38,7 @@ class TriggerNotificationTest { |INSERT INTO data |VALUES (?, ?); """.trimMargin(), - tempFolder + tempFolder, ) val mutator = file.namedMutators.first() @@ -59,7 +59,8 @@ class TriggerNotificationTest { | emit("data2") | } |} - |""".trimMargin() + | + """.trimMargin(), ) } @@ -90,7 +91,7 @@ class TriggerNotificationTest { |DELETE FROM data |WHERE id = ?; """.trimMargin(), - tempFolder + tempFolder, ) val mutator = file.namedMutators.first() @@ -109,7 +110,8 @@ class TriggerNotificationTest { | emit("data") | } |} - |""".trimMargin() + | + """.trimMargin(), ) } @@ -141,7 +143,7 @@ class TriggerNotificationTest { |SET value = ? |WHERE id = ?; """.trimMargin(), - tempFolder + tempFolder, ) val mutator = file.namedMutators.first() @@ -162,7 +164,8 @@ class TriggerNotificationTest { | emit("data") | } |} - |""".trimMargin() + | + """.trimMargin(), ) } @@ -194,7 +197,7 @@ class TriggerNotificationTest { |SET value = ? |WHERE id = ?; """.trimMargin(), - tempFolder + tempFolder, ) val mutator = file.namedMutators.first() @@ -216,7 +219,8 @@ class TriggerNotificationTest { | emit("data2") | } |} - |""".trimMargin() + | + """.trimMargin(), ) } @@ -248,7 +252,7 @@ class TriggerNotificationTest { |SET value = ? |WHERE id = ?; """.trimMargin(), - tempFolder + tempFolder, ) val mutator = file.namedMutators.first() @@ -270,7 +274,8 @@ class TriggerNotificationTest { | emit("data2") | } |} - |""".trimMargin() + | + """.trimMargin(), ) } @@ -302,7 +307,7 @@ class TriggerNotificationTest { |SET value = ? |WHERE id = ?; """.trimMargin(), - tempFolder + tempFolder, ) val mutator = file.namedMutators.first() @@ -323,7 +328,8 @@ class TriggerNotificationTest { | emit("data") | } |} - |""".trimMargin() + | + """.trimMargin(), ) } @@ -355,7 +361,7 @@ class TriggerNotificationTest { |ON CONFLICT (id) DO UPDATE SET value = excluded.value; """.trimMargin(), tempFolder, - dialect = TestDialect.SQLITE_3_24.dialect + dialect = TestDialect.SQLITE_3_24.dialect, ) val mutator = file.namedMutators.first() @@ -376,7 +382,8 @@ class TriggerNotificationTest { | emit("data2") | } |} - |""".trimMargin() + | + """.trimMargin(), ) } @@ -408,7 +415,7 @@ class TriggerNotificationTest { |ON CONFLICT (id) DO UPDATE SET value = excluded.value; """.trimMargin(), tempFolder, - dialect = TestDialect.SQLITE_3_24.dialect + dialect = TestDialect.SQLITE_3_24.dialect, ) val mutator = file.namedMutators.first() @@ -429,7 +436,8 @@ class TriggerNotificationTest { | emit("data2") | } |} - |""".trimMargin() + | + """.trimMargin(), ) } @@ -465,7 +473,7 @@ class TriggerNotificationTest { |DELETE FROM foo; """.trimMargin(), tempFolder, - dialect = TestDialect.SQLITE_3_24.dialect + dialect = TestDialect.SQLITE_3_24.dialect, ) val mutator = file.namedMutators.first() @@ -480,7 +488,8 @@ class TriggerNotificationTest { | emit("foo") | } |} - |""".trimMargin() + | + """.trimMargin(), ) } } diff --git a/sqldelight-compiler/src/test/kotlin/app/cash/sqldelight/core/util/TreeUtilTest.kt b/sqldelight-compiler/src/test/kotlin/app/cash/sqldelight/core/util/TreeUtilTest.kt index ce933d47bb4..bb04a137e81 100644 --- a/sqldelight-compiler/src/test/kotlin/app/cash/sqldelight/core/util/TreeUtilTest.kt +++ b/sqldelight-compiler/src/test/kotlin/app/cash/sqldelight/core/util/TreeUtilTest.kt @@ -18,8 +18,8 @@ class TreeUtilTest { | other_value TEXT AS Int, | a_third_value INTEGER AS Boolean DEFAULT 0 |); - """.trimMargin(), - temporaryFolder + """.trimMargin(), + temporaryFolder, ) val createTable = file.sqlStatements().first().statement.createTableStmt!! @@ -31,7 +31,7 @@ class TreeUtilTest { | other_value TEXT, | a_third_value INTEGER DEFAULT 0 |) - """.trimMargin() + """.trimMargin(), ) } @@ -49,8 +49,8 @@ class TreeUtilTest { | |INSERT INTO test |VALUES ?; - """.trimMargin(), - temporaryFolder + """.trimMargin(), + temporaryFolder, ) val insert1 = file.sqlStatements().elementAt(1).statement.insertStmt!! @@ -59,7 +59,7 @@ class TreeUtilTest { """ |INSERT INTO test (value, other_value) |VALUES (?, ?) - """.trimMargin() + """.trimMargin(), ) val insert2 = file.sqlStatements().elementAt(2).statement.insertStmt!! @@ -68,7 +68,7 @@ class TreeUtilTest { """ |INSERT INTO test |VALUES (?, ?, ?) - """.trimMargin() + """.trimMargin(), ) } @@ -79,8 +79,8 @@ class TreeUtilTest { | value TEXT, | prefix='2 3 4 5 6' |); - """.trimMargin(), - temporaryFolder + """.trimMargin(), + temporaryFolder, ) val createTable = file.sqlStatements().first().statement.createVirtualTableStmt!! @@ -91,7 +91,7 @@ class TreeUtilTest { | value, | prefix='2 3 4 5 6' |) - """.trimMargin() + """.trimMargin(), ) } @@ -102,8 +102,8 @@ class TreeUtilTest { | value TEXT NOT NULL, | prefix='2 3 4 5 6' |); - """.trimMargin(), - temporaryFolder + """.trimMargin(), + temporaryFolder, ) val createTable = file.sqlStatements().first().statement.createVirtualTableStmt!! @@ -114,7 +114,7 @@ class TreeUtilTest { | value, | prefix='2 3 4 5 6' |) - """.trimMargin() + """.trimMargin(), ) } @@ -125,8 +125,8 @@ class TreeUtilTest { | value TEXT NOT NULL UNINDEXED, | prefix='2 3 4 5 6' |); - """.trimMargin(), - temporaryFolder + """.trimMargin(), + temporaryFolder, ) val createTable = file.sqlStatements().first().statement.createVirtualTableStmt!! @@ -137,7 +137,7 @@ class TreeUtilTest { | value UNINDEXED, | prefix='2 3 4 5 6' |) - """.trimMargin() + """.trimMargin(), ) } @@ -148,8 +148,8 @@ class TreeUtilTest { | value TEXT NOT NULL, | prefix='2 3 4 5 6' |); - """.trimMargin(), - temporaryFolder + """.trimMargin(), + temporaryFolder, ) val createTable = file.sqlStatements().first().statement.createVirtualTableStmt!! @@ -160,7 +160,7 @@ class TreeUtilTest { | value, | prefix='2 3 4 5 6' |) - """.trimMargin() + """.trimMargin(), ) } } diff --git a/sqldelight-compiler/src/test/kotlin/app/cash/sqldelight/core/views/InterfaceGeneration.kt b/sqldelight-compiler/src/test/kotlin/app/cash/sqldelight/core/views/InterfaceGeneration.kt index 57a2945f8de..30f70fa6a62 100644 --- a/sqldelight-compiler/src/test/kotlin/app/cash/sqldelight/core/views/InterfaceGeneration.kt +++ b/sqldelight-compiler/src/test/kotlin/app/cash/sqldelight/core/views/InterfaceGeneration.kt @@ -34,13 +34,14 @@ class InterfaceGeneration { |UNION |SELECT 0, 0 |FROM test; - |""".trimMargin(), - temporaryFolder + | + """.trimMargin(), + temporaryFolder, ) assertThat(result.errors).isEmpty() val generatedInterface = result.compilerOutput.get( - File(result.outputDirectory, "com/example/SomeView.kt") + File(result.outputDirectory, "com/example/SomeView.kt"), ) assertThat(generatedInterface).isNotNull() assertThat(generatedInterface.toString()).isEqualTo( @@ -53,7 +54,8 @@ class InterfaceGeneration { | public val val_: Boolean, | public val val__: Boolean, |) - |""".trimMargin() + | + """.trimMargin(), ) } @@ -74,13 +76,14 @@ class InterfaceGeneration { |UNION |SELECT val, val |FROM another_test; - |""".trimMargin(), - temporaryFolder + | + """.trimMargin(), + temporaryFolder, ) assertThat(result.errors).isEmpty() val generatedInterface = result.compilerOutput.get( - File(result.outputDirectory, "com/example/SomeView.kt") + File(result.outputDirectory, "com/example/SomeView.kt"), ) assertThat(generatedInterface).isNotNull() assertThat(generatedInterface.toString()).isEqualTo( @@ -93,7 +96,8 @@ class InterfaceGeneration { | public val val_: Boolean, | public val val__: Boolean, |) - |""".trimMargin() + | + """.trimMargin(), ) } @@ -103,7 +107,7 @@ class InterfaceGeneration { compilationMethod = { _, _, sqlDelightQueriesFile, writer -> SqlDelightCompiler.writeTableInterfaces(sqlDelightQueriesFile, writer) }, - generateDb = false + generateDb = false, ) assertThat(result.errors).isEmpty() for ((expectedFile, actualOutput) in result.compilerOutput) { diff --git a/sqldelight-gradle-plugin/src/dockerTest/kotlin/app/cash/sqldelight/dialect/DialectIntegrationTests.kt b/sqldelight-gradle-plugin/src/dockerTest/kotlin/app/cash/sqldelight/dialect/DialectIntegrationTests.kt index da2370dfef1..c8288e3eb56 100644 --- a/sqldelight-gradle-plugin/src/dockerTest/kotlin/app/cash/sqldelight/dialect/DialectIntegrationTests.kt +++ b/sqldelight-gradle-plugin/src/dockerTest/kotlin/app/cash/sqldelight/dialect/DialectIntegrationTests.kt @@ -40,7 +40,7 @@ private fun GradleRunner.withCommonConfiguration(projectRoot: File): GradleRunne """ |org.gradle.jvmargs=-Xmx4g -XX:MaxMetaspaceSize=1g | - """.trimMargin() + """.trimMargin(), ) return withProjectDir(projectRoot) } diff --git a/sqldelight-gradle-plugin/src/main/kotlin/app/cash/sqldelight/gradle/GenerateMigrationOutputTask.kt b/sqldelight-gradle-plugin/src/main/kotlin/app/cash/sqldelight/gradle/GenerateMigrationOutputTask.kt index 79ead6ca5a2..9bf324aa22f 100644 --- a/sqldelight-gradle-plugin/src/main/kotlin/app/cash/sqldelight/gradle/GenerateMigrationOutputTask.kt +++ b/sqldelight-gradle-plugin/src/main/kotlin/app/cash/sqldelight/gradle/GenerateMigrationOutputTask.kt @@ -26,8 +26,10 @@ import java.util.ServiceLoader @CacheableTask abstract class GenerateMigrationOutputTask : SqlDelightWorkerTask() { - @Suppress("unused") // Required to invalidate the task on version updates. - @Input val pluginVersion = VERSION + @Suppress("unused") + // Required to invalidate the task on version updates. + @Input + val pluginVersion = VERSION @get:OutputDirectory var outputDirectory: File? = null @@ -35,7 +37,9 @@ abstract class GenerateMigrationOutputTask : SqlDelightWorkerTask() { @get:Input abstract val projectName: Property @get:Nested abstract var properties: SqlDelightDatabasePropertiesImpl + @get:Nested abstract var compilationUnit: SqlDelightCompilationUnitImpl + @get:Input abstract var migrationOutputExtension: String @TaskAction @@ -92,11 +96,11 @@ abstract class GenerateMigrationOutputTask : SqlDelightWorkerTask() { environment.forMigrationFiles { migrationFile -> val output = File( outputDirectory, - "${migrationFile.virtualFile!!.nameWithoutExtension}$migrationExtension" + "${migrationFile.virtualFile!!.nameWithoutExtension}$migrationExtension", ) output.writeText( migrationFile.sqlStmtList?.stmtList.orEmpty() - .filterNotNull().joinToString(separator = "\n\n") { "${it.rawSqlText()};" } + .filterNotNull().joinToString(separator = "\n\n") { "${it.rawSqlText()};" }, ) } } diff --git a/sqldelight-gradle-plugin/src/main/kotlin/app/cash/sqldelight/gradle/GenerateSchemaTask.kt b/sqldelight-gradle-plugin/src/main/kotlin/app/cash/sqldelight/gradle/GenerateSchemaTask.kt index e50e9bd8493..d4a77fae19e 100644 --- a/sqldelight-gradle-plugin/src/main/kotlin/app/cash/sqldelight/gradle/GenerateSchemaTask.kt +++ b/sqldelight-gradle-plugin/src/main/kotlin/app/cash/sqldelight/gradle/GenerateSchemaTask.kt @@ -30,8 +30,10 @@ import java.util.ServiceLoader @CacheableTask abstract class GenerateSchemaTask : SqlDelightWorkerTask() { - @Suppress("unused") // Required to invalidate the task on version updates. - @Input val pluginVersion = VERSION + @Suppress("unused") + // Required to invalidate the task on version updates. + @Input + val pluginVersion = VERSION @get:OutputDirectory var outputDirectory: File? = null @@ -39,6 +41,7 @@ abstract class GenerateSchemaTask : SqlDelightWorkerTask() { @get:Input abstract val projectName: Property @get:Nested abstract var properties: SqlDelightDatabasePropertiesImpl + @get:Nested abstract var compilationUnit: SqlDelightCompilationUnitImpl @Input var verifyMigrations: Boolean = false @@ -101,7 +104,7 @@ abstract class GenerateSchemaTask : SqlDelightWorkerTask() { if (file is SqlDelightQueriesFile) sourceFiles.add(file) } sourceFiles.forInitializationStatements( - environment.dialect.allowsReferenceCycles + environment.dialect.allowsReferenceCycles, ) { sqlText -> connection.prepareStatement(sqlText).execute() } diff --git a/sqldelight-gradle-plugin/src/main/kotlin/app/cash/sqldelight/gradle/PropertiesImpl.kt b/sqldelight-gradle-plugin/src/main/kotlin/app/cash/sqldelight/gradle/PropertiesImpl.kt index f4783c1e166..ecc0f94d78d 100644 --- a/sqldelight-gradle-plugin/src/main/kotlin/app/cash/sqldelight/gradle/PropertiesImpl.kt +++ b/sqldelight-gradle-plugin/src/main/kotlin/app/cash/sqldelight/gradle/PropertiesImpl.kt @@ -15,7 +15,7 @@ data class SqlDelightPropertiesFileImpl( override val dialectJar: File, override val minimumSupportedVersion: String, override val currentVersion: String, - override val moduleJars: Collection = emptySet() + override val moduleJars: Collection = emptySet(), ) : SqlDelightPropertiesFile data class SqlDelightDatabasePropertiesImpl( @@ -27,12 +27,12 @@ data class SqlDelightDatabasePropertiesImpl( @Input override val treatNullAsUnknownForEquality: Boolean = false, @Input override val generateAsync: Boolean = false, // Only used by intellij plugin to help with resolution. - @Internal override val rootDirectory: File + @Internal override val rootDirectory: File, ) : SqlDelightDatabaseProperties data class SqlDelightDatabaseNameImpl( @Input override val packageName: String, - @Input override val className: String + @Input override val className: String, ) : SqlDelightDatabaseName data class SqlDelightCompilationUnitImpl( @@ -45,5 +45,5 @@ data class SqlDelightCompilationUnitImpl( data class SqlDelightSourceFolderImpl( // Sources are already cached [SqlDelightTask.getSources] @Internal override val folder: File, - @Input override val dependency: Boolean = false + @Input override val dependency: Boolean = false, ) : SqlDelightSourceFolder diff --git a/sqldelight-gradle-plugin/src/main/kotlin/app/cash/sqldelight/gradle/SqlDelightDatabase.kt b/sqldelight-gradle-plugin/src/main/kotlin/app/cash/sqldelight/gradle/SqlDelightDatabase.kt index 897bb50d512..1510786a38f 100644 --- a/sqldelight-gradle-plugin/src/main/kotlin/app/cash/sqldelight/gradle/SqlDelightDatabase.kt +++ b/sqldelight-gradle-plugin/src/main/kotlin/app/cash/sqldelight/gradle/SqlDelightDatabase.kt @@ -125,7 +125,7 @@ class SqlDelightDatabase( dialect("app.cash.sqldelight:sqlite-3-18-dialect:$VERSION") } } - """.trimIndent() + """.trimIndent(), ) try { @@ -157,7 +157,7 @@ class SqlDelightDatabase( source.sourceSets.map { SqlDelightSourceFolderImpl( folder = File(project.projectDir, "src/$it/$folder"), - dependency = false + dependency = false, ) } } @@ -171,7 +171,7 @@ class SqlDelightDatabase( return@flatMap compilationUnit.sourceFolders.map { SqlDelightSourceFolderImpl( folder = File(project.projectDir, project.relativePath(it.folder.absolutePath)), - dependency = true + dependency = true, ) } }.distinct() diff --git a/sqldelight-gradle-plugin/src/main/kotlin/app/cash/sqldelight/gradle/SqlDelightExtension.kt b/sqldelight-gradle-plugin/src/main/kotlin/app/cash/sqldelight/gradle/SqlDelightExtension.kt index dbeffaa0747..1c7906feef8 100644 --- a/sqldelight-gradle-plugin/src/main/kotlin/app/cash/sqldelight/gradle/SqlDelightExtension.kt +++ b/sqldelight-gradle-plugin/src/main/kotlin/app/cash/sqldelight/gradle/SqlDelightExtension.kt @@ -25,7 +25,7 @@ open class SqlDelightExtension { | sourceSet = files("src/main/sqldelight") | } |} - """.trimMargin() + """.trimMargin(), ) val database = SqlDelightDatabase(project, name = name) diff --git a/sqldelight-gradle-plugin/src/main/kotlin/app/cash/sqldelight/gradle/SqlDelightPlugin.kt b/sqldelight-gradle-plugin/src/main/kotlin/app/cash/sqldelight/gradle/SqlDelightPlugin.kt index 4a24c8cf836..d222c47e5bd 100644 --- a/sqldelight-gradle-plugin/src/main/kotlin/app/cash/sqldelight/gradle/SqlDelightPlugin.kt +++ b/sqldelight-gradle-plugin/src/main/kotlin/app/cash/sqldelight/gradle/SqlDelightPlugin.kt @@ -126,7 +126,7 @@ abstract class SqlDelightPlugin : Plugin { packageName = project.packageName(), ).apply { project.sqliteVersion()?.let(::dialect) - } + }, ) } else if (databases.isEmpty()) { logger.warn("SQLDelight Gradle plugin was applied but there are no databases set up.") @@ -160,7 +160,7 @@ abstract class SqlDelightPlugin : Plugin { } class PropertiesModelBuilder( - private val databases: Iterable + private val databases: Iterable, ) : ToolingModelBuilder { override fun canBuild(modelName: String): Boolean { return modelName == SqlDelightPropertiesFile::class.java.name diff --git a/sqldelight-gradle-plugin/src/main/kotlin/app/cash/sqldelight/gradle/SqlDelightTask.kt b/sqldelight-gradle-plugin/src/main/kotlin/app/cash/sqldelight/gradle/SqlDelightTask.kt index c96e3203753..0bc255f6109 100644 --- a/sqldelight-gradle-plugin/src/main/kotlin/app/cash/sqldelight/gradle/SqlDelightTask.kt +++ b/sqldelight-gradle-plugin/src/main/kotlin/app/cash/sqldelight/gradle/SqlDelightTask.kt @@ -46,8 +46,10 @@ import java.util.ServiceLoader @CacheableTask abstract class SqlDelightTask : SqlDelightWorkerTask() { - @Suppress("unused") // Required to invalidate the task on version updates. - @Input val pluginVersion = VERSION + @Suppress("unused") + // Required to invalidate the task on version updates. + @Input + val pluginVersion = VERSION @get:OutputDirectory var outputDirectory: File? = null @@ -55,6 +57,7 @@ abstract class SqlDelightTask : SqlDelightWorkerTask() { @get:Input abstract val projectName: Property @get:Nested abstract var properties: SqlDelightDatabasePropertiesImpl + @get:Nested abstract var compilationUnit: SqlDelightCompilationUnitImpl @Input var verifyMigrations: Boolean = false @@ -111,11 +114,11 @@ abstract class SqlDelightTask : SqlDelightWorkerTask() { | |Compiling with dialect ${environment.dialect::class.qualifiedName} | - """.trimMargin() + """.trimMargin(), ) generationStatus.errors.forEach { logger.log(ERROR, it) } throw SqlDelightException( - "Generation failed; see the generator error output for details." + "Generation failed; see the generator error output for details.", ) } is Success -> { } diff --git a/sqldelight-gradle-plugin/src/main/kotlin/app/cash/sqldelight/gradle/VerifyMigrationTask.kt b/sqldelight-gradle-plugin/src/main/kotlin/app/cash/sqldelight/gradle/VerifyMigrationTask.kt index 383f4436d28..777278f7764 100644 --- a/sqldelight-gradle-plugin/src/main/kotlin/app/cash/sqldelight/gradle/VerifyMigrationTask.kt +++ b/sqldelight-gradle-plugin/src/main/kotlin/app/cash/sqldelight/gradle/VerifyMigrationTask.kt @@ -33,8 +33,10 @@ import java.util.ServiceLoader @CacheableTask abstract class VerifyMigrationTask : SqlDelightWorkerTask() { - @Suppress("unused") // Required to invalidate the task on version updates. - @Input val pluginVersion = VERSION + @Suppress("unused") + // Required to invalidate the task on version updates. + @Input + val pluginVersion = VERSION @get:Input abstract val projectName: Property @@ -42,6 +44,7 @@ abstract class VerifyMigrationTask : SqlDelightWorkerTask() { @get:Internal abstract var workingDirectory: File @get:Nested abstract var properties: SqlDelightDatabasePropertiesImpl + @get:Nested abstract var compilationUnit: SqlDelightCompilationUnitImpl @Input var verifyMigrations: Boolean = false @@ -135,7 +138,7 @@ abstract class VerifyMigrationTask : SqlDelightWorkerTask() { } val initStatements = ArrayList() sourceFiles.forInitializationStatements( - environment.dialect.allowsReferenceCycles + environment.dialect.allowsReferenceCycles, ) { sqlText -> initStatements.add(CatalogDatabase.InitStatement(sqlText, "Error compiling $sqlText")) } @@ -148,7 +151,7 @@ abstract class VerifyMigrationTask : SqlDelightWorkerTask() { ignoreDefinitions = !parameters.verifyDefinitions.get(), circularReferenceExceptionLogger = { logger.debug(it) - } + }, ) val diffReport = databaseComparator.compare(currentDb, actualCatalog).let { diff -> buildString(diff::printTo) @@ -173,8 +176,8 @@ abstract class VerifyMigrationTask : SqlDelightWorkerTask() { initStatements.add( CatalogDatabase.InitStatement( it.rawSqlText(), - "Error compiling ${file.name}" - ) + "Error compiling ${file.name}", + ), ) } } diff --git a/sqldelight-gradle-plugin/src/main/kotlin/app/cash/sqldelight/gradle/android/PackageName.kt b/sqldelight-gradle-plugin/src/main/kotlin/app/cash/sqldelight/gradle/android/PackageName.kt index 35a340244af..a87cfa81730 100644 --- a/sqldelight-gradle-plugin/src/main/kotlin/app/cash/sqldelight/gradle/android/PackageName.kt +++ b/sqldelight-gradle-plugin/src/main/kotlin/app/cash/sqldelight/gradle/android/PackageName.kt @@ -22,7 +22,7 @@ internal fun Project.packageName(): String { | packageName = "com.example.mypackage" | } |} - """.trimMargin() + """.trimMargin(), ) } diff --git a/sqldelight-gradle-plugin/src/main/kotlin/app/cash/sqldelight/gradle/kotlin/Multiplatform.kt b/sqldelight-gradle-plugin/src/main/kotlin/app/cash/sqldelight/gradle/kotlin/LinkSqlite.kt similarity index 93% rename from sqldelight-gradle-plugin/src/main/kotlin/app/cash/sqldelight/gradle/kotlin/Multiplatform.kt rename to sqldelight-gradle-plugin/src/main/kotlin/app/cash/sqldelight/gradle/kotlin/LinkSqlite.kt index abdf2655b54..5c519852e5e 100644 --- a/sqldelight-gradle-plugin/src/main/kotlin/app/cash/sqldelight/gradle/kotlin/Multiplatform.kt +++ b/sqldelight-gradle-plugin/src/main/kotlin/app/cash/sqldelight/gradle/kotlin/LinkSqlite.kt @@ -5,7 +5,7 @@ import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeCompilation fun Project.linkSqlite() { - val extension = project.extensions.findByType(KotlinMultiplatformExtension ::class.java) ?: return + val extension = project.extensions.findByType(KotlinMultiplatformExtension::class.java) ?: return extension.targets .flatMap { it.compilations } .filterIsInstance() diff --git a/sqldelight-gradle-plugin/src/main/kotlin/app/cash/sqldelight/gradle/kotlin/SourceRoots.kt b/sqldelight-gradle-plugin/src/main/kotlin/app/cash/sqldelight/gradle/kotlin/SourceRoots.kt index 4fd7bbd297c..c56b4fde2be 100644 --- a/sqldelight-gradle-plugin/src/main/kotlin/app/cash/sqldelight/gradle/kotlin/SourceRoots.kt +++ b/sqldelight-gradle-plugin/src/main/kotlin/app/cash/sqldelight/gradle/kotlin/SourceRoots.kt @@ -56,7 +56,7 @@ internal fun SqlDelightDatabase.sources(): List { name = "main", sourceSets = listOf("main"), sourceDirectorySet = sourceSets.getByName("main").kotlin!!, - ) + ), ) } @@ -67,7 +67,7 @@ private fun KotlinJsProjectExtension.sources(): List { name = "main", sourceDirectorySet = sourceSets.getByName("main").kotlin, sourceSets = listOf("main"), - ) + ), ) } @@ -83,7 +83,7 @@ private fun KotlinMultiplatformExtension.sources(): List { variantName = "commonMain", sourceDirectorySet = sourceSets.getByName("commonMain").kotlin, sourceSets = listOf("commonMain"), - ) + ), ) } @@ -114,7 +114,7 @@ private fun BaseExtension.sources(): List { } private fun TaskContainer.namedOrNull( - taskName: String + taskName: String, ): TaskProvider? { return try { named(taskName) diff --git a/sqldelight-gradle-plugin/src/main/kotlin/app/cash/sqldelight/gradle/squash/AnsiSqlMigrationSquasher.kt b/sqldelight-gradle-plugin/src/main/kotlin/app/cash/sqldelight/gradle/squash/AnsiSqlMigrationSquasher.kt index 791d1e23f12..8c2283ba30a 100644 --- a/sqldelight-gradle-plugin/src/main/kotlin/app/cash/sqldelight/gradle/squash/AnsiSqlMigrationSquasher.kt +++ b/sqldelight-gradle-plugin/src/main/kotlin/app/cash/sqldelight/gradle/squash/AnsiSqlMigrationSquasher.kt @@ -14,13 +14,13 @@ import com.intellij.refactoring.suggested.endOffset import com.intellij.refactoring.suggested.startOffset class AnsiSqlMigrationSquasher( - private val createNewSqlFile: (String) -> SqlFileBase + private val createNewSqlFile: (String) -> SqlFileBase, ) : MigrationSquasher { internal lateinit var squasher: MigrationSquasher override fun squish( statement: SqlStmt, - currentFile: SqlFileBase + currentFile: SqlFileBase, ): String { return when { statement.alterTableStmt != null -> { @@ -67,7 +67,7 @@ class AnsiSqlMigrationSquasher( override fun squish( alterTableRules: SqlAlterTableRules, - into: SqlFileBase + into: SqlFileBase, ): String { return when { alterTableRules.alterTableRenameTable != null -> { @@ -83,7 +83,7 @@ class AnsiSqlMigrationSquasher( into.text.replaceRange( createTable.columnDefList.first().startOffset until createTable.columnDefList.last().endOffset, (createTable.columnDefList + alterTableRules.alterTableAddColumn!!.columnDef) - .joinToString(separator = ",\n ") { it.text } + .joinToString(separator = ",\n ") { it.text }, ) } else -> throw IllegalStateException("Cannot squish ${alterTableRules.text}") diff --git a/sqldelight-gradle-plugin/src/main/kotlin/app/cash/sqldelight/gradle/squash/MigrationSquashTask.kt b/sqldelight-gradle-plugin/src/main/kotlin/app/cash/sqldelight/gradle/squash/MigrationSquashTask.kt index b138886edeb..744b77664db 100644 --- a/sqldelight-gradle-plugin/src/main/kotlin/app/cash/sqldelight/gradle/squash/MigrationSquashTask.kt +++ b/sqldelight-gradle-plugin/src/main/kotlin/app/cash/sqldelight/gradle/squash/MigrationSquashTask.kt @@ -29,12 +29,15 @@ import java.util.ServiceLoader @CacheableTask abstract class MigrationSquashTask : SqlDelightWorkerTask() { - @Suppress("unused") // Required to invalidate the task on version updates. - @Input val pluginVersion = VERSION + @Suppress("unused") + // Required to invalidate the task on version updates. + @Input + val pluginVersion = VERSION @Input val projectName: Property = project.objects.property(String::class.java) @Nested lateinit var properties: SqlDelightDatabasePropertiesImpl + @Nested lateinit var compilationUnit: SqlDelightCompilationUnitImpl @TaskAction diff --git a/sqldelight-gradle-plugin/src/test/custom-dialect/dialect/src/main/kotlin/foo/FooDialect.kt b/sqldelight-gradle-plugin/src/test/custom-dialect/dialect/src/main/kotlin/foo/FooDialect.kt index f6b097c4ac2..f9d3e23eade 100644 --- a/sqldelight-gradle-plugin/src/test/custom-dialect/dialect/src/main/kotlin/foo/FooDialect.kt +++ b/sqldelight-gradle-plugin/src/test/custom-dialect/dialect/src/main/kotlin/foo/FooDialect.kt @@ -37,7 +37,7 @@ class FooDialect : SqlDelightDialect by SqliteDialect() { .add( "$cursorName.getLong($columnIndex)?.%M(%M)", MemberName("kotlin.time", "toDuration", isExtension = true), - MemberName("kotlin.time.DurationUnit", "SECONDS") + MemberName("kotlin.time.DurationUnit", "SECONDS"), ) .build() } diff --git a/sqldelight-gradle-plugin/src/test/integration-android-variants/src/test/java/app/cash/sqldelight/integration/IntegrationTests.kt b/sqldelight-gradle-plugin/src/test/integration-android-variants/src/test/java/app/cash/sqldelight/integration/IntegrationTests.kt index 0ed6ee4822e..22d69dc9bc3 100644 --- a/sqldelight-gradle-plugin/src/test/integration-android-variants/src/test/java/app/cash/sqldelight/integration/IntegrationTests.kt +++ b/sqldelight-gradle-plugin/src/test/integration-android-variants/src/test/java/app/cash/sqldelight/integration/IntegrationTests.kt @@ -79,15 +79,19 @@ class IntegrationTests { assertThat(current).isEqualTo(13) } - @Test @kotlin.Throws(InterruptedException::class) fun compiledStatementAcrossThread() { + @Test + @kotlin.Throws(InterruptedException::class) + fun compiledStatementAcrossThread() { keywordsQueries.insertStmt(11, 21) val latch = CountDownLatch(1) - Thread(object : Runnable { - override fun run() { - keywordsQueries.insertStmt(12, 22) - latch.countDown() - } - }).start() + Thread( + object : Runnable { + override fun run() { + keywordsQueries.insertStmt(12, 22) + latch.countDown() + } + }, + ).start() assertTrue(latch.await(10, SECONDS)) var current: Long = 10 for (group in keywordsQueries.selectAll().executeAsList()) { diff --git a/sqldelight-gradle-plugin/src/test/integration-hsql/src/test/kotlin/app/cash/sqldelight/hsql/integration/HsqlTest.kt b/sqldelight-gradle-plugin/src/test/integration-hsql/src/test/kotlin/app/cash/sqldelight/hsql/integration/HsqlTest.kt index 3d2b34cbd31..c7f83c53dcd 100644 --- a/sqldelight-gradle-plugin/src/test/integration-hsql/src/test/kotlin/app/cash/sqldelight/hsql/integration/HsqlTest.kt +++ b/sqldelight-gradle-plugin/src/test/integration-hsql/src/test/kotlin/app/cash/sqldelight/hsql/integration/HsqlTest.kt @@ -35,8 +35,8 @@ class HsqlTest { Dog( name = "Tilda", breed = "Pomeranian", - is_good = true - ) + is_good = true, + ), ) } } diff --git a/sqldelight-gradle-plugin/src/test/integration-migration-callbacks/src/test/java/app/cash/sqldelight/integration/IntegrationTests.kt b/sqldelight-gradle-plugin/src/test/integration-migration-callbacks/src/test/java/app/cash/sqldelight/integration/IntegrationTests.kt index bd57ca5c533..e9352c33fca 100644 --- a/sqldelight-gradle-plugin/src/test/integration-migration-callbacks/src/test/java/app/cash/sqldelight/integration/IntegrationTests.kt +++ b/sqldelight-gradle-plugin/src/test/integration-migration-callbacks/src/test/java/app/cash/sqldelight/integration/IntegrationTests.kt @@ -33,7 +33,7 @@ class IntegrationTests { QueryWrapper.Schema.migrate( driver = database, oldVersion = 0, - newVersion = 2 + newVersion = 2, ) QueryWrapper.Schema.migrateWithCallbacks( driver = database, diff --git a/sqldelight-gradle-plugin/src/test/integration-multiplatform/src/androidMain/kotlin/app/cash/sqldelight/integration/android.kt b/sqldelight-gradle-plugin/src/test/integration-multiplatform/src/androidMain/kotlin/app/cash/sqldelight/integration/Android.kt similarity index 100% rename from sqldelight-gradle-plugin/src/test/integration-multiplatform/src/androidMain/kotlin/app/cash/sqldelight/integration/android.kt rename to sqldelight-gradle-plugin/src/test/integration-multiplatform/src/androidMain/kotlin/app/cash/sqldelight/integration/Android.kt diff --git a/sqldelight-gradle-plugin/src/test/integration-multiplatform/src/commonMain/kotlin/app/cash/sqldelight/integration/common.kt b/sqldelight-gradle-plugin/src/test/integration-multiplatform/src/commonMain/kotlin/app/cash/sqldelight/integration/Common.kt similarity index 100% rename from sqldelight-gradle-plugin/src/test/integration-multiplatform/src/commonMain/kotlin/app/cash/sqldelight/integration/common.kt rename to sqldelight-gradle-plugin/src/test/integration-multiplatform/src/commonMain/kotlin/app/cash/sqldelight/integration/Common.kt diff --git a/sqldelight-gradle-plugin/src/test/integration-multiplatform/src/commonTest/kotlin/app/cash/sqldelight/integration/IntegrationTests.kt b/sqldelight-gradle-plugin/src/test/integration-multiplatform/src/commonTest/kotlin/app/cash/sqldelight/integration/IntegrationTests.kt index 036e25eb255..41058892e66 100644 --- a/sqldelight-gradle-plugin/src/test/integration-multiplatform/src/commonTest/kotlin/app/cash/sqldelight/integration/IntegrationTests.kt +++ b/sqldelight-gradle-plugin/src/test/integration-multiplatform/src/commonTest/kotlin/app/cash/sqldelight/integration/IntegrationTests.kt @@ -134,7 +134,7 @@ class IntegrationTests { @Test fun bigTable() { val bigTable = BigTable( 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, - 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30 + 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, ) bigTableQueries.insert(bigTable) @@ -146,34 +146,42 @@ class IntegrationTests { // Single query subscribed to twice. var equivalentNames1Notified = AtomicInt(0) val equivalentNames1 = personQueries.equivalentNames("Bob") - equivalentNames1.addListener(object : Query.Listener { - override fun queryResultsChanged() { - equivalentNames1Notified.incrementAndGet() - } - }) - equivalentNames1.addListener(object : Query.Listener { - override fun queryResultsChanged() { - equivalentNames1Notified.incrementAndGet() - } - }) + equivalentNames1.addListener( + object : Query.Listener { + override fun queryResultsChanged() { + equivalentNames1Notified.incrementAndGet() + } + }, + ) + equivalentNames1.addListener( + object : Query.Listener { + override fun queryResultsChanged() { + equivalentNames1Notified.incrementAndGet() + } + }, + ) // New instance of existing query subscribed to. var equivalentNames2Notified = AtomicInt(0) val equivalentNames2 = personQueries.equivalentNames("Bob") - equivalentNames2.addListener(object : Query.Listener { - override fun queryResultsChanged() { - equivalentNames2Notified.incrementAndGet() - } - }) + equivalentNames2.addListener( + object : Query.Listener { + override fun queryResultsChanged() { + equivalentNames2Notified.incrementAndGet() + } + }, + ) // Separate query on the same table. var peopleNotified = AtomicInt(0) val people = personQueries.nameIn(listOf("Alec", "Matt", "Jake")) - people.addListener(object : Query.Listener { - override fun queryResultsChanged() { - peopleNotified.incrementAndGet() - } - }) + people.addListener( + object : Query.Listener { + override fun queryResultsChanged() { + peopleNotified.incrementAndGet() + } + }, + ) // Mutation which affects all of the above. personQueries.deleteAll() diff --git a/sqldelight-gradle-plugin/src/test/integration-multiplatform/src/iosMain/kotlin/app/cash/sqldelight/integration/ios.kt b/sqldelight-gradle-plugin/src/test/integration-multiplatform/src/iosMain/kotlin/app/cash/sqldelight/integration/Ios.kt similarity index 99% rename from sqldelight-gradle-plugin/src/test/integration-multiplatform/src/iosMain/kotlin/app/cash/sqldelight/integration/ios.kt rename to sqldelight-gradle-plugin/src/test/integration-multiplatform/src/iosMain/kotlin/app/cash/sqldelight/integration/Ios.kt index 006f74e0b76..e293ddc7dd7 100644 --- a/sqldelight-gradle-plugin/src/test/integration-multiplatform/src/iosMain/kotlin/app/cash/sqldelight/integration/ios.kt +++ b/sqldelight-gradle-plugin/src/test/integration-multiplatform/src/iosMain/kotlin/app/cash/sqldelight/integration/Ios.kt @@ -20,7 +20,7 @@ actual class MPWorker actual constructor() { return MPFuture( worker.execute(TransferMode.SAFE, { backJob.freeze() }) { it() - } + }, ) } diff --git a/sqldelight-gradle-plugin/src/test/integration-mysql-async/src/test/kotlin/app/cash/sqldelight/mysql/integration/MySqlTest.kt b/sqldelight-gradle-plugin/src/test/integration-mysql-async/src/test/kotlin/app/cash/sqldelight/mysql/integration/MySqlTest.kt index 31cd57bb03b..259142b9261 100644 --- a/sqldelight-gradle-plugin/src/test/integration-mysql-async/src/test/kotlin/app/cash/sqldelight/mysql/integration/MySqlTest.kt +++ b/sqldelight-gradle-plugin/src/test/integration-mysql-async/src/test/kotlin/app/cash/sqldelight/mysql/integration/MySqlTest.kt @@ -24,8 +24,8 @@ class MySqlTest { Dog( name = "Tilda", breed = "Pomeranian", - is_good = true - ) + is_good = true, + ), ) } @@ -39,20 +39,20 @@ class MySqlTest { assertThat( dogQueries.selectDogsByBreedAndNames( breed = "Pomeranian", - name = listOf("Tilda", "Buddy") - ).executeAsList() + name = listOf("Tilda", "Buddy"), + ).executeAsList(), ) .containsExactly( Dog( name = "Tilda", breed = "Pomeranian", - is_good = true + is_good = true, ), Dog( name = "Buddy", breed = "Pomeranian", - is_good = true - ) + is_good = true, + ), ) } } diff --git a/sqldelight-gradle-plugin/src/test/integration-mysql-schema/src/test/kotlin/app/cash/sqldelight/mysql/integration/MySqlTest.kt b/sqldelight-gradle-plugin/src/test/integration-mysql-schema/src/test/kotlin/app/cash/sqldelight/mysql/integration/MySqlTest.kt index 39e7d2a86d1..bae0bc1cd6e 100644 --- a/sqldelight-gradle-plugin/src/test/integration-mysql-schema/src/test/kotlin/app/cash/sqldelight/mysql/integration/MySqlTest.kt +++ b/sqldelight-gradle-plugin/src/test/integration-mysql-schema/src/test/kotlin/app/cash/sqldelight/mysql/integration/MySqlTest.kt @@ -48,14 +48,14 @@ class MySqlTest { name = "Hazel", breed = "French Bulldog", owner = 2, - is_good = true + is_good = true, ), Dog( name = "Olive", breed = "French Bulldog", owner = 2, - is_good = true - ) + is_good = true, + ), ) } @@ -71,12 +71,12 @@ class MySqlTest { .containsExactly( Bad_name_dogs( name = "Cat", - breed = "Cat" + breed = "Cat", ), Bad_name_dogs( name = "Dog", - breed = "Dog" - ) + breed = "Dog", + ), ) } } diff --git a/sqldelight-gradle-plugin/src/test/integration-mysql/src/test/kotlin/app/cash/sqldelight/mysql/integration/MySqlTest.kt b/sqldelight-gradle-plugin/src/test/integration-mysql/src/test/kotlin/app/cash/sqldelight/mysql/integration/MySqlTest.kt index 4c13e42648c..b7f02ba732a 100644 --- a/sqldelight-gradle-plugin/src/test/integration-mysql/src/test/kotlin/app/cash/sqldelight/mysql/integration/MySqlTest.kt +++ b/sqldelight-gradle-plugin/src/test/integration-mysql/src/test/kotlin/app/cash/sqldelight/mysql/integration/MySqlTest.kt @@ -52,8 +52,8 @@ class MySqlTest { Dog( name = "Tilda", breed = "Pomeranian", - is_good = true - ) + is_good = true, + ), ) } @@ -66,20 +66,20 @@ class MySqlTest { assertThat( dogQueries.selectDogsByBreedAndNames( breed = "Pomeranian", - name = listOf("Tilda", "Buddy") - ).executeAsList() + name = listOf("Tilda", "Buddy"), + ).executeAsList(), ) .containsExactly( Dog( name = "Tilda", breed = "Pomeranian", - is_good = true + is_good = true, ), Dog( name = "Buddy", breed = "Pomeranian", - is_good = true - ) + is_good = true, + ), ) } @@ -91,8 +91,8 @@ class MySqlTest { time = LocalTime.of(21, 30, 59), datetime = LocalDateTime.of(2020, 1, 1, 21, 30, 59), timestamp = OffsetDateTime.of(1980, 4, 9, 20, 15, 45, 0, ZoneOffset.ofHours(0)), - year = "2022" - ).executeAsOne() + year = "2022", + ).executeAsOne(), ) .isEqualTo( Dates( @@ -100,8 +100,8 @@ class MySqlTest { time = LocalTime.of(21, 30, 59), datetime = LocalDateTime.of(2020, 1, 1, 21, 30, 59), timestamp = OffsetDateTime.of(1980, 4, 9, 20, 15, 45, 0, ZoneOffset.ofHours(0)), - year = "2022-01-01" - ) + year = "2022-01-01", + ), ) } diff --git a/sqldelight-gradle-plugin/src/test/integration-postgresql-migrations/src/test/kotlin/app/cash/sqldelight/postgresql/integration/PostgreSqlTest.kt b/sqldelight-gradle-plugin/src/test/integration-postgresql-migrations/src/test/kotlin/app/cash/sqldelight/postgresql/integration/PostgreSqlTest.kt index e53196b535e..c708bdac8d2 100644 --- a/sqldelight-gradle-plugin/src/test/integration-postgresql-migrations/src/test/kotlin/app/cash/sqldelight/postgresql/integration/PostgreSqlTest.kt +++ b/sqldelight-gradle-plugin/src/test/integration-postgresql-migrations/src/test/kotlin/app/cash/sqldelight/postgresql/integration/PostgreSqlTest.kt @@ -34,8 +34,10 @@ class PostgreSqlTest { productsQueries.insert(Products(1, "sku", true)) assertThat(productsQueries.selectAll().executeAsList()).containsExactly( Products( - 1, "sku", true - ) + 1, + "sku", + true, + ), ) } } diff --git a/sqldelight-gradle-plugin/src/test/integration-postgresql/src/test/kotlin/app/cash/sqldelight/postgresql/integration/PostgreSqlTest.kt b/sqldelight-gradle-plugin/src/test/integration-postgresql/src/test/kotlin/app/cash/sqldelight/postgresql/integration/PostgreSqlTest.kt index 8a47712d585..848652b17fd 100644 --- a/sqldelight-gradle-plugin/src/test/integration-postgresql/src/test/kotlin/app/cash/sqldelight/postgresql/integration/PostgreSqlTest.kt +++ b/sqldelight-gradle-plugin/src/test/integration-postgresql/src/test/kotlin/app/cash/sqldelight/postgresql/integration/PostgreSqlTest.kt @@ -42,8 +42,8 @@ class PostgreSqlTest { Dog( name = "Tilda", breed = "Pomeranian", - is_good = 1 - ) + is_good = 1, + ), ) } @@ -54,8 +54,8 @@ class PostgreSqlTest { Dog( name = "Tilda", breed = "Pomeranian", - is_good = 1 - ) + is_good = 1, + ), ) } @@ -65,8 +65,8 @@ class PostgreSqlTest { Dog( name = "Tilda", breed = "Pomeranian", - is_good = 1 - ) + is_good = 1, + ), ) } @@ -76,8 +76,8 @@ class PostgreSqlTest { date = LocalDate.of(2020, 1, 1), time = LocalTime.of(21, 30, 59, 10000), timestamp = LocalDateTime.of(2020, 1, 1, 21, 30, 59, 10000), - timestamp_with_timezone = OffsetDateTime.of(1980, 4, 9, 20, 15, 45, 0, ZoneOffset.ofHours(0)) - ).executeAsOne() + timestamp_with_timezone = OffsetDateTime.of(1980, 4, 9, 20, 15, 45, 0, ZoneOffset.ofHours(0)), + ).executeAsOne(), ) .isEqualTo( Dates( @@ -85,7 +85,7 @@ class PostgreSqlTest { time = LocalTime.of(21, 30, 59, 10000), timestamp = LocalDateTime.of(2020, 1, 1, 21, 30, 59, 10000), timestamp_with_timezone = OffsetDateTime.of(1980, 4, 9, 20, 15, 45, 0, ZoneOffset.ofHours(0)), - ) + ), ) } @@ -94,17 +94,17 @@ class PostgreSqlTest { date = LocalDate.of(2020, 1, 1), time = LocalTime.of(21, 30, 59, 10000), timestamp = LocalDateTime.of(2020, 1, 1, 21, 30, 59, 10000), - timestamp_with_timezone = OffsetDateTime.of(1980, 4, 9, 20, 15, 45, 0, ZoneOffset.ofHours(0)) + timestamp_with_timezone = OffsetDateTime.of(1980, 4, 9, 20, 15, 45, 0, ZoneOffset.ofHours(0)), ).executeAsOne() assertThat( - database.datesQueries.selectDateTrunc().executeAsOne() + database.datesQueries.selectDateTrunc().executeAsOne(), ) .isEqualTo( SelectDateTrunc( date_trunc = LocalDateTime.of(2020, 1, 1, 21, 0, 0, 0), - date_trunc_ = OffsetDateTime.of(1980, 4, 9, 20, 0, 0, 0, ZoneOffset.ofHours(0)) - ) + date_trunc_ = OffsetDateTime.of(1980, 4, 9, 20, 0, 0, 0, ZoneOffset.ofHours(0)), + ), ) } @@ -133,7 +133,7 @@ class PostgreSqlTest { updateText( id = row.id, version = row.version, - text = "sup2" + text = "sup2", ) assertThat(selectForId(row.id).executeAsOne().text).isEqualTo("sup2") @@ -147,14 +147,14 @@ class PostgreSqlTest { updateText( id = row.id, version = row.version, - text = "sup2" + text = "sup2", ) try { updateText( id = row.id, version = row.version, - text = "sup3" + text = "sup3", ) Assert.fail() } catch (e: OptimisticLockException) { } diff --git a/sqldelight-gradle-plugin/src/test/integration-sqlite-3-24/src/test/java/app/cash/sqldelight/integration/IntegrationTests.kt b/sqldelight-gradle-plugin/src/test/integration-sqlite-3-24/src/test/java/app/cash/sqldelight/integration/IntegrationTests.kt index faa8d7771ba..bd3788eca4b 100644 --- a/sqldelight-gradle-plugin/src/test/integration-sqlite-3-24/src/test/java/app/cash/sqldelight/integration/IntegrationTests.kt +++ b/sqldelight-gradle-plugin/src/test/integration-sqlite-3-24/src/test/java/app/cash/sqldelight/integration/IntegrationTests.kt @@ -28,7 +28,7 @@ class IntegrationTests { Person(2, "Matt", "Precious"), Person(3, "Jake", "Wharton"), Person(4, "Bob", "Bob"), - Person(5, "Bo", "Jangles") + Person(5, "Bo", "Jangles"), ) } @@ -41,7 +41,7 @@ class IntegrationTests { Person(1, "Alec", "Strong"), Person(2, "Matt", "Precious"), Person(3, "James", "Mosley"), - Person(4, "Bob", "Bob") + Person(4, "Bob", "Bob"), ) } } diff --git a/sqldelight-gradle-plugin/src/test/integration-sqlite-3-35/src/test/java/app/cash/sqldelight/integration/IntegrationTests.kt b/sqldelight-gradle-plugin/src/test/integration-sqlite-3-35/src/test/java/app/cash/sqldelight/integration/IntegrationTests.kt index 832f1d3ef21..79d4a08e9f8 100644 --- a/sqldelight-gradle-plugin/src/test/integration-sqlite-3-35/src/test/java/app/cash/sqldelight/integration/IntegrationTests.kt +++ b/sqldelight-gradle-plugin/src/test/integration-sqlite-3-35/src/test/java/app/cash/sqldelight/integration/IntegrationTests.kt @@ -21,7 +21,7 @@ class IntegrationTests { @Test fun returningInsert() { assertThat(database.personQueries.insertAndReturn(1, "Alec", "Strong").executeAsOne()) .isEqualTo( - Person(1, "Alec", "Strong") + Person(1, "Alec", "Strong"), ) } } diff --git a/sqldelight-gradle-plugin/src/test/integration-sqlite-json/src/test/java/app/cash/sqldelight/integration/IntegrationTests.kt b/sqldelight-gradle-plugin/src/test/integration-sqlite-json/src/test/java/app/cash/sqldelight/integration/IntegrationTests.kt index b5a525de61d..0325fa41746 100644 --- a/sqldelight-gradle-plugin/src/test/integration-sqlite-json/src/test/java/app/cash/sqldelight/integration/IntegrationTests.kt +++ b/sqldelight-gradle-plugin/src/test/integration-sqlite-json/src/test/java/app/cash/sqldelight/integration/IntegrationTests.kt @@ -28,7 +28,7 @@ class IntegrationTests { insertUser("user1", jsonPhones("704-555-5555", "705-555-5555")) insertUser("user2", jsonPhones("604-555-5555", "605-555-5555")) assertThat(byAreaCode(areaCode = "704").executeAsList()).containsExactly( - "user1" + "user1", ) } } @@ -40,7 +40,7 @@ class IntegrationTests { insertUser("user3", "704-666-6666") assertThat(byAreaCode2(areaCode = "704").executeAsList()).containsExactly( "user1", - "user3" + "user3", ) } } diff --git a/sqldelight-gradle-plugin/src/test/integration/src/test/java/app/cash/sqldelight/integration/IntegrationTests.kt b/sqldelight-gradle-plugin/src/test/integration/src/test/java/app/cash/sqldelight/integration/IntegrationTests.kt index 9d17de81adf..ba633527f59 100644 --- a/sqldelight-gradle-plugin/src/test/integration/src/test/java/app/cash/sqldelight/integration/IntegrationTests.kt +++ b/sqldelight-gradle-plugin/src/test/integration/src/test/java/app/cash/sqldelight/integration/IntegrationTests.kt @@ -95,20 +95,23 @@ class IntegrationTests { assertThat(current).isEqualTo(13) } - @Test @Throws(InterruptedException::class) + @Test + @Throws(InterruptedException::class) fun compiledStatementAcrossThread() { keywordsQueries.insertStmt(11, 21) val latch = CountDownLatch(1) - Thread(object : Runnable { - override fun run() { - try { - keywordsQueries.insertStmt(12, 22) - } finally { - latch.countDown() + Thread( + object : Runnable { + override fun run() { + try { + keywordsQueries.insertStmt(12, 22) + } finally { + latch.countDown() + } } - } - }).start() + }, + ).start() assertTrue(latch.await(10, SECONDS)) @@ -140,7 +143,7 @@ class IntegrationTests { @Test fun bigTable() { val bigTable = BigTable( 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, - 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30 + 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, ) bigTableQueries.insert(bigTable) @@ -155,7 +158,7 @@ class IntegrationTests { assertThat(varargsQueries.select(setOf(1, 2), 10).executeAsList()).containsExactly( MyTable(1, 1, 10), - MyTable(2, 2, 10) + MyTable(2, 2, 10), ) } @@ -166,18 +169,18 @@ class IntegrationTests { assertThat(groupedStatementQueries.selectAll().executeAsList()).containsExactly( Bug("2", "2", 1, 20), - Bug("1", "1", 0, 11) + Bug("1", "1", 0, 11), ) } @Test fun groupedStatementWithReturn() { assertThat( - personQueries.insertAndReturn(first_name = "Bob", last_name = "Ross").executeAsOne() + personQueries.insertAndReturn(first_name = "Bob", last_name = "Ross").executeAsOne(), ).isEqualTo( InsertAndReturn( first_name = "Bob", - last_name = "Ross" - ) + last_name = "Ross", + ), ) } } diff --git a/sqldelight-gradle-plugin/src/test/kotlin/app/cash/sqldelight/AndroidTestUtil.kt b/sqldelight-gradle-plugin/src/test/kotlin/app/cash/sqldelight/AndroidHome.kt similarity index 98% rename from sqldelight-gradle-plugin/src/test/kotlin/app/cash/sqldelight/AndroidTestUtil.kt rename to sqldelight-gradle-plugin/src/test/kotlin/app/cash/sqldelight/AndroidHome.kt index d3c3bccdad3..fb5cb83b7c6 100644 --- a/sqldelight-gradle-plugin/src/test/kotlin/app/cash/sqldelight/AndroidTestUtil.kt +++ b/sqldelight-gradle-plugin/src/test/kotlin/app/cash/sqldelight/AndroidHome.kt @@ -35,6 +35,6 @@ internal fun androidHome(): String { } } throw IllegalStateException( - "Missing 'ANDROID_HOME' environment variable or local.properties with 'sdk.dir'" + "Missing 'ANDROID_HOME' environment variable or local.properties with 'sdk.dir'", ) } diff --git a/sqldelight-gradle-plugin/src/test/kotlin/app/cash/sqldelight/TemporaryFixture.kt b/sqldelight-gradle-plugin/src/test/kotlin/app/cash/sqldelight/TemporaryFixture.kt index 1554f4bf8d2..edf963ea95d 100644 --- a/sqldelight-gradle-plugin/src/test/kotlin/app/cash/sqldelight/TemporaryFixture.kt +++ b/sqldelight-gradle-plugin/src/test/kotlin/app/cash/sqldelight/TemporaryFixture.kt @@ -66,7 +66,7 @@ internal fun properties(fixtureRoot: File): SqlDelightPropertiesFileImpl { sourceFolders = it.sourceFolders.map { SqlDelightSourceFolderImpl( folder = it.folder, - dependency = it.dependency + dependency = it.dependency, ) }, outputDirectoryFile = it.outputDirectoryFile, @@ -76,14 +76,14 @@ internal fun properties(fixtureRoot: File): SqlDelightPropertiesFileImpl { dependencies = it.dependencies.map { SqlDelightDatabaseNameImpl( packageName = it.packageName, - className = it.className + className = it.className, ) }, deriveSchemaFromMigrations = it.deriveSchemaFromMigrations, treatNullAsUnknownForEquality = it.treatNullAsUnknownForEquality, - rootDirectory = it.rootDirectory + rootDirectory = it.rootDirectory, ) - } + }, ) } diff --git a/sqldelight-gradle-plugin/src/test/kotlin/app/cash/sqldelight/TestUtil.kt b/sqldelight-gradle-plugin/src/test/kotlin/app/cash/sqldelight/TestUtil.kt index 47db136a780..f235b983634 100644 --- a/sqldelight-gradle-plugin/src/test/kotlin/app/cash/sqldelight/TestUtil.kt +++ b/sqldelight-gradle-plugin/src/test/kotlin/app/cash/sqldelight/TestUtil.kt @@ -11,19 +11,19 @@ internal fun String.withInvariantPathSeparators() = replace("\\", "/") internal fun SqlDelightPropertiesFileImpl.withInvariantPathSeparators(): SqlDelightPropertiesFile { return copy( - databases = databases.map { it.withInvariantPathSeparators() } + databases = databases.map { it.withInvariantPathSeparators() }, ) } internal fun SqlDelightDatabasePropertiesImpl.withInvariantPathSeparators(): SqlDelightDatabasePropertiesImpl { return copy( - compilationUnits = compilationUnits.map { it.withInvariantPathSeparators() } + compilationUnits = compilationUnits.map { it.withInvariantPathSeparators() }, ) } internal fun SqlDelightDatabasePropertiesImpl.withSortedCompilationUnits(): SqlDelightDatabasePropertiesImpl { return copy( - compilationUnits = compilationUnits.map { it.withSortedSourceFolders() } + compilationUnits = compilationUnits.map { it.withSortedSourceFolders() }, ) } diff --git a/sqldelight-gradle-plugin/src/test/kotlin/app/cash/sqldelight/GradleRunner.kt b/sqldelight-gradle-plugin/src/test/kotlin/app/cash/sqldelight/WithCommonConfiguration.kt similarity index 95% rename from sqldelight-gradle-plugin/src/test/kotlin/app/cash/sqldelight/GradleRunner.kt rename to sqldelight-gradle-plugin/src/test/kotlin/app/cash/sqldelight/WithCommonConfiguration.kt index bb6f01633d2..61de465df7b 100644 --- a/sqldelight-gradle-plugin/src/test/kotlin/app/cash/sqldelight/GradleRunner.kt +++ b/sqldelight-gradle-plugin/src/test/kotlin/app/cash/sqldelight/WithCommonConfiguration.kt @@ -9,7 +9,7 @@ internal fun GradleRunner.withCommonConfiguration(projectRoot: File): GradleRunn |org.gradle.jvmargs=-Xmx4g -XX:MaxMetaspaceSize=1g |android.useAndroidX=true | - """.trimMargin() + """.trimMargin(), ) File(projectRoot, "local.properties").apply { if (!exists()) writeText("sdk.dir=${androidHome()}\n") diff --git a/sqldelight-gradle-plugin/src/test/kotlin/app/cash/sqldelight/assertions/FileSubject.kt b/sqldelight-gradle-plugin/src/test/kotlin/app/cash/sqldelight/assertions/FileSubject.kt index 59c8712d276..9f10dcfea3c 100644 --- a/sqldelight-gradle-plugin/src/test/kotlin/app/cash/sqldelight/assertions/FileSubject.kt +++ b/sqldelight-gradle-plugin/src/test/kotlin/app/cash/sqldelight/assertions/FileSubject.kt @@ -11,7 +11,7 @@ import java.util.ArrayDeque internal class FileSubject private constructor( metadata: FailureMetadata, - private val actual: File + private val actual: File, ) : Subject(metadata, actual) { fun exists() { assertWithMessage("File $actual exists").that(actual.exists()).isTrue() diff --git a/sqldelight-gradle-plugin/src/test/kotlin/app/cash/sqldelight/integrations/IntegrationTest.kt b/sqldelight-gradle-plugin/src/test/kotlin/app/cash/sqldelight/integrations/IntegrationTest.kt index 1379b8d7134..9e7f19241c2 100644 --- a/sqldelight-gradle-plugin/src/test/kotlin/app/cash/sqldelight/integrations/IntegrationTest.kt +++ b/sqldelight-gradle-plugin/src/test/kotlin/app/cash/sqldelight/integrations/IntegrationTest.kt @@ -143,7 +143,9 @@ class IntegrationTest { assertThat(result.output).contains("BUILD SUCCESSFUL") } - @Test @Category(Instrumentation::class) fun integrationTestsAndroid() { + @Test + @Category(Instrumentation::class) + fun integrationTestsAndroid() { val runner = GradleRunner.create() .withCommonConfiguration(File("src/test/integration-android")) .withArguments("clean", "connectedCheck", "--stacktrace") @@ -178,8 +180,8 @@ class IntegrationTest { testDebugResult.task(":generateDebugQueryWrapperInterface"), { "Could not find task in ${testDebugResult.tasks}" - } - ).outcome + }, + ).outcome, ).isEqualTo(TaskOutcome.UP_TO_DATE) val testReleaseResult = runner @@ -191,8 +193,8 @@ class IntegrationTest { testReleaseResult.task(":generateReleaseQueryWrapperInterface"), { "Could not find task in ${testDebugResult.tasks}" - } - ).outcome + }, + ).outcome, ).isEqualTo(TaskOutcome.UP_TO_DATE) } diff --git a/sqldelight-gradle-plugin/src/test/kotlin/app/cash/sqldelight/integrations/VariantTest.kt b/sqldelight-gradle-plugin/src/test/kotlin/app/cash/sqldelight/integrations/VariantTest.kt index 0e19c0aae40..076fabd4dd0 100644 --- a/sqldelight-gradle-plugin/src/test/kotlin/app/cash/sqldelight/integrations/VariantTest.kt +++ b/sqldelight-gradle-plugin/src/test/kotlin/app/cash/sqldelight/integrations/VariantTest.kt @@ -25,12 +25,14 @@ class VariantTest { 8 SELECT _id, some_column1 ^^^^^^^^^^^^ 9 FROM some_table - """.trimIndent() + """.trimIndent(), ) runner.withArguments( - "clean", "generateReleaseDatabaseInterface", - "--stacktrace", "-Dsqldelight.skip.runtime=true" + "clean", + "generateReleaseDatabaseInterface", + "--stacktrace", + "-Dsqldelight.skip.runtime=true", ) .build() } @@ -51,7 +53,7 @@ class VariantTest { 7 SELECT * 8 FROM full_table ^^^^^^^^^^ - """.trimIndent() + """.trimIndent(), ) } @@ -72,14 +74,14 @@ class VariantTest { with(properties.compilationUnits[0]) { assertThat(sourceFolders).containsExactly( SqlDelightSourceFolderImpl(File(fixtureRoot, "src/main/sqldelight"), false), - SqlDelightSourceFolderImpl(File(fixtureRoot, "src/debug/sqldelight"), false) + SqlDelightSourceFolderImpl(File(fixtureRoot, "src/debug/sqldelight"), false), ) } with(properties.compilationUnits[1]) { assertThat(sourceFolders).containsExactly( SqlDelightSourceFolderImpl(File(fixtureRoot, "src/main/sqldelight"), false), - SqlDelightSourceFolderImpl(File(fixtureRoot, "src/release/sqldelight"), false) + SqlDelightSourceFolderImpl(File(fixtureRoot, "src/release/sqldelight"), false), ) } } diff --git a/sqldelight-gradle-plugin/src/test/kotlin/app/cash/sqldelight/properties/MultiModuleTests.kt b/sqldelight-gradle-plugin/src/test/kotlin/app/cash/sqldelight/properties/MultiModuleTests.kt index 4aacf3831eb..57c9b35c6ba 100644 --- a/sqldelight-gradle-plugin/src/test/kotlin/app/cash/sqldelight/properties/MultiModuleTests.kt +++ b/sqldelight-gradle-plugin/src/test/kotlin/app/cash/sqldelight/properties/MultiModuleTests.kt @@ -31,14 +31,13 @@ class MultiModuleTests { assertThat(outputDirectoryFile).isEqualTo(File(fixtureRoot, "build/generated/sqldelight/code/Database")) assertThat(sourceFolders).containsExactly( SqlDelightSourceFolderImpl(File(fixtureRoot, "src/main/sqldelight"), false), - SqlDelightSourceFolderImpl(File(fixtureRoot, "../ProjectB/src/main/sqldelight"), true) + SqlDelightSourceFolderImpl(File(fixtureRoot, "../ProjectB/src/main/sqldelight"), true), ) } } @Test fun integrationTests() { - val runner = GradleRunner.create() .withCommonConfiguration(File("src/test/multi-module")) .withArguments("clean", ":ProjectA:check", "--stacktrace") @@ -80,7 +79,7 @@ class MultiModuleTests { SqlDelightSourceFolderImpl(File(fixtureRoot, "src/debug/sqldelight"), false), SqlDelightSourceFolderImpl(File(fixtureRoot, "src/main/sqldelight"), false), SqlDelightSourceFolderImpl(File(fixtureRoot, "src/minApi23/sqldelight"), false), - SqlDelightSourceFolderImpl(File(fixtureRoot, "src/minApi23Debug/sqldelight"), false) + SqlDelightSourceFolderImpl(File(fixtureRoot, "src/minApi23Debug/sqldelight"), false), ).sortedBy { it.folder.absolutePath }, outputDirectoryFile = File(fixtureRoot, "build/generated/sqldelight/code/CommonDb/minApi23Debug"), ), @@ -91,7 +90,7 @@ class MultiModuleTests { SqlDelightSourceFolderImpl(File(fixtureRoot, "src/main/sqldelight"), false), SqlDelightSourceFolderImpl(File(fixtureRoot, "src/minApi23/sqldelight"), false), SqlDelightSourceFolderImpl(File(fixtureRoot, "src/minApi23Release/sqldelight"), false), - SqlDelightSourceFolderImpl(File(fixtureRoot, "src/release/sqldelight"), false) + SqlDelightSourceFolderImpl(File(fixtureRoot, "src/release/sqldelight"), false), ).sortedBy { it.folder.absolutePath }, outputDirectoryFile = File(fixtureRoot, "build/generated/sqldelight/code/CommonDb/minApi23Release"), ), @@ -102,7 +101,7 @@ class MultiModuleTests { SqlDelightSourceFolderImpl(File(fixtureRoot, "src/main/sqldelight"), false), SqlDelightSourceFolderImpl(File(fixtureRoot, "src/minApi23/sqldelight"), false), SqlDelightSourceFolderImpl(File(fixtureRoot, "src/minApi23Sqldelight/sqldelight"), false), - SqlDelightSourceFolderImpl(File(fixtureRoot, "src/sqldelight/sqldelight"), false) + SqlDelightSourceFolderImpl(File(fixtureRoot, "src/sqldelight/sqldelight"), false), ).sortedBy { it.folder.absolutePath }, outputDirectoryFile = File(fixtureRoot, "build/generated/sqldelight/code/CommonDb/minApi23Sqldelight"), ), @@ -113,7 +112,7 @@ class MultiModuleTests { SqlDelightSourceFolderImpl(File(fixtureRoot, "src/debug/sqldelight"), false), SqlDelightSourceFolderImpl(File(fixtureRoot, "src/main/sqldelight"), false), SqlDelightSourceFolderImpl(File(fixtureRoot, "src/minApi21/sqldelight"), false), - SqlDelightSourceFolderImpl(File(fixtureRoot, "src/minApi21Debug/sqldelight"), false) + SqlDelightSourceFolderImpl(File(fixtureRoot, "src/minApi21Debug/sqldelight"), false), ).sortedBy { it.folder.absolutePath }, outputDirectoryFile = File(fixtureRoot, "build/generated/sqldelight/code/CommonDb/minApi21Debug"), ), @@ -124,7 +123,7 @@ class MultiModuleTests { SqlDelightSourceFolderImpl(File(fixtureRoot, "src/main/sqldelight"), false), SqlDelightSourceFolderImpl(File(fixtureRoot, "src/minApi21/sqldelight"), false), SqlDelightSourceFolderImpl(File(fixtureRoot, "src/minApi21Release/sqldelight"), false), - SqlDelightSourceFolderImpl(File(fixtureRoot, "src/release/sqldelight"), false) + SqlDelightSourceFolderImpl(File(fixtureRoot, "src/release/sqldelight"), false), ).sortedBy { it.folder.absolutePath }, outputDirectoryFile = File(fixtureRoot, "build/generated/sqldelight/code/CommonDb/minApi21Release"), ), @@ -135,10 +134,10 @@ class MultiModuleTests { SqlDelightSourceFolderImpl(File(fixtureRoot, "src/main/sqldelight"), false), SqlDelightSourceFolderImpl(File(fixtureRoot, "src/minApi21/sqldelight"), false), SqlDelightSourceFolderImpl(File(fixtureRoot, "src/minApi21Sqldelight/sqldelight"), false), - SqlDelightSourceFolderImpl(File(fixtureRoot, "src/sqldelight/sqldelight"), false) + SqlDelightSourceFolderImpl(File(fixtureRoot, "src/sqldelight/sqldelight"), false), ).sortedBy { it.folder.absolutePath }, outputDirectoryFile = File(fixtureRoot, "build/generated/sqldelight/code/CommonDb/minApi21Sqldelight"), - ) + ), ) } @@ -167,7 +166,7 @@ class MultiModuleTests { SqlDelightSourceFolderImpl(File(fixtureRoot, "src/main/sqldelight"), false), ), outputDirectoryFile = File(fixtureRoot, "build/generated/sqldelight/code/Database"), - ) + ), ) } diff --git a/sqldelight-gradle-plugin/src/test/kotlin/app/cash/sqldelight/properties/PropertiesFileTest.kt b/sqldelight-gradle-plugin/src/test/kotlin/app/cash/sqldelight/properties/PropertiesFileTest.kt index 5f5d6fc84c9..fca231db11e 100644 --- a/sqldelight-gradle-plugin/src/test/kotlin/app/cash/sqldelight/properties/PropertiesFileTest.kt +++ b/sqldelight-gradle-plugin/src/test/kotlin/app/cash/sqldelight/properties/PropertiesFileTest.kt @@ -28,7 +28,7 @@ class PropertiesFileTest { with(properties.compilationUnits[0]) { assertThat(outputDirectoryFile).isEqualTo(File(fixtureRoot, "build/generated/sqldelight/code/Database")) assertThat(sourceFolders).containsExactly( - SqlDelightSourceFolderImpl(File(fixtureRoot, "src/main/sqldelight"), false) + SqlDelightSourceFolderImpl(File(fixtureRoot, "src/main/sqldelight"), false), ) } } @@ -88,7 +88,7 @@ class PropertiesFileTest { | | targetFromPreset(presets.android, 'androidLib') |} - """.trimMargin() + """.trimMargin(), ) val database = properties().databases.single() @@ -96,10 +96,10 @@ class PropertiesFileTest { SqlDelightCompilationUnitImpl( name = "commonMain", sourceFolders = listOf( - SqlDelightSourceFolderImpl(File(fixtureRoot, "src/commonMain/sqldelight"), dependency = false) + SqlDelightSourceFolderImpl(File(fixtureRoot, "src/commonMain/sqldelight"), dependency = false), ), outputDirectoryFile = File(fixtureRoot, "build/generated/sqldelight/code/CashDatabase"), - ) + ), ) } } diff --git a/sqldelight-gradle-plugin/src/test/kotlin/app/cash/sqldelight/tests/CompilationUnitTests.kt b/sqldelight-gradle-plugin/src/test/kotlin/app/cash/sqldelight/tests/CompilationUnitTests.kt index f37f24b842d..dc3dbc7e9b8 100644 --- a/sqldelight-gradle-plugin/src/test/kotlin/app/cash/sqldelight/tests/CompilationUnitTests.kt +++ b/sqldelight-gradle-plugin/src/test/kotlin/app/cash/sqldelight/tests/CompilationUnitTests.kt @@ -32,7 +32,7 @@ class CompilationUnitTests { | packageName = "com.sample" | } |} - """.trimMargin() + """.trimMargin(), ) properties().let { properties -> @@ -45,8 +45,8 @@ class CompilationUnitTests { SqlDelightCompilationUnitImpl( name = "main", sourceFolders = listOf(SqlDelightSourceFolderImpl(File(fixtureRoot, "src/main/sqldelight"), false)), - outputDirectoryFile = File(fixtureRoot, "build/generated/sqldelight/code/CommonDb") - ) + outputDirectoryFile = File(fixtureRoot, "build/generated/sqldelight/code/CommonDb"), + ), ) } } @@ -81,7 +81,7 @@ class CompilationUnitTests { | treatNullAsUnknownForEquality = true | } |} - """.trimMargin() + """.trimMargin(), ) properties().let { properties -> @@ -94,10 +94,10 @@ class CompilationUnitTests { name = "main", sourceFolders = listOf(SqlDelightSourceFolderImpl(File(fixtureRoot, "src/main/sqldelight"), false)), outputDirectoryFile = File(fixtureRoot, "build/generated/sqldelight/code/CommonDb"), - ) + ), ), dependencies = emptyList(), - rootDirectory = fixtureRoot + rootDirectory = fixtureRoot, ), SqlDelightDatabasePropertiesImpl( className = "OtherDb", @@ -110,12 +110,12 @@ class CompilationUnitTests { SqlDelightSourceFolderImpl(File(fixtureRoot, "src/main/sqldelight"), false), ), outputDirectoryFile = File(fixtureRoot, "build/generated/sqldelight/code/OtherDb"), - ) + ), ), dependencies = emptyList(), rootDirectory = fixtureRoot, - treatNullAsUnknownForEquality = true - ) + treatNullAsUnknownForEquality = true, + ), ) } } @@ -153,7 +153,7 @@ class CompilationUnitTests { | targetFromPreset(presets.iosX64, 'iosX64') | targetFromPreset(presets.macosX64, 'macosX64') |} - """.trimMargin() + """.trimMargin(), ) properties().let { properties -> @@ -166,8 +166,8 @@ class CompilationUnitTests { SqlDelightCompilationUnitImpl( name = "commonMain", sourceFolders = listOf(SqlDelightSourceFolderImpl(File(fixtureRoot, "src/commonMain/sqldelight"), false)), - outputDirectoryFile = File(fixtureRoot, "build/generated/sqldelight/code/CommonDb") - ) + outputDirectoryFile = File(fixtureRoot, "build/generated/sqldelight/code/CommonDb"), + ), ) } } @@ -230,7 +230,7 @@ class CompilationUnitTests { | targetFromPreset(presets.iosX64, 'iosX64') | targetFromPreset(presets.android, 'androidLib') |} - """.trimMargin() + """.trimMargin(), ) properties().let { properties -> @@ -244,7 +244,7 @@ class CompilationUnitTests { name = "commonMain", sourceFolders = listOf(SqlDelightSourceFolderImpl(File(fixtureRoot, "src/commonMain/sqldelight"), false)), outputDirectoryFile = File(fixtureRoot, "build/generated/sqldelight/code/CommonDb"), - ) + ), ) } } @@ -302,7 +302,7 @@ class CompilationUnitTests { | } | } |} - """.trimMargin() + """.trimMargin(), ) properties().let { properties -> @@ -320,7 +320,7 @@ class CompilationUnitTests { SqlDelightSourceFolderImpl(File(fixtureRoot, "src/main/sqldelight"), false), SqlDelightSourceFolderImpl(File(fixtureRoot, "src/minApi23/sqldelight"), false), SqlDelightSourceFolderImpl(File(fixtureRoot, "src/minApi23Demo/sqldelight"), false), - SqlDelightSourceFolderImpl(File(fixtureRoot, "src/minApi23DemoDebug/sqldelight"), false) + SqlDelightSourceFolderImpl(File(fixtureRoot, "src/minApi23DemoDebug/sqldelight"), false), ).sortedBy { it.folder.absolutePath }, outputDirectoryFile = File(fixtureRoot, "build/generated/sqldelight/code/CommonDb/minApi23DemoDebug"), ), @@ -332,7 +332,7 @@ class CompilationUnitTests { SqlDelightSourceFolderImpl(File(fixtureRoot, "src/minApi23/sqldelight"), false), SqlDelightSourceFolderImpl(File(fixtureRoot, "src/minApi23Demo/sqldelight"), false), SqlDelightSourceFolderImpl(File(fixtureRoot, "src/minApi23DemoRelease/sqldelight"), false), - SqlDelightSourceFolderImpl(File(fixtureRoot, "src/release/sqldelight"), false) + SqlDelightSourceFolderImpl(File(fixtureRoot, "src/release/sqldelight"), false), ).sortedBy { it.folder.absolutePath }, outputDirectoryFile = File(fixtureRoot, "build/generated/sqldelight/code/CommonDb/minApi23DemoRelease"), ), @@ -344,7 +344,7 @@ class CompilationUnitTests { SqlDelightSourceFolderImpl(File(fixtureRoot, "src/minApi23/sqldelight"), false), SqlDelightSourceFolderImpl(File(fixtureRoot, "src/minApi23Demo/sqldelight"), false), SqlDelightSourceFolderImpl(File(fixtureRoot, "src/minApi23DemoSqldelight/sqldelight"), false), - SqlDelightSourceFolderImpl(File(fixtureRoot, "src/sqldelight/sqldelight"), false) + SqlDelightSourceFolderImpl(File(fixtureRoot, "src/sqldelight/sqldelight"), false), ).sortedBy { it.folder.absolutePath }, outputDirectoryFile = File(fixtureRoot, "build/generated/sqldelight/code/CommonDb/minApi23DemoSqldelight"), ), @@ -356,7 +356,7 @@ class CompilationUnitTests { SqlDelightSourceFolderImpl(File(fixtureRoot, "src/main/sqldelight"), false), SqlDelightSourceFolderImpl(File(fixtureRoot, "src/minApi23/sqldelight"), false), SqlDelightSourceFolderImpl(File(fixtureRoot, "src/minApi23Full/sqldelight"), false), - SqlDelightSourceFolderImpl(File(fixtureRoot, "src/minApi23FullDebug/sqldelight"), false) + SqlDelightSourceFolderImpl(File(fixtureRoot, "src/minApi23FullDebug/sqldelight"), false), ).sortedBy { it.folder.absolutePath }, outputDirectoryFile = File(fixtureRoot, "build/generated/sqldelight/code/CommonDb/minApi23FullDebug"), ), @@ -368,7 +368,7 @@ class CompilationUnitTests { SqlDelightSourceFolderImpl(File(fixtureRoot, "src/minApi23/sqldelight"), false), SqlDelightSourceFolderImpl(File(fixtureRoot, "src/minApi23Full/sqldelight"), false), SqlDelightSourceFolderImpl(File(fixtureRoot, "src/minApi23FullRelease/sqldelight"), false), - SqlDelightSourceFolderImpl(File(fixtureRoot, "src/release/sqldelight"), false) + SqlDelightSourceFolderImpl(File(fixtureRoot, "src/release/sqldelight"), false), ).sortedBy { it.folder.absolutePath }, outputDirectoryFile = File(fixtureRoot, "build/generated/sqldelight/code/CommonDb/minApi23FullRelease"), ), @@ -380,7 +380,7 @@ class CompilationUnitTests { SqlDelightSourceFolderImpl(File(fixtureRoot, "src/minApi23/sqldelight"), false), SqlDelightSourceFolderImpl(File(fixtureRoot, "src/minApi23Full/sqldelight"), false), SqlDelightSourceFolderImpl(File(fixtureRoot, "src/minApi23FullSqldelight/sqldelight"), false), - SqlDelightSourceFolderImpl(File(fixtureRoot, "src/sqldelight/sqldelight"), false) + SqlDelightSourceFolderImpl(File(fixtureRoot, "src/sqldelight/sqldelight"), false), ).sortedBy { it.folder.absolutePath }, outputDirectoryFile = File(fixtureRoot, "build/generated/sqldelight/code/CommonDb/minApi23FullSqldelight"), ), @@ -392,7 +392,7 @@ class CompilationUnitTests { SqlDelightSourceFolderImpl(File(fixtureRoot, "src/main/sqldelight"), false), SqlDelightSourceFolderImpl(File(fixtureRoot, "src/minApi21/sqldelight"), false), SqlDelightSourceFolderImpl(File(fixtureRoot, "src/minApi21Demo/sqldelight"), false), - SqlDelightSourceFolderImpl(File(fixtureRoot, "src/minApi21DemoDebug/sqldelight"), false) + SqlDelightSourceFolderImpl(File(fixtureRoot, "src/minApi21DemoDebug/sqldelight"), false), ).sortedBy { it.folder.absolutePath }, outputDirectoryFile = File(fixtureRoot, "build/generated/sqldelight/code/CommonDb/minApi21DemoDebug"), ), @@ -404,7 +404,7 @@ class CompilationUnitTests { SqlDelightSourceFolderImpl(File(fixtureRoot, "src/minApi21/sqldelight"), false), SqlDelightSourceFolderImpl(File(fixtureRoot, "src/minApi21Demo/sqldelight"), false), SqlDelightSourceFolderImpl(File(fixtureRoot, "src/minApi21DemoRelease/sqldelight"), false), - SqlDelightSourceFolderImpl(File(fixtureRoot, "src/release/sqldelight"), false) + SqlDelightSourceFolderImpl(File(fixtureRoot, "src/release/sqldelight"), false), ).sortedBy { it.folder.absolutePath }, outputDirectoryFile = File(fixtureRoot, "build/generated/sqldelight/code/CommonDb/minApi21DemoRelease"), ), @@ -416,7 +416,7 @@ class CompilationUnitTests { SqlDelightSourceFolderImpl(File(fixtureRoot, "src/minApi21/sqldelight"), false), SqlDelightSourceFolderImpl(File(fixtureRoot, "src/minApi21Demo/sqldelight"), false), SqlDelightSourceFolderImpl(File(fixtureRoot, "src/minApi21DemoSqldelight/sqldelight"), false), - SqlDelightSourceFolderImpl(File(fixtureRoot, "src/sqldelight/sqldelight"), false) + SqlDelightSourceFolderImpl(File(fixtureRoot, "src/sqldelight/sqldelight"), false), ).sortedBy { it.folder.absolutePath }, outputDirectoryFile = File(fixtureRoot, "build/generated/sqldelight/code/CommonDb/minApi21DemoSqldelight"), ), @@ -428,7 +428,7 @@ class CompilationUnitTests { SqlDelightSourceFolderImpl(File(fixtureRoot, "src/main/sqldelight"), false), SqlDelightSourceFolderImpl(File(fixtureRoot, "src/minApi21/sqldelight"), false), SqlDelightSourceFolderImpl(File(fixtureRoot, "src/minApi21Full/sqldelight"), false), - SqlDelightSourceFolderImpl(File(fixtureRoot, "src/minApi21FullDebug/sqldelight"), false) + SqlDelightSourceFolderImpl(File(fixtureRoot, "src/minApi21FullDebug/sqldelight"), false), ).sortedBy { it.folder.absolutePath }, outputDirectoryFile = File(fixtureRoot, "build/generated/sqldelight/code/CommonDb/minApi21FullDebug"), ), @@ -440,7 +440,7 @@ class CompilationUnitTests { SqlDelightSourceFolderImpl(File(fixtureRoot, "src/minApi21/sqldelight"), false), SqlDelightSourceFolderImpl(File(fixtureRoot, "src/minApi21Full/sqldelight"), false), SqlDelightSourceFolderImpl(File(fixtureRoot, "src/minApi21FullRelease/sqldelight"), false), - SqlDelightSourceFolderImpl(File(fixtureRoot, "src/release/sqldelight"), false) + SqlDelightSourceFolderImpl(File(fixtureRoot, "src/release/sqldelight"), false), ).sortedBy { it.folder.absolutePath }, outputDirectoryFile = File(fixtureRoot, "build/generated/sqldelight/code/CommonDb/minApi21FullRelease"), ), @@ -452,10 +452,10 @@ class CompilationUnitTests { SqlDelightSourceFolderImpl(File(fixtureRoot, "src/minApi21/sqldelight"), false), SqlDelightSourceFolderImpl(File(fixtureRoot, "src/minApi21Full/sqldelight"), false), SqlDelightSourceFolderImpl(File(fixtureRoot, "src/minApi21FullSqldelight/sqldelight"), false), - SqlDelightSourceFolderImpl(File(fixtureRoot, "src/sqldelight/sqldelight"), false) + SqlDelightSourceFolderImpl(File(fixtureRoot, "src/sqldelight/sqldelight"), false), ).sortedBy { it.folder.absolutePath }, outputDirectoryFile = File(fixtureRoot, "build/generated/sqldelight/code/CommonDb/minApi21FullSqldelight"), - ) + ), ) } } diff --git a/sqldelight-gradle-plugin/src/test/kotlin/app/cash/sqldelight/tests/FailureTest.kt b/sqldelight-gradle-plugin/src/test/kotlin/app/cash/sqldelight/tests/FailureTest.kt index 650596e363f..82cecf7afa9 100644 --- a/sqldelight-gradle-plugin/src/test/kotlin/app/cash/sqldelight/tests/FailureTest.kt +++ b/sqldelight-gradle-plugin/src/test/kotlin/app/cash/sqldelight/tests/FailureTest.kt @@ -22,7 +22,8 @@ class FailureTest { |1 CREATE TABLE test ( |2 value TEXT |3 ); - |""".trimMargin() + | + """.trimMargin(), ) } } diff --git a/sqldelight-gradle-plugin/src/test/kotlin/app/cash/sqldelight/tests/GradlePluginCombinationTests.kt b/sqldelight-gradle-plugin/src/test/kotlin/app/cash/sqldelight/tests/GradlePluginCombinationTests.kt index ce28ad73ed7..e92f5777a35 100644 --- a/sqldelight-gradle-plugin/src/test/kotlin/app/cash/sqldelight/tests/GradlePluginCombinationTests.kt +++ b/sqldelight-gradle-plugin/src/test/kotlin/app/cash/sqldelight/tests/GradlePluginCombinationTests.kt @@ -41,7 +41,7 @@ class GradlePluginCombinationTests { |kotlin { | android() |} - """.trimMargin() + """.trimMargin(), ) configure() @@ -90,7 +90,7 @@ class GradlePluginCombinationTests { | } |} | - """.trimMargin() + """.trimMargin(), ) configure("checkForSqlite") } diff --git a/sqldelight-gradle-plugin/src/test/kotlin/app/cash/sqldelight/tests/MigrationSquashTest.kt b/sqldelight-gradle-plugin/src/test/kotlin/app/cash/sqldelight/tests/MigrationSquashTest.kt index c3e5c77d323..7f6cbd92caa 100644 --- a/sqldelight-gradle-plugin/src/test/kotlin/app/cash/sqldelight/tests/MigrationSquashTest.kt +++ b/sqldelight-gradle-plugin/src/test/kotlin/app/cash/sqldelight/tests/MigrationSquashTest.kt @@ -13,7 +13,7 @@ import java.io.File @RunWith(TestParameterInjector::class) class MigrationSquashTest { @Test fun `squash migrations`( - @TestParameter("mysql", "postgres", "sqlite") dialect: String + @TestParameter("mysql", "postgres", "sqlite") dialect: String, ) { val output = GradleRunner.create() .withCommonConfiguration(File("src/test/migration-squash")) @@ -28,7 +28,7 @@ class MigrationSquashTest { assertWithMessage("Expected ${expected.name} to be generated").that(actual.exists()).isTrue() try { assertWithMessage( - "The squashed migration ${expected.name} looks different when generated fresh:" + "The squashed migration ${expected.name} looks different when generated fresh:", ).that(actual.readText()).isEqualTo(expected.readText()) } finally { actual.delete() diff --git a/sqldelight-gradle-plugin/src/test/kotlin/app/cash/sqldelight/tests/MigrationTest.kt b/sqldelight-gradle-plugin/src/test/kotlin/app/cash/sqldelight/tests/MigrationTest.kt index 49361a9b892..b8a98f14c6f 100644 --- a/sqldelight-gradle-plugin/src/test/kotlin/app/cash/sqldelight/tests/MigrationTest.kt +++ b/sqldelight-gradle-plugin/src/test/kotlin/app/cash/sqldelight/tests/MigrationTest.kt @@ -14,7 +14,7 @@ class MigrationTest { .buildAndFail() assertThat(output.output).contains( - "Verifying a migration requires a database file to be present. To generate one, use the generate Gradle task." + "Verifying a migration requires a database file to be present. To generate one, use the generate Gradle task.", ) } @@ -66,7 +66,8 @@ class MigrationTest { | , value2 TEXT) |/tables[test]/indexes[test.testIndex] - ADDED |/tables[test]/triggers[test.testTrigger] - ADDED - |""".trimMargin() + | + """.trimMargin(), ) } @@ -106,7 +107,8 @@ class MigrationTest { | CREATE VIEW testView AS | SELECT * | FROM test - |""".trimMargin() + | + """.trimMargin(), ) } @@ -120,7 +122,7 @@ class MigrationTest { """ |1.sqm: (1, 5): TABLE expected, got 'TABE' |1 ALTER TABE test ADD COLUMN value2 TEXT - """.trimMargin() + """.trimMargin(), ) } @@ -136,7 +138,7 @@ class MigrationTest { |5 INSERT INTO test (id, new_column) | ^^^^^^^^^^ |6 VALUES ("hello", "world") - """.trimMargin() + """.trimMargin(), ) } @@ -292,7 +294,8 @@ class MigrationTest { | } | } |} - |""".trimMargin() + | + """.trimMargin(), ) } } diff --git a/sqldelight-gradle-plugin/src/test/kotlin/app/cash/sqldelight/tests/PluginTest.kt b/sqldelight-gradle-plugin/src/test/kotlin/app/cash/sqldelight/tests/PluginTest.kt index e80c2087820..0a11def957b 100644 --- a/sqldelight-gradle-plugin/src/test/kotlin/app/cash/sqldelight/tests/PluginTest.kt +++ b/sqldelight-gradle-plugin/src/test/kotlin/app/cash/sqldelight/tests/PluginTest.kt @@ -15,7 +15,7 @@ class PluginTest { .buildAndFail() assertThat(result.output) .contains( - "SQL Delight Gradle plugin applied in project ':' but no supported Kotlin plugin was found" + "SQL Delight Gradle plugin applied in project ':' but no supported Kotlin plugin was found", ) } @@ -27,7 +27,7 @@ class PluginTest { .buildAndFail() assertThat(result.output) .contains( - "SQL Delight Gradle plugin applied in project ':' but no supported Kotlin plugin was found" + "SQL Delight Gradle plugin applied in project ':' but no supported Kotlin plugin was found", ) } diff --git a/sqldelight-gradle-plugin/src/test/multi-module/AndroidProject/androidTest/java/com/squareup/sqldelight/integration/IntegrationTests.kt b/sqldelight-gradle-plugin/src/test/multi-module/AndroidProject/androidTest/java/com/squareup/sqldelight/integration/IntegrationTests.kt index 8b7ffd9f457..8d7aa11d91e 100644 --- a/sqldelight-gradle-plugin/src/test/multi-module/AndroidProject/androidTest/java/com/squareup/sqldelight/integration/IntegrationTests.kt +++ b/sqldelight-gradle-plugin/src/test/multi-module/AndroidProject/androidTest/java/com/squareup/sqldelight/integration/IntegrationTests.kt @@ -22,11 +22,13 @@ class IntegrationTests { var timesNotified = 0 val selectData = database.otherQueries.selectData() - selectData.addListener(object : Query.Listener { - override fun queryResultsChanged() { - timesNotified++ - } - }) + selectData.addListener( + object : Query.Listener { + override fun queryResultsChanged() { + timesNotified++ + } + }, + ) assertThat(selectData.executeAsList()).containsExactly("first_value") diff --git a/sqldelight-gradle-plugin/src/test/multi-module/ProjectA/src/test/java/com/squareup/sqldelight/integration/IntegrationTests.kt b/sqldelight-gradle-plugin/src/test/multi-module/ProjectA/src/test/java/com/squareup/sqldelight/integration/IntegrationTests.kt index c609f70ae3a..9257c37eebf 100644 --- a/sqldelight-gradle-plugin/src/test/multi-module/ProjectA/src/test/java/com/squareup/sqldelight/integration/IntegrationTests.kt +++ b/sqldelight-gradle-plugin/src/test/multi-module/ProjectA/src/test/java/com/squareup/sqldelight/integration/IntegrationTests.kt @@ -22,11 +22,13 @@ class IntegrationTests { var timesNotified = 0 val selectData = database.otherQueries.selectData() - selectData.addListener(object : Query.Listener { - override fun queryResultsChanged() { - timesNotified++ - } - }) + selectData.addListener( + object : Query.Listener { + override fun queryResultsChanged() { + timesNotified++ + } + }, + ) assertThat(selectData.executeAsList()).containsExactly("first_value") diff --git a/sqldelight-gradle-plugin/src/test/multithreaded-sqlite/src/main/kotlin/com/example/db/DbHelper.kt b/sqldelight-gradle-plugin/src/test/multithreaded-sqlite/src/main/kotlin/com/example/db/DbHelper.kt index fd09c029ac9..3fc49203827 100644 --- a/sqldelight-gradle-plugin/src/test/multithreaded-sqlite/src/main/kotlin/com/example/db/DbHelper.kt +++ b/sqldelight-gradle-plugin/src/test/multithreaded-sqlite/src/main/kotlin/com/example/db/DbHelper.kt @@ -16,7 +16,7 @@ import java.util.Properties */ class DbHelper( journalMode: String = "", - foreignKeys: Boolean = false + foreignKeys: Boolean = false, ) { val database: Database by lazy { if (journalMode.isNotEmpty()) { diff --git a/sqldelight-gradle-plugin/src/test/multithreaded-sqlite/src/main/kotlin/com/example/db/utils.kt b/sqldelight-gradle-plugin/src/test/multithreaded-sqlite/src/main/kotlin/com/example/db/Utils.kt similarity index 100% rename from sqldelight-gradle-plugin/src/test/multithreaded-sqlite/src/main/kotlin/com/example/db/utils.kt rename to sqldelight-gradle-plugin/src/test/multithreaded-sqlite/src/main/kotlin/com/example/db/Utils.kt diff --git a/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/FileIndex.kt b/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/FileIndex.kt index 0191e0b8859..9ad9c352a83 100644 --- a/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/FileIndex.kt +++ b/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/FileIndex.kt @@ -30,7 +30,7 @@ import java.io.File class FileIndex( private val properties: SqlDelightDatabaseProperties, override val contentRoot: VirtualFile = - LocalFileSystem.getInstance().findFileByPath(properties.rootDirectory.absolutePath)!! + LocalFileSystem.getInstance().findFileByPath(properties.rootDirectory.absolutePath)!!, ) : SqlDelightFileIndex { override val isConfigured = true override val packageName = properties.packageName @@ -74,7 +74,7 @@ class FileIndex( override fun sourceFolders( file: VirtualFile, - includeDependencies: Boolean + includeDependencies: Boolean, ): Collection { return properties.compilationUnits.map { it.sourceFolders @@ -96,7 +96,7 @@ class FileIndex( override fun sourceFolders( file: SqlDelightFile, - includeDependencies: Boolean + includeDependencies: Boolean, ): Collection { return sourceFolders(file.virtualFile!!, includeDependencies) .map { PsiManager.getInstance(file.project).findDirectory(it)!! } @@ -104,7 +104,7 @@ class FileIndex( private fun File.localVirtualFile() = contentRoot.findFileByRelativePath( this.relativeTo( - File(contentRoot.path) - ).path.replace(File.separatorChar, '/').trimEnd('/') + File(contentRoot.path), + ).path.replace(File.separatorChar, '/').trimEnd('/'), ) } diff --git a/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/GradleSystemListener.kt b/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/GradleSystemListener.kt index 17dbfecf235..3876118dc52 100644 --- a/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/GradleSystemListener.kt +++ b/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/GradleSystemListener.kt @@ -11,7 +11,7 @@ import org.jetbrains.kotlin.idea.framework.GRADLE_SYSTEM_ID class GradleSystemListener : ExternalSystemTaskNotificationListenerAdapter() { override fun onStart( id: ExternalSystemTaskId, - workingDir: String? + workingDir: String?, ) { if (id.projectSystemId == GRADLE_SYSTEM_ID && id.type == RESOLVE_PROJECT) { // Gradle sync just started, pause our existing import if one is happening. diff --git a/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/LoggerTree.kt b/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/LoggerTree.kt index 04fda7b2a44..15f53eb492e 100644 --- a/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/LoggerTree.kt +++ b/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/LoggerTree.kt @@ -4,7 +4,7 @@ import com.intellij.openapi.diagnostic.Logger import timber.log.Timber internal class LoggerTree( - private val logger: Logger + private val logger: Logger, ) : Timber.Tree() { override fun v(message: String?, vararg args: Any?) { logger.info(String.format(message!!, args)) diff --git a/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/ProjectService.kt b/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/ProjectService.kt index 46fa5a452fe..cf5fc8e49d2 100644 --- a/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/ProjectService.kt +++ b/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/ProjectService.kt @@ -86,7 +86,7 @@ class ProjectService(val project: Project) : SqlDelightProjectService, Disposabl } } } - } + }, ) } } @@ -148,7 +148,7 @@ class ProjectService(val project: Project) : SqlDelightProjectService, Disposabl contentFactory = SqlDelightToolWindowFactory(connectionManager), canCloseContent = true, icon = dialect.icon, - ) + ), ).apply { show() hide() diff --git a/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/SqlDelightClassCompletionContributor.kt b/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/SqlDelightClassCompletionContributor.kt index 4d3547b41db..f31beb1a336 100644 --- a/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/SqlDelightClassCompletionContributor.kt +++ b/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/SqlDelightClassCompletionContributor.kt @@ -44,7 +44,7 @@ class SqlDelightClassCompletionContributor : JavaClassNameCompletionContributor( override fun fillCompletionVariants( parameters: CompletionParameters, - resultSet: CompletionResultSet + resultSet: CompletionResultSet, ) { if (parameters.position.getNonStrictParentOfType() == null) return @@ -82,7 +82,7 @@ class SqlDelightClassCompletionContributor : JavaClassNameCompletionContributor( private fun getKotlinClasses( project: Project, prefixMatcher: PrefixMatcher, - scope: GlobalSearchScope + scope: GlobalSearchScope, ): List { val index = KotlinFullClassNameIndex.getInstance() return index.getAllKeys(project) @@ -126,7 +126,7 @@ private class AutoImportInsertionHandler : InsertHandler { private fun InsertionContext.insertAndOrganizeImports( imports: Collection, - newImport: String + newImport: String, ) { val newImports = arrayListOf(newImport) var endOffset = 0 diff --git a/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/SqlDelightClassNameElementAnnotator.kt b/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/SqlDelightClassNameElementAnnotator.kt index 8007a51dffe..97d8a09efe1 100644 --- a/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/SqlDelightClassNameElementAnnotator.kt +++ b/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/SqlDelightClassNameElementAnnotator.kt @@ -78,7 +78,7 @@ internal class SqlDelightClassNameElementAnnotator : Annotator { private fun missingNestedClass( classes: List, - javaTypeMixin: JavaTypeMixin + javaTypeMixin: JavaTypeMixin, ): PsiElement { val elementText = javaTypeMixin.text val className = classes.map { clazz -> findMissingNestedClassName(clazz, elementText) } diff --git a/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/SqlDelightColorSettingsPage.kt b/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/SqlDelightColorSettingsPage.kt index eadbcf90344..7514d33191b 100644 --- a/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/SqlDelightColorSettingsPage.kt +++ b/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/SqlDelightColorSettingsPage.kt @@ -95,6 +95,7 @@ class SqlDelightColorSettingsPage : ColorSettingsPage { |selectById: |SELECT id AS ProductID, title AS ProductName | FROM crm.product
WHERE id = ?; - |""".trimMargin() + | + """.trimMargin() } } diff --git a/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/SqlDelightCopyPasteProcessor.kt b/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/SqlDelightCopyPasteProcessor.kt index 68e585b45a3..43ed22d0192 100644 --- a/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/SqlDelightCopyPasteProcessor.kt +++ b/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/SqlDelightCopyPasteProcessor.kt @@ -34,7 +34,7 @@ class SqlDelightCopyPasteProcessor : CopyPastePostProcessor { if (file !is SqlDelightFile) { return emptyList() @@ -59,7 +59,7 @@ class SqlDelightCopyPasteProcessor : CopyPastePostProcessor, - values: MutableList + values: MutableList, ) { if (DumbService.getInstance(project).isDumb) { return diff --git a/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/SqlDelightErrorHandler.kt b/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/SqlDelightErrorHandler.kt index 01e98cbef42..51da547fb7d 100644 --- a/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/SqlDelightErrorHandler.kt +++ b/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/SqlDelightErrorHandler.kt @@ -54,7 +54,7 @@ class SqlDelightErrorHandler : ErrorReportSubmitter() { events: Array, additionalInfo: String?, parentComponent: Component, - consumer: Consumer + consumer: Consumer, ): Boolean { for (event in events) { if (BUGSNAG_KEY.isNotBlank()) { diff --git a/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/SqlDelightFileIndexImpl.kt b/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/SqlDelightFileIndexImpl.kt index d900ebc0422..0de08f959c3 100644 --- a/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/SqlDelightFileIndexImpl.kt +++ b/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/SqlDelightFileIndexImpl.kt @@ -23,10 +23,10 @@ internal class SqlDelightFileIndexImpl : SqlDelightFileIndex { override fun packageName(file: SqlDelightFile) = "" override fun sourceFolders( file: VirtualFile, - includeDependencies: Boolean + includeDependencies: Boolean, ) = listOf(file.parent) override fun sourceFolders( file: SqlDelightFile, - includeDependencies: Boolean + includeDependencies: Boolean, ) = listOfNotNull(file.parent) } diff --git a/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/SqlDelightFindUsagesHandlerFactory.kt b/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/SqlDelightFindUsagesHandlerFactory.kt index cbabffbb26d..96eec44a332 100644 --- a/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/SqlDelightFindUsagesHandlerFactory.kt +++ b/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/SqlDelightFindUsagesHandlerFactory.kt @@ -36,12 +36,12 @@ class SqlDelightFindUsagesHandlerFactory : FindUsagesHandlerFactory() { override fun createFindUsagesHandler( element: PsiElement, - forHighlightUsages: Boolean + forHighlightUsages: Boolean, ): FindUsagesHandler = SqlDelightIdentifierHandler(element) } private class SqlDelightIdentifierHandler( - private val element: PsiElement + private val element: PsiElement, ) : FindUsagesHandler(element) { private val factory = KotlinFindUsagesHandlerFactory(element.project) private val kotlinHandlers = when (element) { @@ -62,7 +62,7 @@ private class SqlDelightIdentifierHandler( override fun processElementUsages( sourceElement: PsiElement, processor: Processor, - options: FindUsagesOptions + options: FindUsagesOptions, ): Boolean { val generatedFiles = element.generatedVirtualFiles() val ignoringFileProcessor = Processor { t -> @@ -78,9 +78,9 @@ private class SqlDelightIdentifierHandler( it.processElementUsages( it.primaryElements.single(), ignoringFileProcessor, - kotlinFindUsagesOptions + kotlinFindUsagesOptions, ) - } + }, ) } } diff --git a/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/SqlDelightFindUsagesProvider.kt b/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/SqlDelightFindUsagesProvider.kt index ea0461fbb93..5a115276087 100644 --- a/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/SqlDelightFindUsagesProvider.kt +++ b/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/SqlDelightFindUsagesProvider.kt @@ -34,7 +34,7 @@ class SqlDelightFindUsagesProvider : FindUsagesProvider { override fun canFindUsagesFor(element: PsiElement): Boolean { return when (element) { is StmtIdentifierMixin, is SqlTableName, is SqlColumnName, is SqlTableAlias, - is SqlColumnAlias, is SqlViewName, is SqlCteTableName, is SqlNewTableName -> true + is SqlColumnAlias, is SqlViewName, is SqlCteTableName, is SqlNewTableName, -> true else -> false } } diff --git a/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/SqlDelightGotoDeclarationHandler.kt b/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/SqlDelightGotoDeclarationHandler.kt index 9dcefe1137a..0a19f45dc75 100644 --- a/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/SqlDelightGotoDeclarationHandler.kt +++ b/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/SqlDelightGotoDeclarationHandler.kt @@ -55,7 +55,7 @@ class SqlDelightGotoDeclarationHandler : GotoDeclarationHandler { override fun getGotoDeclarationTargets( sourceElement: PsiElement?, offset: Int, - editor: Editor + editor: Editor, ): Array { if (sourceElement == null) { return emptyArray() @@ -63,7 +63,7 @@ class SqlDelightGotoDeclarationHandler : GotoDeclarationHandler { val targetData = ProgressManager.getInstance().runProcess( Computable { targetData(sourceElement) }, - EmptyProgressIndicator().also { it.start() } + EmptyProgressIndicator().also { it.start() }, ) ?: return emptyArray() val function = targetData.function val elementFile = targetData.containingFile @@ -131,13 +131,13 @@ class SqlDelightGotoDeclarationHandler : GotoDeclarationHandler { TargetData( parameter = resolved, function = element.getParentOfType(true)!!, - containingFile = element.containingFile.virtualFile + containingFile = element.containingFile.virtualFile, ) } is KtNamedFunction, is PsiMethod -> TargetData( parameter = null, function = resolved as PsiNamedElement, - containingFile = resolved.containingFile?.virtualFile + containingFile = resolved.containingFile?.virtualFile, ) else -> null } @@ -148,6 +148,6 @@ class SqlDelightGotoDeclarationHandler : GotoDeclarationHandler { data class TargetData( val parameter: PsiNamedElement?, val function: PsiNamedElement, - val containingFile: VirtualFile? + val containingFile: VirtualFile?, ) } diff --git a/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/SqlDelightParameterInfoHandler.kt b/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/SqlDelightParameterInfoHandler.kt index 515ad048db8..694298cf952 100644 --- a/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/SqlDelightParameterInfoHandler.kt +++ b/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/SqlDelightParameterInfoHandler.kt @@ -26,7 +26,7 @@ class SqlDelightParameterInfoHandler : ParameterInfoHandlerWithTabActionSupport< override fun getParametersForLookup( item: LookupElement, - context: ParameterInfoContext + context: ParameterInfoContext, ): Array { return emptyArray() } @@ -63,14 +63,14 @@ class SqlDelightParameterInfoHandler : ParameterInfoHandlerWithTabActionSupport< override fun showParameterInfo( element: SqlValuesExpression, - context: CreateParameterInfoContext + context: CreateParameterInfoContext, ) { context.showHint(element, element.textRange.startOffset, this) } override fun updateParameterInfo( parameterOwner: SqlValuesExpression, - context: UpdateParameterInfoContext + context: UpdateParameterInfoContext, ) { val offset = context.offset val index = ParameterInfoUtils.getCurrentParameterIndex(parameterOwner.node, offset, SqlTypes.COMMA) @@ -94,7 +94,7 @@ class SqlDelightParameterInfoHandler : ParameterInfoHandlerWithTabActionSupport< !context.isUIComponentEnabled, false, false, - context.defaultParameterColor + context.defaultParameterColor, ) } diff --git a/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/SqlDelightReferenceContributor.kt b/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/SqlDelightReferenceContributor.kt index c064a51bfff..56b13ef320d 100644 --- a/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/SqlDelightReferenceContributor.kt +++ b/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/SqlDelightReferenceContributor.kt @@ -25,11 +25,11 @@ internal class SqlDelightReferenceContributor : PsiReferenceContributor() { object : PsiReferenceProvider() { override fun getReferencesByElement( element: PsiElement, - context: ProcessingContext + context: ProcessingContext, ): Array { return arrayOf(JavaTypeReference(element as JavaTypeMixin)) } - } + }, ) } diff --git a/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/SqlDelightRenameProcessor.kt b/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/SqlDelightRenameProcessor.kt index c1612176279..a1caa322cbd 100644 --- a/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/SqlDelightRenameProcessor.kt +++ b/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/SqlDelightRenameProcessor.kt @@ -35,7 +35,7 @@ class SqlDelightRenameProcessor : RenamePsiElementProcessor() { element: PsiElement, newName: String, usages: Array, - listener: RefactoringElementListener? + listener: RefactoringElementListener?, ) { val newTypeName = newName.capitalize() val currentTypeName = when (element) { @@ -58,7 +58,7 @@ class SqlDelightRenameProcessor : RenamePsiElementProcessor() { override fun findReferences( element: PsiElement, searchScope: SearchScope, - searchInCommentsAndStrings: Boolean + searchInCommentsAndStrings: Boolean, ): Collection { if (element !is StmtIdentifierMixin) return super.findReferences(element, searchScope, searchInCommentsAndStrings) return element.generatedMethods().flatMap { element.references(it) } diff --git a/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/actions/GenerateInsertIntoQueryAction.kt b/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/actions/GenerateInsertIntoQueryAction.kt index 851d13440c8..76c3f621231 100644 --- a/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/actions/GenerateInsertIntoQueryAction.kt +++ b/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/actions/GenerateInsertIntoQueryAction.kt @@ -25,7 +25,11 @@ internal class GenerateInsertIntoQueryAction : BaseGenerateAction(InsertIntoHand val stmtList = file.findChildOfType() ?: return insertNewLineAndCleanup(editor, stmtList) TemplateManager.getInstance(project).startTemplate( - editor, template, false, mapOf("table" to tableName), null + editor, + template, + false, + mapOf("table" to tableName), + null, ) } } diff --git a/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/actions/GenerateSelectAllQueryAction.kt b/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/actions/GenerateSelectAllQueryAction.kt index 4116ca000a5..93808395208 100644 --- a/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/actions/GenerateSelectAllQueryAction.kt +++ b/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/actions/GenerateSelectAllQueryAction.kt @@ -26,7 +26,11 @@ internal class GenerateSelectAllQueryAction : BaseGenerateAction(SelectAllHandle val stmtList = file.findChildOfType() ?: return insertNewLineAndCleanup(editor, stmtList) TemplateManager.getInstance(project).startTemplate( - editor, selectAllTemplate, false, mapOf("table" to tableName), null + editor, + selectAllTemplate, + false, + mapOf("table" to tableName), + null, ) } } diff --git a/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/actions/GenerateActionUtil.kt b/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/actions/InsertNewLineAndCleanup.kt similarity index 100% rename from sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/actions/GenerateActionUtil.kt rename to sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/actions/InsertNewLineAndCleanup.kt diff --git a/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/actions/QueryByPrimaryKeyHandler.kt b/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/actions/QueryByPrimaryKeyHandler.kt index 0f9bb7860a8..7f2d4c683cb 100644 --- a/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/actions/QueryByPrimaryKeyHandler.kt +++ b/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/actions/QueryByPrimaryKeyHandler.kt @@ -35,7 +35,11 @@ class QueryByPrimaryKeyHandler(private val templateName: String) : CodeInsightAc val stmtList = file.findChildOfType() ?: return insertNewLineAndCleanup(editor, stmtList) TemplateManager.getInstance(project).startTemplate( - editor, template, false, args, null + editor, + template, + false, + args, + null, ) } } diff --git a/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/actions/file/SqlDelightCreateFileAction.kt b/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/actions/file/SqlDelightCreateFileAction.kt index 53d5d807147..11e946a0956 100644 --- a/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/actions/file/SqlDelightCreateFileAction.kt +++ b/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/actions/file/SqlDelightCreateFileAction.kt @@ -37,14 +37,14 @@ class SqlDelightCreateFileAction : CreateFileFromTemplateAction( CAPTION, "Creates new SqlDelight file or table", - SqlDelightFileType.icon + SqlDelightFileType.icon, ), DumbAware { override fun postProcess( createdElement: PsiFile, templateName: String, - customProperties: MutableMap? + customProperties: MutableMap?, ) { super.postProcess(createdElement, templateName, customProperties) @@ -157,9 +157,11 @@ class SqlDelightCreateFileAction : val element = try { CreateFromTemplateDialog( - project, dir, template, + project, + dir, + template, AttributesDefaults(className).withFixedName(true), - properties + properties, ).create() } catch (e: IncorrectOperationException) { throw e diff --git a/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/gradle/FileIndexMap.kt b/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/gradle/FileIndexMap.kt index 771038fc3e2..a666efd68e8 100644 --- a/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/gradle/FileIndexMap.kt +++ b/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/gradle/FileIndexMap.kt @@ -53,11 +53,11 @@ internal class FileIndexMap { synchronized(this) { if (!initialized) { initialized = true - if (!module.isDisposed && !module.project.isDisposed) + if (!module.isDisposed && !module.project.isDisposed) { try { ProgressManager.getInstance().runProcessWithProgressAsynchronously( FetchModuleModels(module, projectPath), - EmptyProgressIndicator().apply { start() } + EmptyProgressIndicator().apply { start() }, ) } catch (e: Throwable) { // IntelliJ can fail to start the fetch command, reinitialize later in this case. @@ -65,6 +65,7 @@ internal class FileIndexMap { initialized = false } } + } } } } @@ -73,10 +74,10 @@ internal class FileIndexMap { private inner class FetchModuleModels( private val module: Module, - private val projectPath: String + private val projectPath: String, ) : Task.Backgroundable( /* project = */ module.project, - /* title = */ "Importing ${module.name} SQLDelight" + /* title = */ "Importing ${module.name} SQLDelight", ) { override fun run(indicator: ProgressIndicator) { FileIndexingNotification.getInstance(module.project).unconfiguredReason = Syncing @@ -85,7 +86,7 @@ internal class FileIndexMap { /* gradleHome = */ null, /* serviceDirectory = */ null, /* distributionType = */ DistributionType.DEFAULT_WRAPPED, - /* isOfflineWork = */ false + /* isOfflineWork = */ false, ) try { fileIndices.putAll( @@ -115,7 +116,7 @@ internal class FileIndexMap { val pluginDescriptor = PluginManagerCore.getPlugin(PluginId.getId("com.squareup.sqldelight"))!! val shouldInvalidate = pluginDescriptor.addDialect( listOf(value!!.dialectJar.toURI()) + - value.moduleJars.map { it.toURI() } + value.moduleJars.map { it.toURI() }, ) val database = value.databases.first() @@ -127,7 +128,7 @@ internal class FileIndexMap { return@mapValues FileIndex(database) } - } + }, ) Timber.i("Initialized file index") EditorNotifications.getInstance(module.project).updateAllNotifications() @@ -138,7 +139,7 @@ internal class FileIndexMap { FileIndexingNotification.UnconfiguredReason.Incompatible( """ Connecting with the SQLDelight plugin failed: try building from the command line. - """.trimIndent() + """.trimIndent(), ) } finally { fetchThread = null diff --git a/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/inspections/InspectionExt.kt b/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/inspections/InspectionExt.kt index 05e04cee310..7f39298730e 100644 --- a/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/inspections/InspectionExt.kt +++ b/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/inspections/InspectionExt.kt @@ -31,7 +31,7 @@ internal inline fun PsiElementVisitor.ignoreInvalidElements(block: () -> Unit) { private inline fun ensureReady( file: PsiFile, defaultValue: () -> T, - block: InspectionProperties.() -> T + block: InspectionProperties.() -> T, ): T { val sqlDelightFile = file as? SqlDelightFile ?: return defaultValue() val module = file.module ?: return defaultValue() diff --git a/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/inspections/MismatchJoinColumnInspection.kt b/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/inspections/MismatchJoinColumnInspection.kt index 40121db1d06..7c1c8437594 100644 --- a/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/inspections/MismatchJoinColumnInspection.kt +++ b/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/inspections/MismatchJoinColumnInspection.kt @@ -17,7 +17,7 @@ internal class MismatchJoinColumnInspection : LocalInspectionTool() { override fun checkFile( file: PsiFile, manager: InspectionManager, - isOnTheFly: Boolean + isOnTheFly: Boolean, ) = ensureFileReady(file) { val joinConstraints = file.findChildrenOfType() .mapNotNull { it.expr?.binaryEqualityExpr() } @@ -33,15 +33,21 @@ internal class MismatchJoinColumnInspection : LocalInspectionTool() { if (column1.isColumnSameAs(column2)) { return@mapNotNull manager.createProblemDescriptor( - joinEquality, "Join condition always evaluates to true", isOnTheFly, - emptyArray(), ProblemHighlightType.WARNING + joinEquality, + "Join condition always evaluates to true", + isOnTheFly, + emptyArray(), + ProblemHighlightType.WARNING, ) } if (!column1.isTypeSameAs(column2)) { return@mapNotNull manager.createProblemDescriptor( - joinEquality, "Join compares two columns of different types", isOnTheFly, - emptyArray(), ProblemHighlightType.WARNING + joinEquality, + "Join compares two columns of different types", + isOnTheFly, + emptyArray(), + ProblemHighlightType.WARNING, ) } return@mapNotNull null diff --git a/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/inspections/MixedNamedAndPositionalParamsInspection.kt b/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/inspections/MixedNamedAndPositionalParamsInspection.kt index eee9fd378ef..3f59fde0893 100644 --- a/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/inspections/MixedNamedAndPositionalParamsInspection.kt +++ b/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/inspections/MixedNamedAndPositionalParamsInspection.kt @@ -40,7 +40,7 @@ internal class MixedNamedAndPositionalParamsInspection : LocalInspectionTool() { holder.registerProblem( o, "Mixed usage of named and positional parameters is not recommended", - ProblemHighlightType.WARNING + ProblemHighlightType.WARNING, ) } } diff --git a/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/inspections/NullEqualityInspection.kt b/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/inspections/NullEqualityInspection.kt index e5eebe4109b..3a674ef82bb 100644 --- a/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/inspections/NullEqualityInspection.kt +++ b/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/inspections/NullEqualityInspection.kt @@ -14,7 +14,7 @@ internal class NullEqualityInspection : LocalInspectionTool() { override fun buildVisitor( holder: ProblemsHolder, isOnTheFly: Boolean, - session: LocalInspectionToolSession + session: LocalInspectionToolSession, ) = ensureReady(session.file) { return object : SqlVisitor() { diff --git a/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/inspections/RedundantNullCheckInspection.kt b/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/inspections/RedundantNullCheckInspection.kt index a20a95df653..e36916c9af9 100644 --- a/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/inspections/RedundantNullCheckInspection.kt +++ b/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/inspections/RedundantNullCheckInspection.kt @@ -19,7 +19,7 @@ internal class RedundantNullCheckInspection : LocalInspectionTool() { override fun buildVisitor( holder: ProblemsHolder, isOnTheFly: Boolean, - session: LocalInspectionToolSession + session: LocalInspectionToolSession, ) = ensureReady(session.file) { object : SqlVisitor() { diff --git a/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/inspections/SchemaNeedsMigrationInspection.kt b/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/inspections/SchemaNeedsMigrationInspection.kt index c481eb58bdf..8fee75f25b4 100644 --- a/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/inspections/SchemaNeedsMigrationInspection.kt +++ b/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/inspections/SchemaNeedsMigrationInspection.kt @@ -25,7 +25,7 @@ internal class SchemaNeedsMigrationInspection : LocalInspectionTool() { override fun buildVisitor( holder: ProblemsHolder, - isOnTheFly: Boolean + isOnTheFly: Boolean, ) = ensureReady(holder.file) { object : SqlVisitor() { override fun visitCreateTableStmt(createTable: SqlCreateTableStmt) = ignoreInvalidElements { @@ -58,8 +58,10 @@ internal class SchemaNeedsMigrationInspection : LocalInspectionTool() { }*/ holder.registerProblem( - createTable.tableName, "Table needs to be added in a migration", GENERIC_ERROR, - CreateTableMigrationQuickFix(createTable, topMigrationFile) + createTable.tableName, + "Table needs to be added in a migration", + GENERIC_ERROR, + CreateTableMigrationQuickFix(createTable, topMigrationFile), ) return } @@ -73,8 +75,10 @@ internal class SchemaNeedsMigrationInspection : LocalInspectionTool() { if (oldSignature != signature) { holder.registerProblem( - createTable.tableName, "Table needs to be altered in a migration", GENERIC_ERROR, - AlterTableMigrationQuickFix(createTable, oldSignature, signature) + createTable.tableName, + "Table needs to be altered in a migration", + GENERIC_ERROR, + AlterTableMigrationQuickFix(createTable, oldSignature, signature), ) } } @@ -98,26 +102,26 @@ internal class SchemaNeedsMigrationInspection : LocalInspectionTool() { project: Project, file: PsiFile, startElement: PsiElement, - endElement: PsiElement + endElement: PsiElement, ) { val strategy = SqlDelightProjectService.getInstance(file.project).dialect.migrationStrategy val changeName = strategy.tableNameChanged( oldName = oldName, - newName = createTableRef.element?.tableName?.name ?: return + newName = createTableRef.element?.tableName?.name ?: return, ) refactoringExecutor.performChangeSignature( SuggestedMigrationData( declarationPointer = createTableRef, newestMigrationFile = newestMigrationFile, - preparedMigration = changeName - ) + preparedMigration = changeName, + ), ) } } inner class CreateTableMigrationQuickFix( createTableStmt: SqlCreateTableStmt, - private val newestMigrationFile: MigrationFile? + private val newestMigrationFile: MigrationFile?, ) : LocalQuickFixOnPsiElement(createTableStmt) { private val createTableRef = SmartPointerManager.getInstance(createTableStmt.project) .createSmartPsiElementPointer(createTableStmt, createTableStmt.containingFile) @@ -131,14 +135,14 @@ internal class SchemaNeedsMigrationInspection : LocalInspectionTool() { project: Project, file: PsiFile, startElement: PsiElement, - endElement: PsiElement + endElement: PsiElement, ) { refactoringExecutor.performChangeSignature( SuggestedMigrationData( declarationPointer = createTableRef, newestMigrationFile = newestMigrationFile, - preparedMigration = "${createTableRef.element?.text.orEmpty()};" - ) + preparedMigration = "${createTableRef.element?.text.orEmpty()};", + ), ) } } @@ -160,7 +164,7 @@ internal class SchemaNeedsMigrationInspection : LocalInspectionTool() { project: Project, file: PsiFile, startElement: PsiElement, - endElement: PsiElement + endElement: PsiElement, ) { val migrationData = refactoringExecutor.prepareChangeSignature( declaration = createTableRef, diff --git a/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/inspections/UnusedColumnInspection.kt b/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/inspections/UnusedColumnInspection.kt index d6153bc58a8..01f8effcaa3 100644 --- a/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/inspections/UnusedColumnInspection.kt +++ b/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/inspections/UnusedColumnInspection.kt @@ -30,7 +30,7 @@ internal class UnusedColumnInspection : LocalInspectionTool() { override fun buildVisitor( holder: ProblemsHolder, isOnTheFly: Boolean, - session: LocalInspectionToolSession + session: LocalInspectionToolSession, ) = ensureReady(session.file) { object : SqlVisitor() { override fun visitCreateTableStmt(o: SqlCreateTableStmt) = ignoreInvalidElements { @@ -59,8 +59,10 @@ internal class UnusedColumnInspection : LocalInspectionTool() { candidates.forEach { columnDef -> holder.registerProblem( - columnDef.columnName, "Unused symbol", ProblemHighlightType.LIKE_UNUSED_SYMBOL, - SafeDeleteQuickFix(o, columnDef) + columnDef.columnName, + "Unused symbol", + ProblemHighlightType.LIKE_UNUSED_SYMBOL, + SafeDeleteQuickFix(o, columnDef), ) } } @@ -84,7 +86,7 @@ internal class UnusedColumnInspection : LocalInspectionTool() { project: Project, file: PsiFile, startElement: PsiElement, - endElement: PsiElement + endElement: PsiElement, ) { WriteCommandAction.writeCommandAction(project).run { val createTable = createTableRef.element ?: return@run @@ -109,7 +111,8 @@ internal class UnusedColumnInspection : LocalInspectionTool() { """.trimMargin() val dummyFile = factory.createFileFromText( "_Dummy_.${SqlDelightFileType.EXTENSION}", - SqlDelightFileType, createTableStmt + SqlDelightFileType, + createTableStmt, ) val newCreateTable = dummyFile.findChildOfType() ?: return@run diff --git a/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/inspections/UnusedImportInspection.kt b/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/inspections/UnusedImportInspection.kt index 2d562ce33ef..29a76be1dbe 100644 --- a/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/inspections/UnusedImportInspection.kt +++ b/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/inspections/UnusedImportInspection.kt @@ -22,7 +22,7 @@ internal class UnusedImportInspection : LocalInspectionTool() { override fun checkFile( file: PsiFile, manager: InspectionManager, - isOnTheFly: Boolean + isOnTheFly: Boolean, ) = ensureFileReady(file) { val javaTypes = file.columnJavaTypes() @@ -32,8 +32,11 @@ internal class UnusedImportInspection : LocalInspectionTool() { } .map { importStmtMixin -> manager.createProblemDescriptor( - importStmtMixin, "Unused import", isOnTheFly, - arrayOf(RemoveUnusedImportQuickFix(file)), ProblemHighlightType.LIKE_UNUSED_SYMBOL + importStmtMixin, + "Unused import", + isOnTheFly, + arrayOf(RemoveUnusedImportQuickFix(file)), + ProblemHighlightType.LIKE_UNUSED_SYMBOL, ) } .toTypedArray() @@ -49,7 +52,7 @@ internal class UnusedImportInspection : LocalInspectionTool() { project: Project, file: PsiFile, startElement: PsiElement, - endElement: PsiElement + endElement: PsiElement, ) { OptimizeImportsProcessor(project, file).run() } diff --git a/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/inspections/UnusedQueryInspection.kt b/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/inspections/UnusedQueryInspection.kt index 9ef8f0a5264..5367a942881 100644 --- a/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/inspections/UnusedQueryInspection.kt +++ b/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/inspections/UnusedQueryInspection.kt @@ -30,11 +30,13 @@ internal class UnusedQueryInspection : LocalInspectionTool() { override fun buildVisitor( holder: ProblemsHolder, isOnTheFly: Boolean, - session: LocalInspectionToolSession + session: LocalInspectionToolSession, ) = ensureReady(session.file) { val fileName = "${sqlDelightFile.virtualFile?.queriesName}.kt" val generatedFile = FilenameIndex.getFilesByName( - sqlDelightFile.project, fileName, GlobalSearchScope.moduleScope(module) + sqlDelightFile.project, + fileName, + GlobalSearchScope.moduleScope(module), ).firstOrNull() as KtFile? ?: return PsiElementVisitor.EMPTY_VISITOR val allMethods = generatedFile.classes[0].methods return object : SqlDelightVisitor() { @@ -52,7 +54,10 @@ internal class UnusedQueryInspection : LocalInspectionTool() { } } holder.registerProblem( - o, "Unused symbol", ProblemHighlightType.LIKE_UNUSED_SYMBOL, SafeDeleteQuickFix(o) + o, + "Unused symbol", + ProblemHighlightType.LIKE_UNUSED_SYMBOL, + SafeDeleteQuickFix(o), ) } } @@ -70,7 +75,7 @@ internal class UnusedQueryInspection : LocalInspectionTool() { project: Project, file: PsiFile, startElement: PsiElement, - endElement: PsiElement + endElement: PsiElement, ) { WriteCommandAction.writeCommandAction(project).run { val element = ref.element ?: return@run diff --git a/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/inspections/suppression/SqlDelightInspectionSuppressor.kt b/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/inspections/suppression/SqlDelightInspectionSuppressor.kt index bb9f2f3f987..00fefe5fd54 100644 --- a/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/inspections/suppression/SqlDelightInspectionSuppressor.kt +++ b/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/inspections/suppression/SqlDelightInspectionSuppressor.kt @@ -44,9 +44,9 @@ internal class SqlDelightInspectionSuppressor : InspectionSuppressor { classes = arrayOf( SqlStmt::class, SqlDelightImportStmt::class, - SqlDelightStmtIdentifier::class + SqlDelightStmtIdentifier::class, ), - withSelf = true + withSelf = true, ) ?: return false val comment = stmt.comment ?: run { @@ -60,7 +60,7 @@ internal class SqlDelightInspectionSuppressor : InspectionSuppressor { val matcher = commentPattern.matcher(comment.text) return matcher.matches() && SuppressionUtil.isInspectionToolIdMentioned( matcher.group(1), - toolId + toolId, ) } diff --git a/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/inspections/suppression/SqlDelightSuppressInspectionQuickFix.kt b/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/inspections/suppression/SqlDelightSuppressInspectionQuickFix.kt index addabdb0ba2..f743bc2013a 100644 --- a/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/inspections/suppression/SqlDelightSuppressInspectionQuickFix.kt +++ b/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/inspections/suppression/SqlDelightSuppressInspectionQuickFix.kt @@ -68,9 +68,9 @@ internal class SqlDelightSuppressInspectionQuickFix(toolId: String) : classes = arrayOf( SqlStmt::class, SqlDelightImportStmt::class, - SqlDelightStmtIdentifier::class + SqlDelightStmtIdentifier::class, ), - withSelf = true + withSelf = true, ) } } diff --git a/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/intentions/AddImportIntention.kt b/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/intentions/AddImportIntention.kt index e2a01903ebe..1952674a411 100644 --- a/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/intentions/AddImportIntention.kt +++ b/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/intentions/AddImportIntention.kt @@ -49,11 +49,12 @@ internal class AddImportIntention( if (classes.size == 1) { PsiDocumentManager.getInstance(project).commitAllDocuments() WriteCommandAction.runWriteCommandAction( - project, QuickFixBundle.message("add.import"), + project, + QuickFixBundle.message("add.import"), null, { document.addImport(file, "import ${classes.first().qualifiedName};") - } + }, ) } else { showImportPopup(project, editor, file, classes) @@ -64,11 +65,12 @@ internal class AddImportIntention( project: Project, editor: Editor, psiFile: PsiFile, - classes: List + classes: List, ) { val document = editor.document val step = object : BaseListPopupStep( - QuickFixBundle.message("class.to.import.chooser.title"), classes + QuickFixBundle.message("class.to.import.chooser.title"), + classes, ) { override fun isAutoSelectionEnabled(): Boolean { return false @@ -90,11 +92,12 @@ internal class AddImportIntention( return doFinalStep { PsiDocumentManager.getInstance(project).commitAllDocuments() WriteCommandAction.runWriteCommandAction( - project, QuickFixBundle.message("add.import"), + project, + QuickFixBundle.message("add.import"), null, { document.addImport(psiFile, "import ${selectedValue.qualifiedName};") - } + }, ) } } @@ -143,7 +146,7 @@ internal class AddImportIntention( hintText, element.textOffset, element.textRange.endOffset, - this + this, ) return true } diff --git a/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/intentions/ExpandColumnNamesWildcardQuickFix.kt b/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/intentions/ExpandColumnNamesWildcardQuickFix.kt index 9664e3c70f1..8a572de3f2f 100644 --- a/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/intentions/ExpandColumnNamesWildcardQuickFix.kt +++ b/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/intentions/ExpandColumnNamesWildcardQuickFix.kt @@ -23,13 +23,13 @@ class ExpandColumnNamesWildcardQuickFix : BaseIntentionAction() { val caret = editor.caretModel.offset return selectStatementAtCaretWithColumnNamesWildcard( file = file as? SqlDelightFile ?: return false, - caret = caret + caret = caret, ) != null } private fun selectStatementAtCaretWithColumnNamesWildcard( file: SqlDelightFile, - caret: Int + caret: Int, ): SqlSelectStmt? { val selectStatement = file.findElementOfTypeAtOffset(caret) ?: return null val resultColumns = selectStatement.resultColumnList diff --git a/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/intentions/IntroduceTableAliasIntention.kt b/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/intentions/IntroduceTableAliasIntention.kt index fd37a59a6eb..df5afadfdfa 100644 --- a/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/intentions/IntroduceTableAliasIntention.kt +++ b/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/intentions/IntroduceTableAliasIntention.kt @@ -48,7 +48,7 @@ internal class IntroduceTableAliasIntention : BaseElementAtCaretIntentionAction( tableName.first().toString(), tableName.split(regex) .filter(String::isNotBlank) - .joinToString("") { it.first().toLowerCase().toString() } + .joinToString("") { it.first().toLowerCase().toString() }, ) .distinct() @@ -64,7 +64,9 @@ internal class IntroduceTableAliasIntention : BaseElementAtCaretIntentionAction( val callback = { alias: String -> WriteCommandAction.runWriteCommandAction(project) { document.replaceString( - tableNameRangeMarker.startOffset, tableNameRangeMarker.endOffset, "$tableName $alias" + tableNameRangeMarker.startOffset, + tableNameRangeMarker.endOffset, + "$tableName $alias", ) tableReferenceMarkers.forEach { rangeMarker -> document.replaceString(rangeMarker.startOffset, rangeMarker.endOffset, alias) diff --git a/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/intentions/QualifyColumnNameIntention.kt b/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/intentions/QualifyColumnNameIntention.kt index a0c7e92976b..3d9eeba61dd 100644 --- a/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/intentions/QualifyColumnNameIntention.kt +++ b/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/intentions/QualifyColumnNameIntention.kt @@ -52,7 +52,9 @@ class QualifyColumnNameIntention : BaseElementAtCaretIntentionAction() { val callback = { qualifier: String -> WriteCommandAction.runWriteCommandAction(project) { document.replaceString( - columnRange.startOffset, columnRange.endOffset, "$qualifier.$columnText" + columnRange.startOffset, + columnRange.endOffset, + "$qualifier.$columnText", ) } } diff --git a/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/lang/SqlDelightFileViewProviderFactory.kt b/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/lang/SqlDelightFileViewProviderFactory.kt index 1e654b81594..a6fe7623043 100644 --- a/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/lang/SqlDelightFileViewProviderFactory.kt +++ b/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/lang/SqlDelightFileViewProviderFactory.kt @@ -55,7 +55,7 @@ class SqlDelightFileViewProviderFactory : FileViewProviderFactory { file: VirtualFile, language: Language, manager: PsiManager, - eventSystemEnabled: Boolean + eventSystemEnabled: Boolean, ): FileViewProvider { val module = SqlDelightProjectService.getInstance(manager.project).module(file) ?: return SingleRootFileViewProvider(manager, file, eventSystemEnabled) @@ -68,7 +68,7 @@ private class SqlDelightFileViewProvider( virtualFile: VirtualFile, eventSystemEnabled: Boolean, private val language: Language, - private val module: Module + private val module: Module, ) : SingleRootFileViewProvider(manager, virtualFile, eventSystemEnabled, language) { private val threadPool = Executors.newScheduledThreadPool(1) @@ -120,12 +120,13 @@ private class SqlDelightFileViewProvider( e.printStackTrace() null } - } + }, ).expireWhen(thisCondition) .finishOnUiThread(ModalityState.NON_MODAL, ::writeFiles) .submit(NonUrgentExecutor.getInstance()) }, - 1, TimeUnit.SECONDS + 1, + TimeUnit.SECONDS, ) if (!updateTransitive) return @@ -145,7 +146,9 @@ private class SqlDelightFileViewProvider( } }.expireWhen(thisCondition) .submit(NonUrgentExecutor.getInstance()) - }, 1, TimeUnit.SECONDS + }, + 1, + TimeUnit.SECONDS, ) } @@ -222,6 +225,6 @@ private class SqlDelightFileViewProvider( private data class GeneratedFile( val path: String, - val transitive: Boolean = false + val transitive: Boolean = false, ) } diff --git a/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/lang/SqlDelightFoldingBuilder.kt b/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/lang/SqlDelightFoldingBuilder.kt index a093599cae9..ccd98c8c9ee 100644 --- a/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/lang/SqlDelightFoldingBuilder.kt +++ b/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/lang/SqlDelightFoldingBuilder.kt @@ -87,7 +87,7 @@ class SqlDelightFoldingBuilder : FoldingBuilder, DumbAware { } private fun PsiElement.toCreateTriggerDescriptor( - createTriggerStmt: PsiElement? + createTriggerStmt: PsiElement?, ): FoldingDescriptor? { val triggerNameElement = (createTriggerStmt as? SqlCreateTriggerStmt)?.triggerName ?: return null diff --git a/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/lang/SqlDelightHighlightVisitor.kt b/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/lang/SqlDelightHighlightVisitor.kt index 178cdd30e50..2e9a7e62c47 100644 --- a/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/lang/SqlDelightHighlightVisitor.kt +++ b/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/lang/SqlDelightHighlightVisitor.kt @@ -46,7 +46,7 @@ class SqlDelightHighlightVisitor : SqlVisitor(), HighlightVisitor { file: PsiFile, updateWholeFile: Boolean, holder: HighlightInfoHolder, - action: Runnable + action: Runnable, ): Boolean { myHolder = holder try { @@ -114,34 +114,36 @@ class SqlDelightHighlightVisitor : SqlVisitor(), HighlightVisitor { private fun createSymbolTypeInfo(attributesKey: TextAttributesKey): HighlightInfoType { return HighlightInfoType.HighlightInfoTypeImpl( - HighlightInfoType.SYMBOL_TYPE_SEVERITY, attributesKey, false + HighlightInfoType.SYMBOL_TYPE_SEVERITY, + attributesKey, + false, ) } companion object { val SQL_ALIAS = TextAttributesKey.createTextAttributesKey( "SQL.ALIAS", - DefaultLanguageHighlighterColors.LOCAL_VARIABLE + DefaultLanguageHighlighterColors.LOCAL_VARIABLE, ) val SQL_COLUMN_NAME = TextAttributesKey.createTextAttributesKey( "SQL.COLUMN_NAME", - DefaultLanguageHighlighterColors.INSTANCE_FIELD + DefaultLanguageHighlighterColors.INSTANCE_FIELD, ) val SQL_FUNCTION_NAME = TextAttributesKey.createTextAttributesKey( "SQL.FUNCTION_NAME", - DefaultLanguageHighlighterColors.STATIC_METHOD + DefaultLanguageHighlighterColors.STATIC_METHOD, ) val SQL_STMT_IDENTIFIER_NAME = TextAttributesKey.createTextAttributesKey( "SQL.STMT_IDENTIFIER_NAME", - DefaultLanguageHighlighterColors.INSTANCE_METHOD + DefaultLanguageHighlighterColors.INSTANCE_METHOD, ) val SQL_TABLE_NAME = TextAttributesKey.createTextAttributesKey( "SQL.TABLE_NAME", - DefaultLanguageHighlighterColors.CLASS_NAME + DefaultLanguageHighlighterColors.CLASS_NAME, ) val SQL_TYPE_NAME = TextAttributesKey.createTextAttributesKey( "SQL.TYPE_NAME", - DefaultLanguageHighlighterColors.KEYWORD + DefaultLanguageHighlighterColors.KEYWORD, ) } } diff --git a/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/lang/SqlDelightHighlighter.kt b/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/lang/SqlDelightHighlighter.kt index c216200fbe3..ebee42702a7 100644 --- a/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/lang/SqlDelightHighlighter.kt +++ b/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/lang/SqlDelightHighlighter.kt @@ -30,34 +30,44 @@ class SqlDelightHighlighter : SyntaxHighlighterBase() { companion object { val SQLITE_KEYWORD = TextAttributesKey.createTextAttributesKey( - "SQLITE.KEYWORD", DefaultLanguageHighlighterColors.KEYWORD + "SQLITE.KEYWORD", + DefaultLanguageHighlighterColors.KEYWORD, ) val SQLITE_NUMBER = TextAttributesKey.createTextAttributesKey( - "SQLITE.NUMBER", DefaultLanguageHighlighterColors.NUMBER + "SQLITE.NUMBER", + DefaultLanguageHighlighterColors.NUMBER, ) val SQLITE_STRING = TextAttributesKey.createTextAttributesKey( - "SQLITE.STRING", DefaultLanguageHighlighterColors.STRING + "SQLITE.STRING", + DefaultLanguageHighlighterColors.STRING, ) val SQLITE_OPERATOR = TextAttributesKey.createTextAttributesKey( - "SQLITE.OPERATOR", DefaultLanguageHighlighterColors.OPERATION_SIGN + "SQLITE.OPERATOR", + DefaultLanguageHighlighterColors.OPERATION_SIGN, ) val SQLITE_PAREN = TextAttributesKey.createTextAttributesKey( - "SQLITE.PAREN", DefaultLanguageHighlighterColors.PARENTHESES + "SQLITE.PAREN", + DefaultLanguageHighlighterColors.PARENTHESES, ) val SQLITE_DOT = TextAttributesKey.createTextAttributesKey( - "SQLITE.DOT", DefaultLanguageHighlighterColors.DOT + "SQLITE.DOT", + DefaultLanguageHighlighterColors.DOT, ) val SQLITE_SEMICOLON = TextAttributesKey.createTextAttributesKey( - "SQLITE.SEMICOLON", DefaultLanguageHighlighterColors.SEMICOLON + "SQLITE.SEMICOLON", + DefaultLanguageHighlighterColors.SEMICOLON, ) val SQLITE_COMMA = TextAttributesKey.createTextAttributesKey( - "SQLITE.COMMA", DefaultLanguageHighlighterColors.COMMA + "SQLITE.COMMA", + DefaultLanguageHighlighterColors.COMMA, ) val SQLITE_LINE_COMMENT = TextAttributesKey.createTextAttributesKey( - "SQLITE.LINE_COMMENT", DefaultLanguageHighlighterColors.LINE_COMMENT + "SQLITE.LINE_COMMENT", + DefaultLanguageHighlighterColors.LINE_COMMENT, ) val SQLITE_DOC = TextAttributesKey.createTextAttributesKey( - "SQLITE.DOC", DefaultLanguageHighlighterColors.DOC_COMMENT + "SQLITE.DOC", + DefaultLanguageHighlighterColors.DOC_COMMENT, ) private val TEXT_ATTRIBUTES_MAP = mapOf( @@ -224,7 +234,7 @@ class SqlDelightHighlighter : SyntaxHighlighterBase() { // Comments SqlTypes.COMMENT.index to SQLITE_LINE_COMMENT, - SqlTypes.JAVADOC.index to SQLITE_DOC + SqlTypes.JAVADOC.index to SQLITE_DOC, ) } } diff --git a/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/lang/SqlDelightImportOptimizer.kt b/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/lang/SqlDelightImportOptimizer.kt index f055610bc0c..bed1d0da18f 100644 --- a/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/lang/SqlDelightImportOptimizer.kt +++ b/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/lang/SqlDelightImportOptimizer.kt @@ -32,7 +32,8 @@ class SqlDelightImportOptimizer : ImportOptimizer { val factory = PsiFileFactory.getInstance(file.project) val dummyFile = factory.createFileFromText( "_Dummy_.${SqlDelightFileType.EXTENSION}", - SqlDelightFileType, remainingImports + SqlDelightFileType, + remainingImports, ) val newImportList = dummyFile.findChildOfType() if (newImportList != null) { diff --git a/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/lang/SqlDelightPairedBraceMatcher.kt b/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/lang/SqlDelightPairedBraceMatcher.kt index e3b4b099657..a5acd6a848f 100644 --- a/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/lang/SqlDelightPairedBraceMatcher.kt +++ b/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/lang/SqlDelightPairedBraceMatcher.kt @@ -30,7 +30,7 @@ class SqlDelightPairedBraceMatcher : PairedBraceMatcher { override fun isPairedBracesAllowedBeforeType( lbraceType: IElementType, - contextType: IElementType? + contextType: IElementType?, ) = true override fun getCodeConstructStart(file: PsiFile?, openingBraceOffset: Int) = openingBraceOffset diff --git a/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/lang/SqlDelightStructureViewFactory.kt b/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/lang/SqlDelightStructureViewFactory.kt index 9630b935485..eeea1b80184 100644 --- a/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/lang/SqlDelightStructureViewFactory.kt +++ b/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/lang/SqlDelightStructureViewFactory.kt @@ -48,7 +48,7 @@ class SqlDelightStructureViewFactory : PsiStructureViewFactory { } internal class SqlDelightStructureViewModel( - psiFile: PsiFile + psiFile: PsiFile, ) : StructureViewModelBase(psiFile, SqlDelightStructureViewElement(psiFile)), StructureViewModel.ElementInfoProvider { override fun isAlwaysLeaf(element: StructureViewTreeElement) = false @@ -56,7 +56,7 @@ internal class SqlDelightStructureViewModel( } internal class SqlDelightStructureViewElement( - private val element: PsiElement + private val element: PsiElement, ) : StructureViewTreeElement, ItemPresentation, NavigationItem { @@ -76,7 +76,7 @@ internal class SqlDelightStructureViewElement( is SqlCreateTableStmt -> "CREATE TABLE ${element.name}" is SqlCreateVirtualTableStmt -> "CREATE VIRTUAL TABLE ${element.name}" else -> throw IllegalStateException( - "Unhandled table name element for parent ${element.parent}" + "Unhandled table name element for parent ${element.parent}", ) } is SqlIndexName -> "CREATE INDEX ${element.text}" diff --git a/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/lang/completion/SqlDelightKeywordCompletionContributor.kt b/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/lang/completion/SqlDelightKeywordCompletionContributor.kt index ac5ffa65d3a..489c21808fe 100644 --- a/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/lang/completion/SqlDelightKeywordCompletionContributor.kt +++ b/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/lang/completion/SqlDelightKeywordCompletionContributor.kt @@ -39,7 +39,7 @@ class SqlDelightKeywordCompletionContributor : CompletionContributor() { override fun addCompletions( parameters: CompletionParameters, context: ProcessingContext, - result: CompletionResultSet + result: CompletionResultSet, ) { val originalFile = parameters.originalFile val project = originalFile.project @@ -86,7 +86,7 @@ class SqlDelightKeywordCompletionContributor : CompletionContributor() { private val ignoredKeywords = setOf( ";", "=", "(", ")", ".", ",", "+", "-", "~", ">>", "<<", "<", ">", "<=", ">=", "==", "!=", "<>", "*", "/", "%", "&", "|", "||", "TRUE", "FALSE", "E", "ROWID", "id", "digit", "javadoc", - "string", "0x" + "string", "0x", ) override fun convertItem(o: Any?): String? { diff --git a/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/macro/DbColumnsMacro.kt b/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/macro/DbColumnsMacro.kt index 17a09fe81e7..c73d27e8d92 100644 --- a/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/macro/DbColumnsMacro.kt +++ b/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/macro/DbColumnsMacro.kt @@ -20,7 +20,7 @@ class DbColumnsMacro : MacroBase("dbColumns", "dbColumns(tableName)") { override fun calculateResult( params: Array, context: ExpressionContext, - quick: Boolean + quick: Boolean, ): Result? { if (params.isEmpty()) { return null diff --git a/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/macro/PkMacro.kt b/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/macro/PkMacro.kt index a0775cdc46b..a8d525caecf 100644 --- a/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/macro/PkMacro.kt +++ b/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/macro/PkMacro.kt @@ -15,7 +15,7 @@ class PkMacro : MacroBase("pk", "pk(tableName)") { override fun calculateResult( params: Array, context: ExpressionContext, - quick: Boolean + quick: Boolean, ): Result? { if (params.isEmpty()) { return null diff --git a/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/notifications/FileIndexingNotification.kt b/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/notifications/FileIndexingNotification.kt index 6a66715b785..72943ecfbbc 100644 --- a/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/notifications/FileIndexingNotification.kt +++ b/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/notifications/FileIndexingNotification.kt @@ -19,7 +19,7 @@ import org.jetbrains.kotlin.utils.addToStdlib.firstIsInstance import java.awt.Color class FileIndexingNotification( - private val project: Project + private val project: Project, ) : EditorNotifications.Provider(), DumbAware { internal var unconfiguredReason: UnconfiguredReason = GradleSyncing set(value) { diff --git a/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/refactoring/SqlDelightSignatureBuilder.kt b/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/refactoring/SqlDelightSignatureBuilder.kt index 5331f10f95b..bc0d4738ec8 100644 --- a/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/refactoring/SqlDelightSignatureBuilder.kt +++ b/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/refactoring/SqlDelightSignatureBuilder.kt @@ -13,7 +13,7 @@ internal class SqlDelightSignatureBuilder { name = tableName, type = null, parameters = columns, - additionalData = null // TODO: support table constraints + additionalData = null, // TODO: support table constraints ) } } diff --git a/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/refactoring/SqlDelightSuggestedRefactoringExecution.kt b/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/refactoring/SqlDelightSuggestedRefactoringExecution.kt index ad760ef0980..adf4c27db21 100644 --- a/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/refactoring/SqlDelightSuggestedRefactoringExecution.kt +++ b/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/refactoring/SqlDelightSuggestedRefactoringExecution.kt @@ -26,13 +26,13 @@ internal class SqlDelightSuggestedRefactoringExecution { class SuggestedMigrationData( val declarationPointer: SmartPsiElementPointer, val newestMigrationFile: MigrationFile?, - val preparedMigration: String + val preparedMigration: String, ) fun prepareChangeSignature( declaration: SmartPsiElementPointer, oldSignature: Signature, - newSignature: Signature + newSignature: Signature, ): SuggestedMigrationData? { val file = declaration.containingFile as SqlDelightFile? ?: return null @@ -73,7 +73,7 @@ internal class SqlDelightSuggestedRefactoringExecution { return SuggestedMigrationData( declarationPointer = declaration, newestMigrationFile = migrationFile, - preparedMigration = migration.joinToString("\n").trim() + preparedMigration = migration.joinToString("\n").trim(), ) } @@ -90,21 +90,21 @@ internal class SqlDelightSuggestedRefactoringExecution { private fun newColumns( oldList: List, - newList: List + newList: List, ): List { return newList.intersectBy(oldList, Parameter::id) } private fun removedColumns( oldList: List, - newList: List + newList: List, ): List { return oldList.intersectBy(newList, Parameter::id) } private inline fun List.intersectBy( other: List, - f: (T) -> R + f: (T) -> R, ): List { val set = other.mapTo(mutableSetOf(), f) return filter { f(it) !in set } @@ -113,7 +113,7 @@ internal class SqlDelightSuggestedRefactoringExecution { @Suppress("NAME_SHADOWING") private fun columnNameChanges( oldList: List, - newList: List + newList: List, ): List> { val old = oldList.mapTo(mutableSetOf(), Parameter::name) val new = newList.mapTo(mutableSetOf(), Parameter::name) @@ -130,7 +130,7 @@ internal class SqlDelightSuggestedRefactoringExecution { } fun performChangeSignature( - migrationData: SuggestedMigrationData + migrationData: SuggestedMigrationData, ) { val declarationPointer = migrationData.declarationPointer val project = declarationPointer.project @@ -171,7 +171,7 @@ internal class SqlDelightSuggestedRefactoringExecution { private fun writeToFile( declaration: SmartPsiElementPointer, migrationFile: MigrationFile, - migration: String + migration: String, ) { val project = declaration.project val element = declaration.element ?: return diff --git a/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/run/ArgumentsInputDialogImpl.kt b/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/run/ArgumentsInputDialogImpl.kt index 69c869d6df5..c003bd8c2d2 100644 --- a/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/run/ArgumentsInputDialogImpl.kt +++ b/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/run/ArgumentsInputDialogImpl.kt @@ -17,7 +17,7 @@ internal interface ArgumentsInputDialog { internal class ArgumentsInputDialogImpl( project: Project, - private val parameters: List + private val parameters: List, ) : DialogWrapper(project), ArgumentsInputDialog { init { @@ -33,7 +33,7 @@ internal class ArgumentsInputDialogImpl( row("${parameter.name}:") { textField(parameter::value, { _result.add(parameter.copy(value = it)) - }) + },) } } } diff --git a/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/run/ConnectionOptions.kt b/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/run/ConnectionOptions.kt index 1c903e3ee45..5fad43db926 100644 --- a/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/run/ConnectionOptions.kt +++ b/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/run/ConnectionOptions.kt @@ -68,6 +68,6 @@ internal class ConnectionOptions(val project: Project) { internal class DialectConnections( var selectedOption: String? = null, var orderedOptions: MutableList = ArrayList(), - val serializedProperties: MutableMap = mutableMapOf() + val serializedProperties: MutableMap = mutableMapOf(), ) } diff --git a/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/run/RunSqlAction.kt b/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/run/RunSqlAction.kt index ea37d0d3864..5e5c7c341ed 100644 --- a/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/run/RunSqlAction.kt +++ b/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/run/RunSqlAction.kt @@ -21,7 +21,7 @@ internal class RunSqlAction( project, connectionManager, ), - private val dialogFactory: ArgumentsInputDialog.Factory = ArgumentsInputDialogFactoryImpl() + private val dialogFactory: ArgumentsInputDialog.Factory = ArgumentsInputDialogFactoryImpl(), ) : AnAction() { override fun actionPerformed(e: AnActionEvent) { val parameters = findParameters(stmt) @@ -38,7 +38,7 @@ internal class RunSqlAction( } private fun findParameters( - sqlStmt: SqlStmt + sqlStmt: SqlStmt, ): List { val bindableQuery = object : BindableQuery(null, sqlStmt) { override val id = 0 @@ -50,7 +50,7 @@ internal class RunSqlAction( return argumentList.zip(parameters) { range, name -> SqlParameter( name = name, - range = range + range = range, ) } } diff --git a/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/run/SqlDelightRunVisitor.kt b/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/run/SqlDelightRunVisitor.kt index 82a481610dc..017e7bfe211 100644 --- a/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/run/SqlDelightRunVisitor.kt +++ b/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/run/SqlDelightRunVisitor.kt @@ -26,7 +26,7 @@ internal class SqlDelightRunVisitor( private data class RunSqliteStatementGutterIconRenderer( private val stmt: SqlStmt, - private val connectionManager: ConnectionManager + private val connectionManager: ConnectionManager, ) : GutterIconRenderer() { override fun isNavigateAction() = true override fun getIcon(): Icon = AllIcons.RunConfigurations.TestState.Run diff --git a/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/run/SqlDelightStatementExecutor.kt b/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/run/SqlDelightStatementExecutor.kt index 7b73d8df31d..eaa02c14195 100644 --- a/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/run/SqlDelightStatementExecutor.kt +++ b/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/run/SqlDelightStatementExecutor.kt @@ -22,7 +22,7 @@ import javax.swing.JPanel internal class SqlDelightStatementExecutor( private val project: Project, - private val connectionManager: ConnectionManager + private val connectionManager: ConnectionManager, ) { fun execute(sqlStmt: String, identifier: StmtIdentifier?) { val consoleView = getConsoleView(project, identifier) ?: return @@ -63,7 +63,7 @@ internal class SqlDelightStatementExecutor( project, connectionManager, consoleView.component, - name = identifier?.name ?: "SQL" + name = identifier?.name ?: "SQL", ) contentManager.addContent(newExecution) diff --git a/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/run/SqlParameter.kt b/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/run/SqlParameter.kt index d6a74b01369..5fe729d1f95 100644 --- a/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/run/SqlParameter.kt +++ b/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/run/SqlParameter.kt @@ -3,5 +3,5 @@ package app.cash.sqldelight.intellij.run internal data class SqlParameter( val name: String, val value: String = "", - val range: IntRange + val range: IntRange, ) diff --git a/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/run/android/SqlDelightRunAnnotator.kt b/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/run/android/SqlDelightRunAnnotator.kt index c36bd4c287f..08f027118aa 100644 --- a/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/run/android/SqlDelightRunAnnotator.kt +++ b/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/run/android/SqlDelightRunAnnotator.kt @@ -26,7 +26,7 @@ import javax.swing.Icon class SqlDelightRunAnnotator : Annotator { override fun annotate( element: PsiElement, - holder: AnnotationHolder + holder: AnnotationHolder, ) { if (element.parent !is SqlStmtList || element !is SqlStmt) return @@ -42,7 +42,7 @@ class SqlDelightRunAnnotator : Annotator { * Shows an icon in the gutter when a SQLite statement is recognized. eg. Room @Query annotations. */ private data class RunSqliteStatementGutterIconRenderer( - private val element: SmartPsiElementPointer + private val element: SmartPsiElementPointer, ) : GutterIconRenderer() { private val sqliteExplorerProjectService = DatabaseInspectorProjectService.getInstance(element.project) @@ -61,7 +61,7 @@ class SqlDelightRunAnnotator : Annotator { } private class SqlDelightRunStatementAction( - private val originalElement: SmartPsiElementPointer + private val originalElement: SmartPsiElementPointer, ) : AnAction() { override fun actionPerformed(e: AnActionEvent) { val element = originalElement.element ?: return @@ -77,7 +77,7 @@ class SqlDelightRunAnnotator : Annotator { | db.execSQL("$text"); | } |} - """.trimMargin() + """.trimMargin() val psiFile = PsiFileFactory.getInstance(element.project) .createFileFromText("Util.java", JavaLanguage.INSTANCE, s) @@ -86,7 +86,9 @@ class SqlDelightRunAnnotator : Annotator { PsiTreeUtil.findChildOfType(psiFile, PsiLanguageInjectionHost::class.java) ?: return RunSqliteStatementGutterIconAction( - host.project, host, DatabaseInspectorViewsFactoryImpl.getInstance() + host.project, + host, + DatabaseInspectorViewsFactoryImpl.getInstance(), ).actionPerformed(e) } } diff --git a/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/run/window/ConnectionListPanel.kt b/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/run/window/ConnectionListPanel.kt index 41f4e1d881d..e9953214eec 100644 --- a/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/run/window/ConnectionListPanel.kt +++ b/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/run/window/ConnectionListPanel.kt @@ -33,7 +33,9 @@ internal class ConnectionListPanel( } private val clearSelectedConnection: AnActionButton = object : AnActionButton( - "Stop", "Stop using connection", AllIcons.RunConfigurations.ShowIgnored + "Stop", + "Stop using connection", + AllIcons.RunConfigurations.ShowIgnored, ) { init { isEnabled = false @@ -69,7 +71,7 @@ internal class ConnectionListPanel( weightx = 1.0 gridx = 0 gridy = 0 - } + }, ) list.addListSelectionListener { @@ -84,17 +86,19 @@ internal class ConnectionListPanel( PsiDocumentManager.getInstance(project).reparseFiles(emptyList(), true) } - list.addMouseListener(object : MouseAdapter() { - override fun mouseClicked(e: MouseEvent) { - if (e.clickCount == 2 && e.button == MouseEvent.BUTTON1) { - val currentProperties = connectionOptions.currentOption() - val properties = connectionManager.createNewConnectionProperties(project, currentProperties) - ?: return - connectionOptions.replaceOption(properties) - updateModel() + list.addMouseListener( + object : MouseAdapter() { + override fun mouseClicked(e: MouseEvent) { + if (e.clickCount == 2 && e.button == MouseEvent.BUTTON1) { + val currentProperties = connectionOptions.currentOption() + val properties = connectionManager.createNewConnectionProperties(project, currentProperties) + ?: return + connectionOptions.replaceOption(properties) + updateModel() + } } - } - }) + }, + ) updateModel() } diff --git a/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/run/window/SqlDelightToolWindowFactory.kt b/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/run/window/SqlDelightToolWindowFactory.kt index cf1669d4abc..da4bf99e7bd 100644 --- a/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/run/window/SqlDelightToolWindowFactory.kt +++ b/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/run/window/SqlDelightToolWindowFactory.kt @@ -15,11 +15,11 @@ import javax.swing.GroupLayout import javax.swing.JPanel internal class SqlDelightToolWindowFactory( - private val connectionManager: ConnectionManager + private val connectionManager: ConnectionManager, ) : ToolWindowFactory { override fun createToolWindowContent( project: Project, - toolWindow: ToolWindow + toolWindow: ToolWindow, ) { val runSqlText = JPanel(BorderLayout()).apply { add( @@ -27,7 +27,7 @@ internal class SqlDelightToolWindowFactory( margin = Insets(8, 8, 8, 8) isEditable = false }, - BorderLayout.CENTER + BorderLayout.CENTER, ) } @@ -43,7 +43,7 @@ internal fun ContentManager.createWithConnectionSidePanel( project: Project, connectionManager: ConnectionManager, component: Component, - name: String? = null + name: String? = null, ): Content { val panel = JPanel() @@ -55,13 +55,13 @@ internal fun ContentManager.createWithConnectionSidePanel( layout.setHorizontalGroup( layout.createSequentialGroup() .addComponent(connectionList, 50, 200, 300) - .addComponent(component) + .addComponent(component), ) layout.setVerticalGroup( layout.createParallelGroup() .addComponent(connectionList) - .addComponent(component) + .addComponent(component), ) return factory.createContent(panel, name, false) diff --git a/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/util/GeneratedVirtualFile.kt b/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/util/GeneratedVirtualFile.kt index 318d51128df..d71cc662f43 100644 --- a/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/util/GeneratedVirtualFile.kt +++ b/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/util/GeneratedVirtualFile.kt @@ -29,7 +29,7 @@ class GeneratedVirtualFile(private val path: String, module: Module) { operator fun getValue( thisRef: Nothing?, - property: KProperty<*> + property: KProperty<*>, ): VirtualFile { applicationManager.assertWriteAccessAllowed() synchronized(this) { diff --git a/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/util/VirtualFileUtil.kt b/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/util/IsAncestorOf.kt similarity index 100% rename from sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/util/VirtualFileUtil.kt rename to sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/util/IsAncestorOf.kt diff --git a/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/util/PsiUtil.kt b/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/util/PsiUtil.kt index 68cad82d217..760bd9cc100 100644 --- a/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/util/PsiUtil.kt +++ b/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/util/PsiUtil.kt @@ -24,7 +24,7 @@ internal inline fun PsiElement.prevSiblingOfType(): T? PsiTreeUtil.getPrevSiblingOfType(this, T::class.java) internal inline fun PsiFile.findElementOfTypeAtOffset( - offset: Int + offset: Int, ): T? { return PsiTreeUtil.findElementOfClassAtOffset(this, offset, T::class.java, false) } diff --git a/sqldelight-idea-plugin/src/test/kotlin/app/cash/sqldelight/intellij/FindUsagesTest.kt b/sqldelight-idea-plugin/src/test/kotlin/app/cash/sqldelight/intellij/FindUsagesTest.kt index 68f0781394c..0e6fed127c3 100644 --- a/sqldelight-idea-plugin/src/test/kotlin/app/cash/sqldelight/intellij/FindUsagesTest.kt +++ b/sqldelight-idea-plugin/src/test/kotlin/app/cash/sqldelight/intellij/FindUsagesTest.kt @@ -20,40 +20,40 @@ class FindUsagesTest : SqlDelightProjectTestCase() { // With the kotlin 1.3.30 plugin the test breaks. Find usages still works. Investigate later. fun ignoretestFindsBothKotlinAndJavaUsages() { myFixture.openFileInEditor( - tempRoot.findFileByRelativePath("src/main/java/com/example/SampleClass.java")!! + tempRoot.findFileByRelativePath("src/main/java/com/example/SampleClass.java")!!, ) val javaCallsite = searchForElement("someQuery").single() myFixture.openFileInEditor( - tempRoot.findFileByRelativePath("src/main/kotlin/com/example/KotlinClass.kt")!! + tempRoot.findFileByRelativePath("src/main/kotlin/com/example/KotlinClass.kt")!!, ) val kotlinCallsite = searchForElement("someQuery").single() myFixture.openFileInEditor( - tempRoot.findFileByRelativePath("src/main/sqldelight/com/example/Main.sq")!! + tempRoot.findFileByRelativePath("src/main/sqldelight/com/example/Main.sq")!!, ) val identifier = searchForElement("someQuery").single() assertThat(myFixture.findUsages(identifier)).containsExactly( KotlinReferenceUsageInfo(javaCallsite), - KotlinReferenceUsageInfo(kotlinCallsite.references.firstIsInstance()) + KotlinReferenceUsageInfo(kotlinCallsite.references.firstIsInstance()), ) } // With the kotlin 1.3.30 plugin the test breaks. Find usages still works. Investigate later. fun ignoretestFindsUsagesOfAllGeneratedMethods() { myFixture.openFileInEditor( - tempRoot.findFileByRelativePath("src/main/kotlin/com/example/KotlinClass.kt")!! + tempRoot.findFileByRelativePath("src/main/kotlin/com/example/KotlinClass.kt")!!, ) val callsites = searchForElement("multiQuery") myFixture.openFileInEditor( - tempRoot.findFileByRelativePath("src/main/sqldelight/com/example/Main.sq")!! + tempRoot.findFileByRelativePath("src/main/sqldelight/com/example/Main.sq")!!, ) val identifier = searchForElement("multiQuery").single() assertThat(myFixture.findUsages(identifier)).containsExactly( *callsites.map { KotlinReferenceUsageInfo(it.references.firstIsInstance()) - }.toTypedArray() + }.toTypedArray(), ) } @@ -71,7 +71,7 @@ class FindUsagesTest : SqlDelightProjectTestCase() { |someSelect: |SELECT * |FROM test; - """.trimMargin() + """.trimMargin(), ) val tableName = searchForElement("test") assertThat(tableName).hasSize(3) @@ -79,7 +79,7 @@ class FindUsagesTest : SqlDelightProjectTestCase() { assertThat(myFixture.findUsages(tableName.first())).containsExactly( *tableName.map { UsageInfo(it) - }.toTypedArray() + }.toTypedArray(), ) } @@ -102,7 +102,7 @@ class FindUsagesTest : SqlDelightProjectTestCase() { |SELECT value |FROM test |WHERE test.value = ?; - """.trimMargin() + """.trimMargin(), ) val tableName = searchForElement("value") assertThat(tableName).hasSize(5) @@ -110,7 +110,7 @@ class FindUsagesTest : SqlDelightProjectTestCase() { assertThat(myFixture.findUsages(tableName.first())).containsExactly( *tableName.map { UsageInfo(it) - }.toTypedArray() + }.toTypedArray(), ) } @@ -124,7 +124,7 @@ class FindUsagesTest : SqlDelightProjectTestCase() { |someSelect: |SELECT * |FROM test; - """.trimMargin() + """.trimMargin(), ) val viewName = searchForElement("test") + searchForElement("test") @@ -133,7 +133,7 @@ class FindUsagesTest : SqlDelightProjectTestCase() { assertThat(myFixture.findUsages(viewName.first())).containsExactly( *viewName.map { UsageInfo(it) - }.toTypedArray() + }.toTypedArray(), ) } @@ -152,7 +152,7 @@ class FindUsagesTest : SqlDelightProjectTestCase() { |someSelect: |SELECT stuff_alias |FROM test_view; - """.trimMargin() + """.trimMargin(), ) val columnAlias = searchForElement("stuff_alias") + searchForElement("stuff_alias") @@ -161,7 +161,7 @@ class FindUsagesTest : SqlDelightProjectTestCase() { assertThat(myFixture.findUsages(columnAlias.first())).containsExactly( *columnAlias.drop(1).map { UsageInfo(it) - }.toTypedArray() + }.toTypedArray(), ) } @@ -177,7 +177,7 @@ class FindUsagesTest : SqlDelightProjectTestCase() { |SELECT test_alias.* |FROM test test_alias |WHERE test_alias.stuff = ?; - """.trimMargin() + """.trimMargin(), ) val tableAlias = searchForElement("test_alias") + searchForElement("test_alias") @@ -186,7 +186,7 @@ class FindUsagesTest : SqlDelightProjectTestCase() { assertThat(myFixture.findUsages(tableAlias.first())).containsExactly( *tableAlias.drop(1).map { UsageInfo(it) - }.toTypedArray() + }.toTypedArray(), ) } @@ -206,7 +206,7 @@ class FindUsagesTest : SqlDelightProjectTestCase() { |SELECT test_alias.* |FROM test_alias |WHERE test_alias.stuff = ?; - """.trimMargin() + """.trimMargin(), ) val tableName = searchForElement("test_alias") assertThat(tableName).hasSize(4) @@ -214,7 +214,7 @@ class FindUsagesTest : SqlDelightProjectTestCase() { assertThat(myFixture.findUsages(tableName.first())).containsExactly( *tableName.map { UsageInfo(it) - }.toTypedArray() + }.toTypedArray(), ) } @@ -234,7 +234,7 @@ class FindUsagesTest : SqlDelightProjectTestCase() { |SELECT stuff_alias |FROM test_alias |WHERE test_alias.stuff_alias = ?; - """.trimMargin() + """.trimMargin(), ) val columnAlias = searchForElement("stuff_alias") + searchForElement("stuff_alias") @@ -243,7 +243,7 @@ class FindUsagesTest : SqlDelightProjectTestCase() { assertThat(myFixture.findUsages(columnAlias.first())).containsExactly( *columnAlias.drop(1).map { UsageInfo(it) - }.toTypedArray() + }.toTypedArray(), ) } @@ -257,12 +257,12 @@ class FindUsagesTest : SqlDelightProjectTestCase() { | |ALTER TABLE test RENAME TO test2; |ALTER TABLE test2 RENAME TO test3; - """.trimMargin() + """.trimMargin(), ) val newName = searchForElement("test2").single() assertThat(myFixture.findUsages(newName)).containsExactly( - *(searchForElement("test2") + newName).map(::UsageInfo).toTypedArray() + *(searchForElement("test2") + newName).map(::UsageInfo).toTypedArray(), ) } } diff --git a/sqldelight-idea-plugin/src/test/kotlin/app/cash/sqldelight/intellij/ReferenceContrubutorTest.kt b/sqldelight-idea-plugin/src/test/kotlin/app/cash/sqldelight/intellij/ReferenceContrubutorTest.kt index 989c2a7890c..95368538448 100644 --- a/sqldelight-idea-plugin/src/test/kotlin/app/cash/sqldelight/intellij/ReferenceContrubutorTest.kt +++ b/sqldelight-idea-plugin/src/test/kotlin/app/cash/sqldelight/intellij/ReferenceContrubutorTest.kt @@ -16,7 +16,7 @@ class ReferenceContrubutorTest : SqlDelightFixtureTestCase() { | |public class SomeClass { |} - """.trimMargin() + """.trimMargin(), ) myFixture.configureByText( SqlDelightFileType, @@ -26,7 +26,7 @@ class ReferenceContrubutorTest : SqlDelightFixtureTestCase() { |CREATE TABLE new_table ( | col TEXT AS SomeClass NOT NULL |); - """.trimMargin() + """.trimMargin(), ) val reference = myFixture.getReferenceAtCaretPositionWithAssertion() val psiClass = myFixture.findClass("com.somepackage.SomeClass") @@ -41,7 +41,7 @@ class ReferenceContrubutorTest : SqlDelightFixtureTestCase() { | |public class SomeClass { |} - """.trimMargin() + """.trimMargin(), ) myFixture.configureByText( SqlDelightFileType, @@ -51,7 +51,7 @@ class ReferenceContrubutorTest : SqlDelightFixtureTestCase() { |CREATE TABLE new_table ( | col TEXT AS SomeClass NOT NULL |); - """.trimMargin() + """.trimMargin(), ) val reference = myFixture.getReferenceAtCaretPositionWithAssertion() val psiClass = myFixture.findClass("com.somepackage.SomeClass") @@ -65,7 +65,7 @@ class ReferenceContrubutorTest : SqlDelightFixtureTestCase() { |package com.somepackage | |class SomeClass - """.trimMargin() + """.trimMargin(), ) myFixture.configureByText( SqlDelightFileType, @@ -75,7 +75,7 @@ class ReferenceContrubutorTest : SqlDelightFixtureTestCase() { |CREATE TABLE new_table ( | col TEXT AS SomeClass NOT NULL |); - """.trimMargin() + """.trimMargin(), ) val reference = myFixture.getReferenceAtCaretPositionWithAssertion() val psiClass = myFixture.findClass("com.somepackage.SomeClass") @@ -89,7 +89,7 @@ class ReferenceContrubutorTest : SqlDelightFixtureTestCase() { |package com.somepackage | |class SomeClass - """.trimMargin() + """.trimMargin(), ) myFixture.configureByText( SqlDelightFileType, @@ -99,7 +99,7 @@ class ReferenceContrubutorTest : SqlDelightFixtureTestCase() { |CREATE TABLE new_table ( | col TEXT AS SomeClass NOT NULL |); - """.trimMargin() + """.trimMargin(), ) val reference = myFixture.getReferenceAtCaretPositionWithAssertion() val psiClass = myFixture.findClass("com.somepackage.SomeClass") @@ -113,7 +113,7 @@ class ReferenceContrubutorTest : SqlDelightFixtureTestCase() { |package com.somepackage | |expect class SomeExpectClass - """.trimMargin() + """.trimMargin(), ) myFixture.configureByText( SqlDelightFileType, @@ -123,7 +123,7 @@ class ReferenceContrubutorTest : SqlDelightFixtureTestCase() { |CREATE TABLE new_table ( | col TEXT AS SomeExpectClass NOT NULL |); - """.trimMargin() + """.trimMargin(), ) val reference = myFixture.getReferenceAtCaretPositionWithAssertion() val psiClass = psiFile.childrenOfType().single() @@ -137,7 +137,7 @@ class ReferenceContrubutorTest : SqlDelightFixtureTestCase() { |package com.somepackage | |expect class SomeExpectClass - """.trimMargin() + """.trimMargin(), ) myFixture.configureByText( SqlDelightFileType, @@ -147,7 +147,7 @@ class ReferenceContrubutorTest : SqlDelightFixtureTestCase() { |CREATE TABLE new_table ( | col TEXT AS SomeExpectClass NOT NULL |); - """.trimMargin() + """.trimMargin(), ) val reference = myFixture.getReferenceAtCaretPositionWithAssertion() val psiClass = file.childrenOfType().single() @@ -161,7 +161,7 @@ class ReferenceContrubutorTest : SqlDelightFixtureTestCase() { |package kotlin | |class Int - """.trimMargin() + """.trimMargin(), ) myFixture.configureByText( SqlDelightFileType, @@ -171,7 +171,7 @@ class ReferenceContrubutorTest : SqlDelightFixtureTestCase() { |CREATE TABLE new_table ( | col TEXT AS Int NOT NULL |); - """.trimMargin() + """.trimMargin(), ) val reference = myFixture.getReferenceAtCaretPositionWithAssertion() val psiClass = file.childrenOfType().single() @@ -185,7 +185,7 @@ class ReferenceContrubutorTest : SqlDelightFixtureTestCase() { |package kotlin | |class Int - """.trimMargin() + """.trimMargin(), ) myFixture.configureByText( SqlDelightFileType, @@ -195,7 +195,7 @@ class ReferenceContrubutorTest : SqlDelightFixtureTestCase() { |CREATE TABLE new_table ( | col TEXT AS Int NOT NULL |); - """.trimMargin() + """.trimMargin(), ) val reference = myFixture.getReferenceAtCaretPositionWithAssertion() val psiClass = file.childrenOfType().single() @@ -209,7 +209,7 @@ class ReferenceContrubutorTest : SqlDelightFixtureTestCase() { |package com.example | |class SomeClass - """.trimMargin() + """.trimMargin(), ) myFixture.configureByText( SqlDelightFileType, @@ -217,7 +217,7 @@ class ReferenceContrubutorTest : SqlDelightFixtureTestCase() { |CREATE TABLE new_table ( | col TEXT AS SomeClass NOT NULL |); - """.trimMargin() + """.trimMargin(), ) val reference = myFixture.getReferenceAtCaretPositionWithAssertion() val psiClass = file.childrenOfType().single() @@ -231,7 +231,7 @@ class ReferenceContrubutorTest : SqlDelightFixtureTestCase() { |package com.somepackage | |class SomeClass - """.trimMargin() + """.trimMargin(), ) myFixture.configureByText( SqlDelightFileType, @@ -239,7 +239,7 @@ class ReferenceContrubutorTest : SqlDelightFixtureTestCase() { |CREATE TABLE new_table ( | col TEXT AS SomeClass NOT NULL |); - """.trimMargin() + """.trimMargin(), ) val reference = myFixture.getReferenceAtCaretPositionWithAssertion() assertThat(reference.resolve()).isNull() @@ -254,7 +254,7 @@ class ReferenceContrubutorTest : SqlDelightFixtureTestCase() { |class SomeClass { | class NestedClass |} - """.trimMargin() + """.trimMargin(), ) myFixture.configureByText( SqlDelightFileType, @@ -264,7 +264,7 @@ class ReferenceContrubutorTest : SqlDelightFixtureTestCase() { |CREATE TABLE new_table ( | col TEXT AS SomeClass.NestedClass NOT NULL |); - """.trimMargin() + """.trimMargin(), ) val psiClass = myFixture.findClass("com.somepackage.SomeClass.NestedClass") val reference = myFixture.getReferenceAtCaretPositionWithAssertion() @@ -278,7 +278,7 @@ class ReferenceContrubutorTest : SqlDelightFixtureTestCase() { |package com.somepackage | |typealias SomeType = Int - """.trimMargin() + """.trimMargin(), ) myFixture.configureByText( SqlDelightFileType, @@ -288,7 +288,7 @@ class ReferenceContrubutorTest : SqlDelightFixtureTestCase() { |CREATE TABLE new_table ( | col TEXT AS SomeType NOT NULL |); - """.trimMargin() + """.trimMargin(), ) val typeAlias = file.childrenOfType().single().psiOrParent val reference = myFixture.getReferenceAtCaretPositionWithAssertion() @@ -302,7 +302,7 @@ class ReferenceContrubutorTest : SqlDelightFixtureTestCase() { |package com.somepackage | |enum class SomeEnum - """.trimMargin() + """.trimMargin(), ) myFixture.configureByText( SqlDelightFileType, @@ -312,7 +312,7 @@ class ReferenceContrubutorTest : SqlDelightFixtureTestCase() { |CREATE TABLE new_table ( | col TEXT AS SomeEnum NOT NULL |); - """.trimMargin() + """.trimMargin(), ) val psiClass = myFixture.findClass("com.somepackage.SomeEnum") val reference = myFixture.getReferenceAtCaretPositionWithAssertion() diff --git a/sqldelight-idea-plugin/src/test/kotlin/app/cash/sqldelight/intellij/SqlDelightFixtureTestCase.kt b/sqldelight-idea-plugin/src/test/kotlin/app/cash/sqldelight/intellij/SqlDelightFixtureTestCase.kt index dad00d09deb..775601a43ab 100644 --- a/sqldelight-idea-plugin/src/test/kotlin/app/cash/sqldelight/intellij/SqlDelightFixtureTestCase.kt +++ b/sqldelight-idea-plugin/src/test/kotlin/app/cash/sqldelight/intellij/SqlDelightFixtureTestCase.kt @@ -57,14 +57,14 @@ abstract class SqlDelightFixtureTestCase : LightJavaCodeInsightFixtureTestCase() override fun sourceFolders( file: SqlDelightFile, - includeDependencies: Boolean + includeDependencies: Boolean, ): List { return listOf(myFixture.file.parent!!) } override fun sourceFolders( file: VirtualFile, - includeDependencies: Boolean + includeDependencies: Boolean, ): Collection { return listOf(module.rootManager.contentRoots.first()) } diff --git a/sqldelight-idea-plugin/src/test/kotlin/app/cash/sqldelight/intellij/SqlDelightInlayParameterHintsProviderTest.kt b/sqldelight-idea-plugin/src/test/kotlin/app/cash/sqldelight/intellij/SqlDelightInlayParameterHintsProviderTest.kt index 7dbaaedee0c..8fd27cf305b 100644 --- a/sqldelight-idea-plugin/src/test/kotlin/app/cash/sqldelight/intellij/SqlDelightInlayParameterHintsProviderTest.kt +++ b/sqldelight-idea-plugin/src/test/kotlin/app/cash/sqldelight/intellij/SqlDelightInlayParameterHintsProviderTest.kt @@ -19,7 +19,7 @@ class SqlDelightInlayParameterHintsProviderTest : SqlDelightFixtureTestCase() { | |INSERT INTO hockeyPlayer (column1, column2, column3, column4, column5, column6) |VALUES (?, ?, ?, ?, ?, ?); - """.trimMargin() + """.trimMargin(), ) myFixture.testInlays() } @@ -37,7 +37,7 @@ class SqlDelightInlayParameterHintsProviderTest : SqlDelightFixtureTestCase() { |insert: |INSERT INTO example (name, description) |VALUES (?, ?); - """.trimMargin() + """.trimMargin(), ) myFixture.testInlays() } diff --git a/sqldelight-idea-plugin/src/test/kotlin/app/cash/sqldelight/intellij/SqlDelightParameterInfoHandlerTest.kt b/sqldelight-idea-plugin/src/test/kotlin/app/cash/sqldelight/intellij/SqlDelightParameterInfoHandlerTest.kt index 6109ca3814e..68d941e39b5 100644 --- a/sqldelight-idea-plugin/src/test/kotlin/app/cash/sqldelight/intellij/SqlDelightParameterInfoHandlerTest.kt +++ b/sqldelight-idea-plugin/src/test/kotlin/app/cash/sqldelight/intellij/SqlDelightParameterInfoHandlerTest.kt @@ -19,7 +19,7 @@ class SqlDelightParameterInfoHandlerTest : SqlDelightFixtureTestCase() { |insert: |INSERT INTO example (name, description) |VALUES (?, ?); - """.trimMargin() + """.trimMargin(), ) val parameterInfoHandler = SqlDelightParameterInfoHandler() diff --git a/sqldelight-idea-plugin/src/test/kotlin/app/cash/sqldelight/intellij/SqlDelightProjectTestCase.kt b/sqldelight-idea-plugin/src/test/kotlin/app/cash/sqldelight/intellij/SqlDelightProjectTestCase.kt index 3fa1210eec9..dca2d6e0f91 100644 --- a/sqldelight-idea-plugin/src/test/kotlin/app/cash/sqldelight/intellij/SqlDelightProjectTestCase.kt +++ b/sqldelight-idea-plugin/src/test/kotlin/app/cash/sqldelight/intellij/SqlDelightProjectTestCase.kt @@ -48,29 +48,29 @@ abstract class SqlDelightProjectTestCase : LightJavaCodeInsightFixtureTestCase() SqlDelightCompilationUnitImpl( name = "internalDebug", outputDirectoryFile = File(tempRoot.path, "build"), - sourceFolders = listOf(SqlDelightSourceFolderImpl(File(tempRoot.path, "src/main/sqldelight"), false), SqlDelightSourceFolderImpl(File(tempRoot.path, "src/internal/sqldelight"), false), SqlDelightSourceFolderImpl(File(tempRoot.path, "src/debug/sqldelight"), false), SqlDelightSourceFolderImpl(File(tempRoot.path, "src/internalDebug/sqldelight"), false)) + sourceFolders = listOf(SqlDelightSourceFolderImpl(File(tempRoot.path, "src/main/sqldelight"), false), SqlDelightSourceFolderImpl(File(tempRoot.path, "src/internal/sqldelight"), false), SqlDelightSourceFolderImpl(File(tempRoot.path, "src/debug/sqldelight"), false), SqlDelightSourceFolderImpl(File(tempRoot.path, "src/internalDebug/sqldelight"), false)), ), SqlDelightCompilationUnitImpl( name = "internalRelease", outputDirectoryFile = File(tempRoot.path, "build"), - sourceFolders = listOf(SqlDelightSourceFolderImpl(File(tempRoot.path, "src/main/sqldelight"), false), SqlDelightSourceFolderImpl(File(tempRoot.path, "src/internal/sqldelight"), false), SqlDelightSourceFolderImpl(File(tempRoot.path, "src/release/sqldelight"), false), SqlDelightSourceFolderImpl(File(tempRoot.path, "src/internalRelease/sqldelight"), false)) + sourceFolders = listOf(SqlDelightSourceFolderImpl(File(tempRoot.path, "src/main/sqldelight"), false), SqlDelightSourceFolderImpl(File(tempRoot.path, "src/internal/sqldelight"), false), SqlDelightSourceFolderImpl(File(tempRoot.path, "src/release/sqldelight"), false), SqlDelightSourceFolderImpl(File(tempRoot.path, "src/internalRelease/sqldelight"), false)), ), SqlDelightCompilationUnitImpl( name = "productionDebug", outputDirectoryFile = File(tempRoot.path, "build"), - sourceFolders = listOf(SqlDelightSourceFolderImpl(File(tempRoot.path, "src/main/sqldelight"), false), SqlDelightSourceFolderImpl(File(tempRoot.path, "src/production/sqldelight"), false), SqlDelightSourceFolderImpl(File(tempRoot.path, "src/debug/sqldelight"), false), SqlDelightSourceFolderImpl(File(tempRoot.path, "src/productionDebug/sqldelight"), false)) + sourceFolders = listOf(SqlDelightSourceFolderImpl(File(tempRoot.path, "src/main/sqldelight"), false), SqlDelightSourceFolderImpl(File(tempRoot.path, "src/production/sqldelight"), false), SqlDelightSourceFolderImpl(File(tempRoot.path, "src/debug/sqldelight"), false), SqlDelightSourceFolderImpl(File(tempRoot.path, "src/productionDebug/sqldelight"), false)), ), SqlDelightCompilationUnitImpl( name = "productionRelease", outputDirectoryFile = File(tempRoot.path, "build"), - sourceFolders = listOf(SqlDelightSourceFolderImpl(File(tempRoot.path, "src/main/sqldelight"), false), SqlDelightSourceFolderImpl(File(tempRoot.path, "src/production/sqldelight"), false), SqlDelightSourceFolderImpl(File(tempRoot.path, "src/release/sqldelight"), false), SqlDelightSourceFolderImpl(File(tempRoot.path, "src/productionRelease/sqldelight"), false)) - ) + sourceFolders = listOf(SqlDelightSourceFolderImpl(File(tempRoot.path, "src/main/sqldelight"), false), SqlDelightSourceFolderImpl(File(tempRoot.path, "src/production/sqldelight"), false), SqlDelightSourceFolderImpl(File(tempRoot.path, "src/release/sqldelight"), false), SqlDelightSourceFolderImpl(File(tempRoot.path, "src/productionRelease/sqldelight"), false)), + ), ), dependencies = emptyList(), rootDirectory = File(tempRoot.path).absoluteFile, deriveSchemaFromMigrations = false, treatNullAsUnknownForEquality = false, - generateAsync = false + generateAsync = false, ) } @@ -87,7 +87,7 @@ abstract class SqlDelightProjectTestCase : LightJavaCodeInsightFixtureTestCase() private data class SqlDelightSourceFolderImpl( override val folder: File, - override val dependency: Boolean + override val dependency: Boolean, ) : SqlDelightSourceFolder private data class SqlDelightCompilationUnitImpl( diff --git a/sqldelight-idea-plugin/src/test/kotlin/app/cash/sqldelight/intellij/annotations/ClassNameAnnotatorTest.kt b/sqldelight-idea-plugin/src/test/kotlin/app/cash/sqldelight/intellij/annotations/ClassNameAnnotatorTest.kt index 983282fc640..152f919b143 100644 --- a/sqldelight-idea-plugin/src/test/kotlin/app/cash/sqldelight/intellij/annotations/ClassNameAnnotatorTest.kt +++ b/sqldelight-idea-plugin/src/test/kotlin/app/cash/sqldelight/intellij/annotations/ClassNameAnnotatorTest.kt @@ -7,7 +7,7 @@ import org.jetbrains.kotlin.idea.KotlinFileType class ClassNameAnnotatorTest : SqlDelightProjectTestCase() { fun testResolveOnSamePackageImport() { myFixture.openFileInEditor( - tempRoot.findFileByRelativePath("src/main/sqldelight/com/example/Main.sq")!! + tempRoot.findFileByRelativePath("src/main/sqldelight/com/example/Main.sq")!!, ) myFixture.checkHighlighting() @@ -20,7 +20,7 @@ class ClassNameAnnotatorTest : SqlDelightProjectTestCase() { |CREATE TABLE test ( | value TEXT AS KoolKidz |); - """.trimMargin() + """.trimMargin(), ) myFixture.checkHighlighting() @@ -35,7 +35,7 @@ class ClassNameAnnotatorTest : SqlDelightProjectTestCase() { |CREATE TABLE test ( | value TEXT AS KotlinClass.InnerClass |); - """.trimMargin() + """.trimMargin(), ) myFixture.checkHighlighting() @@ -50,7 +50,7 @@ class ClassNameAnnotatorTest : SqlDelightProjectTestCase() { |CREATE TABLE new_table ( | col TEXT AS SomeClass NOT NULL |); - """.trimMargin() + """.trimMargin(), ) myFixture.checkHighlighting() @@ -65,7 +65,7 @@ class ClassNameAnnotatorTest : SqlDelightProjectTestCase() { |class SomeClass { | class FirstLevel |} - """.trimMargin() + """.trimMargin(), ) myFixture.configureByText( @@ -76,7 +76,7 @@ class ClassNameAnnotatorTest : SqlDelightProjectTestCase() { |CREATE TABLE new_table ( | col TEXT AS SomeClass.FirstLevel.SecondLevel NOT NULL |); - """.trimMargin() + """.trimMargin(), ) myFixture.checkHighlighting() diff --git a/sqldelight-idea-plugin/src/test/kotlin/app/cash/sqldelight/intellij/annotations/OptimisticLockAnnotatorTest.kt b/sqldelight-idea-plugin/src/test/kotlin/app/cash/sqldelight/intellij/annotations/OptimisticLockAnnotatorTest.kt index 9659a53092f..f2385824526 100644 --- a/sqldelight-idea-plugin/src/test/kotlin/app/cash/sqldelight/intellij/annotations/OptimisticLockAnnotatorTest.kt +++ b/sqldelight-idea-plugin/src/test/kotlin/app/cash/sqldelight/intellij/annotations/OptimisticLockAnnotatorTest.kt @@ -23,7 +23,7 @@ class OptimisticLockAnnotatorTest : SqlDelightProjectTestCase() { | id = :id AND | version = :version |; - """.trimMargin() + """.trimMargin(), ) myFixture.checkHighlighting() @@ -46,7 +46,7 @@ class OptimisticLockAnnotatorTest : SqlDelightProjectTestCase() { |WHERE | id = :id |; - """.trimMargin() + """.trimMargin(), ) myFixture.checkHighlighting() @@ -70,7 +70,7 @@ class OptimisticLockAnnotatorTest : SqlDelightProjectTestCase() { | id = :id AND | version = :version |; - """.trimMargin() + """.trimMargin(), ) myFixture.checkHighlighting() @@ -94,7 +94,7 @@ class OptimisticLockAnnotatorTest : SqlDelightProjectTestCase() { |WHERE | id = :id |; - """.trimMargin() + """.trimMargin(), ) myFixture.checkHighlighting() @@ -119,7 +119,7 @@ class OptimisticLockAnnotatorTest : SqlDelightProjectTestCase() { | id = :id AND | version = :version |; - """.trimMargin() + """.trimMargin(), ) myFixture.checkHighlighting() @@ -144,7 +144,7 @@ class OptimisticLockAnnotatorTest : SqlDelightProjectTestCase() { | id = :id AND | version = :version |; - """.trimMargin() + """.trimMargin(), ) myFixture.checkHighlighting() @@ -169,7 +169,7 @@ class OptimisticLockAnnotatorTest : SqlDelightProjectTestCase() { | id = :id AND | version <> :version |; - """.trimMargin() + """.trimMargin(), ) myFixture.checkHighlighting() @@ -195,7 +195,7 @@ class OptimisticLockAnnotatorTest : SqlDelightProjectTestCase() { | version = :version |LIMIT 10 |; - """.trimMargin() + """.trimMargin(), ) myFixture.checkHighlighting() @@ -219,7 +219,7 @@ class OptimisticLockAnnotatorTest : SqlDelightProjectTestCase() { | id = :id |LIMIT 10 |; - """.trimMargin() + """.trimMargin(), ) myFixture.checkHighlighting() @@ -244,7 +244,7 @@ class OptimisticLockAnnotatorTest : SqlDelightProjectTestCase() { | version = :version |LIMIT 10 |; - """.trimMargin() + """.trimMargin(), ) myFixture.checkHighlighting() @@ -269,7 +269,7 @@ class OptimisticLockAnnotatorTest : SqlDelightProjectTestCase() { | id = :id |LIMIT 10 |; - """.trimMargin() + """.trimMargin(), ) myFixture.checkHighlighting() @@ -295,7 +295,7 @@ class OptimisticLockAnnotatorTest : SqlDelightProjectTestCase() { | version = :version |LIMIT 10 |; - """.trimMargin() + """.trimMargin(), ) myFixture.checkHighlighting() @@ -321,7 +321,7 @@ class OptimisticLockAnnotatorTest : SqlDelightProjectTestCase() { | version = :version |LIMIT 10 |; - """.trimMargin() + """.trimMargin(), ) myFixture.checkHighlighting() @@ -347,7 +347,7 @@ class OptimisticLockAnnotatorTest : SqlDelightProjectTestCase() { | version <> :version |LIMIT 10 |; - """.trimMargin() + """.trimMargin(), ) myFixture.checkHighlighting() diff --git a/sqldelight-idea-plugin/src/test/kotlin/app/cash/sqldelight/intellij/autocomplete/AutocompleteTests.kt b/sqldelight-idea-plugin/src/test/kotlin/app/cash/sqldelight/intellij/autocomplete/AutocompleteTests.kt index efd0a60e85a..f3221f7c9b7 100644 --- a/sqldelight-idea-plugin/src/test/kotlin/app/cash/sqldelight/intellij/autocomplete/AutocompleteTests.kt +++ b/sqldelight-idea-plugin/src/test/kotlin/app/cash/sqldelight/intellij/autocomplete/AutocompleteTests.kt @@ -38,7 +38,7 @@ class AutocompleteTests : SqlDelightFixtureTestCase() { | |someUpdate: |UPDATE - """.trimMargin() + """.trimMargin(), ) val lookupElements: List = myFixture.complete(BASIC, 1) @@ -62,7 +62,7 @@ class AutocompleteTests : SqlDelightFixtureTestCase() { |someUpdate: |UPDATE test |SET - """.trimMargin() + """.trimMargin(), ) myFixture.complete(BASIC, 1).let { @@ -86,7 +86,7 @@ class AutocompleteTests : SqlDelightFixtureTestCase() { |someUpdate: |UPDATE test |SET value = - """.trimMargin() + """.trimMargin(), ) val lookupElements = myFixture.complete(BASIC, 1) @@ -109,7 +109,7 @@ class AutocompleteTests : SqlDelightFixtureTestCase() { | |someInsert: |INSERT INTO - """.trimMargin() + """.trimMargin(), ) myFixture.complete(BASIC, 1).let { @@ -133,7 +133,7 @@ class AutocompleteTests : SqlDelightFixtureTestCase() { | |someInsert: |INSERT INTO test () - """.trimMargin() + """.trimMargin(), ) as SqlDelightFile fun PsiElement.printTree(printer: (String) -> Unit) { @@ -165,7 +165,7 @@ class AutocompleteTests : SqlDelightFixtureTestCase() { | |someDelete: |DELETE FROM - """.trimMargin() + """.trimMargin(), ) myFixture.complete(BASIC, 1).let { @@ -190,7 +190,7 @@ class AutocompleteTests : SqlDelightFixtureTestCase() { |someSelect: |SELECT * |FROM - """.trimMargin() + """.trimMargin(), ) myFixture.complete(BASIC, 1).let { @@ -215,7 +215,7 @@ class AutocompleteTests : SqlDelightFixtureTestCase() { |someSelect: |SELECT * |FROM - """.trimMargin() + """.trimMargin(), ) myFixture.complete(BASIC, 1).let { diff --git a/sqldelight-idea-plugin/src/test/kotlin/app/cash/sqldelight/intellij/gotodeclaration/GoToDeclarationHandlerTest.kt b/sqldelight-idea-plugin/src/test/kotlin/app/cash/sqldelight/intellij/gotodeclaration/GoToDeclarationHandlerTest.kt index b3f119b0ee0..868144c3701 100644 --- a/sqldelight-idea-plugin/src/test/kotlin/app/cash/sqldelight/intellij/gotodeclaration/GoToDeclarationHandlerTest.kt +++ b/sqldelight-idea-plugin/src/test/kotlin/app/cash/sqldelight/intellij/gotodeclaration/GoToDeclarationHandlerTest.kt @@ -12,33 +12,33 @@ class GoToDeclarationHandlerTest : SqlDelightProjectTestCase() { fun testMethodGoesToIdentifier() { myFixture.openFileInEditor( - tempRoot.findFileByRelativePath("src/main/java/com/example/SampleClass.java")!! + tempRoot.findFileByRelativePath("src/main/java/com/example/SampleClass.java")!!, ) val sourceElement = searchForElement("someQuery").single() val elements = goToDeclarationHandler.getGotoDeclarationTargets(sourceElement, 0, editor) myFixture.openFileInEditor( - tempRoot.findFileByRelativePath("src/main/sqldelight/com/example/Main.sq")!! + tempRoot.findFileByRelativePath("src/main/sqldelight/com/example/Main.sq")!!, ) val offset = file.text.indexOf("someQuery") assertThat(elements).asList().containsExactly( - file.findElementAt(offset)!!.getStrictParentOfType() + file.findElementAt(offset)!!.getStrictParentOfType(), ) } fun testMethodGoesToIdentifierFromKotlin() { myFixture.openFileInEditor( - tempRoot.findFileByRelativePath("src/main/kotlin/com/example/KotlinClass.kt")!! + tempRoot.findFileByRelativePath("src/main/kotlin/com/example/KotlinClass.kt")!!, ) val sourceElement = searchForElement("someQuery").single() val elements = goToDeclarationHandler.getGotoDeclarationTargets(sourceElement, 0, editor) myFixture.openFileInEditor( - tempRoot.findFileByRelativePath("src/main/sqldelight/com/example/Main.sq")!! + tempRoot.findFileByRelativePath("src/main/sqldelight/com/example/Main.sq")!!, ) val offset = file.text.indexOf("someQuery") assertThat(elements).asList().containsExactly( - file.findElementAt(offset)!!.getStrictParentOfType() + file.findElementAt(offset)!!.getStrictParentOfType(), ) } } diff --git a/sqldelight-idea-plugin/src/test/kotlin/app/cash/sqldelight/intellij/gotodeclaration/GoToDeclarationTest.kt b/sqldelight-idea-plugin/src/test/kotlin/app/cash/sqldelight/intellij/gotodeclaration/GoToDeclarationTest.kt index 6b2a3d33e21..3a2ecf23e5c 100644 --- a/sqldelight-idea-plugin/src/test/kotlin/app/cash/sqldelight/intellij/gotodeclaration/GoToDeclarationTest.kt +++ b/sqldelight-idea-plugin/src/test/kotlin/app/cash/sqldelight/intellij/gotodeclaration/GoToDeclarationTest.kt @@ -18,7 +18,7 @@ class GoToDeclarationTest : SqlDelightFixtureTestCase() { |CREATE TABLE foreignTable ( | value INTEGER NOT NULL PRIMARY KEY |); - """.trimMargin() + """.trimMargin(), ) val foreignTable = file.findChildrenOfType().single() @@ -30,7 +30,7 @@ class GoToDeclarationTest : SqlDelightFixtureTestCase() { | value INTEGER NOT NULL PRIMARY KEY, | foreign_value INTEGER NOT NULL REFERENCES foreignTable(value) |); - """.trimMargin() + """.trimMargin(), ) val element = file.findChildrenOfType().single() @@ -44,7 +44,7 @@ class GoToDeclarationTest : SqlDelightFixtureTestCase() { |CREATE TABLE foreignTable ( | value INTEGER NOT NULL PRIMARY KEY |); - """.trimMargin() + """.trimMargin(), ) val foreignColumn = file.findChildrenOfType().single() @@ -55,7 +55,7 @@ class GoToDeclarationTest : SqlDelightFixtureTestCase() { |CREATE TABLE localTable ( | foreign_value INTEGER NOT NULL REFERENCES foreignTable(value) |); - """.trimMargin() + """.trimMargin(), ) val element = file.findChildrenOfType().single { it.name == "value" } @@ -63,7 +63,6 @@ class GoToDeclarationTest : SqlDelightFixtureTestCase() { } fun testJoinClauseResolves() { - myFixture.configureByText( "ForeignTable.sq", """ @@ -78,7 +77,7 @@ class GoToDeclarationTest : SqlDelightFixtureTestCase() { |SELECT * |FROM table |JOIN other ON other.other_value = value - """.trimMargin() + """.trimMargin(), ) val table = file.findChildrenOfType() diff --git a/sqldelight-idea-plugin/src/test/kotlin/app/cash/sqldelight/intellij/highlighting/HighlightingTests.kt b/sqldelight-idea-plugin/src/test/kotlin/app/cash/sqldelight/intellij/highlighting/HighlightingTests.kt index 1035b20fbce..208f8ab6922 100644 --- a/sqldelight-idea-plugin/src/test/kotlin/app/cash/sqldelight/intellij/highlighting/HighlightingTests.kt +++ b/sqldelight-idea-plugin/src/test/kotlin/app/cash/sqldelight/intellij/highlighting/HighlightingTests.kt @@ -60,7 +60,7 @@ class HighlightingTests : SqlDelightFixtureTestCase() { | className ASC |LIMIT 50 |; - """.trimMargin() + """.trimMargin(), ) myFixture.checkHighlighting() diff --git a/sqldelight-idea-plugin/src/test/kotlin/app/cash/sqldelight/intellij/inspections/SafeDeleteColumnQuickFixTest.kt b/sqldelight-idea-plugin/src/test/kotlin/app/cash/sqldelight/intellij/inspections/SafeDeleteColumnQuickFixTest.kt index 4628d0128ab..cad8fb48b2f 100644 --- a/sqldelight-idea-plugin/src/test/kotlin/app/cash/sqldelight/intellij/inspections/SafeDeleteColumnQuickFixTest.kt +++ b/sqldelight-idea-plugin/src/test/kotlin/app/cash/sqldelight/intellij/inspections/SafeDeleteColumnQuickFixTest.kt @@ -17,7 +17,7 @@ class SafeDeleteColumnQuickFixTest : SqlDelightFixtureTestCase() { | player_number INTEGER NOT NULL PRIMARY KEY, | full_name TEXT NOT NULL |); - """.trimMargin() + """.trimMargin(), ) val file = myFixture.file @@ -33,7 +33,7 @@ class SafeDeleteColumnQuickFixTest : SqlDelightFixtureTestCase() { |CREATE TABLE hockeyPlayer( | full_name TEXT NOT NULL |); - """.trimMargin() + """.trimMargin(), ) } @@ -45,7 +45,7 @@ class SafeDeleteColumnQuickFixTest : SqlDelightFixtureTestCase() { | player_number INTEGER NOT NULL PRIMARY KEY, | full_name TEXT NOT NULL |); - """.trimMargin() + """.trimMargin(), ) val file = myFixture.file @@ -61,7 +61,7 @@ class SafeDeleteColumnQuickFixTest : SqlDelightFixtureTestCase() { |CREATE TABLE hockeyPlayer( | player_number INTEGER NOT NULL PRIMARY KEY |); - """.trimMargin() + """.trimMargin(), ) } @@ -72,7 +72,7 @@ class SafeDeleteColumnQuickFixTest : SqlDelightFixtureTestCase() { |CREATE TABLE hockeyPlayer( | player_number INTEGER NOT NULL PRIMARY KEY |); - """.trimMargin() + """.trimMargin(), ) val file = myFixture.file @@ -86,7 +86,7 @@ class SafeDeleteColumnQuickFixTest : SqlDelightFixtureTestCase() { myFixture.checkResult( """ |CREATE TABLE hockeyPlayer(); - """.trimMargin() + """.trimMargin(), ) } } diff --git a/sqldelight-idea-plugin/src/test/kotlin/app/cash/sqldelight/intellij/inspections/SafeDeleteQueryQuickFixTest.kt b/sqldelight-idea-plugin/src/test/kotlin/app/cash/sqldelight/intellij/inspections/SafeDeleteQueryQuickFixTest.kt index 6856dcb5871..71c53b87aa5 100644 --- a/sqldelight-idea-plugin/src/test/kotlin/app/cash/sqldelight/intellij/inspections/SafeDeleteQueryQuickFixTest.kt +++ b/sqldelight-idea-plugin/src/test/kotlin/app/cash/sqldelight/intellij/inspections/SafeDeleteQueryQuickFixTest.kt @@ -21,7 +21,7 @@ class SafeDeleteQueryQuickFixTest : SqlDelightFixtureTestCase() { | |selectNumber: |SELECT player_number FROM hockeyPlayer; - """.trimMargin() + """.trimMargin(), ) val file = myFixture.file @@ -40,7 +40,7 @@ class SafeDeleteQueryQuickFixTest : SqlDelightFixtureTestCase() { | |selectNumber: |SELECT player_number FROM hockeyPlayer; - """.trimMargin() + """.trimMargin(), ) } } diff --git a/sqldelight-idea-plugin/src/test/kotlin/app/cash/sqldelight/intellij/intentions/ExpandColumnNamesWildcardQuickFixTest.kt b/sqldelight-idea-plugin/src/test/kotlin/app/cash/sqldelight/intellij/intentions/ExpandColumnNamesWildcardQuickFixTest.kt index d93f886559b..8d30003117c 100644 --- a/sqldelight-idea-plugin/src/test/kotlin/app/cash/sqldelight/intellij/intentions/ExpandColumnNamesWildcardQuickFixTest.kt +++ b/sqldelight-idea-plugin/src/test/kotlin/app/cash/sqldelight/intellij/intentions/ExpandColumnNamesWildcardQuickFixTest.kt @@ -13,7 +13,7 @@ class ExpandColumnNamesWildcardQuickFixTest : SqlDelightFixtureTestCase() { |select_all: |SELECT * |FROM test; - """.trimMargin() + """.trimMargin(), ) val intention = ExpandColumnNamesWildcardQuickFix() @@ -28,7 +28,7 @@ class ExpandColumnNamesWildcardQuickFixTest : SqlDelightFixtureTestCase() { |select_all: |SELECT _id |FROM test; - """.trimMargin() + """.trimMargin(), ) val intention = ExpandColumnNamesWildcardQuickFix() @@ -43,7 +43,7 @@ class ExpandColumnNamesWildcardQuickFixTest : SqlDelightFixtureTestCase() { |select_all: |SELECT * |FROM test; - """.trimMargin() + """.trimMargin(), ) val intention = ExpandColumnNamesWildcardQuickFix() @@ -54,7 +54,7 @@ class ExpandColumnNamesWildcardQuickFixTest : SqlDelightFixtureTestCase() { |select_all: |SELECT _id, title |FROM test; - """.trimMargin() + """.trimMargin(), ) } @@ -65,7 +65,7 @@ class ExpandColumnNamesWildcardQuickFixTest : SqlDelightFixtureTestCase() { |select_all: |SELECT *, 1 |FROM test; - """.trimMargin() + """.trimMargin(), ) val intention = ExpandColumnNamesWildcardQuickFix() @@ -80,7 +80,7 @@ class ExpandColumnNamesWildcardQuickFixTest : SqlDelightFixtureTestCase() { |select_all: |SELECT COUNT(*) |FROM test; - """.trimMargin() + """.trimMargin(), ) val intention = ExpandColumnNamesWildcardQuickFix() @@ -95,7 +95,7 @@ class ExpandColumnNamesWildcardQuickFixTest : SqlDelightFixtureTestCase() { |select_all: |SELECT *, 1, COUNT(*), title |FROM test; - """.trimMargin() + """.trimMargin(), ) val intention = ExpandColumnNamesWildcardQuickFix() @@ -106,7 +106,7 @@ class ExpandColumnNamesWildcardQuickFixTest : SqlDelightFixtureTestCase() { |select_all: |SELECT _id, title, 1, COUNT(*) |FROM test; - """.trimMargin() + """.trimMargin(), ) } @@ -116,6 +116,7 @@ class ExpandColumnNamesWildcardQuickFixTest : SqlDelightFixtureTestCase() { | _id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, | title TEXT NOT NULL |); - |""".trimMargin() + | + """.trimMargin() } } diff --git a/sqldelight-idea-plugin/src/test/kotlin/app/cash/sqldelight/intellij/intentions/QualifyColumnNameIntentionTest.kt b/sqldelight-idea-plugin/src/test/kotlin/app/cash/sqldelight/intellij/intentions/QualifyColumnNameIntentionTest.kt index ee3cb65b803..9f24a8cc680 100644 --- a/sqldelight-idea-plugin/src/test/kotlin/app/cash/sqldelight/intellij/intentions/QualifyColumnNameIntentionTest.kt +++ b/sqldelight-idea-plugin/src/test/kotlin/app/cash/sqldelight/intellij/intentions/QualifyColumnNameIntentionTest.kt @@ -12,7 +12,7 @@ class QualifyColumnNameIntentionTest : SqlDelightFixtureTestCase() { CREATE_TABLE + """ |SELECT id, name |FROM team; - """.trimMargin() + """.trimMargin(), ) val intention = QualifyColumnNameIntention() @@ -20,8 +20,8 @@ class QualifyColumnNameIntentionTest : SqlDelightFixtureTestCase() { intention.isAvailable( myFixture.project, myFixture.editor, - myFixture.file.findElementAt(myFixture.editor.caretModel.offset)!! - ) + myFixture.file.findElementAt(myFixture.editor.caretModel.offset)!!, + ), ) .isTrue() } @@ -32,7 +32,7 @@ class QualifyColumnNameIntentionTest : SqlDelightFixtureTestCase() { CREATE_TABLE + """ |SELECT id, team.name |FROM team; - """.trimMargin() + """.trimMargin(), ) val intention = QualifyColumnNameIntention() @@ -40,8 +40,8 @@ class QualifyColumnNameIntentionTest : SqlDelightFixtureTestCase() { intention.isAvailable( myFixture.project, myFixture.editor, - myFixture.file.findElementAt(myFixture.editor.caretModel.offset)!! - ) + myFixture.file.findElementAt(myFixture.editor.caretModel.offset)!!, + ), ) .isFalse() } @@ -52,21 +52,21 @@ class QualifyColumnNameIntentionTest : SqlDelightFixtureTestCase() { CREATE_TABLE + """ |SELECT id, name |FROM team; - """.trimMargin() + """.trimMargin(), ) val intention = QualifyColumnNameIntention() intention.invoke( myFixture.project, myFixture.editor, - myFixture.file.findElementAt(myFixture.editor.caretModel.offset)!! + myFixture.file.findElementAt(myFixture.editor.caretModel.offset)!!, ) myFixture.checkResult( CREATE_TABLE + """ |SELECT id, team.name |FROM team; - """.trimMargin() + """.trimMargin(), ) } @@ -76,21 +76,21 @@ class QualifyColumnNameIntentionTest : SqlDelightFixtureTestCase() { CREATE_TABLE + """ |SELECT id, name |FROM team t; - """.trimMargin() + """.trimMargin(), ) val intention = QualifyColumnNameIntention() intention.invoke( myFixture.project, myFixture.editor, - myFixture.file.findElementAt(myFixture.editor.caretModel.offset)!! + myFixture.file.findElementAt(myFixture.editor.caretModel.offset)!!, ) myFixture.checkResult( CREATE_TABLE + """ |SELECT id, t.name |FROM team t; - """.trimMargin() + """.trimMargin(), ) } @@ -100,6 +100,7 @@ class QualifyColumnNameIntentionTest : SqlDelightFixtureTestCase() { | id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, | name TEXT NOT NULL UNIQUE |); - |""".trimMargin() + | + """.trimMargin() } } diff --git a/sqldelight-idea-plugin/src/test/kotlin/app/cash/sqldelight/intellij/intentions/TableAliasIntentionTest.kt b/sqldelight-idea-plugin/src/test/kotlin/app/cash/sqldelight/intellij/intentions/TableAliasIntentionTest.kt index 58b72b1c7b0..d08228bbcd0 100644 --- a/sqldelight-idea-plugin/src/test/kotlin/app/cash/sqldelight/intellij/intentions/TableAliasIntentionTest.kt +++ b/sqldelight-idea-plugin/src/test/kotlin/app/cash/sqldelight/intellij/intentions/TableAliasIntentionTest.kt @@ -13,7 +13,7 @@ class TableAliasIntentionTest : SqlDelightFixtureTestCase() { |SELECT first_name, last_name, number, team, name |FROM hockeyPlayer |JOIN team ON hockeyPlayer.team = team.id; - """.trimMargin() + """.trimMargin(), ) val intention = IntroduceTableAliasIntention() @@ -21,8 +21,8 @@ class TableAliasIntentionTest : SqlDelightFixtureTestCase() { intention.isAvailable( myFixture.project, myFixture.editor, - myFixture.file.findElementAt(myFixture.editor.caretModel.offset)!! - ) + myFixture.file.findElementAt(myFixture.editor.caretModel.offset)!!, + ), ) .isTrue() } @@ -34,7 +34,7 @@ class TableAliasIntentionTest : SqlDelightFixtureTestCase() { |SELECT first_name, last_name, number, team, name |FROM hockeyPlayer hp |JOIN team ON hp.team = team.id; - """.trimMargin() + """.trimMargin(), ) val intention = IntroduceTableAliasIntention() @@ -42,8 +42,8 @@ class TableAliasIntentionTest : SqlDelightFixtureTestCase() { intention.isAvailable( myFixture.project, myFixture.editor, - myFixture.file.findElementAt(myFixture.editor.caretModel.offset)!! - ) + myFixture.file.findElementAt(myFixture.editor.caretModel.offset)!!, + ), ) .isFalse() } @@ -54,7 +54,7 @@ class TableAliasIntentionTest : SqlDelightFixtureTestCase() { CREATE_TABLE + """ |SELECT id, team.name |FROM team; - """.trimMargin() + """.trimMargin(), ) val intention = IntroduceTableAliasIntention() @@ -62,8 +62,8 @@ class TableAliasIntentionTest : SqlDelightFixtureTestCase() { intention.isAvailable( myFixture.project, myFixture.editor, - myFixture.file.findElementAt(myFixture.editor.caretModel.offset)!! - ) + myFixture.file.findElementAt(myFixture.editor.caretModel.offset)!!, + ), ) .isFalse() } @@ -75,14 +75,14 @@ class TableAliasIntentionTest : SqlDelightFixtureTestCase() { |SELECT first_name, last_name, number, team, name |FROM hockeyPlayer |JOIN team ON hockeyPlayer.team = team.id; - """.trimMargin() + """.trimMargin(), ) val intention = IntroduceTableAliasIntention() intention.invoke( myFixture.project, myFixture.editor, - myFixture.file.findElementAt(myFixture.editor.caretModel.offset)!! + myFixture.file.findElementAt(myFixture.editor.caretModel.offset)!!, ) myFixture.checkResult( @@ -90,7 +90,7 @@ class TableAliasIntentionTest : SqlDelightFixtureTestCase() { |SELECT first_name, last_name, number, team, name |FROM hockeyPlayer |JOIN team t ON hockeyPlayer.team = t.id; - """.trimMargin() + """.trimMargin(), ) } @@ -109,6 +109,7 @@ class TableAliasIntentionTest : SqlDelightFixtureTestCase() { | id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, | name TEXT NOT NULL UNIQUE |); - |""".trimMargin() + | + """.trimMargin() } } diff --git a/sqldelight-idea-plugin/src/test/kotlin/app/cash/sqldelight/intellij/lang/SqlDelightCommenterTest.kt b/sqldelight-idea-plugin/src/test/kotlin/app/cash/sqldelight/intellij/lang/SqlDelightCommenterTest.kt index d6ea96d972d..6bdee79158f 100644 --- a/sqldelight-idea-plugin/src/test/kotlin/app/cash/sqldelight/intellij/lang/SqlDelightCommenterTest.kt +++ b/sqldelight-idea-plugin/src/test/kotlin/app/cash/sqldelight/intellij/lang/SqlDelightCommenterTest.kt @@ -53,7 +53,7 @@ class SqlDelightCommenterTest : SqlDelightFixtureTestCase() { | _id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, | title TEXT NOT NULL |); - """.trimMargin() + """.trimMargin(), ) val commentAction = CommentByLineCommentAction() @@ -64,7 +64,7 @@ class SqlDelightCommenterTest : SqlDelightFixtureTestCase() { |-- _id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, |-- title TEXT NOT NULL |-- ); - """.trimMargin() + """.trimMargin(), ) commentAction.actionPerformedImpl(project, myFixture.editor) @@ -74,7 +74,7 @@ class SqlDelightCommenterTest : SqlDelightFixtureTestCase() { | _id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, | title TEXT NOT NULL |); - """.trimMargin() + """.trimMargin(), ) } @@ -91,7 +91,7 @@ class SqlDelightCommenterTest : SqlDelightFixtureTestCase() { |select_all: |SELECT * |FROM test; - """.trimMargin() + """.trimMargin(), ) myFixture.type("/**") @@ -110,7 +110,7 @@ class SqlDelightCommenterTest : SqlDelightFixtureTestCase() { |select_all: |SELECT * |FROM test; - """.trimMargin() + """.trimMargin(), ) } } diff --git a/sqldelight-idea-plugin/src/test/kotlin/app/cash/sqldelight/intellij/lang/SqlDelightImportOptimizerTest.kt b/sqldelight-idea-plugin/src/test/kotlin/app/cash/sqldelight/intellij/lang/SqlDelightImportOptimizerTest.kt index af99b08a096..f8336acca85 100644 --- a/sqldelight-idea-plugin/src/test/kotlin/app/cash/sqldelight/intellij/lang/SqlDelightImportOptimizerTest.kt +++ b/sqldelight-idea-plugin/src/test/kotlin/app/cash/sqldelight/intellij/lang/SqlDelightImportOptimizerTest.kt @@ -20,7 +20,7 @@ class SqlDelightImportOptimizerTest : SqlDelightFixtureTestCase() { | last_name TEXT AS @Nullable String NOT NULL, | list TEXT AS List |); - """.trimMargin() + """.trimMargin(), ) project.executeWriteCommand("") { @@ -38,7 +38,7 @@ class SqlDelightImportOptimizerTest : SqlDelightFixtureTestCase() { | last_name TEXT AS @Nullable String NOT NULL, | list TEXT AS List |); - """.trimMargin() + """.trimMargin(), ) } } diff --git a/sqldelight-idea-plugin/src/test/kotlin/app/cash/sqldelight/intellij/lang/SqlDelightPairedBraceMatcherTest.kt b/sqldelight-idea-plugin/src/test/kotlin/app/cash/sqldelight/intellij/lang/SqlDelightPairedBraceMatcherTest.kt index c22aaec14aa..8395836a422 100644 --- a/sqldelight-idea-plugin/src/test/kotlin/app/cash/sqldelight/intellij/lang/SqlDelightPairedBraceMatcherTest.kt +++ b/sqldelight-idea-plugin/src/test/kotlin/app/cash/sqldelight/intellij/lang/SqlDelightPairedBraceMatcherTest.kt @@ -26,7 +26,8 @@ class SqlDelightPairedBraceMatcherTest : SqlDelightFixtureTestCase() { SqlDelightFileType, """ |CREATE TABLE test - |""".trimMargin() + | + """.trimMargin(), ) myFixture.type('(') @@ -34,7 +35,8 @@ class SqlDelightPairedBraceMatcherTest : SqlDelightFixtureTestCase() { myFixture.checkResult( """ |CREATE TABLE test () - |""".trimMargin() + | + """.trimMargin(), ) } } diff --git a/sqldelight-idea-plugin/src/test/kotlin/app/cash/sqldelight/intellij/lang/SqlDelightStructureViewFactoryTest.kt b/sqldelight-idea-plugin/src/test/kotlin/app/cash/sqldelight/intellij/lang/SqlDelightStructureViewFactoryTest.kt index fbf95c07886..f7a835cd31e 100644 --- a/sqldelight-idea-plugin/src/test/kotlin/app/cash/sqldelight/intellij/lang/SqlDelightStructureViewFactoryTest.kt +++ b/sqldelight-idea-plugin/src/test/kotlin/app/cash/sqldelight/intellij/lang/SqlDelightStructureViewFactoryTest.kt @@ -54,7 +54,7 @@ class SqlDelightStructureViewFactoryTest : SqlDelightFixtureTestCase() { |ON test (_id); | |CREATE VIRTUAL TABLE virtual_table USING custom_module; - """.trimMargin() + """.trimMargin(), ) myFixture.testStructureView { consumer -> @@ -68,8 +68,8 @@ class SqlDelightStructureViewFactoryTest : SqlDelightFixtureTestCase() { "CREATE VIEW select_all_view", "CREATE TRIGGER trigger_1", "CREATE INDEX some_index", - "CREATE VIRTUAL TABLE virtual_table" - ) + "CREATE VIRTUAL TABLE virtual_table", + ), ) } } diff --git a/sqldelight-idea-plugin/src/test/kotlin/app/cash/sqldelight/intellij/rename/SqlStmtIdentifierTests.kt b/sqldelight-idea-plugin/src/test/kotlin/app/cash/sqldelight/intellij/rename/SqlStmtIdentifierTests.kt index d01b5f42454..8bfc7fc7ce4 100644 --- a/sqldelight-idea-plugin/src/test/kotlin/app/cash/sqldelight/intellij/rename/SqlStmtIdentifierTests.kt +++ b/sqldelight-idea-plugin/src/test/kotlin/app/cash/sqldelight/intellij/rename/SqlStmtIdentifierTests.kt @@ -10,20 +10,20 @@ import com.intellij.psi.PsiElement class SqlStmtIdentifierTests : SqlDelightProjectTestCase() { fun testRenamingIdentifierRenamesKotlinAndJavaUsages() { myFixture.openFileInEditor( - tempRoot.findFileByRelativePath("src/main/sqldelight/com/example/Main.sq")!! + tempRoot.findFileByRelativePath("src/main/sqldelight/com/example/Main.sq")!!, ) val identifier = searchForElement("someQuery").single() myFixture.renameElement(identifier, "newSomeQuery") myFixture.openFileInEditor( - tempRoot.findFileByRelativePath("src/main/java/com/example/SampleClass.java")!! + tempRoot.findFileByRelativePath("src/main/java/com/example/SampleClass.java")!!, ) assertThat(searchForElement("newSomeQuery")).hasSize(1) assertThat(searchForElement("someQuery")).isEmpty() myFixture.openFileInEditor( - tempRoot.findFileByRelativePath("src/main/kotlin/com/example/KotlinClass.kt")!! + tempRoot.findFileByRelativePath("src/main/kotlin/com/example/KotlinClass.kt")!!, ) assertThat(searchForElement("newSomeQuery")).hasSize(1) assertThat(searchForElement("someQuery")).isEmpty() @@ -31,14 +31,14 @@ class SqlStmtIdentifierTests : SqlDelightProjectTestCase() { fun testRenamingQueryWithMultipleMethods() { myFixture.openFileInEditor( - tempRoot.findFileByRelativePath("src/main/sqldelight/com/example/Main.sq")!! + tempRoot.findFileByRelativePath("src/main/sqldelight/com/example/Main.sq")!!, ) val identifier = searchForElement("multiQuery").single() myFixture.renameElement(identifier, "newMultiQuery") myFixture.openFileInEditor( - tempRoot.findFileByRelativePath("src/main/kotlin/com/example/KotlinClass.kt")!! + tempRoot.findFileByRelativePath("src/main/kotlin/com/example/KotlinClass.kt")!!, ) assertThat(searchForElement("newMultiQuery")).hasSize(2) assertThat(searchForElement("multiQuery")).isEmpty() @@ -46,25 +46,25 @@ class SqlStmtIdentifierTests : SqlDelightProjectTestCase() { fun testRenamingQueryWithCustomTypes() { myFixture.openFileInEditor( - tempRoot.findFileByRelativePath("src/main/sqldelight/com/example/Main.sq")!! + tempRoot.findFileByRelativePath("src/main/sqldelight/com/example/Main.sq")!!, ) val identifier = searchForElement("generatesType").single() myFixture.renameElement(identifier, "newGeneratesType") myFixture.openFileInEditor( - tempRoot.findFileByRelativePath("src/main/kotlin/com/example/GeneratesTypeImpl.kt")!! + tempRoot.findFileByRelativePath("src/main/kotlin/com/example/GeneratesTypeImpl.kt")!!, ) assertThat(searchForElement("NewGeneratesType")).hasSize(1) assertThat(searchForElement("GeneratesType")).isEmpty() myFixture.openFileInEditor( - tempRoot.findFileByRelativePath("src/main/kotlin/com/example/KotlinClass.kt")!! + tempRoot.findFileByRelativePath("src/main/kotlin/com/example/KotlinClass.kt")!!, ) assertThat(searchForElement("NewGeneratesType")).hasSize(1) assertThat(searchForElement("GeneratesType")).isEmpty() myFixture.openFileInEditor( - tempRoot.findFileByRelativePath("src/main/java/com/example/SampleClass.java")!! + tempRoot.findFileByRelativePath("src/main/java/com/example/SampleClass.java")!!, ) assertThat(searchForElement("NewGeneratesType")).hasSize(1) assertThat(searchForElement("GeneratesType")).isEmpty() @@ -72,13 +72,13 @@ class SqlStmtIdentifierTests : SqlDelightProjectTestCase() { fun testRenamingTableName() { myFixture.openFileInEditor( - tempRoot.findFileByRelativePath("src/main/sqldelight/com/example/Main.sq")!! + tempRoot.findFileByRelativePath("src/main/sqldelight/com/example/Main.sq")!!, ) val identifier = searchForElement("main").first() myFixture.renameElement(identifier, "newMain") myFixture.openFileInEditor( - tempRoot.findFileByRelativePath("src/main/kotlin/com/example/MainImpl.kt")!! + tempRoot.findFileByRelativePath("src/main/kotlin/com/example/MainImpl.kt")!!, ) assertThat(searchForElement("NewMain")).hasSize(1) assertThat(searchForElement("Main")).isEmpty() @@ -86,13 +86,13 @@ class SqlStmtIdentifierTests : SqlDelightProjectTestCase() { fun testRenamingViewName() { myFixture.openFileInEditor( - tempRoot.findFileByRelativePath("src/main/sqldelight/com/example/Main.sq")!! + tempRoot.findFileByRelativePath("src/main/sqldelight/com/example/Main.sq")!!, ) val identifier = searchForElement("someView").first() myFixture.renameElement(identifier, "newView") myFixture.openFileInEditor( - tempRoot.findFileByRelativePath("src/main/kotlin/com/example/ViewImpl.kt")!! + tempRoot.findFileByRelativePath("src/main/kotlin/com/example/ViewImpl.kt")!!, ) assertThat(searchForElement("NewView")).hasSize(1) assertThat(searchForElement("SomeView")).isEmpty() diff --git a/sqldelight-idea-plugin/src/test/kotlin/app/cash/sqldelight/intellij/rename/SqliteElementTests.kt b/sqldelight-idea-plugin/src/test/kotlin/app/cash/sqldelight/intellij/rename/SqliteElementTests.kt index 869398a4e4b..8018f6a3cd4 100644 --- a/sqldelight-idea-plugin/src/test/kotlin/app/cash/sqldelight/intellij/rename/SqliteElementTests.kt +++ b/sqldelight-idea-plugin/src/test/kotlin/app/cash/sqldelight/intellij/rename/SqliteElementTests.kt @@ -29,7 +29,7 @@ class SqliteElementTests : SqlDelightFixtureTestCase() { |someSelect: |SELECT * |FROM test; - """.trimMargin() + """.trimMargin(), ) myFixture.renameElementAtCaret("newTest") @@ -56,7 +56,7 @@ class SqliteElementTests : SqlDelightFixtureTestCase() { |someSelect: |SELECT * |FROM newTest; - """.trimMargin() + """.trimMargin(), ) } @@ -85,7 +85,7 @@ class SqliteElementTests : SqlDelightFixtureTestCase() { |someSelect: |SELECT value |FROM test; - """.trimMargin() + """.trimMargin(), ) myFixture.renameElementAtCaret("newValue") @@ -112,7 +112,7 @@ class SqliteElementTests : SqlDelightFixtureTestCase() { |someSelect: |SELECT newValue |FROM test; - """.trimMargin() + """.trimMargin(), ) } @@ -126,7 +126,7 @@ class SqliteElementTests : SqlDelightFixtureTestCase() { |someSelect: |SELECT * |FROM myView; - """.trimMargin() + """.trimMargin(), ) myFixture.renameElementAtCaret("newView") @@ -138,7 +138,7 @@ class SqliteElementTests : SqlDelightFixtureTestCase() { |someSelect: |SELECT * |FROM newView; - """.trimMargin() + """.trimMargin(), ) } @@ -152,7 +152,7 @@ class SqliteElementTests : SqlDelightFixtureTestCase() { |someSelect: |SELECT columnAlias |FROM myView; - """.trimMargin() + """.trimMargin(), ) myFixture.renameElementAtCaret("newAlias") @@ -164,7 +164,7 @@ class SqliteElementTests : SqlDelightFixtureTestCase() { |someSelect: |SELECT newAlias |FROM myView; - """.trimMargin() + """.trimMargin(), ) } @@ -179,7 +179,7 @@ class SqliteElementTests : SqlDelightFixtureTestCase() { |SELECT tableAlias.columnAlias |FROM myView tableAlias |WHERE tableAlias.columnAlias = 1; - """.trimMargin() + """.trimMargin(), ) myFixture.renameElementAtCaret("newAlias") @@ -192,7 +192,7 @@ class SqliteElementTests : SqlDelightFixtureTestCase() { |SELECT newAlias.columnAlias |FROM myView newAlias |WHERE newAlias.columnAlias = 1; - """.trimMargin() + """.trimMargin(), ) } @@ -210,7 +210,7 @@ class SqliteElementTests : SqlDelightFixtureTestCase() { |SELECT tableAlias.columnAlias |FROM tableAlias |WHERE tableAlias.columnAlias = 1; - """.trimMargin() + """.trimMargin(), ) myFixture.renameElementAtCaret("newAlias") @@ -226,7 +226,7 @@ class SqliteElementTests : SqlDelightFixtureTestCase() { |SELECT newAlias.columnAlias |FROM newAlias |WHERE newAlias.columnAlias = 1; - """.trimMargin() + """.trimMargin(), ) } @@ -241,7 +241,7 @@ class SqliteElementTests : SqlDelightFixtureTestCase() { |SELECT test.columnAlias |FROM test |WHERE test.columnAlias = 1; - """.trimMargin() + """.trimMargin(), ) myFixture.renameElementAtCaret("newAlias") @@ -254,7 +254,7 @@ class SqliteElementTests : SqlDelightFixtureTestCase() { |SELECT test.newAlias |FROM test |WHERE test.newAlias = 1; - """.trimMargin() + """.trimMargin(), ) } } diff --git a/sqlite-migrations/src/main/kotlin/app/cash/sqlite/migrations/CatalogDatabase.kt b/sqlite-migrations/src/main/kotlin/app/cash/sqlite/migrations/CatalogDatabase.kt index c197fd6040e..045d1be252c 100644 --- a/sqlite-migrations/src/main/kotlin/app/cash/sqlite/migrations/CatalogDatabase.kt +++ b/sqlite-migrations/src/main/kotlin/app/cash/sqlite/migrations/CatalogDatabase.kt @@ -11,7 +11,7 @@ import java.sql.DriverManager import java.sql.SQLException class CatalogDatabase private constructor( - internal val catalog: Catalog + internal val catalog: Catalog, ) : Database() { companion object { @@ -20,12 +20,12 @@ class CatalogDatabase private constructor( .withLimitOptions( LimitOptionsBuilder.builder() .routineTypes(emptyList()) - .toOptions() + .toOptions(), ) .withLoadOptions( LoadOptionsBuilder.builder() .withSchemaInfoLevel(SchemaInfoLevelBuilder.maximum()) - .toOptions() + .toOptions(), ) fun withInitStatements(initStatements: List): CatalogDatabase { diff --git a/sqlite-migrations/src/main/kotlin/app/cash/sqlite/migrations/DatabaseFilesCollector.kt b/sqlite-migrations/src/main/kotlin/app/cash/sqlite/migrations/FindDatabaseFiles.kt similarity index 100% rename from sqlite-migrations/src/main/kotlin/app/cash/sqlite/migrations/DatabaseFilesCollector.kt rename to sqlite-migrations/src/main/kotlin/app/cash/sqlite/migrations/FindDatabaseFiles.kt diff --git a/sqlite-migrations/src/main/kotlin/app/cash/sqlite/migrations/ObjectDifferDatabaseComparator.kt b/sqlite-migrations/src/main/kotlin/app/cash/sqlite/migrations/ObjectDifferDatabaseComparator.kt index 454f3992b7b..79b231bcf29 100644 --- a/sqlite-migrations/src/main/kotlin/app/cash/sqlite/migrations/ObjectDifferDatabaseComparator.kt +++ b/sqlite-migrations/src/main/kotlin/app/cash/sqlite/migrations/ObjectDifferDatabaseComparator.kt @@ -10,14 +10,14 @@ import de.danielbechler.diff.node.DiffNode.State.UNTOUCHED class ObjectDifferDatabaseComparator( private val ignoreDefinitions: Boolean, - private val circularReferenceExceptionLogger: ((String) -> Unit)? = null + private val circularReferenceExceptionLogger: ((String) -> Unit)? = null, ) : DatabaseComparator { override fun compare(db1: CatalogDatabase, db2: CatalogDatabase): DatabaseDiff { return ObjectDifferDatabaseDiff( differBuilder().compare(db1.catalog, db2.catalog), db1, - db2 + db2, ) } @@ -40,27 +40,29 @@ class ObjectDifferDatabaseComparator( // This is only used to compare definitions. Definitions include whitespace and comments // so we want those removed. - comparison().ofType(String::class.java).toUse(object : ComparisonStrategy { - override fun compare(node: DiffNode, type: Class<*>, working: Any?, base: Any?) { - if (working == null && base == null) { - node.state = UNTOUCHED - } else if (working == null || working !is String) { - node.state = REMOVED - } else if (base == null || base !is String) { - node.state = ADDED - } else if (working.normalizeDefinition() - .equals(base.normalizeDefinition(), ignoreCase = true) - ) { - node.state = UNTOUCHED - } else { - node.state = CHANGED + comparison().ofType(String::class.java).toUse( + object : ComparisonStrategy { + override fun compare(node: DiffNode, type: Class<*>, working: Any?, base: Any?) { + if (working == null && base == null) { + node.state = UNTOUCHED + } else if (working == null || working !is String) { + node.state = REMOVED + } else if (base == null || base !is String) { + node.state = ADDED + } else if (working.normalizeDefinition() + .equals(base.normalizeDefinition(), ignoreCase = true) + ) { + node.state = UNTOUCHED + } else { + node.state = CHANGED + } } - } - private fun String.normalizeDefinition() = - replace(Regex("--(.*)"), "") - .replace(Regex("[\\s\"]+"), "") - }) + private fun String.normalizeDefinition() = + replace(Regex("--(.*)"), "") + .replace(Regex("[\\s\"]+"), "") + }, + ) // Custom error handler for circular reference warnings which allows to override SL4J warning log val circularReferenceExceptionLogger = circularReferenceExceptionLogger diff --git a/sqlite-migrations/src/main/kotlin/app/cash/sqlite/migrations/ObjectDifferDatabaseDiff.kt b/sqlite-migrations/src/main/kotlin/app/cash/sqlite/migrations/ObjectDifferDatabaseDiff.kt index e32e23e68a4..dd95a87c205 100644 --- a/sqlite-migrations/src/main/kotlin/app/cash/sqlite/migrations/ObjectDifferDatabaseDiff.kt +++ b/sqlite-migrations/src/main/kotlin/app/cash/sqlite/migrations/ObjectDifferDatabaseDiff.kt @@ -8,7 +8,7 @@ import schemacrawler.schema.JdbcDriverInfo class ObjectDifferDatabaseDiff( private val diff: DiffNode, private val db1: CatalogDatabase, - private val db2: CatalogDatabase + private val db2: CatalogDatabase, ) : DatabaseDiff { override fun printTo(out: Appendable) = with(out) { @@ -28,7 +28,8 @@ class ObjectDifferDatabaseDiff( |${node.canonicalGet(db1.catalog).toString().prependIndent(" ")} | AFTER: |${node.canonicalGet(db2.catalog).toString().prependIndent(" ")} - |""".trimMargin() + | + """.trimMargin(), ) } } else if (node.state == DiffNode.State.ADDED || node.state == DiffNode.State.REMOVED) { diff --git a/test-util/src/main/kotlin/app/cash/sqldelight/test/util/FixtureCompiler.kt b/test-util/src/main/kotlin/app/cash/sqldelight/test/util/FixtureCompiler.kt index 595e39e1ef2..9fa0ce42689 100644 --- a/test-util/src/main/kotlin/app/cash/sqldelight/test/util/FixtureCompiler.kt +++ b/test-util/src/main/kotlin/app/cash/sqldelight/test/util/FixtureCompiler.kt @@ -40,7 +40,7 @@ object FixtureCompiler { compilationMethod: CompilationMethod = SqlDelightCompiler::writeInterfaces, fileName: String = "Test.sq", treatNullAsUnknownForEquality: Boolean = false, - generateAsync: Boolean = false + generateAsync: Boolean = false, ): CompilationResult { writeSql(sql, temporaryFolder, fileName) return compileFixture( @@ -48,14 +48,14 @@ object FixtureCompiler { compilationMethod, overrideDialect = overrideDialect, treatNullAsUnknownForEquality = treatNullAsUnknownForEquality, - generateAsync = generateAsync + generateAsync = generateAsync, ) } fun writeSql( sql: String, temporaryFolder: TemporaryFolder, - fileName: String + fileName: String, ) { val srcRootDir = temporaryFolder.fixtureRoot().apply { mkdirs() } val fixtureSrcDir = File(srcRootDir, "com/example").apply { mkdirs() } @@ -78,7 +78,7 @@ object FixtureCompiler { val parser = TestEnvironment(dialect = dialect, treatNullAsUnknownForEquality = treatNullAsUnknownForEquality, generateAsync = generateAsync) val environment = parser.build( temporaryFolder.fixtureRoot().path, - createAnnotationHolder(errors) + createAnnotationHolder(errors), ) if (errors.isNotEmpty()) { @@ -138,7 +138,7 @@ object FixtureCompiler { SqlDelightCompiler.writeInterfaces( file = topMigration!!, output = fileWriter, - includeAll = true + includeAll = true, ) } @@ -156,7 +156,7 @@ object FixtureCompiler { } private fun createAnnotationHolder( - errors: MutableList + errors: MutableList, ) = object : SqlAnnotationHolder { override fun createErrorAnnotation(element: PsiElement, s: String) { val documentManager = PsiDocumentManager.getInstance(element.project) @@ -188,7 +188,7 @@ object FixtureCompiler { val compilerOutput: Map, val errors: List, val sourceFiles: String, - val compiledFile: SqlDelightQueriesFile + val compiledFile: SqlDelightQueriesFile, ) } diff --git a/test-util/src/main/kotlin/app/cash/sqldelight/test/util/TestEnvironment.kt b/test-util/src/main/kotlin/app/cash/sqldelight/test/util/TestEnvironment.kt index d71bc55e12f..96f96dbee9a 100644 --- a/test-util/src/main/kotlin/app/cash/sqldelight/test/util/TestEnvironment.kt +++ b/test-util/src/main/kotlin/app/cash/sqldelight/test/util/TestEnvironment.kt @@ -23,7 +23,7 @@ internal class TestEnvironment( ) { fun build( root: String, - annotationHolder: SqlAnnotationHolder + annotationHolder: SqlAnnotationHolder, ): SqlDelightEnvironment { val compilationUnit = object : SqlDelightCompilationUnit { override val name = "test"