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

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

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

import app.cash.sqldelight.dialects.sqlite_3_30.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 ordering_term: GeneratedParserUtilBase.Parser? = null

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

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

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

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




© 2015 - 2025 Weber Informatics LLC | Privacy Policy