Skip to content

Commit

Permalink
feat: Add a name property to all datatype classes
Browse files Browse the repository at this point in the history
  • Loading branch information
felipebz committed Aug 29, 2023
1 parent c160256 commit 42ec1f0
Show file tree
Hide file tree
Showing 12 changed files with 33 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import org.sonar.plugins.plsqlopen.api.symbols.Scope
class AssociativeArrayDatatype(node: AstNode? = null, currentScope: Scope?, val nestedType: PlSqlDatatype) : PlSqlDatatype {
override val type = PlSqlType.ASSOCIATIVE_ARRAY

val name: String = currentScope?.let {
override val name: String = currentScope?.let {
if (it.identifier != null && it.type == PlSqlGrammar.CREATE_PACKAGE)
it.identifier + "."
else "" } +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ import org.sonar.plugins.plsqlopen.api.symbols.PlSqlType
class BooleanDatatype : PlSqlDatatype {
override val type = PlSqlType.BOOLEAN

override val name: String = "BOOLEAN"

override fun toString(): String {
return "Boolean"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,13 @@ import org.sonar.plugins.plsqlopen.api.symbols.PlSqlType
class CharacterDatatype : PlSqlDatatype {

override val type = PlSqlType.CHARACTER

override val name: String
get() = if (this.length == null)
"VARCHAR2"
else
"VARCHAR2(${this.length})"

val length: Int?

constructor() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ import org.sonar.plugins.plsqlopen.api.symbols.PlSqlType
class DateDatatype : PlSqlDatatype {
override val type = PlSqlType.DATE

override val name: String = "DATE"

override fun toString(): String {
return "Date"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ import org.sonar.plugins.plsqlopen.api.symbols.PlSqlType
class ExceptionDatatype : PlSqlDatatype {
override val type = PlSqlType.EXCEPTION

override val name: String = "EXCEPTION"

override fun toString(): String {
return "Exception"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ import org.sonar.plugins.plsqlopen.api.symbols.PlSqlType
class LobDatatype : PlSqlDatatype {
override val type = PlSqlType.LOB

override val name: String = "LOB"

override fun toString(): String {
return "Lob"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ import org.sonar.plugins.plsqlopen.api.symbols.PlSqlType
class NullDatatype : PlSqlDatatype {
override val type = PlSqlType.NULL

override val name: String = "NULL"

override fun toString(): String {
return "Null"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,15 @@ import org.sonar.plugins.plsqlopen.api.symbols.PlSqlType
class NumericDatatype : PlSqlDatatype {

override val type = PlSqlType.NUMERIC

override val name: String
get() = if (this.length == null)
"NUMBER()"
else if (this.precision == null)
"NUMBER(${this.length})"
else
"NUMBER(${this.length}, ${this.precision})"

val length: Int?
val precision: Int?

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,5 @@ import org.sonar.plugins.plsqlopen.api.symbols.PlSqlType

interface PlSqlDatatype {
val type: PlSqlType
val name: String?
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import org.sonar.plugins.plsqlopen.api.symbols.Symbol
class RecordDatatype(node: AstNode? = null, currentScope: Scope?, val fields: List<Symbol>) : PlSqlDatatype {
override val type = PlSqlType.RECORD

val name: String = currentScope?.let {
override val name: String = currentScope?.let {
if (it.identifier != null && it.type == PlSqlGrammar.CREATE_PACKAGE)
it.identifier + "."
else "" } +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ import org.sonar.plugins.plsqlopen.api.symbols.PlSqlType
class RowtypeDatatype : PlSqlDatatype {
override val type = PlSqlType.ROWTYPE

override val name: String? = null

override fun toString(): String {
return "Rowtype"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ import org.sonar.plugins.plsqlopen.api.symbols.PlSqlType
class UnknownDatatype : PlSqlDatatype {
override val type = PlSqlType.UNKNOWN

override val name: String? = null

override fun toString(): String {
return "Unknown"
}
Expand Down

0 comments on commit 42ec1f0

Please sign in to comment.