[all-commits] [llvm/llvm-project] d75fb1: [clangd] Support `#pragma mark` in the outline

David Goldman via All-commits all-commits at lists.llvm.org
Thu Sep 23 14:14:30 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: d75fb1ee794e94a011e88739df84c359c987a65b
      https://github.com/llvm/llvm-project/commit/d75fb1ee794e94a011e88739df84c359c987a65b
  Author: David Goldman <davg at google.com>
  Date:   2021-09-23 (Thu, 23 Sep 2021)

  Changed paths:
    M clang-tools-extra/clangd/CollectMacros.cpp
    M clang-tools-extra/clangd/CollectMacros.h
    M clang-tools-extra/clangd/FindSymbols.cpp
    M clang-tools-extra/clangd/ParsedAST.cpp
    M clang-tools-extra/clangd/ParsedAST.h
    M clang-tools-extra/clangd/Preamble.cpp
    M clang-tools-extra/clangd/Preamble.h
    M clang-tools-extra/clangd/SourceCode.cpp
    M clang-tools-extra/clangd/SourceCode.h
    M clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp
    M clang-tools-extra/clangd/unittests/ParsedASTTests.cpp
    M clang/include/clang/Lex/PPCallbacks.h

  Log Message:
  -----------
  [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




More information about the All-commits mailing list