All Downloads are FREE. Search and download functionalities are using the official Maven repository.

app.cash.sqldelight.dialects.sqlite_3_33.grammar.SqliteParserUtil.kt Maven / Gradle / Ivy

There is a newer version: 2.0.2
Show newest version
package app.cash.sqldelight.dialects.sqlite_3_33.grammar

import app.cash.sqldelight.dialects.sqlite_3_33.grammar.psi.SqliteTypes
import com.alecstrong.sql.psi.core.SqlParserUtil
import com.intellij.lang.ASTNode
import com.intellij.lang.PsiBuilder
import com.intellij.lang.parser.GeneratedParserUtilBase
import com.intellij.psi.PsiElement
import java.lang.AssertionError
import kotlin.Boolean
import kotlin.Int
import kotlin.Unit
import kotlin.jvm.JvmStatic

public object SqliteParserUtil : GeneratedParserUtilBase() {
  public var createElement: (ASTNode) -> PsiElement = { SqliteTypes.Factory.createElement(it) }

  public var overrides: GeneratedParserUtilBase.Parser? = null

  public var update_stmt: GeneratedParserUtilBase.Parser? = null

  public var update_stmt_limited: GeneratedParserUtilBase.Parser? = null

  @JvmStatic
  public fun overridesExt(
    builder: PsiBuilder,
    level: Int,
    overrides: GeneratedParserUtilBase.Parser,
  ): Boolean = (this.overrides ?: overrides).parse(builder, level)

  @JvmStatic
  public fun updateStmtExt(
    builder: PsiBuilder,
    level: Int,
    update_stmt: GeneratedParserUtilBase.Parser,
  ): Boolean = (this.update_stmt ?: update_stmt).parse(builder, level)

  @JvmStatic
  public fun updateStmtLimitedExt(
    builder: PsiBuilder,
    level: Int,
    update_stmt_limited: GeneratedParserUtilBase.Parser,
  ): Boolean = (this.update_stmt_limited ?: update_stmt_limited).parse(builder, level)

  public fun reset(): Unit {
    createElement = { SqliteTypes.Factory.createElement(it) }
    overrides = null
    update_stmt = null
    update_stmt_limited = null
  }

  public fun overrideSqlParser(): Unit {
    SqlParserUtil.update_stmt = Parser { psiBuilder, i -> update_stmt?.parse(psiBuilder, i) ?:
        SqliteParser.update_stmt_real(psiBuilder, i) }
    SqlParserUtil.update_stmt_limited = Parser { psiBuilder, i ->
        update_stmt_limited?.parse(psiBuilder, i) ?:
        SqliteParser.update_stmt_limited_real(psiBuilder, i) }
    val currentCreateElement = SqlParserUtil.createElement
    SqlParserUtil.createElement = {
      try {
        createElement(it)
      } catch(e: AssertionError) {
        currentCreateElement(it)
      }
    }
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy