Skip to content

Commit 29b6e61

Browse files
committed
feat(devins-lang): try add support for parsing and verifying SQL scripts before inserting them into the editor.
This commit introduces the ability to parse and verify SQL scripts before they are inserted into the editor, enhancing the user experience by ensuring the accuracy and integrity of the code. The commit includes the addition of language parameter support for parsing and verifying SQL scripts, as well as the creation of a new test file to ensure the functionality works as expected.
1 parent 6a4db18 commit 29b6e61

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

exts/database/src/main/kotlin/cc/unitmesh/database/flow/AutoSqlBackgroundTask.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import cc.unitmesh.devti.AutoDevBundle
44
import cc.unitmesh.devti.util.parser.parseCodeFromString
55
import com.intellij.database.console.DatabaseRunners
66
import com.intellij.database.console.runConfiguration.DatabaseScriptRunner
7+
import com.intellij.database.util.DasUtil
78
import com.intellij.lang.Language
89
import com.intellij.openapi.command.WriteCommandAction
910
import com.intellij.openapi.diagnostic.logger
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package cc.unitmesh.database.flow;
2+
3+
import com.intellij.psi.PsiFileFactory
4+
import com.intellij.sql.psi.SqlLanguage
5+
import com.intellij.testFramework.LightPlatformTestCase
6+
7+
class AutoSqlBackgroundTaskTest: LightPlatformTestCase() {
8+
9+
fun testShouldParseCode() {
10+
// Given
11+
val code = """
12+
SELECT * FROM table where;
13+
""".trimIndent()
14+
//
15+
// val inspectionManager = InspectionManager.getInstance(project)
16+
// inspectionManager.
17+
18+
// When
19+
val psiFile =
20+
PsiFileFactory.getInstance(project).createFileFromText("temp.sql", SqlLanguage.INSTANCE, code)
21+
22+
// Then
23+
24+
}
25+
}

0 commit comments

Comments
 (0)