[clangd][vscode] clang-format the the extension code.

Summary:
As we are going to grow the extension in the near future, it is time to
formalize the TS code format/style of our extension (although we'd lose the
history).

We use default options of clang-format:
- 80 max line length
- 2 space indent

Reviewers: ilya-biryukov, sammccall, jvikstrom

Subscribers: MaskRay, jkorous, arphaman, kadircet, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D65657

llvm-svn: 367684
This commit is contained in:
Haojian Wu 2019-08-02 14:24:02 +00:00
parent 522fb7eedc
commit 13a81444cd
5 changed files with 105 additions and 99 deletions

View File

@ -50,6 +50,11 @@ point to the binary.
# When VS Code starts, press <F5>.
```
## Contributing
Please follow the exsiting code style when contributing to the extension, we
recommend to run `npm run format` before sending a patch.
## Publish to VS Code Marketplace
New changes to `clangd-vscode` are not released until a new version is published

View File

@ -32,6 +32,7 @@
"vscode:prepublish": "tsc -p ./",
"compile": "tsc -watch -p ./",
"postinstall": "node ./node_modules/vscode/bin/install",
"format": "clang-format --style=LLVM -i --glob=\"{src,test}/*.ts\"",
"test": "node ./node_modules/vscode/bin/test"
},
"dependencies": {
@ -42,6 +43,7 @@
"@types/mocha": "^2.2.32",
"@types/node": "^6.0.40",
"mocha": "^5.2.0",
"clang-format": "1.2.4",
"typescript": "^2.0.3",
"vscode": "^1.1.0"
},

View File

@ -44,9 +44,7 @@ class FileStatus {
this.statusBarItem.hide();
}
dispose() {
this.statusBarItem.dispose();
}
dispose() { this.statusBarItem.dispose(); }
}
/**
@ -91,7 +89,8 @@ export function activate(context: vscode.ExtensionContext) {
revealOutputChannelOn: vscodelc.RevealOutputChannelOn.Never
};
const clangdClient = new vscodelc.LanguageClient('Clang Language Server',serverOptions, clientOptions);
const clangdClient = new vscodelc.LanguageClient(
'Clang Language Server', serverOptions, clientOptions);
console.log('Clang Language Server is now active!');
context.subscriptions.push(clangdClient.start());
context.subscriptions.push(vscode.commands.registerCommand(
@ -113,11 +112,9 @@ export function activate(context: vscode.ExtensionContext) {
vscode.window.showTextDocument(doc);
}));
const status = new FileStatus();
context.subscriptions.push(vscode.window.onDidChangeActiveTextEditor(() => {
status.updateStatus();
}));
clangdClient.onDidChangeState(
({ newState }) => {
context.subscriptions.push(vscode.window.onDidChangeActiveTextEditor(
() => { status.updateStatus(); }));
clangdClient.onDidChangeState(({newState}) => {
if (newState == vscodelc.State.Running) {
// clangd starts or restarts after crash.
clangdClient.onNotification(

View File

@ -6,7 +6,6 @@ import * as myExtension from '../src/extension';
// TODO: add tests
suite("Extension Tests", () => {
// Defines a Mocha unit test
test("Something 1", () => {
assert.equal(-1, [ 1, 2, 3 ].indexOf(5));

View File

@ -5,17 +5,20 @@
// By default the test runner in use is Mocha based.
//
// You can provide your own test runner if you want to override it by exporting
// a function run(testRoot: string, clb: (error:Error) => void) that the extension
// host can call to run the tests. The test runner is expected to use console.log
// to report the results back to the caller. When the tests are finished, return
// a possible error to the callback or null if none.
// a function run(testRoot: string, clb: (error:Error) => void) that the
// extension host can call to run the tests. The test runner is expected to use
// console.log to report the results back to the caller. When the tests are
// finished, return a possible error to the callback or null if none.
var testRunner = require('vscode/lib/testrunner');
// You can directly control Mocha options by uncommenting the following lines
// See https://github.com/mochajs/mocha/wiki/Using-mocha-programmatically#set-options for more info
// See
// https://github.com/mochajs/mocha/wiki/Using-mocha-programmatically#set-options
// for more info
testRunner.configure({
ui: 'tdd', // the TDD UI is being used in extension.test.ts (suite, test, etc.)
ui : 'tdd', // the TDD UI is being used in extension.test.ts (suite, test,
// etc.)
useColors : true // colored output from test results
});