<commit_before>/* eslint max-len: 0 */

import includes from "lodash/collection/includes";
import repeating from "repeating";
import Renamer from "./lib/renamer";
import type NodePath from "../path";
import traverse from "../index";
import defaults from "lodash/object/defaults";
import * as messages from "babel-messages";
import Binding from "./binding";
import globals from "globals";
import * as t from "babel-types";
import { scope as scopeCache } from "../cache";

/**
 * To avoid creating a new Scope instance for each traversal, we maintain a cache on the
 * node itself containing all scopes it has been associated with.
 */

function getCache(node, parentScope, self) {
  let scopes: Array<Scope> = scopeCache.get(node) || [];

<<<<<<< HEAD
function matchesParent(scope, parentScope) {
  if (scope.parent === parentScope) {
    return true;
  }
}

function getCacheMultiple(node, parentScope, self, singleCache) {
  let scopes: Array<Scope> = node[CACHE_MULTIPLE_KEY] = node[CACHE_MULTIPLE_KEY] || [];

  if (singleCache) {
    // we have a scope assocation miss so push it onto our scopes
    scopes.push(singleCache);
    node[CACHE_SINGLE_KEY] = null;
  }

  // loop through and check each scope to see if it matches our parent
=======
>>>>>>> Move scope cache to the cache module
  for (let scope of scopes) {
    if (scope.parent === parentScope) return scope;
  }

  scopes.push(self);

  if (!scopeCache.has(node)) {
    scopeCache.set(node, scopes);
  }
}

//

let collectorVisitor = {
  For(path) {
    for (let key of (t.FOR_INIT_KEYS: Array)) {
      let declar = path.get(key);
      if (declar.isVar()) path.scope.getFunctionParent().registerBinding("var", declar);
    }
  },

  Declaration(path) {
    // delegate block scope handling to the `blockVariableVisitor`
    if (path.isBlockScoped()) return;

    // this will be hit again once we traverse into it after this iteration<commit_msg>Remove merge artificats<commit_after>/* eslint max-len: 0 */

import includes from "lodash/collection/includes";
import repeating from "repeating";
import Renamer from "./lib/renamer";
import type NodePath from "../path";
import traverse from "../index";
import defaults from "lodash/object/defaults";
import * as messages from "babel-messages";
import Binding from "./binding";
import globals from "globals";
import * as t from "babel-types";
import { scope as scopeCache } from "../cache";

/**
 * To avoid creating a new Scope instance for each traversal, we maintain a cache on the
 * node itself containing all scopes it has been associated with.
 */

function getCache(node, parentScope, self) {
  let scopes: Array<Scope> = scopeCache.get(node) || [];

  for (let scope of scopes) {
    if (scope.parent === parentScope) return scope;
  }

  scopes.push(self);

  if (!scopeCache.has(node)) {
    scopeCache.set(node, scopes);
  }
}

//

let collectorVisitor = {
  For(path) {
    for (let key of (t.FOR_INIT_KEYS: Array)) {
      let declar = path.get(key);
      if (declar.isVar()) path.scope.getFunctionParent().registerBinding("var", declar);
    }
  },

  Declaration(path) {
    // delegate block scope handling to the `blockVariableVisitor`
    if (path.isBlockScoped()) return;

    // this will be hit again once we traverse into it after this iteration
{'fraction_non_alphanumeric': 0.1275106512477176, 'fraction_numerical': 0.0006086427267194157, 'mean_word_length': 3.7915451895043732, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, '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': '5096559', 'n_tokens_mistral': 1007, 'n_tokens_neox': 969, 'n_words': 341}