* Search the position where API called in the given document segment. * @param doc the text document from source code file. * @param api The list of Smali code that call native API. * @param seg The searching segment [start-line, end-line], if null then search the whole document. * @returns the
(
doc: vscode.TextDocument,
api: string[],
seg: number[] | null,
)
| 182 | * @returns the position where API called, return false if not found. |
| 183 | */ |
| 184 | function getApiCallPosition( |
| 185 | doc: vscode.TextDocument, |
| 186 | api: string[], |
| 187 | seg: number[] | null, |
| 188 | ): vscode.Position | false { |
| 189 | if (seg == null) { |
| 190 | seg = [0, doc.lineCount]; |
| 191 | } |
| 192 | |
| 193 | // remove space in string |
| 194 | const bytecode = String(api[0]).replace(/\s/g, ""); |
| 195 | const method = String(api[api.length - 1]).replace(/\s/g, ""); |
| 196 | |
| 197 | for (let lineNumber = seg[0]; lineNumber < seg[1]; lineNumber++) { |
| 198 | const lineText = doc.lineAt(lineNumber); |
| 199 | |
| 200 | if ( |
| 201 | lineText.text.includes(bytecode) && |
| 202 | lineText.text.includes(method) |
| 203 | ) { |
| 204 | return lineText.range.start; |
| 205 | } |
| 206 | } |
| 207 | return false; |
| 208 | } |
| 209 | |
| 210 | /** |
| 211 | * Search and highlight where APIs called in source code. |
no outgoing calls
no test coverage detected