<commit_before>/* @flow */

import Rule from '../Rule'

import type { Phase } from '../types'

function escapePath (filePath) {
  return filePath.replace(/\\/g, '\\\\')
}

export default class PatchSyncTeX extends Rule {
  static parameterTypes: Array<Set<string>> = [
    new Set(['KnitrConcordance']),
    new Set(['SyncTeX'])
  ]
  static phases: Set<Phase> = new Set(['finalize'])
  static description: string = 'Patches SyncTeX files if LaTeX document was generated by knitr so PDF reverse sync will work.'

  constructCommand () {
    const filePath = escapePath(this.filePath)
    const synctexPath = escapePath(this.resolvePath('$OUTDIR/$JOB'))
    const lines = [
      'library(patchSynctex)',
      `patchSynctex('${filePath}',syncfile='${synctexPath}')`]

    return {
      args: ['Rscript', '-e', lines.join(';')],
      severity: 'warning'
    }
  }
}
<commit_msg>Use parameters for path resolution<commit_after>/* @flow */

import Rule from '../Rule'

import type { Phase } from '../types'

function escapePath (filePath) {
  return filePath.replace(/\\/g, '\\\\')
}

export default class PatchSyncTeX extends Rule {
  static parameterTypes: Array<Set<string>> = [
    new Set(['Knitr']),
    new Set(['SyncTeX']),
    new Set(['KnitrConcordance'])
  ]
  static phases: Set<Phase> = new Set(['finalize'])
  static description: string = 'Patches SyncTeX files if LaTeX document was generated by knitr so PDF reverse sync will work.'

  constructCommand () {
    const filePath = escapePath(this.firstParameter.filePath)
    const synctexPath = escapePath(this.secondParameter.filePath.replace(/\.synctex(\.gz)?$/i, ''))
    const lines = [
      'library(patchSynctex)',
      `patchSynctex('${filePath}',syncfile='${synctexPath}')`]

    return {
      args: ['Rscript', '-e', lines.join(';')],
      severity: 'warning'
    }
  }
}

{'fraction_non_alphanumeric': 0.16224986479177933, 'fraction_numerical': 0.0, 'mean_word_length': 3.6717171717171717, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '1069029', 'n_tokens_mistral': 601, 'n_tokens_neox': 581, 'n_words': 148}