<commit_before>!(function () {
  'use strict';

  angular.module('rh.ngCustomInterpolate', []).provider('$interpolate', ['$provide', $InterpolateProvider]);

  /**
   * @ngdoc object
   * @name ng.$interpolateProvider
   * @function
   *
   * @description
   *
   * Used for configuring the interpolation markup. Defaults to `{{` and `}}`.
   *
   * @example
   <doc:example module="customInterpolationApp">
   <doc:source>
   <script>
   var customInterpolationApp = angular.module('customInterpolationApp', []);

   customInterpolationApp.config(function($interpolateProvider) {
        $interpolateProvider.startSymbol('//');
        $interpolateProvider.endSymbol('//');
    });


   customInterpolationApp.controller('DemoController', function DemoController() {
     this.label = "This binding is brought you by // interpolation symbols.";
   });
   </script>
   <div ng-app="App" ng-controller="DemoController as demo">
   //demo.label//
   </div>
   </doc:source>
   <doc:scenario>
   it('should interpolate binding with custom symbols', function() {
    expect(binding('demo.label')).toBe('This binding is brought you by // interpolation symbols.');
   });
   </doc:scenario>
   </doc:example>
   */
  function $InterpolateProvider($provide) {
    var suffix = 'InterpolationSyntax';
    var syntaxes = [];
    this.$$syntaxes = syntaxes;
    var syntaxSymbols = {};

    /**
     * @ngdoc method
     * @name ng.$interpolateProvider#startSymbol
     * @methodOf ng.$interpolateProvider
     * @description
     * Symbol to denote start of expression in the interpolated string. Defaults to `{{`.
     *
     * @param {string=} value new value to set the starting symbol to.
     * @returns {string|self} Returns the symbol when used as getter and self if used as setter.
     */
    this.startSymbol = function (name, value) {
      if (value) {
        syntaxSymbols[name].startSymbol(value);
      } else if (name) {
        if (syntaxSymbols[name]) {
          return syntaxSymbols[name].startSymbol();
        } else {
          syntaxSymbols['default'].startSymbol(name);
        }
      } else {
        return syntaxSymbols['default'].startSymbol();
      }
      return this;
    };

    /**
     * @ngdoc method
     * @name ng.$interpolateProvider#endSymbol
     * @methodOf ng.$interpolateProvider
     * @description
     * Symbol to denote the end of expression in the interpolated string. Defaults to `}}`.
     *
     * @param {string=} value new value to set the ending symbol to.
     * @returns {string|self} Returns the symbol when used as getter and self if used as setter.
     */
    this.endSymbol = function (name, value) {
      if (value) {
        syntaxSymbols[name].endSymbol(value);
      } else if (name) {
        if (syntaxSymbols[name]) {
          return syntaxSymbols[name].endSymbol();
        } else {
          syntaxSymbols['default'].endSymbol(name);
        }
      } else {
        return syntaxSymbols['default'].endSymbol();
      }
      return this;
    };

    // TODO docs
    this.registerSyntax = function (name, startSymbol, endSymbol, parseFnFactory) {

      function startSymbolFn(value) {
        if (value) {
          startSymbol = value;
          return this;
        } else {
          return startSymbol;
        }
      }

      function endSymbolFn(value) {
        if (value) {
          endSymbol = value;
          return this;
        } else {
          return endSymbol;
        }
      }

      syntaxSymbols[name] = {
        startSymbol: startSymbolFn,
        endSymbol: endSymbolFn
      };

      $provide.factory(name + suffix, ['$injector', '$exceptionHandler',
        function ($injector, $exceptionHandler) {
          var parseFn,
            startSymbolLength = startSymbol.length,
            endSymbolLength = endSymbol.length;
          try {
            parseFn = $injector.invoke(parseFnFactory);
          } catch (e) {
            $exceptionHandler(e);
          }
          return {
            name: name,
            fn: parseFn,
            startSymbol: startSymbolFn,
            endSymbol: endSymbolFn,
            handle: function (parts, text) {
              var exp, startIndex, endIndex, fn,
                hasInterpolation = false,
                index = 0,
                length = text.length;

              while (index < length) {
                if (((startIndex = text.indexOf(startSymbol, index)) != -1) &&
                  ((endIndex = text.indexOf(endSymbol, startIndex + startSymbolLength)) != -1)) {
                  (index != startIndex) && this.next(parts, text.substring(index, startIndex));
                  parts.push(fn = this.fn(exp = text.substring(startIndex + startSymbolLength, endIndex)));
                  fn.exp = exp;
                  index = endIndex + endSymbolLength;
                  hasInterpolation = true;
                } else {
                  // we did not find anything, so we have to add the remainder to the parts array
                  if (index != length) {
                    hasInterpolation = this.next(parts, text.substring(index));
                  }
                  index = length;
                }
              }
              return hasInterpolation;
            },
            next: function (parts, text) {
              var index = indexOf(syntaxes, name);
              if (index != -1 && syntaxes[index + 1]) {
                return $injector.get(syntaxes[index + 1] + suffix).handle(parts, text);
              } else {
                parts.push(text);
                return false;
              }
            }
          };
        }]);


      for (var i = 0; i < syntaxes.length; i++) {
        var syntax = syntaxSymbols[syntaxes[i]];
        if (startSymbol.indexOf(syntax.startSymbol()) != -1) {
          syntaxes.splice(i, 0, name);
          break;
        }
      }
      if (i === syntaxes.length) {
        syntaxes.push(name);
      }

      return this;
    };

    this.registerSyntax('default', '{{', '}}', ['$parse', function ($parse) {
      return $parse;
    }]);

    this.$get = ['$exceptionHandler', '$sce', '$injector', function ($exceptionHandler, $sce, $injector) {
      /**
       * @ngdoc function
       * @name ng.$interpolate
       * @function
       *
       * @requires $parse
       * @requires $sce
       *
       * @description
       *
       * Compiles a string with markup into an interpolation function. This service is used by the
       * HTML {@link ng.$compile $compile} service for data binding. See
       * {@link ng.$interpolateProvider $interpolateProvider} for configuring the
       * interpolation markup.
       *
       *
       <pre>
       var $interpolate = ...; // injected
       var exp = $interpolate('Hello {{name}}!');
       expect(exp({name:'Angular'}).toEqual('Hello Angular!');
       </pre>
       *
       *
       * @param {string} text The text with markup to interpolate.
       * @param {boolean=} mustHaveExpression if set to true then the interpolation string must have
       *    embedded expression in order to return an interpolation function. Strings with no
       *    embedded expression will return null for the interpolation function.
       * @param {string=} trustedContext when provided, the returned function passes the interpolated
       *    result through {@link ng.$sce#methods_getTrusted $sce.getTrusted(interpolatedResult, trustedContext)}
       *    before returning it.  Refer to the {@link ng.$sce $sce} service that
       *    provides Strict Contextual Escaping for details.
       * @returns {function(context)} an interpolation function which is used to compute the
       *    interpolated string. The function has these parameters:
       *
       *    * `context`: an object against which any expressions embedded in the strings are evaluated
       *      against.
       *
       */
      function $interpolate(text, mustHaveExpression, trustedContext) {
        var parts = [],
          length = text.length,
          hasInterpolation,
          fn,
          concat = [];

        hasInterpolation = $injector.get(syntaxes[0] + suffix).handle(parts, text);

        if (!(length = parts.length)) {
          // we added, nothing, must have been an empty string.
          parts.push('');
          length = 1;
        }

        // Concatenating expressions makes it hard to reason about whether some combination of
        // concatenated values are unsafe to use and could easily lead to XSS.  By requiring that a
        // single expression be used for iframe[src], object[src], etc., we ensure that the value
        // that's used is assigned or constructed by some JS code somewhere that is more testable or<commit_msg>chore($interpolate): rename suffix to Suffix to follow angular style<commit_after>!(function () {
  'use strict';

  angular.module('rh.ngCustomInterpolate', []).provider('$interpolate', ['$provide', $InterpolateProvider]);

  /**
   * @ngdoc object
   * @name ng.$interpolateProvider
   * @function
   *
   * @description
   *
   * Used for configuring the interpolation markup. Defaults to `{{` and `}}`.
   *
   * @example
   <doc:example module="customInterpolationApp">
   <doc:source>
   <script>
   var customInterpolationApp = angular.module('customInterpolationApp', []);

   customInterpolationApp.config(function($interpolateProvider) {
        $interpolateProvider.startSymbol('//');
        $interpolateProvider.endSymbol('//');
    });


   customInterpolationApp.controller('DemoController', function DemoController() {
     this.label = "This binding is brought you by // interpolation symbols.";
   });
   </script>
   <div ng-app="App" ng-controller="DemoController as demo">
   //demo.label//
   </div>
   </doc:source>
   <doc:scenario>
   it('should interpolate binding with custom symbols', function() {
    expect(binding('demo.label')).toBe('This binding is brought you by // interpolation symbols.');
   });
   </doc:scenario>
   </doc:example>
   */
  function $InterpolateProvider($provide) {
    var Suffix = 'InterpolationSyntax',
      syntaxes = [],
      syntaxSymbols = {};
    this.$$syntaxes = syntaxes;

    /**
     * @ngdoc method
     * @name ng.$interpolateProvider#startSymbol
     * @methodOf ng.$interpolateProvider
     * @description
     * Symbol to denote start of expression in the interpolated string. Defaults to `{{`.
     *
     * @param {string=} value new value to set the starting symbol to.
     * @returns {string|self} Returns the symbol when used as getter and self if used as setter.
     */
    this.startSymbol = function (name, value) {
      if (value) {
        syntaxSymbols[name].startSymbol(value);
      } else if (name) {
        if (syntaxSymbols[name]) {
          return syntaxSymbols[name].startSymbol();
        } else {
          syntaxSymbols['default'].startSymbol(name);
        }
      } else {
        return syntaxSymbols['default'].startSymbol();
      }
      return this;
    };

    /**
     * @ngdoc method
     * @name ng.$interpolateProvider#endSymbol
     * @methodOf ng.$interpolateProvider
     * @description
     * Symbol to denote the end of expression in the interpolated string. Defaults to `}}`.
     *
     * @param {string=} value new value to set the ending symbol to.
     * @returns {string|self} Returns the symbol when used as getter and self if used as setter.
     */
    this.endSymbol = function (name, value) {
      if (value) {
        syntaxSymbols[name].endSymbol(value);
      } else if (name) {
        if (syntaxSymbols[name]) {
          return syntaxSymbols[name].endSymbol();
        } else {
          syntaxSymbols['default'].endSymbol(name);
        }
      } else {
        return syntaxSymbols['default'].endSymbol();
      }
      return this;
    };

    // TODO docs
    this.registerSyntax = function (name, startSymbol, endSymbol, parseFnFactory) {

      function startSymbolFn(value) {
        if (value) {
          startSymbol = value;
          return this;
        } else {
          return startSymbol;
        }
      }

      function endSymbolFn(value) {
        if (value) {
          endSymbol = value;
          return this;
        } else {
          return endSymbol;
        }
      }

      syntaxSymbols[name] = {
        startSymbol: startSymbolFn,
        endSymbol: endSymbolFn
      };

      $provide.factory(name + Suffix, ['$injector', '$exceptionHandler',
        function ($injector, $exceptionHandler) {
          var parseFn,
            startSymbolLength = startSymbol.length,
            endSymbolLength = endSymbol.length;
          try {
            parseFn = $injector.invoke(parseFnFactory);
          } catch (e) {
            $exceptionHandler(e);
          }
          return {
            name: name,
            fn: parseFn,
            startSymbol: startSymbolFn,
            endSymbol: endSymbolFn,
            handle: function (parts, text) {
              var exp, startIndex, endIndex, fn,
                hasInterpolation = false,
                index = 0,
                length = text.length;

              while (index < length) {
                if (((startIndex = text.indexOf(startSymbol, index)) != -1) &&
                  ((endIndex = text.indexOf(endSymbol, startIndex + startSymbolLength)) != -1)) {
                  (index != startIndex) && this.next(parts, text.substring(index, startIndex));
                  parts.push(fn = this.fn(exp = text.substring(startIndex + startSymbolLength, endIndex)));
                  fn.exp = exp;
                  index = endIndex + endSymbolLength;
                  hasInterpolation = true;
                } else {
                  // we did not find anything, so we have to add the remainder to the parts array
                  if (index != length) {
                    hasInterpolation = this.next(parts, text.substring(index));
                  }
                  index = length;
                }
              }
              return hasInterpolation;
            },
            next: function (parts, text) {
              var index = indexOf(syntaxes, name);
              if (index != -1 && syntaxes[index + 1]) {
                return $injector.get(syntaxes[index + 1] + Suffix).handle(parts, text);
              } else {
                parts.push(text);
                return false;
              }
            }
          };
        }]);


      for (var i = 0; i < syntaxes.length; i++) {
        var syntax = syntaxSymbols[syntaxes[i]];
        if (startSymbol.indexOf(syntax.startSymbol()) != -1) {
          syntaxes.splice(i, 0, name);
          break;
        }
      }
      if (i === syntaxes.length) {
        syntaxes.push(name);
      }

      return this;
    };

    this.registerSyntax('default', '{{', '}}', ['$parse', function ($parse) {
      return $parse;
    }]);

    this.$get = ['$exceptionHandler', '$sce', '$injector', function ($exceptionHandler, $sce, $injector) {
      /**
       * @ngdoc function
       * @name ng.$interpolate
       * @function
       *
       * @requires $parse
       * @requires $sce
       *
       * @description
       *
       * Compiles a string with markup into an interpolation function. This service is used by the
       * HTML {@link ng.$compile $compile} service for data binding. See
       * {@link ng.$interpolateProvider $interpolateProvider} for configuring the
       * interpolation markup.
       *
       *
       <pre>
       var $interpolate = ...; // injected
       var exp = $interpolate('Hello {{name}}!');
       expect(exp({name:'Angular'}).toEqual('Hello Angular!');
       </pre>
       *
       *
       * @param {string} text The text with markup to interpolate.
       * @param {boolean=} mustHaveExpression if set to true then the interpolation string must have
       *    embedded expression in order to return an interpolation function. Strings with no
       *    embedded expression will return null for the interpolation function.
       * @param {string=} trustedContext when provided, the returned function passes the interpolated
       *    result through {@link ng.$sce#methods_getTrusted $sce.getTrusted(interpolatedResult, trustedContext)}
       *    before returning it.  Refer to the {@link ng.$sce $sce} service that
       *    provides Strict Contextual Escaping for details.
       * @returns {function(context)} an interpolation function which is used to compute the
       *    interpolated string. The function has these parameters:
       *
       *    * `context`: an object against which any expressions embedded in the strings are evaluated
       *      against.
       *
       */
      function $interpolate(text, mustHaveExpression, trustedContext) {
        var parts = [],
          length = text.length,
          hasInterpolation,
          fn,
          concat = [];

        hasInterpolation = $injector.get(syntaxes[0] + Suffix).handle(parts, text);

        if (!(length = parts.length)) {
          // we added, nothing, must have been an empty string.
          parts.push('');
          length = 1;
        }

        // Concatenating expressions makes it hard to reason about whether some combination of
        // concatenated values are unsafe to use and could easily lead to XSS.  By requiring that a
        // single expression be used for iframe[src], object[src], etc., we ensure that the value
        // that's used is assigned or constructed by some JS code somewhere that is more testable or
{'fraction_non_alphanumeric': 0.1132872723119968, 'fraction_numerical': 0.0012562096728144807, 'mean_word_length': 2.0475030450669913, 'pattern_counts': {'":': 0, '<': 31, '<?xml version=': 0, '>': 27, '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': '3580102', 'n_tokens_mistral': 4779, 'n_tokens_neox': 4631, 'n_words': 1323}