File tree Expand file tree Collapse file tree 31 files changed +65
-44
lines changed Expand file tree Collapse file tree 31 files changed +65
-44
lines changed Original file line number Diff line number Diff line change @@ -39,7 +39,6 @@ add_clang_library(clangDaemon
39
39
Cancellation.cpp
40
40
ClangdLSPServer.cpp
41
41
ClangdServer.cpp
42
- ClangdUnit.cpp
43
42
CodeComplete.cpp
44
43
CodeCompletionStrings.cpp
45
44
Compiler.cpp
@@ -62,6 +61,7 @@ add_clang_library(clangDaemon
62
61
Logger.cpp
63
62
Protocol.cpp
64
63
Quality.cpp
64
+ ParsedAST.cpp
65
65
Preamble.cpp
66
66
RIFF.cpp
67
67
Selection.cpp
Original file line number Diff line number Diff line change 7
7
// ===-------------------------------------------------------------------===//
8
8
9
9
#include " ClangdServer.h"
10
- #include " ClangdUnit.h"
11
10
#include " CodeComplete.h"
12
11
#include " FindSymbols.h"
13
12
#include " Format.h"
14
13
#include " FormattedString.h"
15
14
#include " Headers.h"
15
+ #include " ParsedAST.h"
16
16
#include " Preamble.h"
17
17
#include " Protocol.h"
18
18
#include " SemanticHighlighting.h"
Original file line number Diff line number Diff line change 8
8
#include " FindSymbols.h"
9
9
10
10
#include " AST.h"
11
- #include " ClangdUnit.h"
12
11
#include " FuzzyMatch.h"
13
12
#include " Logger.h"
13
+ #include " ParsedAST.h"
14
14
#include " Quality.h"
15
15
#include " SourceCode.h"
16
16
#include " index/Index.h"
Original file line number Diff line number Diff line change 1
- // ===--- ClangdUnit .cpp ------------------------------------------*- C++-*-===//
1
+ // ===--- ParsedAST .cpp - ------------------------------------------*- C++-*-===//
2
2
//
3
3
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4
4
// See https://llvm.org/LICENSE.txt for license information.
5
5
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6
6
//
7
7
// ===----------------------------------------------------------------------===//
8
8
9
- #include " ClangdUnit .h"
9
+ #include " ParsedAST .h"
10
10
#include " ../clang-tidy/ClangTidyDiagnosticConsumer.h"
11
11
#include " ../clang-tidy/ClangTidyModuleRegistry.h"
12
12
#include " AST.h"
Original file line number Diff line number Diff line change 1
- // ===--- ClangdUnit .h ---------------------------- ----------------*- C++-*-===//
1
+ // ===--- ParsedAST .h - Building translation units ----------------*- C++-*-===//
2
2
//
3
3
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4
4
// See https://llvm.org/LICENSE.txt for license information.
5
5
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6
6
//
7
7
// ===----------------------------------------------------------------------===//
8
+ //
9
+ // This file exposes building a file as if it were open in clangd, and defines
10
+ // the ParsedAST structure that holds the results.
11
+ //
12
+ // This is similar to a clang -fsyntax-only run that produces a clang AST, but
13
+ // we have several customizations:
14
+ // - preamble handling
15
+ // - capturing diagnostics for later access
16
+ // - running clang-tidy checks checks
17
+ //
18
+ //
19
+ // ===----------------------------------------------------------------------===//
8
20
9
- #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_CLANGDUNIT_H
10
- #define LLVM_CLANG_TOOLS_EXTRA_CLANGD_CLANGDUNIT_H
21
+ #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_PARSEDAST_H
22
+ #define LLVM_CLANG_TOOLS_EXTRA_CLANGD_PARSEDAST_H
11
23
12
24
#include " Compiler.h"
13
25
#include " Diagnostics.h"
@@ -136,4 +148,4 @@ void dumpAST(ParsedAST &AST, llvm::raw_ostream &OS);
136
148
} // namespace clangd
137
149
} // namespace clang
138
150
139
- #endif // LLVM_CLANG_TOOLS_EXTRA_CLANGD_CLANGDUNIT_H
151
+ #endif // LLVM_CLANG_TOOLS_EXTRA_CLANGD_PARSEDAST_H
Original file line number Diff line number Diff line change @@ -25,7 +25,7 @@ bool compileCommandsAreEqual(const tooling::CompileCommand &LHS,
25
25
}
26
26
27
27
// This collects macro definitions in the *preamble region* of the main file.
28
- // (Contrast with CollectMainFileMacroExpansions in ClangdUnit .cpp, which
28
+ // (Contrast with CollectMainFileMacroExpansions in ParsedAST .cpp, which
29
29
// collects macro *expansions* in the rest of the main file.
30
30
class CollectMainFileMacros : public PPCallbacks {
31
31
public:
Original file line number Diff line number Diff line change 8
8
9
9
#include " SemanticHighlighting.h"
10
10
#include " Logger.h"
11
+ #include " ParsedAST.h"
11
12
#include " Protocol.h"
12
13
#include " SourceCode.h"
13
14
#include " clang/AST/ASTContext.h"
Original file line number Diff line number Diff line change 17
17
#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_SEMANTICHIGHLIGHTING_H
18
18
#define LLVM_CLANG_TOOLS_EXTRA_CLANGD_SEMANTICHIGHLIGHTING_H
19
19
20
- #include " ClangdUnit.h"
21
20
#include " Protocol.h"
22
21
23
22
namespace clang {
24
23
namespace clangd {
24
+ class ParsedAST ;
25
25
26
26
enum class HighlightingKind {
27
27
Variable = 0 ,
Original file line number Diff line number Diff line change 43
43
44
44
#include " TUScheduler.h"
45
45
#include " Cancellation.h"
46
- #include " ClangdUnit.h"
47
46
#include " Compiler.h"
48
47
#include " Diagnostics.h"
49
48
#include " GlobalCompilationDatabase.h"
50
49
#include " Logger.h"
50
+ #include " ParsedAST.h"
51
51
#include " Preamble.h"
52
52
#include " Trace.h"
53
53
#include " index/CanonicalIncludes.h"
Original file line number Diff line number Diff line change 11
11
#include " FindSymbols.h"
12
12
#include " FormattedString.h"
13
13
#include " Logger.h"
14
+ #include " ParsedAST.h"
14
15
#include " Protocol.h"
15
16
#include " SourceCode.h"
16
17
#include " URI.h"
Original file line number Diff line number Diff line change 13
13
#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_XREFS_H
14
14
#define LLVM_CLANG_TOOLS_EXTRA_CLANGD_XREFS_H
15
15
16
- #include " ClangdUnit.h"
17
16
#include " FormattedString.h"
17
+ #include " Path.h"
18
18
#include " Protocol.h"
19
19
#include " index/Index.h"
20
+ #include " clang/AST/Type.h"
20
21
#include " index/SymbolLocation.h"
22
+ #include " clang/Format/Format.h"
21
23
#include " clang/Index/IndexSymbol.h"
22
24
#include " llvm/ADT/Optional.h"
23
25
#include " llvm/Support/raw_ostream.h"
24
26
#include < vector>
25
27
26
28
namespace clang {
27
29
namespace clangd {
30
+ class ParsedAST ;
28
31
29
32
// Describes where a symbol is declared and defined (as far as clangd knows).
30
33
// There are three cases:
Original file line number Diff line number Diff line change 7
7
// ===----------------------------------------------------------------------===//
8
8
9
9
#include " index/Background.h"
10
- #include " ClangdUnit.h"
11
10
#include " Compiler.h"
12
11
#include " Context.h"
13
12
#include " FSProvider.h"
14
13
#include " Headers.h"
15
14
#include " Logger.h"
15
+ #include " ParsedAST.h"
16
16
#include " Path.h"
17
17
#include " SourceCode.h"
18
18
#include " Symbol.h"
Original file line number Diff line number Diff line change 7
7
// ===----------------------------------------------------------------------===//
8
8
9
9
#include " index/BackgroundRebuild.h"
10
- #include " ClangdUnit.h"
11
10
#include " Compiler.h"
12
11
#include " Headers.h"
13
12
#include " Logger.h"
13
+ #include " ParsedAST.h"
14
14
#include " Path.h"
15
15
#include " SourceCode.h"
16
16
#include " Symbol.h"
Original file line number Diff line number Diff line change 7
7
// ===----------------------------------------------------------------------===//
8
8
9
9
#include " FileIndex.h"
10
- #include " ClangdUnit.h"
11
10
#include " Logger.h"
11
+ #include " ParsedAST.h"
12
12
#include " SymbolCollector.h"
13
13
#include " index/CanonicalIncludes.h"
14
14
#include " index/Index.h"
Original file line number Diff line number Diff line change 8
8
9
9
#include " refactor/Rename.h"
10
10
#include " AST.h"
11
- #include " ClangdUnit.h"
12
11
#include " Logger.h"
12
+ #include " ParsedAST.h"
13
13
#include " SourceCode.h"
14
14
#include " index/SymbolCollector.h"
15
15
#include " clang/Tooling/Refactoring/Rename/RenamingAction.h"
Original file line number Diff line number Diff line change 19
19
#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_REFACTOR_ACTIONS_TWEAK_H
20
20
#define LLVM_CLANG_TOOLS_EXTRA_CLANGD_REFACTOR_ACTIONS_TWEAK_H
21
21
22
- #include " ClangdUnit .h"
22
+ #include " ParsedAST .h"
23
23
#include " Protocol.h"
24
24
#include " Selection.h"
25
25
#include " clang/Tooling/Core/Replacement.h"
Original file line number Diff line number Diff line change 47
47
// ===----------------------------------------------------------------------===//
48
48
49
49
#include " AST.h"
50
- #include " ClangdUnit.h"
51
50
#include " Logger.h"
51
+ #include " ParsedAST.h"
52
52
#include " Selection.h"
53
53
#include " SourceCode.h"
54
54
#include " refactor/Tweak.h"
Original file line number Diff line number Diff line change 5
5
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6
6
//
7
7
// ===----------------------------------------------------------------------===//
8
- #include " ClangdUnit.h"
9
8
#include " Logger.h"
9
+ #include " ParsedAST.h"
10
10
#include " Protocol.h"
11
11
#include " Selection.h"
12
12
#include " SourceCode.h"
Original file line number Diff line number Diff line change 5
5
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6
6
//
7
7
// ===----------------------------------------------------------------------===//
8
- #include " ClangdUnit.h"
9
8
#include " Logger.h"
9
+ #include " ParsedAST.h"
10
10
#include " SourceCode.h"
11
11
#include " refactor/Tweak.h"
12
12
#include " clang/AST/ASTContext.h"
Original file line number Diff line number Diff line change 5
5
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6
6
//
7
7
// ===----------------------------------------------------------------------===//
8
- #include " ClangdUnit.h"
9
8
#include " Logger.h"
9
+ #include " ParsedAST.h"
10
10
#include " SourceCode.h"
11
11
#include " refactor/Tweak.h"
12
12
#include " clang/AST/ASTContext.h"
Original file line number Diff line number Diff line change @@ -28,7 +28,6 @@ add_unittest(ClangdUnitTests ClangdTests
28
28
CancellationTests.cpp
29
29
CanonicalIncludesTests.cpp
30
30
ClangdTests.cpp
31
- ClangdUnitTests.cpp
32
31
CodeCompleteTests.cpp
33
32
CodeCompletionStringsTests.cpp
34
33
ContextTests.cpp
@@ -50,6 +49,7 @@ add_unittest(ClangdUnitTests ClangdTests
50
49
IndexActionTests.cpp
51
50
IndexTests.cpp
52
51
JSONTransportTests.cpp
52
+ ParsedASTTests.cpp
53
53
PrintASTTests.cpp
54
54
QualityTests.cpp
55
55
RenameTests.cpp
Original file line number Diff line number Diff line change 7
7
// ===----------------------------------------------------------------------===//
8
8
9
9
#include " Annotations.h"
10
- #include " ClangdUnit.h"
11
10
#include " Diagnostics.h"
11
+ #include " ParsedAST.h"
12
12
#include " Path.h"
13
13
#include " Protocol.h"
14
14
#include " SourceCode.h"
Original file line number Diff line number Diff line change 6
6
//
7
7
// ===----------------------------------------------------------------------===//
8
8
9
- #include " ClangdUnit.h"
10
9
#include " ExpectedTypes.h"
10
+ #include " ParsedAST.h"
11
11
#include " TestTU.h"
12
12
#include " clang/AST/ASTContext.h"
13
13
#include " clang/AST/Decl.h"
Original file line number Diff line number Diff line change 8
8
9
9
#include " AST.h"
10
10
#include " Annotations.h"
11
- #include " ClangdUnit.h"
12
11
#include " Compiler.h"
12
+ #include " ParsedAST.h"
13
13
#include " SyncAPI.h"
14
14
#include " TestFS.h"
15
15
#include " TestTU.h"
You can’t perform that action at this time.
0 commit comments