-
Notifications
You must be signed in to change notification settings - Fork 516
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use an inspection instead of the refactoring support APIs
- Loading branch information
1 parent
4702fd8
commit db3f0bc
Showing
17 changed files
with
324 additions
and
444 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
sqldelight-compiler/src/main/kotlin/app/cash/sqldelight/core/lang/psi/SignatureData.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package app.cash.sqldelight.core.lang.psi | ||
|
||
import app.cash.sqldelight.core.lang.util.type | ||
import com.alecstrong.sql.psi.core.psi.QueryElement.QueryColumn | ||
import com.alecstrong.sql.psi.core.psi.SqlColumnDef | ||
import com.intellij.refactoring.suggested.SuggestedRefactoringSupport | ||
import com.intellij.refactoring.suggested.SuggestedRefactoringSupport.ParameterAdditionalData | ||
|
||
fun QueryColumn.parameterValue(): SuggestedRefactoringSupport.Parameter? = element.type().let { type -> | ||
val column = type.column ?: return null | ||
SuggestedRefactoringSupport.Parameter( | ||
id = type.name, | ||
name = type.name, | ||
type = column.columnType.typeName.text, | ||
additionalData = column.columnConstraintList.takeIf { it.isNotEmpty() }?.let { list -> | ||
ColumnConstraints((list.filter { it.text.isNotBlank() }.joinToString(" ") { it.text.trim() })) | ||
} | ||
) | ||
} | ||
|
||
fun SqlColumnDef.asParameter() = SuggestedRefactoringSupport.Parameter( | ||
id = columnName.name, | ||
name = columnName.name, | ||
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 { | ||
override fun toString(): String { | ||
return constraints | ||
} | ||
} |
19 changes: 0 additions & 19 deletions
19
...ht-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/ActiveEditorChangeListener.kt
This file was deleted.
Oops, something went wrong.
132 changes: 0 additions & 132 deletions
132
sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/FileGeneratorService.kt
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.