njames93 created this revision.
njames93 added reviewers: sammccall, hokein.
Herald added subscribers: usaxena95, kadircet, arphaman.
njames93 requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay, ilya-biryukov.
Herald added a project: clang.

We should be using enumMember as thats defined in LSP, enumConstant is non 
standard so clients aren't likely to support it
Fixes https://github.com/clangd/clangd/issues/622n


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D93113

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

Index: clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
===================================================================
--- clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
+++ clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
@@ -51,7 +51,7 @@
       {HighlightingKind::Class, "Class"},
       {HighlightingKind::Enum, "Enum"},
       {HighlightingKind::Namespace, "Namespace"},
-      {HighlightingKind::EnumConstant, "EnumConstant"},
+      {HighlightingKind::EnumMember, "EnumMember"},
       {HighlightingKind::Field, "Field"},
       {HighlightingKind::StaticField, "StaticField"},
       {HighlightingKind::Method, "Method"},
@@ -212,18 +212,18 @@
     )cpp",
       R"cpp(
       enum class $Enum[[E]] {
-        $EnumConstant[[A]],
-        $EnumConstant[[B]],
+        $EnumMember[[A]],
+        $EnumMember[[B]],
       };
       enum $Enum[[EE]] {
-        $EnumConstant[[Hi]],
+        $EnumMember[[Hi]],
       };
       struct $Class[[A]] {
         $Enum[[E]] $Field[[EEE]];
         $Enum[[EE]] $Field[[EEEE]];
       };
-      int $Variable[[I]] = $EnumConstant[[Hi]];
-      $Enum[[E]] $Variable[[L]] = $Enum[[E]]::$EnumConstant[[B]];
+      int $Variable[[I]] = $EnumMember[[Hi]];
+      $Enum[[E]] $Variable[[L]] = $Enum[[E]]::$EnumMember[[B]];
     )cpp",
       R"cpp(
       namespace $Namespace[[abc]] {
@@ -233,7 +233,7 @@
           namespace $Namespace[[cde]] {
             struct $Class[[A]] {
               enum class $Enum[[B]] {
-                $EnumConstant[[Hi]],
+                $EnumMember[[Hi]],
               };
             };
           }
@@ -244,7 +244,7 @@
             $Namespace[[abc]]::$Namespace[[bcd]]::$Namespace[[cde]];
       $Namespace[[abc]]::$Namespace[[bcd]]::$Class[[A]] $Variable[[AA]];
       $Namespace[[vwz]]::$Class[[A]]::$Enum[[B]] $Variable[[AAA]] =
-            $Namespace[[vwz]]::$Class[[A]]::$Enum[[B]]::$EnumConstant[[Hi]];
+            $Namespace[[vwz]]::$Class[[A]]::$Enum[[B]]::$EnumMember[[Hi]];
       ::$Namespace[[vwz]]::$Class[[A]] $Variable[[B]];
       ::$Namespace[[abc]]::$Namespace[[bcd]]::$Class[[A]] $Variable[[BB]];
     )cpp",
@@ -357,7 +357,7 @@
     )cpp",
       R"cpp(
       enum $Enum[[En]] {
-        $EnumConstant[[EC]],
+        $EnumMember[[EC]],
       };
       class $Class[[Foo]] {};
       class $Class[[Bar]] {
@@ -371,15 +371,15 @@
           $Field[[I]] (123) {}
       };
       class $Class[[Bar2]] : public $Class[[Bar]] {
-        $Class[[Bar2]]() : $Class[[Bar]]($Class[[Foo]](), $EnumConstant[[EC]]) {}
+        $Class[[Bar2]]() : $Class[[Bar]]($Class[[Foo]](), $EnumMember[[EC]]) {}
       };
     )cpp",
       R"cpp(
       enum $Enum[[E]] {
-        $EnumConstant[[E]],
+        $EnumMember[[E]],
       };
       class $Class[[Foo]] {};
-      $Enum[[auto]] $Variable[[AE]] = $Enum[[E]]::$EnumConstant[[E]];
+      $Enum[[auto]] $Variable[[AE]] = $Enum[[E]]::$EnumMember[[E]];
       $Class[[auto]] $Variable[[AF]] = $Class[[Foo]]();
       $Class[[decltype]](auto) $Variable[[AF2]] = $Class[[Foo]]();
       $Class[[auto]] *$Variable[[AFP]] = &$Variable[[AF]];
Index: clang-tools-extra/clangd/SemanticHighlighting.h
===================================================================
--- clang-tools-extra/clangd/SemanticHighlighting.h
+++ clang-tools-extra/clangd/SemanticHighlighting.h
@@ -48,7 +48,7 @@
   StaticField,
   Class,
   Enum,
-  EnumConstant,
+  EnumMember,
   Typedef,
   DependentType,
   DependentName,
Index: clang-tools-extra/clangd/SemanticHighlighting.cpp
===================================================================
--- clang-tools-extra/clangd/SemanticHighlighting.cpp
+++ clang-tools-extra/clangd/SemanticHighlighting.cpp
@@ -82,7 +82,7 @@
   if (isa<EnumDecl>(D))
     return HighlightingKind::Enum;
   if (isa<EnumConstantDecl>(D))
-    return HighlightingKind::EnumConstant;
+    return HighlightingKind::EnumMember;
   if (isa<ParmVarDecl>(D))
     return HighlightingKind::Parameter;
   if (auto *VD = dyn_cast<VarDecl>(D))
@@ -427,8 +427,8 @@
     return OS << "Class";
   case HighlightingKind::Enum:
     return OS << "Enum";
-  case HighlightingKind::EnumConstant:
-    return OS << "EnumConstant";
+  case HighlightingKind::EnumMember:
+    return OS << "EnumMember";
   case HighlightingKind::Typedef:
     return OS << "Typedef";
   case HighlightingKind::DependentType:
@@ -570,8 +570,8 @@
     return "class";
   case HighlightingKind::Enum:
     return "enum";
-  case HighlightingKind::EnumConstant:
-    return "enumConstant"; // nonstandard
+  case HighlightingKind::EnumMember:
+    return "enumMember";
   case HighlightingKind::Typedef:
     return "type";
   case HighlightingKind::DependentType:
@@ -647,7 +647,7 @@
     return "entity.name.type.class.cpp";
   case HighlightingKind::Enum:
     return "entity.name.type.enum.cpp";
-  case HighlightingKind::EnumConstant:
+  case HighlightingKind::EnumMember:
     return "variable.other.enummember.cpp";
   case HighlightingKind::Typedef:
     return "entity.name.type.typedef.cpp";
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to