Commit Graph

8 Commits

Author SHA1 Message Date
Krasimir Georgiev f7de84ab9f [clangd] Fix Output.log error
llvm-svn: 295305
2017-02-16 10:53:27 +00:00
Krasimir Georgiev 1b8bfd4b76 [clangd] Implement format on type
Summary:
This patch adds onTypeFormatting to clangd.

The trigger character is '}' and it works by scanning for the matching '{' and formatting the range in-between.

There are problems with ';' as a trigger character, the cursor position is before the `|`:
```
int main() {
  int i;|
}
```
becomes:
```
int main() {  int i;| }
```
which is not likely what the user intended.

Also formatting at semicolon in a non-properly closed scope puts the following tokens in the same unwrapped line, which doesn't reformat nicely.

Reviewers: bkramer

Reviewed By: bkramer

Subscribers: cfe-commits

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

llvm-svn: 295304
2017-02-16 10:49:46 +00:00
Benjamin Kramer 0ac6d124cf [clangd] Fix another use after free that I missed because COW strings.
llvm-svn: 295198
2017-02-15 17:04:57 +00:00
Benjamin Kramer e14bd4246d [clangd] Synchronize logs access.
I don't think that this is necessary for correctness, but makes tsan
much more useful.

llvm-svn: 295194
2017-02-15 16:44:11 +00:00
Benjamin Kramer 4eaf89f2d9 [clangd] Fix use after free.
llvm-svn: 295187
2017-02-15 15:56:14 +00:00
Benjamin Kramer d0b2ccd219 [clangd] Refactor stream output into a single thread-safe output object.
This abstracts away the passing of raw_ostreams everywhere, thread
safety will be used soon.

llvm-svn: 294747
2017-02-10 14:08:40 +00:00
Benjamin Kramer f86708dbf5 [clangd] Strip file:// from the URI when calling formatting.
It confuses FileManager on windows.

llvm-svn: 294314
2017-02-07 16:10:17 +00:00
Benjamin Kramer bb1cdb63e5 Add a prototype for clangd
clangd is a language server protocol implementation based on clang. It's
supposed to provide editor integration while not suffering from the
confined ABI of libclang.

This implementation is limited to the bare minimum functionality of
doing (whole-document) formatting and rangeFormatting. The JSON parsing
is based on LLVM's YAMLParser but yet most of the code of clangd is
currently dealing with JSON serialization and deserialization.

This was only tested with VS Code so far, mileage with other LSP clients
may vary.

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

llvm-svn: 294291
2017-02-07 10:28:20 +00:00