[PATCH] D66001: [clangd] Added highlighting for constructor initializers.

Johan Vikström via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Aug 9 05:18:46 PDT 2019


This revision was automatically updated to reflect the committed changes.
Closed by commit rL368434: [clangd] Added highlighting for constructor initializers. (authored by jvikstrom, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D66001?vs=214346&id=214362#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D66001

Files:
  clang-tools-extra/trunk/clangd/SemanticHighlighting.cpp
  clang-tools-extra/trunk/clangd/unittests/SemanticHighlightingTests.cpp


Index: clang-tools-extra/trunk/clangd/unittests/SemanticHighlightingTests.cpp
===================================================================
--- clang-tools-extra/trunk/clangd/unittests/SemanticHighlightingTests.cpp
+++ clang-tools-extra/trunk/clangd/unittests/SemanticHighlightingTests.cpp
@@ -285,6 +285,24 @@
       };
 
       $Class[[A]] &$Class[[A]]::operator=($Class[[A]] &&$Variable[[O]]) = default;
+    )cpp",
+    R"cpp(
+      enum $Enum[[En]] {
+        $EnumConstant[[EC]],
+      };
+      class $Class[[Foo]] {};
+      class $Class[[Bar]] {
+        $Class[[Foo]] $Field[[Fo]];
+        $Enum[[En]] $Field[[E]];
+        $Primitive[[int]] $Field[[I]];
+        $Class[[Bar]] ($Class[[Foo]] $Variable[[F]],
+                $Enum[[En]] $Variable[[E]])
+        : $Field[[Fo]] ($Variable[[F]]), $Field[[E]] ($Variable[[E]]),
+          $Field[[I]] (123) {}
+      };
+      class $Class[[Bar2]] : public $Class[[Bar]] {
+        $Class[[Bar2]]() : $Class[[Bar]]($Class[[Foo]](), $EnumConstant[[EC]]) {}
+      };
     )cpp"};
   for (const auto &TestCase : TestCases) {
     checkHighlightings(TestCase);
Index: clang-tools-extra/trunk/clangd/SemanticHighlighting.cpp
===================================================================
--- clang-tools-extra/trunk/clangd/SemanticHighlighting.cpp
+++ clang-tools-extra/trunk/clangd/SemanticHighlighting.cpp
@@ -11,6 +11,7 @@
 #include "Protocol.h"
 #include "SourceCode.h"
 #include "clang/AST/ASTContext.h"
+#include "clang/AST/DeclCXX.h"
 #include "clang/AST/RecursiveASTVisitor.h"
 #include <algorithm>
 
@@ -136,6 +137,13 @@
         HighlightingTokenCollector>::TraverseNestedNameSpecifierLoc(NNSLoc);
   }
 
+  bool TraverseConstructorInitializer(CXXCtorInitializer *CI) {
+    if (const FieldDecl *FD = CI->getMember())
+      addToken(CI->getSourceLocation(), FD);
+    return RecursiveASTVisitor<
+        HighlightingTokenCollector>::TraverseConstructorInitializer(CI);
+  }
+
 private:
   void addTypeLoc(SourceLocation Loc, const TypeLoc &TL) {
     if (const Type *TP = TL.getTypePtr()) {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D66001.214362.patch
Type: text/x-patch
Size: 2071 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190809/65f96d80/attachment.bin>


More information about the cfe-commits mailing list