Skip to content

Commit 2927d1b

Browse files
committed
clang-format all
1 parent 1f92cc8 commit 2927d1b

File tree

4 files changed

+93
-21
lines changed

4 files changed

+93
-21
lines changed

.clang-format

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
---
2+
AlignAfterOpenBracket: Align
3+
AlignConsecutiveAssignments: false
4+
AlignConsecutiveDeclarations: false
5+
AlignEscapedNewlinesLeft: false
6+
AlignOperands: true
7+
AlignTrailingComments: true
8+
AllowAllParametersOfDeclarationOnNextLine: true
9+
AllowShortBlocksOnASingleLine: true
10+
AllowShortCaseLabelsOnASingleLine: true
11+
AllowShortFunctionsOnASingleLine: All
12+
AllowShortIfStatementsOnASingleLine: true
13+
AllowShortLoopsOnASingleLine: true
14+
AlwaysBreakAfterReturnType: None
15+
AlwaysBreakBeforeMultilineStrings: true
16+
AlwaysBreakTemplateDeclarations: true
17+
BinPackArguments: true
18+
BinPackParameters: true
19+
BreakBeforeBinaryOperators: All
20+
BreakBeforeBraces: WebKit
21+
BreakBeforeTernaryOperators: false
22+
BreakConstructorInitializersBeforeComma: false
23+
BreakStringLiterals: true
24+
ConstructorInitializerAllOnOneLineOrOnePerLine: true
25+
Cpp11BracedListStyle: false
26+
DerivePointerAlignment: false
27+
IncludeCategories:
28+
- Regex: '^"(llvm|llvm-c|clang|clang-c)/'
29+
Priority: 2
30+
- Regex: '^(<|"(gtest|isl|json)/)'
31+
Priority: 3
32+
- Regex: '.\*'
33+
Priority: 1
34+
IndentCaseLabels: false
35+
IndentWrappedFunctionNames: true
36+
KeepEmptyLinesAtTheStartOfBlocks: true
37+
MaxEmptyLinesToKeep: 1
38+
NamespaceIndentation: None
39+
ObjCSpaceAfterProperty: false
40+
ObjCSpaceBeforeProtocolList: false
41+
PenaltyBreakBeforeFirstCallParameter: 150
42+
PenaltyBreakComment: 100
43+
PenaltyBreakFirstLessLess: 0
44+
PenaltyBreakString: 100
45+
PenaltyExcessCharacter: 1000000
46+
PenaltyReturnTypeOnItsOwnLine: 200
47+
PointerAlignment: Left
48+
ReflowComments: true
49+
SortIncludes: true
50+
SpaceAfterCStyleCast: false
51+
SpaceBeforeAssignmentOperators: true
52+
SpaceBeforeParens: ControlStatements
53+
SpaceInEmptyParentheses: false
54+
SpacesBeforeTrailingComments: 1
55+
SpacesInAngles: false
56+
SpacesInCStyleCastParentheses: false
57+
SpacesInContainerLiterals: false
58+
SpacesInParentheses: false
59+
SpacesInSquareBrackets: false
60+
Standard: Cpp11
61+
AccessModifierOffset: -2
62+
BreakBeforeBraces: Attach
63+
JavaScriptQuotes: Single
64+
JavaScriptWrapImports: false
65+
UseTab: Never
66+
TabWidth: 2
67+
ConstructorInitializerIndentWidth: 2
68+
ContinuationIndentWidth: 2
69+
IndentWidth: 2
70+
ColumnLimit: 0
71+
Language: JavaScript
72+
...

src/clangMode.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ for (let l of ['cpp', 'c', 'objective-c', 'objective-cpp', 'java', 'javascript',
99
}
1010
}
1111

12-
export const MODES: vscode.DocumentFilter[] = languages.map((language) => ({language, scheme: 'file'}));
12+
export const MODES: vscode.DocumentFilter[] = languages.map((language) => ({ language, scheme: 'file' }));

src/clangPath.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import fs = require('fs');
44
import path = require('path');
55

6-
let binPathCache: {[bin: string]: string} = {};
6+
let binPathCache: { [bin: string]: string } = {};
77

88
export function getBinPath(binname: string) {
99
if (binPathCache[binname]) {

src/extension.ts

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import * as vscode from 'vscode';
22
import cp = require('child_process');
33
import path = require('path');
4-
import {MODES} from './clangMode';
5-
import {getBinPath} from './clangPath';
4+
import { MODES } from './clangMode';
5+
import { getBinPath } from './clangPath';
66
import sax = require('sax');
77

88
export class ClangDocumentFormattingEditProvider implements vscode.DocumentFormattingEditProvider, vscode.DocumentRangeFormattingEditProvider {
@@ -31,15 +31,15 @@ export class ClangDocumentFormattingEditProvider implements vscode.DocumentForma
3131
let parser = sax.parser(true, options);
3232

3333
let edits: vscode.TextEdit[] = [];
34-
let currentEdit: {length: number, offset: number, text: string};
34+
let currentEdit: { length: number, offset: number, text: string };
3535

3636
let codeBuffer = new Buffer(codeContent);
3737
// encoding position cache
3838
let codeByteOffsetCache = {
3939
byte: 0,
4040
offset: 0
4141
};
42-
let byteToOffset = function(editInfo: {length: number, offset: number}) {
42+
let byteToOffset = function (editInfo: { length: number, offset: number }) {
4343
let offset = editInfo.offset;
4444
let length = editInfo.length;
4545

@@ -68,20 +68,20 @@ export class ClangDocumentFormattingEditProvider implements vscode.DocumentForma
6868
}
6969

7070
switch (tag.name) {
71-
case 'replacements':
72-
return;
73-
74-
case 'replacement':
75-
currentEdit = {
76-
length: parseInt(tag.attributes['length'].toString()),
77-
offset: parseInt(tag.attributes['offset'].toString()),
78-
text: ''
79-
};
80-
byteToOffset(currentEdit);
81-
break;
82-
83-
default:
84-
reject(`Unexpected tag ${tag.name}`);
71+
case 'replacements':
72+
return;
73+
74+
case 'replacement':
75+
currentEdit = {
76+
length: parseInt(tag.attributes['length'].toString()),
77+
offset: parseInt(tag.attributes['offset'].toString()),
78+
text: ''
79+
};
80+
byteToOffset(currentEdit);
81+
break;
82+
83+
default:
84+
reject(`Unexpected tag ${tag.name}`);
8585
}
8686

8787
};
@@ -219,7 +219,7 @@ export class ClangDocumentFormattingEditProvider implements vscode.DocumentForma
219219
workingPath = path.dirname(document.fileName);
220220
}
221221

222-
let child = cp.execFile(formatCommandBinPath, formatArgs, {cwd: workingPath}, childCompleted);
222+
let child = cp.execFile(formatCommandBinPath, formatArgs, { cwd: workingPath }, childCompleted);
223223
child.stdin.end(codeContent);
224224

225225
if (token) {

0 commit comments

Comments
 (0)