Skip to content
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -91,15 +91,26 @@ val nextSynonyms = arrayOf(
"then"
)

val skipInvokes = arrayOf(
val forbiddenMethodInvokes = arrayOf(
"<init>",
"<clinit>",
"valueOf",
"getClass"
"getClass",
)

// TODO: SAT-1589
fun shouldSkipInvoke(invoke: String) = (invoke in skipInvokes) || (invoke.endsWith('$'))
val forbiddenClassInvokes = arrayOf(
"soot.dummy.InvokeDynamic"
)

/**
* Filters out
* ```soot.dummy.InvokeDynamic#makeConcat```,
* ```soot.dummy.InvokeDynamic#makeConcatWithConstants```,
* constructor calls (```<init>```), ```bootstrap$```
* and other unwanted things from name and comment text.
*/
fun shouldSkipInvoke(className: String, methodName: String) =
className in forbiddenClassInvokes || methodName in forbiddenMethodInvokes || methodName.endsWith("$")

fun squashDocRegularStatements(sentences: List<DocStatement>): List<DocStatement> {
val newStatements = mutableListOf<DocStatement>()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -301,8 +301,9 @@ open class SimpleCommentBuilder(
*/
protected fun addTextRecursion(sentenceBlock: SimpleSentenceBlock, stmt: Stmt, frequency: Int) {
if (stmt is JAssignStmt || stmt is JInvokeStmt) {
val className = stmt.invokeExpr.methodRef.declaringClass.name
val methodName = stmt.invokeExpr.method.name
addTextRecursion(sentenceBlock, methodName, frequency)
addTextRecursion(sentenceBlock, className, methodName, frequency)
}
}

Expand Down Expand Up @@ -337,7 +338,7 @@ open class SimpleCommentBuilder(
isPrivate: Boolean,
frequency: Int
) {
if (!shouldSkipInvoke(methodName))
if (!shouldSkipInvoke(className, methodName))
sentenceBlock.stmtTexts.add(
StmtDescription(
StmtType.Invoke,
Expand All @@ -352,10 +353,11 @@ open class SimpleCommentBuilder(
*/
protected fun addTextRecursion(
sentenceBlock: SimpleSentenceBlock,
className: String,
methodName: String,
frequency: Int
) {
if (!shouldSkipInvoke(methodName))
if (!shouldSkipInvoke(className, methodName))
sentenceBlock.stmtTexts.add(
StmtDescription(
StmtType.RecursionAssignment,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -385,11 +385,12 @@ class SimpleNameBuilder(
prefix = "Return"
name = name ?: ""
} else if (statementTag.basicTypeTag == BasicTypeTag.Invoke && statementTag.uniquenessTag == UniquenessTag.Unique) {
val declaringClass = stmt.invokeExpr.methodRef.declaringClass
val methodName = stmt.invokeExpr.method.name.capitalize()
if (!shouldSkipInvoke(methodName)) {
if (!shouldSkipInvoke(declaringClass.name, methodName)) {
if (stmt is JAssignStmt || stmt is JInvokeStmt) {
type = NameType.Invoke
prefix += stmt.invokeExpr.methodRef.declaringClass.javaStyleName.substringBefore('$') //class name
prefix += declaringClass.javaStyleName.substringBefore('$')
prefix += methodName
name =
"" //todo change var name to val name, everything should be mapped through .convertNodeToString
Expand Down