* Parse a .method directive line and class context into SmaliMethod.
(
line: string,
className: string,
)
| 86 | * Parse a .method directive line and class context into SmaliMethod. |
| 87 | */ |
| 88 | function parseMethodFromLine( |
| 89 | line: string, |
| 90 | className: string, |
| 91 | ): SmaliMethod | null { |
| 92 | // .method public static foo(ILjava/lang/String;)V |
| 93 | const match = line.match( |
| 94 | /\.method\s+(?:(?:public|private|protected|static|final|synthetic|bridge|varargs|declared-synchronized|abstract|native|strictfp|constructor)\s+)*(\S+)\(([^)]*)\)(\S+)/, |
| 95 | ); |
| 96 | if (!match) return null; |
| 97 | |
| 98 | const methodName = match[1]; |
| 99 | const paramStr = match[2]; |
| 100 | const returnType = match[3]; |
| 101 | const isStatic = /\bstatic\b/.test(line); |
| 102 | const isConstructor = methodName === "<init>" || methodName === "<clinit>"; |
| 103 | |
| 104 | return { |
| 105 | className: smaliTypeToJava("L" + className + ";"), |
| 106 | methodName, |
| 107 | paramTypes: parseSmaliParams(paramStr), |
| 108 | returnType, |
| 109 | isStatic, |
| 110 | isConstructor, |
| 111 | }; |
| 112 | } |
| 113 | |
| 114 | /** |
| 115 | * Get the class name from the .class directive in the document. |
no test coverage detected