diff options
author | thakis@chromium.org <thakis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-02-02 22:25:26 +0000 |
---|---|---|
committer | thakis@chromium.org <thakis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-02-02 22:25:26 +0000 |
commit | ab3768311de1ae88cf64da69895010f3c8455002 (patch) | |
tree | 87e9176385764d2eb586cedd3c5551f76cf9d170 /third_party | |
parent | f0872324565c7eea599aac569bc265a72c2930c6 (diff) | |
download | chromium_src-ab3768311de1ae88cf64da69895010f3c8455002.zip chromium_src-ab3768311de1ae88cf64da69895010f3c8455002.tar.gz chromium_src-ab3768311de1ae88cf64da69895010f3c8455002.tar.bz2 |
Remove third_party/clang_format/scripts.
`git cl format` should now use the deps-pulled scripts in
third_party/clang_format/script (note no trailing 's'). If this change breaks
`git cl format` for you, run `gclient` once to let depot_tools auto-update.
Things should work after that.
BUG=240309
NOTRY=true
Review URL: https://codereview.chromium.org/142023007
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@248431 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'third_party')
6 files changed, 1 insertions, 335 deletions
diff --git a/third_party/clang_format/README.chromium b/third_party/clang_format/README.chromium index 103b5ea..a72a5f2 100644 --- a/third_party/clang_format/README.chromium +++ b/third_party/clang_format/README.chromium @@ -3,7 +3,7 @@ Short Name: clang-format URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-format/ Version: 3.5 Date: 8 January 2014 -Revision: 198831 +Revision: See DEPS License: University of Illinois/NCSA Open Source License License File: NOT_SHIPPED Security Critical: No diff --git a/third_party/clang_format/scripts/clang-format-bbedit.applescript b/third_party/clang_format/scripts/clang-format-bbedit.applescript deleted file mode 100644 index fa88fe9..0000000 --- a/third_party/clang_format/scripts/clang-format-bbedit.applescript +++ /dev/null @@ -1,27 +0,0 @@ --- In this file, change "/path/to/" to the path where you installed clang-format --- and save it to ~/Library/Application Support/BBEdit/Scripts. You can then --- select the script from the Script menu and clang-format will format the --- selection. Note that you can rename the menu item by renaming the script, and --- can assign the menu item a keyboard shortcut in the BBEdit preferences, under --- Menus & Shortcuts. -on urlToPOSIXPath(theURL) - return do shell script "python -c \"import urllib, urlparse, sys; print urllib.unquote(urlparse.urlparse(sys.argv[1])[2])\" " & quoted form of theURL -end urlToPOSIXPath - -tell application "BBEdit" - set selectionOffset to characterOffset of selection - set selectionLength to length of selection - set fileURL to URL of text document 1 -end tell - -set filePath to urlToPOSIXPath(fileURL) -set newContents to do shell script "/path/to/clang-format -offset=" & selectionOffset & " -length=" & selectionLength & " " & quoted form of filePath - -tell application "BBEdit" - -- "set contents of text document 1 to newContents" scrolls to the bottom while - -- replacing a selection flashes a bit but doesn't affect the scroll position. - set currentLength to length of contents of text document 1 - select characters 1 thru currentLength of text document 1 - set text of selection to newContents - select characters selectionOffset thru (selectionOffset + selectionLength - 1) of text document 1 -end tell diff --git a/third_party/clang_format/scripts/clang-format-diff.py b/third_party/clang_format/scripts/clang-format-diff.py deleted file mode 100755 index d575a8a..0000000 --- a/third_party/clang_format/scripts/clang-format-diff.py +++ /dev/null @@ -1,114 +0,0 @@ -#!/usr/bin/python -# -#===- clang-format-diff.py - ClangFormat Diff Reformatter ----*- python -*--===# -# -# The LLVM Compiler Infrastructure -# -# This file is distributed under the University of Illinois Open Source -# License. See LICENSE.TXT for details. -# -#===------------------------------------------------------------------------===# - -r""" -ClangFormat Diff Reformatter -============================ - -This script reads input from a unified diff and reformats all the changed -lines. This is useful to reformat all the lines touched by a specific patch. -Example usage for git users: - - git diff -U0 HEAD^ | clang-format-diff.py -p1 -i - -""" - -import argparse -import difflib -import re -import string -import subprocess -import StringIO -import sys - - -# Change this to the full path if clang-format is not on the path. -binary = 'clang-format' - - -def main(): - parser = argparse.ArgumentParser(description= - 'Reformat changed lines in diff. Without -i ' - 'option just output the diff that would be ' - 'introduced.') - parser.add_argument('-i', action='store_true', default=False, - help='apply edits to files instead of displaying a diff') - parser.add_argument('-p', metavar='NUM', default=0, - help='strip the smallest prefix containing P slashes') - parser.add_argument('-regex', metavar='PATTERN', default=None, - help='custom pattern selecting file paths to reformat ' - '(case sensitive, overrides -iregex)') - parser.add_argument('-iregex', metavar='PATTERN', default= - r'.*\.(cpp|cc|c\+\+|cxx|c|cl|h|hpp|m|mm|inc|js)', - help='custom pattern selecting file paths to reformat ' - '(case insensitive, overridden by -regex)') - parser.add_argument( - '-style', - help= - 'formatting style to apply (LLVM, Google, Chromium, Mozilla, WebKit)') - args = parser.parse_args() - - # Extract changed lines for each file. - filename = None - lines_by_file = {} - for line in sys.stdin: - match = re.search('^\+\+\+\ (.*?/){%s}(\S*)' % args.p, line) - if match: - filename = match.group(2) - if filename == None: - continue - - if args.regex is not None: - if not re.match('^%s$' % args.regex, filename): - continue - else: - if not re.match('^%s$' % args.iregex, filename, re.IGNORECASE): - continue - - match = re.search('^@@.*\+(\d+)(,(\d+))?', line) - if match: - start_line = int(match.group(1)) - line_count = 1 - if match.group(3): - line_count = int(match.group(3)) - if line_count == 0: - continue - end_line = start_line + line_count - 1; - lines_by_file.setdefault(filename, []).extend( - ['-lines', str(start_line) + ':' + str(end_line)]) - - # Reformat files containing changes in place. - for filename, lines in lines_by_file.iteritems(): - command = [binary, filename] - if args.i: - command.append('-i') - command.extend(lines) - if args.style: - command.extend(['-style', args.style]) - p = subprocess.Popen(command, stdout=subprocess.PIPE, - stderr=None, stdin=subprocess.PIPE) - stdout, stderr = p.communicate() - if p.returncode != 0: - sys.exit(p.returncode); - - if not args.i: - with open(filename) as f: - code = f.readlines() - formatted_code = StringIO.StringIO(stdout).readlines() - diff = difflib.unified_diff(code, formatted_code, - filename, filename, - '(before formatting)', '(after formatting)') - diff_string = string.join(diff, '') - if len(diff_string) > 0: - sys.stdout.write(diff_string) - -if __name__ == '__main__': - main() diff --git a/third_party/clang_format/scripts/clang-format-sublime.py b/third_party/clang_format/scripts/clang-format-sublime.py deleted file mode 100644 index 16ff56e..0000000 --- a/third_party/clang_format/scripts/clang-format-sublime.py +++ /dev/null @@ -1,58 +0,0 @@ -# This file is a minimal clang-format sublime-integration. To install: -# - Change 'binary' if clang-format is not on the path (see below). -# - Put this file into your sublime Packages directory, e.g. on Linux: -# ~/.config/sublime-text-2/Packages/User/clang-format-sublime.py -# - Add a key binding: -# { "keys": ["ctrl+shift+c"], "command": "clang_format" }, -# -# With this integration you can press the bound key and clang-format will -# format the current lines and selections for all cursor positions. The lines -# or regions are extended to the next bigger syntactic entities. -# -# It operates on the current, potentially unsaved buffer and does not create -# or save any files. To revert a formatting, just undo. - -from __future__ import print_function -import sublime -import sublime_plugin -import subprocess - -# Change this to the full path if clang-format is not on the path. -binary = 'clang-format' - -# Change this to format according to other formatting styles. See the output of -# 'clang-format --help' for a list of supported styles. The default looks for -# a '.clang-format' or '_clang-format' file to indicate the style that should be -# used. -style = 'file' - -class ClangFormatCommand(sublime_plugin.TextCommand): - def run(self, edit): - encoding = self.view.encoding() - if encoding == 'Undefined': - encoding = 'utf-8' - regions = [] - command = [binary, '-style', style] - for region in self.view.sel(): - regions.append(region) - region_offset = min(region.a, region.b) - region_length = abs(region.b - region.a) - command.extend(['-offset', str(region_offset), - '-length', str(region_length), - '-assume-filename', str(self.view.file_name())]) - old_viewport_position = self.view.viewport_position() - buf = self.view.substr(sublime.Region(0, self.view.size())) - p = subprocess.Popen(command, stdout=subprocess.PIPE, - stderr=subprocess.PIPE, stdin=subprocess.PIPE) - output, error = p.communicate(buf.encode(encoding)) - if error: - print(error) - self.view.replace( - edit, sublime.Region(0, self.view.size()), - output.decode(encoding)) - self.view.sel().clear() - for region in regions: - self.view.sel().add(region) - # FIXME: Without the 10ms delay, the viewport sometimes jumps. - sublime.set_timeout(lambda: self.view.set_viewport_position( - old_viewport_position, False), 10) diff --git a/third_party/clang_format/scripts/clang-format.el b/third_party/clang_format/scripts/clang-format.el deleted file mode 100644 index 520a3e2..0000000 --- a/third_party/clang_format/scripts/clang-format.el +++ /dev/null @@ -1,56 +0,0 @@ -;;; Clang-format emacs integration for use with C/Objective-C/C++. - -;; This defines a function clang-format-region that you can bind to a key. -;; A minimal .emacs would contain: -;; -;; (load "<path-to-clang>/tools/clang-format/clang-format.el") -;; (global-set-key [C-M-tab] 'clang-format-region) -;; -;; Depending on your configuration and coding style, you might need to modify -;; 'style' in clang-format, below. - -(require 'json) - -;; *Location of the clang-format binary. If it is on your PATH, a full path name -;; need not be specified. -(defvar clang-format-binary "clang-format") - -(defun clang-format-region () - "Use clang-format to format the currently active region." - (interactive) - (let ((beg (if mark-active - (region-beginning) - (min (line-beginning-position) (1- (point-max))))) - (end (if mark-active - (region-end) - (line-end-position)))) - (clang-format beg end))) - -(defun clang-format-buffer () - "Use clang-format to format the current buffer." - (interactive) - (clang-format (point-min) (point-max))) - -(defun clang-format (begin end) - "Use clang-format to format the code between BEGIN and END." - (let* ((orig-windows (get-buffer-window-list (current-buffer))) - (orig-window-starts (mapcar #'window-start orig-windows)) - (orig-point (point)) - (style "file")) - (unwind-protect - (call-process-region (point-min) (point-max) clang-format-binary - t (list t nil) nil - "-offset" (number-to-string (1- begin)) - "-length" (number-to-string (- end begin)) - "-cursor" (number-to-string (1- (point))) - "-assume-filename" (buffer-file-name) - "-style" style) - (goto-char (point-min)) - (let ((json-output (json-read-from-string - (buffer-substring-no-properties - (point-min) (line-beginning-position 2))))) - (delete-region (point-min) (line-beginning-position 2)) - (goto-char (1+ (cdr (assoc 'Cursor json-output)))) - (dotimes (index (length orig-windows)) - (set-window-start (nth index orig-windows) - (nth index orig-window-starts))))))) diff --git a/third_party/clang_format/scripts/clang-format.py b/third_party/clang_format/scripts/clang-format.py deleted file mode 100644 index f5a5756..0000000 --- a/third_party/clang_format/scripts/clang-format.py +++ /dev/null @@ -1,79 +0,0 @@ -# This file is a minimal clang-format vim-integration. To install: -# - Change 'binary' if clang-format is not on the path (see below). -# - Add to your .vimrc: -# -# map <C-I> :pyf <path-to-this-file>/clang-format.py<CR> -# imap <C-I> <ESC>:pyf <path-to-this-file>/clang-format.py<CR>i -# -# The first line enables clang-format for NORMAL and VISUAL mode, the second -# line adds support for INSERT mode. Change "C-I" to another binding if you -# need clang-format on a different key (C-I stands for Ctrl+i). -# -# With this integration you can press the bound key and clang-format will -# format the current line in NORMAL and INSERT mode or the selected region in -# VISUAL mode. The line or region is extended to the next bigger syntactic -# entity. -# -# It operates on the current, potentially unsaved buffer and does not create -# or save any files. To revert a formatting, just undo. - -import difflib -import json -import subprocess -import sys -import vim - -# Change this to the full path if clang-format is not on the path. -binary = 'clang-format' - -# Change this to format according to other formatting styles. See the output of -# 'clang-format --help' for a list of supported styles. The default looks for -# a '.clang-format' or '_clang-format' file to indicate the style that should be -# used. -style = 'file' - -# Get the current text. -buf = vim.current.buffer -text = '\n'.join(buf) - -# Determine range to format. -cursor = int(vim.eval('line2byte(line("."))+col(".")')) - 2 -lines = '%s:%s' % (vim.current.range.start + 1, vim.current.range.end + 1) - -# Avoid flashing an ugly, ugly cmd prompt on Windows when invoking clang-format. -startupinfo = None -if sys.platform.startswith('win32'): - startupinfo = subprocess.STARTUPINFO() - startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW - startupinfo.wShowWindow = subprocess.SW_HIDE - -# Call formatter. -command = [binary, '-lines', lines, '-style', style, '-cursor', str(cursor)] -if vim.current.buffer.name: - command.extend(['-assume-filename', vim.current.buffer.name]) -p = subprocess.Popen(command, - stdout=subprocess.PIPE, stderr=subprocess.PIPE, - stdin=subprocess.PIPE, startupinfo=startupinfo) -stdout, stderr = p.communicate(input=text) - -# If successful, replace buffer contents. -if stderr: - message = stderr.splitlines()[0] - parts = message.split(' ', 2) - if len(parts) > 2: - message = parts[2] - print 'Formatting failed: %s (total %d warnings, %d errors)' % ( - message, stderr.count('warning:'), stderr.count('error:')) - -if not stdout: - print ('No output from clang-format (crashed?).\n' + - 'Please report to bugs.llvm.org.') -else: - lines = stdout.split('\n') - output = json.loads(lines[0]) - lines = lines[1:] - sequence = difflib.SequenceMatcher(None, vim.current.buffer, lines) - for op in reversed(sequence.get_opcodes()): - if op[0] is not 'equal': - vim.current.buffer[op[1]:op[2]] = lines[op[3]:op[4]] - vim.command('goto %d' % (output['Cursor'] + 1)) |