// FIXME: skip tokens inside macros for now.
return;
+ // Non top level decls that are included from a header are not filtered by
+ // topLevelDecls. (example: method declarations being included from another
+ // file for a class from another file)
+ if (!isInsideMainFile(Loc, SM))
+ return;
+
auto R = getTokenRange(SM, Ctx.getLangOpts(), Loc);
if (!R) {
// R should always have a value, if it doesn't something is very wrong.
return ExpectedTokens;
}
-void checkHighlightings(llvm::StringRef Code) {
+void checkHighlightings(llvm::StringRef Code,
+ std::vector<std::pair</*FileName*/ llvm::StringRef,
+ /*FileContent*/ llvm::StringRef>>
+ AdditionalFiles = {}) {
Annotations Test(Code);
- auto AST = TestTU::withCode(Test.code()).build();
+ auto TU = TestTU::withCode(Test.code());
+ for (auto File : AdditionalFiles)
+ TU.AdditionalFiles.insert({File.first, File.second});
+ auto AST = TU.build();
std::vector<HighlightingToken> ActualTokens = getSemanticHighlightings(AST);
EXPECT_THAT(ActualTokens, getExpectedTokens(Test)) << Code;
}
for (const auto &TestCase : TestCases) {
checkHighlightings(TestCase);
}
+
+ checkHighlightings(R"cpp(
+ class $Class[[A]] {
+ #include "imp.h"
+ };
+ #endif
+ )cpp",
+ {{"imp.h", R"cpp(
+ int someMethod();
+ void otherMethod();
+ )cpp"}});
}
TEST(SemanticHighlighting, GeneratesHighlightsWhenFileChange) {