[clangd] Support `#pragma mark` in the outline
authorDavid Goldman <davg@google.com>
Mon, 12 Jul 2021 16:29:48 +0000 (12:29 -0400)
committerDavid Goldman <davg@google.com>
Thu, 23 Sep 2021 21:13:30 +0000 (17:13 -0400)
commitd75fb1ee794e94a011e88739df84c359c987a65b
treec4c2b3200d034d4c3c9171d8f2236d38724cf60a
parent5fcde57b73fbc068c51f55a80894a6ef208d4afd
[clangd] Support `#pragma mark` in the outline

Xcode uses `#pragma mark -` to draw a divider in the outline view
and `#pragma mark Note` to add `Note` in the outline view. For more
information, see https://nshipster.com/pragma/.

Since the LSP spec doesn't contain dividers for the symbol outline,
instead we treat `#pragma mark -` as a group with children - the
decls that come after it, implicitly terminating when the symbol's
parent ends.

The following code:

```
@implementation MyClass

- (id)init {}

- (int)foo;
@end
```

Would give an outline like

```
MyClass
        > Overrides
                    > init
        > Public Accessors
                    > foo
```

Differential Revision: https://reviews.llvm.org/D105904
12 files changed:
clang-tools-extra/clangd/CollectMacros.cpp
clang-tools-extra/clangd/CollectMacros.h
clang-tools-extra/clangd/FindSymbols.cpp
clang-tools-extra/clangd/ParsedAST.cpp
clang-tools-extra/clangd/ParsedAST.h
clang-tools-extra/clangd/Preamble.cpp
clang-tools-extra/clangd/Preamble.h
clang-tools-extra/clangd/SourceCode.cpp
clang-tools-extra/clangd/SourceCode.h
clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp
clang-tools-extra/clangd/unittests/ParsedASTTests.cpp
clang/include/clang/Lex/PPCallbacks.h