[PATCH] D63559: [clangd] Added functionality for getting semantic highlights for variable and function declarations

Haojian Wu via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Jun 25 01:36:41 PDT 2019


hokein added inline comments.


================
Comment at: clang-tools-extra/clangd/SemanticHighlight.cpp:43
+
+  unsigned int Len =
+      clang::Lexer::MeasureTokenLength(D->getLocation(), SM, Ctx.getLangOpts());
----------------
we can reuse the getTokenRange() function (in SourceCode.h), you need to sync your branch to master.


================
Comment at: clang-tools-extra/clangd/SemanticHighlight.cpp:46
+
+  if (D->getLocation().isMacroID()) {
+    // FIXME; This is inside a macro. For now skip the token
----------------
I'd move this line at the beginning of the method.


================
Comment at: clang-tools-extra/clangd/unittests/SemanticHighlightTests.cpp:57
+
+  checkTokensExists(Tokens, Variables, SemanticHighlightKind::Variable);
+  checkTokensExists(Tokens, Function, SemanticHighlightKind::Function);
----------------

```
checkHighlights(R"cpp(void $Function[[Foo]]))cpp");

checkHighlights(...) {
   ...
   ExpectedTokens = annotation.ranges(toString(SemanticHighlightKind::Variable));
   ExpectedTokens = annotation.ranges(toString(SemanticHighlightKind::Function));
   EXPECT_THAT(ExpectedTokens, UnorderedElementsAreArray(ActualTokens));
}


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D63559/new/

https://reviews.llvm.org/D63559





More information about the cfe-commits mailing list