Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 38 additions & 1 deletion src/main/scala/io/appthreat/atom/slicing/UsageSlicing.scala
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,17 @@ object UsageSlicing:
case param: MethodParameterIn if !param.name.matches("(this|self)") => param
}.flatMap(param => paramAnnotationSlices(param, typeMap))

(mainSlices ++ annotationSlices)
val httpStatusMethods = filteredDecls.flatMap {
case p: MethodParameterIn => Some(p.method)
case l: Local => l.method.headOption
case m: Method => Some(m)
case _ => None
}.toSet

val statusSlices =
httpStatusMethods.toList.flatMap(m => httpStatusFieldAccessSlices(m, typeMap))

(mainSlices ++ annotationSlices ++ statusSlices)
.groupBy { case (method, _) => method }
.view
.filterKeys(m => !isExcludedMethod(m))
Expand Down Expand Up @@ -143,6 +153,33 @@ object UsageSlicing:
}.toList
end paramAnnotationSlices

private def httpStatusFieldAccessSlices(
method: Method,
typeMap: Map[String, String]
): List[(Method, ObjectUsageSlice)] =
method.call
.nameExact(Operators.fieldAccess)
.methodFullName(".*HttpStatus.*")
.flatMap { call =>
call.argument.collectFirst { case fi: FieldIdentifier =>
val statusDef = CallDef(
fi.canonicalName,
"org.springframework.http.HttpStatus",
Option(s"org.springframework.http.HttpStatus.${fi.canonicalName}"),
Some(true),
call.lineNumber.map(_.intValue()),
call.columnNumber.map(_.intValue())
)
method -> ObjectUsageSlice(
targetObj = statusDef,
definedBy = Some(statusDef),
invokedCalls = List.empty,
argToCalls = List.empty
)
}
}.toList
end httpStatusFieldAccessSlices

private def createMethodObjectUsageSlice(
m: Method,
invokedCalls: List[ObservedCall],
Expand Down
Loading