<commit_before>/*
 * (C) Copyright 2010-2015 SAP SE.
 *
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 */

package eu.aniketos.dasca.crosslanguage.builder

import java.io.File
import scala.collection.JavaConverters._
import scala.io.Source
import scala.{ Option => ? }
import com.ibm.wala.dalvik.classLoader.DexIMethod
import com.ibm.wala.ipa.callgraph.CallGraph
import org.apache.commons.io.FileUtils

/**
 * @author D062824
 */
object DalvikLineNumberCalculator {
  val MethodRegex = """\s*\.method (.+)""".r
  val LineRegex = """\s*\.line ([0-9]+)\s*""".r
  val AnnotationRegex = """\s*\.annotation .+""".r
  val EndAnnotationRegex = """\s*\.end annotation\s*""".r
  val InstructionRegex = """\s*[a-zA-Z].*""".r

  def setLineNumbers(apkUnzipDir: File, cg: CallGraph) = {
    for (
      node <- cg.iterator().asScala;
      method <- ?(node.getMethod).collect({ case m: DexIMethod => m })
    ) {
      val path = method.getDeclaringClass.getName.toString().substring(1) + ".smali"
      val smaliFile = new File(new File(apkUnzipDir, "smali"), path)
      val methodString = method.getReference().getName().toString() + node.getMethod().getReference().getDescriptor()
      var lastLine = -1
      var inCorrectMethod = false
      var correctMethodFound = false<commit_msg>Removed author tag.<commit_after>/*
 * (C) Copyright 2010-2015 SAP SE.
 *
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 */

package eu.aniketos.dasca.crosslanguage.builder

import java.io.File
import scala.collection.JavaConverters._
import scala.io.Source
import scala.{ Option => ? }
import com.ibm.wala.dalvik.classLoader.DexIMethod
import com.ibm.wala.ipa.callgraph.CallGraph
import org.apache.commons.io.FileUtils

object DalvikLineNumberCalculator {
  val MethodRegex = """\s*\.method (.+)""".r
  val LineRegex = """\s*\.line ([0-9]+)\s*""".r
  val AnnotationRegex = """\s*\.annotation .+""".r
  val EndAnnotationRegex = """\s*\.end annotation\s*""".r
  val InstructionRegex = """\s*[a-zA-Z].*""".r

  def setLineNumbers(apkUnzipDir: File, cg: CallGraph) = {
    for (
      node <- cg.iterator().asScala;
      method <- ?(node.getMethod).collect({ case m: DexIMethod => m })
    ) {
      val path = method.getDeclaringClass.getName.toString().substring(1) + ".smali"
      val smaliFile = new File(new File(apkUnzipDir, "smali"), path)
      val methodString = method.getReference().getName().toString() + node.getMethod().getReference().getDescriptor()
      var lastLine = -1
      var inCorrectMethod = false
      var correctMethodFound = false
{'fraction_non_alphanumeric': 0.15154604145429834, 'fraction_numerical': 0.01291199456337071, 'mean_word_length': 3.665610142630745, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3234954', 'n_tokens_mistral': 999, 'n_tokens_neox': 949, 'n_words': 227}