Skip to content

Commit

Permalink
feat: Add JsonDatatype (#182)
Browse files Browse the repository at this point in the history
  • Loading branch information
felipebz committed Jun 14, 2024
1 parent 708e999 commit 0b72375
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ open class DefaultTypeSolver {
if (anchoredDatatype.lastChild.type === PlSqlKeyword.ROWTYPE) {
type = RowtypeDatatype()
}
} else if (node.hasDirectChildren(PlSqlGrammar.JSON_DATATYPE)) {
type = JsonDatatype()
} else {
val datatype = node.firstChild
type = scope?.getSymbol(datatype.tokenOriginalValue, Symbol.Kind.TYPE)?.datatype ?: UnknownDatatype()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ enum class PlSqlGrammar : GrammarRuleKey {
ANCHORED_DATATYPE,
CUSTOM_DATATYPE,
REF_DATATYPE,
JSON_DATATYPE,

// Literals
LITERAL,
Expand Down Expand Up @@ -432,6 +433,8 @@ enum class PlSqlGrammar : GrammarRuleKey {

b.rule(REF_DATATYPE).define(REF, MEMBER_EXPRESSION)

b.rule(JSON_DATATYPE).define(JSON)

b.rule(DATATYPE).define(b.firstOf(
NUMERIC_DATATYPE,
LOB_DATATYPE,
Expand All @@ -440,6 +443,7 @@ enum class PlSqlGrammar : GrammarRuleKey {
DATE_DATATYPE,
ANCHORED_DATATYPE,
REF_DATATYPE,
JSON_DATATYPE,
CUSTOM_DATATYPE),
b.optional(b.firstOf(
b.sequence(NOT, NULL),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ enum class PlSqlType {
ASSOCIATIVE_ARRAY,
NULL,
RECORD,
JSON,
EXCEPTION;

val isCharacter: Boolean
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/**
* Z PL/SQL Analyzer
* Copyright (C) 2015-2024 Felipe Zorzo
* mailto:felipe AT felipezorzo DOT com DOT br
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package org.sonar.plugins.plsqlopen.api.symbols.datatype

import org.sonar.plugins.plsqlopen.api.symbols.PlSqlType

class JsonDatatype : PlSqlDatatype {
override val type = PlSqlType.JSON

override val name: String = "JSON"

override fun toString(): String {
return "Json"
}
}

0 comments on commit 0b72375

Please sign in to comment.