Skip to content

Commit

Permalink
Fix antlr dep partiql-lang (#1534)
Browse files Browse the repository at this point in the history
  • Loading branch information
alancai98 authored Aug 2, 2024
1 parent 6c314d2 commit f1d785f
Show file tree
Hide file tree
Showing 9 changed files with 40 additions and 41 deletions.
9 changes: 8 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
Thank you to all who have contributed!
-->

## [0.14.7]

### Fixed
- `partiql-lang`'s `PartiQLParserBuilder.standard()` will use the ANTLR dependency from `partiql-parser` to
prevent `NoSuchMethodError`s

## [0.14.6]

### Added
Expand Down Expand Up @@ -1087,7 +1093,8 @@ breaking changes if migrating from v0.9.2. The breaking changes accidentally int
### Added
Initial alpha release of PartiQL.

[Unreleased]: https://github.com/partiql/partiql-lang-kotlin/compare/v0.14.6...HEAD
[Unreleased]: https://github.com/partiql/partiql-lang-kotlin/compare/v0.14.7...HEAD
[0.14.7]: https://github.com/partiql/partiql-lang-kotlin/compare/v0.14.6...v0.14.7
[0.14.6]: https://github.com/partiql/partiql-lang-kotlin/compare/v0.14.5...v0.14.6
[0.14.5]: https://github.com/partiql/partiql-lang-kotlin/compare/v0.14.4...v0.14.5
[0.14.4]: https://github.com/partiql/partiql-lang-kotlin/compare/v0.14.3...v0.14.4
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
group=org.partiql
version=0.14.6
version=0.14.7

ossrhUsername=EMPTY
ossrhPassword=EMPTY
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,18 @@
*/
package org.partiql.cli.shell

import org.antlr.v4.runtime.BaseErrorListener
import org.antlr.v4.runtime.CharStreams
import org.antlr.v4.runtime.CommonTokenStream
import org.antlr.v4.runtime.RecognitionException
import org.antlr.v4.runtime.Recognizer
import org.jline.reader.Highlighter
import org.jline.reader.LineReader
import org.jline.utils.AttributedString
import org.jline.utils.AttributedStringBuilder
import org.jline.utils.AttributedStyle
import org.partiql.parser.antlr.PartiQLParser
import org.partiql.parser.antlr.PartiQLTokens
import org.partiql.parser.thirdparty.antlr.v4.runtime.BaseErrorListener
import org.partiql.parser.thirdparty.antlr.v4.runtime.CharStreams
import org.partiql.parser.thirdparty.antlr.v4.runtime.CommonTokenStream
import org.partiql.parser.thirdparty.antlr.v4.runtime.RecognitionException
import org.partiql.parser.thirdparty.antlr.v4.runtime.Recognizer
import java.nio.charset.StandardCharsets
import java.util.regex.Pattern

Expand Down Expand Up @@ -141,12 +141,12 @@ internal class ShellHighlighter : Highlighter {
msg: String?,
e: RecognitionException?
) {
if (offendingSymbol != null && offendingSymbol is org.antlr.v4.runtime.Token && offendingSymbol.type != PartiQLParser.EOF) {
if (offendingSymbol != null && offendingSymbol is org.partiql.parser.thirdparty.antlr.v4.runtime.Token && offendingSymbol.type != PartiQLParser.EOF) {
throw OffendingSymbolException(offendingSymbol)
}
}

class OffendingSymbolException(val offendingSymbol: org.antlr.v4.runtime.Token) : Exception()
class OffendingSymbolException(val offendingSymbol: org.partiql.parser.thirdparty.antlr.v4.runtime.Token) : Exception()
}

private fun getTokenStream(input: String): CommonTokenStream {
Expand Down
10 changes: 1 addition & 9 deletions partiql-lang/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ kotlin {

dependencies {
api(project(":partiql-ast"))
api(project(":partiql-parser"))
api(project(":partiql-parser", configuration = "shadow"))
api(project(":partiql-plan"))
api(project(":partiql-planner"))
api(project(":partiql-spi"))
Expand All @@ -36,7 +36,6 @@ dependencies {
api(Deps.ionElement)
api(Deps.ionJava)
api(Deps.ionSchema)
shadow(Deps.antlrRuntime)
implementation(Deps.csv)
implementation(Deps.kotlinReflect)
implementation(Deps.kotlinxCoroutines)
Expand All @@ -52,15 +51,8 @@ dependencies {
testImplementation(Deps.kotlinxCoroutinesTest)
}

val relocations = mapOf(
"org.antlr" to "org.partiql.lang.thirdparty.antlr"
)

tasks.shadowJar {
configurations = listOf(project.configurations.shadow.get())
for ((from, to) in relocations) {
relocate(from, to)
}
}

// Workaround for https://github.com/johnrengelman/shadow/issues/651
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,6 @@

package org.partiql.lang.syntax.impl

import org.antlr.v4.runtime.BailErrorStrategy
import org.antlr.v4.runtime.BaseErrorListener
import org.antlr.v4.runtime.CharStreams
import org.antlr.v4.runtime.CommonTokenStream
import org.antlr.v4.runtime.ParserRuleContext
import org.antlr.v4.runtime.RecognitionException
import org.antlr.v4.runtime.Recognizer
import org.antlr.v4.runtime.Token
import org.antlr.v4.runtime.TokenSource
import org.antlr.v4.runtime.TokenStream
import org.antlr.v4.runtime.atn.PredictionMode
import org.antlr.v4.runtime.misc.ParseCancellationException
import org.antlr.v4.runtime.tree.ParseTree
import org.partiql.errors.ErrorCode
import org.partiql.errors.Property
import org.partiql.errors.PropertyValueMap
Expand All @@ -41,6 +28,19 @@ import org.partiql.lang.util.getAntlrDisplayString
import org.partiql.lang.util.getIonValue
import org.partiql.parser.antlr.PartiQLParser
import org.partiql.parser.antlr.PartiQLTokens
import org.partiql.parser.thirdparty.antlr.v4.runtime.BailErrorStrategy
import org.partiql.parser.thirdparty.antlr.v4.runtime.BaseErrorListener
import org.partiql.parser.thirdparty.antlr.v4.runtime.CharStreams
import org.partiql.parser.thirdparty.antlr.v4.runtime.CommonTokenStream
import org.partiql.parser.thirdparty.antlr.v4.runtime.ParserRuleContext
import org.partiql.parser.thirdparty.antlr.v4.runtime.RecognitionException
import org.partiql.parser.thirdparty.antlr.v4.runtime.Recognizer
import org.partiql.parser.thirdparty.antlr.v4.runtime.Token
import org.partiql.parser.thirdparty.antlr.v4.runtime.TokenSource
import org.partiql.parser.thirdparty.antlr.v4.runtime.TokenStream
import org.partiql.parser.thirdparty.antlr.v4.runtime.atn.PredictionMode
import org.partiql.parser.thirdparty.antlr.v4.runtime.misc.ParseCancellationException
import org.partiql.parser.thirdparty.antlr.v4.runtime.tree.ParseTree
import java.io.InputStream
import java.nio.channels.ClosedByInterruptException
import java.nio.charset.StandardCharsets
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,6 @@ import com.amazon.ionelement.api.ionNull
import com.amazon.ionelement.api.ionString
import com.amazon.ionelement.api.ionSymbol
import com.amazon.ionelement.api.loadSingleElement
import org.antlr.v4.runtime.ParserRuleContext
import org.antlr.v4.runtime.Token
import org.antlr.v4.runtime.tree.TerminalNode
import org.partiql.errors.ErrorCode
import org.partiql.errors.Property
import org.partiql.errors.PropertyValueMap
Expand All @@ -62,6 +59,9 @@ import org.partiql.lang.util.getPrecisionFromTimeString
import org.partiql.lang.util.unaryMinus
import org.partiql.parser.antlr.PartiQLParser
import org.partiql.parser.antlr.PartiQLParserBaseVisitor
import org.partiql.parser.thirdparty.antlr.v4.runtime.ParserRuleContext
import org.partiql.parser.thirdparty.antlr.v4.runtime.Token
import org.partiql.parser.thirdparty.antlr.v4.runtime.tree.TerminalNode
import org.partiql.pig.runtime.SymbolPrimitive
import org.partiql.value.datetime.DateTimeException
import org.partiql.value.datetime.TimeZone
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ import com.amazon.ionelement.api.ionString
import com.amazon.ionelement.api.ionSymbol
import com.amazon.ionelement.api.loadSingleElement
import com.amazon.ionelement.api.toIonValue
import org.antlr.v4.runtime.Token
import org.antlr.v4.runtime.tree.TerminalNode
import org.partiql.errors.ErrorCode
import org.partiql.errors.Property
import org.partiql.errors.PropertyValueMap
import org.partiql.lang.syntax.ParserException
import org.partiql.parser.antlr.PartiQLParser
import org.partiql.parser.thirdparty.antlr.v4.runtime.Token
import org.partiql.parser.thirdparty.antlr.v4.runtime.tree.TerminalNode
import java.math.BigInteger

// workaround until ErrorAndErrorContexts no longer uses IonSystem
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ import com.amazon.ion.system.IonSystemBuilder
import io.mockk.every
import io.mockk.spyk
import io.mockk.verify
import org.antlr.v4.runtime.misc.ParseCancellationException
import org.junit.Assert
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.assertThrows
import org.partiql.lang.domains.PartiqlAst
import org.partiql.lang.syntax.ParserException
import org.partiql.parser.thirdparty.antlr.v4.runtime.misc.ParseCancellationException

/**
* This test class is used for spying the [PartiQLPigParser].
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,6 @@ package org.partiql.lang.syntax.impl
import com.amazon.ionelement.api.ionInt
import io.mockk.every
import io.mockk.spyk
import org.antlr.v4.runtime.CharStreams
import org.antlr.v4.runtime.CommonToken
import org.antlr.v4.runtime.Token
import org.antlr.v4.runtime.TokenSource
import org.junit.jupiter.api.Assertions.assertTrue
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.parallel.Execution
Expand All @@ -32,6 +28,10 @@ import org.partiql.lang.domains.PartiqlAst
import org.partiql.lang.eval.CompileOptions
import org.partiql.lang.eval.visitors.VisitorTransformBase
import org.partiql.parser.antlr.PartiQLTokens
import org.partiql.parser.thirdparty.antlr.v4.runtime.CharStreams
import org.partiql.parser.thirdparty.antlr.v4.runtime.CommonToken
import org.partiql.parser.thirdparty.antlr.v4.runtime.Token
import org.partiql.parser.thirdparty.antlr.v4.runtime.TokenSource
import java.io.InputStream
import java.util.concurrent.atomic.AtomicBoolean
import kotlin.concurrent.thread
Expand Down

0 comments on commit f1d785f

Please sign in to comment.