Normalize multiline-related code that will cause syntax error.

    This is for purposes of checking syntax.
187707
def normalize_multiline(line):
    
    if line.startswith('def ') and line.rstrip().endswith(':'):
        return line + ' pass'
    elif line.startswith('return '):
        return 'def _(): ' + line
    elif line.startswith('@'):
        return line + 'def _(): pass'
    elif line.startswith('class '):
        return line + ' pass'
    elif line.startswith(('if ', 'elif ', 'for ', 'while ')):
        return line + ' pass'
    else:
        return line
713082
def filter_skiplines(code, errors):
    
    if not errors:
        return errors

    enums = set(er.lnum for er in errors)
    removed = set([
        num for num, l in enumerate(code.split('\n'), 1)
        if num in enums and SKIP_PATTERN(l)
    ])

    if removed:
        errors = [er for er in errors if er.lnum not in removed]

    return errors
845868
def _code_line(self, line):
        """"""
        assert self._containers
        container = self._containers[-1]
        # Handle extra spaces.
        text = line
        while text:
            if text.startswith('  '):
                r = re.match(r'(^ +)', text)
                n = len(r.group(1))
                container.addElement(S(c=n))
                text = text[n:]
            elif '  ' in text:
                assert not text.startswith(' ')
                i = text.index('  ')
                container.addElement(Span(text=text[:i]))
                text = text[i:]
            else:
                container.addElement(Span(text=text))
                text = ''
385672
def normalize(string: Text) -> Text:
    

    string = string.lower()
    string = unidecode(string)
    string = RE_WHITESPACES.sub(' ', string).strip()

    return string
1336028
def syntax_error!(message)
      raise SyntaxError.new(message, options[:file], @orig_line, @lineno,
                            @orig_line && @line ? @orig_line.size - @line.size : 0)
    rescue SyntaxError => ex
      # HACK: Manipulate stacktrace for Rails and other frameworks
      # to find the right file.
      ex.backtrace.unshift "#{options[:file]}:#{@lineno}"
      raise
    end
174749
def normalize_value(values)
      Array.wrap(values).map do |value|
        value.is_a?(String) ? value.gsub("\n", "") : value
      end
    end
895834
def normalize_cpp_function(self, function, line):
        """"""
        # Drop member function cv/ref qualifiers like const, const&, &, and &&
        for ref in ('const', 'const&', '&&', '&'):
            if function.endswith(ref):
                function = function[:-len(ref)].strip()

        # Drop the prefix and return type if there is any if it's not operator
        # overloading--operator overloading syntax doesn't have the things
        # we're dropping here and can look curious, so don't try
        if '::operator' not in function:
            function = drop_prefix_and_return_type(function)

        # Collapse types
        function = collapse(
            function,
            open_string='<',
            close_string='>',
            replacement='<T>',
            exceptions=('name omitted', 'IPC::ParamTraits')
        )

        # Collapse arguments
        if self.collapse_arguments:
            function = collapse(
                function,
                open_string='(',
                close_string=')',
                replacement='',
                exceptions=('anonymous namespace', 'operator')
            )

        # Remove PGO cold block labels like "[clone .cold.222]". bug #1397926
        if 'clone .cold' in function:
            function = collapse(
                function,
                open_string='[',
                close_string=']',
                replacement=''
            )

        if self.signatures_with_line_numbers_re.match(function):
            function = '{}:{}'.format(function, line)

        # Remove spaces before all stars, ampersands, and commas
        function = self.fixup_space.sub('', function)

        # Ensure a space after commas
        function = self.fixup_comma.sub(', ', function)

        return function
1140298
function normalizeLineEndings(lineEnding, value) {
  if (autils.isBinaryFile(value)) {
    return value;
  }
  return value.replace(lineEndingRegex, lineEnding);
}
769038
def p_error(self, elem):
        ''''''
        self.errors.append("Syntax error on line " + str(self.lexer.lineno)
                           + ". Got unexpected token " + elem.type)
