<commit_before>package org.angularjs.closurerunner;

import com.google.javascript.jscomp.AbstractCompiler;
import com.google.javascript.jscomp.CompilerPass;
import com.google.javascript.jscomp.DiagnosticType;
import com.google.javascript.jscomp.JsAst;
import com.google.javascript.jscomp.JSError;
import com.google.javascript.jscomp.NodeTraversal;
import com.google.javascript.jscomp.NodeTraversal.AbstractPostOrderCallback;
import com.google.javascript.jscomp.SourceFile;

import com.google.javascript.rhino.Node;

import org.json.JSONObject;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import java.io.PrintStream;

class MinerrPass extends AbstractPostOrderCallback implements CompilerPass {
  final AbstractCompiler compiler;
  final Pattern minerrInstanceRegex = Pattern.compile("^(\\S+)MinErr$");
  private Map<String, Map<String, String>> namespaces;
  private Map<String, String> globalNamespace;
  private List<Node> minerrInstances;
  private PrintStream errorConfigOutput;
  private Node minerrDefNode;
  private String minerrDefSource;

  static final String MINERR_SOURCE = 
    "function minErr(module) {\n" +
    "  var stringify = function (arg) {\n" +
    "    if (typeof arg == 'function') {\n" +
    "      return arg.toString().replace(/ \\{[\\s\\S]*$/, '');\n" +
    "    } else if (typeof arg == 'undefined') {\n" +
    "      return 'undefined';\n" +
    "    } else if (!(typeof arg == 'string')) {\n" +
    "      return JSON.stringify(arg);\n" +
    "    }\n" +
    "    return arg; };\n" +
    "  return function () {\n" +
    "    var code = arguments[0],\n" +
    "      prefix = '[' + (module ? module + ':' : '') + code + '] ',\n" +
    "      message,\n" +
    "      i = 1;\n" +
    "    message = prefix + 'MINERR_URL' + (module ? module + 'MINERR_SEPARATOR' : '') + code;\n" +
    "    for(; i < arguments.length; i++) {\n" +
    "      message = message + (i == 1 ? '?' : '&') + 'p' + (i-1) + '=' + stringify(arguments[i]);\n" +
    "    }\n" +
    "    return new Error(message); }; }";

  static final DiagnosticType THROW_IS_NOT_MINERR_ERROR_WARNING = 
      DiagnosticType.warning("JSC_THROW_IS_NOT_MINERR_ERROR_WARNING",
          "Throw expression is not a minErr instance.");

  static final DiagnosticType UNSUPPORTED_STRING_EXPRESSION_ERROR =
      DiagnosticType.error("JSC_UNSUPPORTED_STRING_EXPRESSION_ERROR",
          "Can't extract a static string value where one was expected.");

  static final DiagnosticType MULTIPLE_MINERR_DEFINITION_WARNING =
      DiagnosticType.warning("JSC_MULTIPLE_MINERR_DEFINITION_WARNING",
          "Found definitions for the function 'minErr' in multiple locations.");<commit_msg>fix(MinerrPass): Encode URL params correctly<commit_after>package org.angularjs.closurerunner;

import com.google.javascript.jscomp.AbstractCompiler;
import com.google.javascript.jscomp.CompilerPass;
import com.google.javascript.jscomp.DiagnosticType;
import com.google.javascript.jscomp.JsAst;
import com.google.javascript.jscomp.JSError;
import com.google.javascript.jscomp.NodeTraversal;
import com.google.javascript.jscomp.NodeTraversal.AbstractPostOrderCallback;
import com.google.javascript.jscomp.SourceFile;

import com.google.javascript.rhino.Node;

import org.json.JSONObject;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import java.io.PrintStream;

class MinerrPass extends AbstractPostOrderCallback implements CompilerPass {
  final AbstractCompiler compiler;
  final Pattern minerrInstanceRegex = Pattern.compile("^(\\S+)MinErr$");
  private Map<String, Map<String, String>> namespaces;
  private Map<String, String> globalNamespace;
  private List<Node> minerrInstances;
  private PrintStream errorConfigOutput;
  private Node minerrDefNode;
  private String minerrDefSource;

  static final String MINERR_SOURCE = 
    "function minErr(module) {\n" +
    "  var stringify = function (arg) {\n" +
    "    if (typeof arg == 'function') {\n" +
    "      return arg.toString().replace(/ \\{[\\s\\S]*$/, '');\n" +
    "    } else if (typeof arg == 'undefined') {\n" +
    "      return 'undefined';\n" +
    "    } else if (!(typeof arg == 'string')) {\n" +
    "      return JSON.stringify(arg);\n" +
    "    }\n" +
    "    return arg; };\n" +
    "  return function () {\n" +
    "    var code = arguments[0],\n" +
    "      prefix = '[' + (module ? module + ':' : '') + code + '] ',\n" +
    "      message,\n" +
    "      i = 1;\n" +
    "    message = prefix + 'MINERR_URL' + (module ? module + 'MINERR_SEPARATOR' : '') + code;\n" +
    "    for(; i < arguments.length; i++) {\n" +
    "      message = message + (i == 1 ? '?' : '&') + 'p' + (i-1) + '=' + encodeURIComponent(stringify(arguments[i]));\n" +
    "    }\n" +
    "    return new Error(message); }; }";

  static final DiagnosticType THROW_IS_NOT_MINERR_ERROR_WARNING = 
      DiagnosticType.warning("JSC_THROW_IS_NOT_MINERR_ERROR_WARNING",
          "Throw expression is not a minErr instance.");

  static final DiagnosticType UNSUPPORTED_STRING_EXPRESSION_ERROR =
      DiagnosticType.error("JSC_UNSUPPORTED_STRING_EXPRESSION_ERROR",
          "Can't extract a static string value where one was expected.");

  static final DiagnosticType MULTIPLE_MINERR_DEFINITION_WARNING =
      DiagnosticType.warning("JSC_MULTIPLE_MINERR_DEFINITION_WARNING",
          "Found definitions for the function 'minErr' in multiple locations.");
{'fraction_non_alphanumeric': 0.13904219334164145, 'fraction_numerical': 0.001424247819120527, 'mean_word_length': 3.6314921681780707, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 11, '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': '2972397', 'n_tokens_mistral': 1798, 'n_tokens_neox': 1751, 'n_words': 381}