diff --git a/zpa-core/src/main/kotlin/org/sonar/plsqlopen/symbols/DefaultTypeSolver.kt b/zpa-core/src/main/kotlin/org/sonar/plsqlopen/symbols/DefaultTypeSolver.kt index 633561c4..14151c1b 100644 --- a/zpa-core/src/main/kotlin/org/sonar/plsqlopen/symbols/DefaultTypeSolver.kt +++ b/zpa-core/src/main/kotlin/org/sonar/plsqlopen/symbols/DefaultTypeSolver.kt @@ -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() diff --git a/zpa-core/src/main/kotlin/org/sonar/plugins/plsqlopen/api/PlSqlGrammar.kt b/zpa-core/src/main/kotlin/org/sonar/plugins/plsqlopen/api/PlSqlGrammar.kt index bdc9ee63..2c4dd944 100644 --- a/zpa-core/src/main/kotlin/org/sonar/plugins/plsqlopen/api/PlSqlGrammar.kt +++ b/zpa-core/src/main/kotlin/org/sonar/plugins/plsqlopen/api/PlSqlGrammar.kt @@ -52,6 +52,7 @@ enum class PlSqlGrammar : GrammarRuleKey { ANCHORED_DATATYPE, CUSTOM_DATATYPE, REF_DATATYPE, + JSON_DATATYPE, // Literals LITERAL, @@ -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, @@ -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), diff --git a/zpa-core/src/main/kotlin/org/sonar/plugins/plsqlopen/api/symbols/PlSqlType.kt b/zpa-core/src/main/kotlin/org/sonar/plugins/plsqlopen/api/symbols/PlSqlType.kt index 4bddf744..628b4e07 100644 --- a/zpa-core/src/main/kotlin/org/sonar/plugins/plsqlopen/api/symbols/PlSqlType.kt +++ b/zpa-core/src/main/kotlin/org/sonar/plugins/plsqlopen/api/symbols/PlSqlType.kt @@ -31,6 +31,7 @@ enum class PlSqlType { ASSOCIATIVE_ARRAY, NULL, RECORD, + JSON, EXCEPTION; val isCharacter: Boolean diff --git a/zpa-core/src/main/kotlin/org/sonar/plugins/plsqlopen/api/symbols/datatype/JsonDatatype.kt b/zpa-core/src/main/kotlin/org/sonar/plugins/plsqlopen/api/symbols/datatype/JsonDatatype.kt new file mode 100644 index 00000000..cacee678 --- /dev/null +++ b/zpa-core/src/main/kotlin/org/sonar/plugins/plsqlopen/api/symbols/datatype/JsonDatatype.kt @@ -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" + } +}