Skip to content

Commit

Permalink
clang-format all
Browse files Browse the repository at this point in the history
  • Loading branch information
xaverh committed Apr 20, 2017
1 parent 1f92cc8 commit 2927d1b
Show file tree
Hide file tree
Showing 4 changed files with 93 additions and 21 deletions.
72 changes: 72 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -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
...
2 changes: 1 addition & 1 deletion src/clangMode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'}));
export const MODES: vscode.DocumentFilter[] = languages.map((language) => ({ language, scheme: 'file' }));
2 changes: 1 addition & 1 deletion src/clangPath.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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]) {
Expand Down
38 changes: 19 additions & 19 deletions src/extension.ts
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down Expand Up @@ -31,15 +31,15 @@ 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
let codeByteOffsetCache = {
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;

Expand Down Expand Up @@ -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}`);
}

};
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 2927d1b

Please sign in to comment.