mirror of
https://github.com/github/codeql.git
synced 2025-12-18 01:33:15 +01:00
Cleanup getLabel
This commit is contained in:
@@ -256,6 +256,8 @@ class KotlinFileExtractor(val logger: FileLogger, val tw: FileTrapWriter, val fi
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
fun getLabel(element: IrElement) : String? {
|
||||
when (element) {
|
||||
is IrFile -> return "@\"${element.path};sourcefile\"" // todo: remove copy-pasted code
|
||||
@@ -266,13 +268,14 @@ class KotlinFileExtractor(val logger: FileLogger, val tw: FileTrapWriter, val fi
|
||||
is IrProperty -> return getPropertyLabel(element)
|
||||
|
||||
// Fresh entities:
|
||||
is IrBody -> return "*"
|
||||
is IrExpression -> return "*"
|
||||
is IrBody -> return null
|
||||
is IrExpression -> return null
|
||||
|
||||
// todo:
|
||||
is IrField -> return null
|
||||
// todo add others:
|
||||
else -> return null
|
||||
else -> {
|
||||
logger.warnElement(Severity.ErrorSevere, "Unhandled element type: ${element::class}", element)
|
||||
return null
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -88,15 +88,7 @@ class CommentExtractor(private val fileExtractor: KotlinFileExtractor) {
|
||||
file.accept(IrVisitorLookup(ownerPsi, file), owners)
|
||||
|
||||
for (ownerIr in owners) {
|
||||
val label = fileExtractor.getLabel(ownerIr)
|
||||
if (label == null) {
|
||||
logger.warn(Severity.Warn, "Couldn't get label for element: $ownerIr")
|
||||
continue
|
||||
}
|
||||
if (label == "*") {
|
||||
logger.info("Skipping fresh entity label for element: $ownerIr")
|
||||
continue
|
||||
}
|
||||
val label = fileExtractor.getLabel(ownerIr) ?: continue
|
||||
val existingLabel = tw.getExistingLabelFor<DbTop>(label)
|
||||
if (existingLabel == null) {
|
||||
logger.warn(Severity.Warn, "Couldn't get existing label for $label")
|
||||
|
||||
Reference in New Issue
Block a user