Skip to content

Commit

Permalink
fix: Correct coverage import for package bodies declared in same file…
Browse files Browse the repository at this point in the history
… as package spec
  • Loading branch information
felipebz committed Jun 28, 2024
1 parent eb0d9cc commit 2334bb8
Showing 1 changed file with 21 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,34 @@ package org.sonar.plsqlopen.symbols
import com.felipebz.flr.api.AstNodeType
import org.sonar.api.scanner.ScannerSide
import org.sonar.plsqlopen.squid.SonarQubePlSqlFile
import org.sonar.plugins.plsqlopen.api.PlSqlGrammar
import org.sonar.plugins.plsqlopen.api.symbols.Scope

@ScannerSide
class ObjectLocator {
private var scope: Scope = ScopeImpl()

private val mappedObjects
get() = scope.innerScopes.map {
val plSqlFile = it.plSqlFile as SonarQubePlSqlFile? ?: return@map null
val identifier = it.identifier ?: return@map null
val type = it.type ?: return@map null
val firstLine = it.firstToken?.line ?: return@map null
val lastLine = it.lastToken?.line ?: return@map null
MappedObject(identifier, type, plSqlFile.type(), plSqlFile.path(), plSqlFile.inputFile, firstLine, lastLine)
}.filterNotNull()
get() = scope.innerScopes
.union(scope.innerScopes
.flatMap { it.innerScopes }
.filter { it.type == PlSqlGrammar.CREATE_PACKAGE_BODY || it.type == PlSqlGrammar.CREATE_TYPE_BODY })
.map {
val plSqlFile = it.plSqlFile as SonarQubePlSqlFile? ?: return@map null
val identifier = it.identifier ?: return@map null
val type = it.type ?: return@map null
val firstLine = it.firstToken?.line ?: return@map null
val lastLine = it.lastToken?.line ?: return@map null
MappedObject(
identifier,
type,
plSqlFile.type(),
plSqlFile.path(),
plSqlFile.inputFile,
firstLine,
lastLine
)
}.filterNotNull()

fun setScope(scope: Scope) {
this.scope = scope
Expand Down

0 comments on commit 2334bb8

Please sign in to comment.