From 2927d1b1942cecb823b0b5e36f86877f3a00dd73 Mon Sep 17 00:00:00 2001 From: Xaver Hellauer Date: Thu, 20 Apr 2017 18:36:36 +0200 Subject: [PATCH] clang-format all --- .clang-format | 72 ++++++++++++++++++++++++++++++++++++++++++++++++ src/clangMode.ts | 2 +- src/clangPath.ts | 2 +- src/extension.ts | 38 ++++++++++++------------- 4 files changed, 93 insertions(+), 21 deletions(-) create mode 100644 .clang-format diff --git a/.clang-format b/.clang-format new file mode 100644 index 0000000..6c71dae --- /dev/null +++ b/.clang-format @@ -0,0 +1,72 @@ +--- +AlignAfterOpenBracket: Align +AlignConsecutiveAssignments: false +AlignConsecutiveDeclarations: false +AlignEscapedNewlinesLeft: false +AlignOperands: true +AlignTrailingComments: true +AllowAllParametersOfDeclarationOnNextLine: true +AllowShortBlocksOnASingleLine: true +AllowShortCaseLabelsOnASingleLine: true +AllowShortFunctionsOnASingleLine: All +AllowShortIfStatementsOnASingleLine: true +AllowShortLoopsOnASingleLine: true +AlwaysBreakAfterReturnType: None +AlwaysBreakBeforeMultilineStrings: true +AlwaysBreakTemplateDeclarations: true +BinPackArguments: true +BinPackParameters: true +BreakBeforeBinaryOperators: All +BreakBeforeBraces: WebKit +BreakBeforeTernaryOperators: false +BreakConstructorInitializersBeforeComma: false +BreakStringLiterals: true +ConstructorInitializerAllOnOneLineOrOnePerLine: true +Cpp11BracedListStyle: false +DerivePointerAlignment: false +IncludeCategories: + - Regex: '^"(llvm|llvm-c|clang|clang-c)/' + Priority: 2 + - Regex: '^(<|"(gtest|isl|json)/)' + Priority: 3 + - Regex: '.\*' + Priority: 1 +IndentCaseLabels: false +IndentWrappedFunctionNames: true +KeepEmptyLinesAtTheStartOfBlocks: true +MaxEmptyLinesToKeep: 1 +NamespaceIndentation: None +ObjCSpaceAfterProperty: false +ObjCSpaceBeforeProtocolList: false +PenaltyBreakBeforeFirstCallParameter: 150 +PenaltyBreakComment: 100 +PenaltyBreakFirstLessLess: 0 +PenaltyBreakString: 100 +PenaltyExcessCharacter: 1000000 +PenaltyReturnTypeOnItsOwnLine: 200 +PointerAlignment: Left +ReflowComments: true +SortIncludes: true +SpaceAfterCStyleCast: false +SpaceBeforeAssignmentOperators: true +SpaceBeforeParens: ControlStatements +SpaceInEmptyParentheses: false +SpacesBeforeTrailingComments: 1 +SpacesInAngles: false +SpacesInCStyleCastParentheses: false +SpacesInContainerLiterals: false +SpacesInParentheses: false +SpacesInSquareBrackets: false +Standard: Cpp11 +AccessModifierOffset: -2 +BreakBeforeBraces: Attach +JavaScriptQuotes: Single +JavaScriptWrapImports: false +UseTab: Never +TabWidth: 2 +ConstructorInitializerIndentWidth: 2 +ContinuationIndentWidth: 2 +IndentWidth: 2 +ColumnLimit: 0 +Language: JavaScript +... diff --git a/src/clangMode.ts b/src/clangMode.ts index bb03bea..deedae9 100644 --- a/src/clangMode.ts +++ b/src/clangMode.ts @@ -9,4 +9,4 @@ for (let l of ['cpp', 'c', 'objective-c', 'objective-cpp', 'java', 'javascript', } } -export const MODES: vscode.DocumentFilter[] = languages.map((language) => ({language, scheme: 'file'})); \ No newline at end of file +export const MODES: vscode.DocumentFilter[] = languages.map((language) => ({ language, scheme: 'file' })); \ No newline at end of file diff --git a/src/clangPath.ts b/src/clangPath.ts index b40128e..df165d5 100644 --- a/src/clangPath.ts +++ b/src/clangPath.ts @@ -3,7 +3,7 @@ import fs = require('fs'); import path = require('path'); -let binPathCache: {[bin: string]: string} = {}; +let binPathCache: { [bin: string]: string } = {}; export function getBinPath(binname: string) { if (binPathCache[binname]) { diff --git a/src/extension.ts b/src/extension.ts index 253c426..ca70210 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -1,8 +1,8 @@ import * as vscode from 'vscode'; import cp = require('child_process'); import path = require('path'); -import {MODES} from './clangMode'; -import {getBinPath} from './clangPath'; +import { MODES } from './clangMode'; +import { getBinPath } from './clangPath'; import sax = require('sax'); export class ClangDocumentFormattingEditProvider implements vscode.DocumentFormattingEditProvider, vscode.DocumentRangeFormattingEditProvider { @@ -31,7 +31,7 @@ export class ClangDocumentFormattingEditProvider implements vscode.DocumentForma let parser = sax.parser(true, options); let edits: vscode.TextEdit[] = []; - let currentEdit: {length: number, offset: number, text: string}; + let currentEdit: { length: number, offset: number, text: string }; let codeBuffer = new Buffer(codeContent); // encoding position cache @@ -39,7 +39,7 @@ export class ClangDocumentFormattingEditProvider implements vscode.DocumentForma byte: 0, offset: 0 }; - let byteToOffset = function(editInfo: {length: number, offset: number}) { + let byteToOffset = function (editInfo: { length: number, offset: number }) { let offset = editInfo.offset; let length = editInfo.length; @@ -68,20 +68,20 @@ export class ClangDocumentFormattingEditProvider implements vscode.DocumentForma } switch (tag.name) { - case 'replacements': - return; - - case 'replacement': - currentEdit = { - length: parseInt(tag.attributes['length'].toString()), - offset: parseInt(tag.attributes['offset'].toString()), - text: '' - }; - byteToOffset(currentEdit); - break; - - default: - reject(`Unexpected tag ${tag.name}`); + case 'replacements': + return; + + case 'replacement': + currentEdit = { + length: parseInt(tag.attributes['length'].toString()), + offset: parseInt(tag.attributes['offset'].toString()), + text: '' + }; + byteToOffset(currentEdit); + break; + + default: + reject(`Unexpected tag ${tag.name}`); } }; @@ -219,7 +219,7 @@ export class ClangDocumentFormattingEditProvider implements vscode.DocumentForma workingPath = path.dirname(document.fileName); } - let child = cp.execFile(formatCommandBinPath, formatArgs, {cwd: workingPath}, childCompleted); + let child = cp.execFile(formatCommandBinPath, formatArgs, { cwd: workingPath }, childCompleted); child.stdin.end(codeContent); if (token) {