enum class VisitKind { No, OnlyDecl, OnlyChildren, DeclAndChildren };
void traverseDecl(Decl *D, std::vector<DocumentSymbol> &Results) {
+ // Skip symbols which do not originate from the main file.
+ if (!isInsideMainFile(D->getLocation(), AST.getSourceManager()))
+ return;
+
if (auto *Templ = llvm::dyn_cast<TemplateDecl>(D)) {
// TemplatedDecl might be null, e.g. concepts.
if (auto *TD = Templ->getTemplatedDecl())
}
)cpp";
TU.Code = R"cpp(
+ int i; // declaration to finish preamble
#include "bar.h"
int test() {
}
)cpp";
- EXPECT_THAT(getSymbols(TU.build()), ElementsAre(WithName("test")));
+ EXPECT_THAT(getSymbols(TU.build()),
+ ElementsAre(WithName("i"), WithName("test")));
}
TEST(DocumentSymbols, Template) {