Skip to content

Commit

Permalink
feat: Replace usages of Enum.values() by Enum.entries (new in Kotlin …
Browse files Browse the repository at this point in the history
…1.9)
  • Loading branch information
felipebz committed Aug 31, 2023
1 parent 9d50cc6 commit 975a8df
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,11 @@ object PlSqlLexer {
.withChannel(regexp(PlSqlTokenType.INTEGER_LITERAL, INTEGER_LITERAL))
.withChannel(regexp(PlSqlTokenType.STRING_LITERAL, STRING_LITERAL))
.withChannel(regexp(PlSqlTokenType.DATE_LITERAL, DATE_LITERAL))
.withChannel(IdentifierAndKeywordChannel(or(SIMPLE_IDENTIFIER, QUOTED_IDENTIFIER), false, PlSqlKeyword.values()))
.withChannel(IdentifierAndKeywordChannel(or(SIMPLE_IDENTIFIER, QUOTED_IDENTIFIER), false,
PlSqlKeyword.entries.toTypedArray()
))
.withChannel(RegexPunctuatorChannel(*PlSqlPunctuator.values().filter { it.isRegex }.toTypedArray()))
.withChannel(PunctuatorChannel(*PlSqlPunctuator.values().filter { !it.isRegex }.toTypedArray()))
.withChannel(PunctuatorChannel(*PlSqlPunctuator.entries.filter { !it.isRegex }.toTypedArray()))
.withChannel(BlackHoleChannel("(?is)" + or(
"\\s&&?$SIMPLE_IDENTIFIER",
"\\\$if.*?\\\$then",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ enum class DclGrammar : GrammarRuleKey {
}

private fun createDclCommands(b: PlSqlGrammarBuilder) {
val keywords = PlSqlKeyword.values().toList()
val keywords = PlSqlKeyword.entries
val rest = keywords.subList(1, keywords.size).toTypedArray()
b.rule(IDENTIFIER_OR_KEYWORD).define(b.firstOf(GenericTokenType.IDENTIFIER, keywords[0], *rest))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -509,10 +509,10 @@ enum class PlSqlKeyword(override val value: String, val isReserved: Boolean = fa
override fun hasToBeSkippedFromAst(node: AstNode?) = false

companion object {
fun keywordValues(): Array<String> =
values().map { it.value }.toTypedArray()
val keywordValues: List<String> =
entries.map { it.value }

val nonReservedKeywords: List<PlSqlKeyword> =
values().filter { !it.isReserved }
entries.filter { !it.isReserved }
}
}

0 comments on commit 975a8df

Please sign in to comment.