87383
def x_parse_error(err, content, source):
    
    lineno, column = err.position
    if "<doc>" in content:
        #Adjust the position since we are taking the <doc> part out of the tags
        #since we may have put that in ourselves.
        column -= 5
    start = lineno - (1 if lineno == 1 else 2)
    lines = []
    tcontent = content.replace("<doc>", "").replace("</doc>", "").split('\n')
    for context in IT.islice(tcontent, start, lineno):
        lines.append(context.strip())
    last = wrap_line(lines.pop(), column)
    lines.extend(last)
    
    caret = '{:=>{}}'.format('^', len(last[-1]))
    if source is not None:
        err.msg = '\nIn: {}\n{}\n{}\n{}'.format(source, err, '\n'.join(lines), caret)
    else:
        err.msg = '{}\n{}\n{}'.format(err, '\n'.join(lines), caret)

    raise err
65552
def _normalize(self, string):
		'''  '''

		string = string.replace(u'\xa0', '')
		string = string.strip()
		return string
254989
def blacken_code(code):
    
    if black is None:
        raise NotImplementedError

    major, minor, _ = platform.python_version_tuple()
    pyversion = 'py{major}{minor}'.format(major=major, minor=minor)
    target_versions = [black.TargetVersion[pyversion.upper()]]

    line_length = black.DEFAULT_LINE_LENGTH
    string_normalization = True

    mode = black.FileMode(
        target_versions=target_versions,
        line_length=line_length,
        string_normalization=string_normalization,
    )

    return black.format_file_contents(code, fast=False, mode=mode)
724918
def _format_line(self, data, column=0, rel_line=1):
        ''
        line_length = len(data)

        if line_length > 140:
            if rel_line == 0:
                # Trim from the beginning
                data = '... %s' % data[-140:]
            elif rel_line == 1:
                # Trim surrounding the error position
                if column < 70:
                    data = '%s ...' % data[:140]
                elif column > line_length - 70:
                    data = '... %s' % data[-140:]
                else:
                    data = '... %s ...' % data[column - 70:column + 70]

            elif rel_line == 2:
                # Trim from the end
                data = '%s ...' % data[:140]

        data = unicodehelper.decode(data)
        return data
994492
def _maybe_normalize(self, var):
        
        if self.normalize:
            try:
                return self._norm.normalize(var)
            except HGVSUnsupportedOperationError as e:
                _logger.warning(str(e) + "; returning unnormalized variant")
                # fall through to return unnormalized variant
        return var
5252
def format_code(text)
      simple_format( truncate( Sanitize.clean(markdown(text)).html_safe, escape: false, length: 300, separator: ' ', omission: ' …' ))
    end
383050
def fix_line_range(source_code, start, end, options):
    """"""
    # TODO confirm behaviour outside range (indexing starts at 1)
    start = max(start, 1)

    options.line_range = [start, end]
    from autopep8 import fix_code
    fixed = fix_code(source_code, options)

    try:
        if options.docformatter:
            from docformatter import format_code
            fixed = format_code(
                fixed,
                summary_wrap_length=options.max_line_length - 1,
                description_wrap_length=(options.max_line_length
                                         - 2 * options.indent_size),
                pre_summary_newline=options.pre_summary_newline,
                post_description_blank=options.post_description_blank,
                force_wrap=options.force_wrap,
                line_range=[start, end])
    except AttributeError:  # e.g. using autopep8.parse_args, pragma: no cover
        pass

    return fixed
1028770
function normalizeBlocks(input) {

    var numberOfLinesToIndent = 0;
    var thisLineContainsStuff = false;
    var thisLinesIndentation = '';
    var out = '';

    for (var i = 0; i < input.length; i++) {

        var chr = input[i];

        if (chr == '\r') {
            continue;
        }

        if (chr === '\n') {
            if (!thisLineContainsStuff) {
                numberOfLinesToIndent++;
            } else {
                out += '\n';
            }

            thisLineContainsStuff = false;
            thisLinesIndentation = '';
            continue;
        }

        if (!thisLineContainsStuff && (chr === ' ' || chr === '\t')) {
            thisLinesIndentation += chr;
            continue;
        }

        if (chr !== ' ' || chr !== '\t') {

            if (!thisLineContainsStuff) {
                for (var j = 0; j < numberOfLinesToIndent; j++) {
                    out += thisLinesIndentation + '\n';
                }

                out += thisLinesIndentation + chr;
            } else {
                out += chr;
            }

            numberOfLinesToIndent = 0;
            thisLineContainsStuff = true;

        }

    }

    return out;

}