jvikstrom updated this revision to Diff 209514. jvikstrom marked 2 inline comments as done. jvikstrom added a comment.
Address comments. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D64624/new/ https://reviews.llvm.org/D64624 Files: clang-tools-extra/clangd/SemanticHighlighting.cpp clang-tools-extra/clangd/SemanticHighlighting.h clang-tools-extra/clangd/test/semantic-highlighting.test 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 @@ -37,7 +37,8 @@ {HighlightingKind::Function, "Function"}, {HighlightingKind::Class, "Class"}, {HighlightingKind::Enum, "Enum"}, - {HighlightingKind::Namespace, "Namespace"}}; + {HighlightingKind::Namespace, "Namespace"}, + {HighlightingKind::EnumConstant, "EnumConstant"}}; std::vector<HighlightingToken> ExpectedTokens; for (const auto &KindString : KindToString) { std::vector<HighlightingToken> Toks = makeHighlightingTokens( @@ -103,12 +104,19 @@ } )cpp", R"cpp( - enum class $Enum[[E]] {}; - enum $Enum[[EE]] {}; + enum class $Enum[[E]] { + $EnumConstant[[A]], + $EnumConstant[[B]], + }; + enum $Enum[[EE]] { + $EnumConstant[[Hi]], + }; struct $Class[[A]] { $Enum[[E]] EEE; $Enum[[EE]] EEEE; }; + int $Variable[[I]] = $EnumConstant[[Hi]]; + $Enum[[E]] $Variable[[L]] = $Enum[[E]]::$EnumConstant[[B]]; )cpp", R"cpp( namespace $Namespace[[abc]] { @@ -118,7 +126,7 @@ namespace $Namespace[[cde]] { struct $Class[[A]] { enum class $Enum[[B]] { - Hi, + $EnumConstant[[Hi]], }; }; } @@ -129,7 +137,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]]::Hi; + $Namespace[[vwz]]::$Class[[A]]::$Enum[[B]]::$EnumConstant[[Hi]]; ::$Namespace[[vwz]]::$Class[[A]] $Variable[[B]]; ::$Namespace[[abc]]::$Namespace[[bcd]]::$Class[[A]] $Variable[[BB]]; )cpp"}; Index: clang-tools-extra/clangd/test/semantic-highlighting.test =================================================================== --- clang-tools-extra/clangd/test/semantic-highlighting.test +++ clang-tools-extra/clangd/test/semantic-highlighting.test @@ -17,6 +17,9 @@ # CHECK-NEXT: "entity.name.type.enum.cpp" # CHECK-NEXT: ], # CHECK-NEXT: [ +# CHECK-NEXT: "constant.other.enum.cpp" +# CHECK-NEXT: ], +# CHECK-NEXT: [ # CHECK-NEXT: "entity.name.namespace.cpp" # CHECK-NEXT: ] # CHECK-NEXT: ] Index: clang-tools-extra/clangd/SemanticHighlighting.h =================================================================== --- clang-tools-extra/clangd/SemanticHighlighting.h +++ clang-tools-extra/clangd/SemanticHighlighting.h @@ -28,6 +28,7 @@ Function, Class, Enum, + EnumConstant, Namespace, NumKinds, Index: clang-tools-extra/clangd/SemanticHighlighting.cpp =================================================================== --- clang-tools-extra/clangd/SemanticHighlighting.cpp +++ clang-tools-extra/clangd/SemanticHighlighting.cpp @@ -119,6 +119,10 @@ addToken(Loc, HighlightingKind::Enum); return; } + if (isa<EnumConstantDecl>(D)) { + addToken(Loc, HighlightingKind::EnumConstant); + return; + } if (isa<VarDecl>(D)) { addToken(Loc, HighlightingKind::Variable); return; @@ -249,6 +253,8 @@ return "entity.name.type.class.cpp"; case HighlightingKind::Enum: return "entity.name.type.enum.cpp"; + case HighlightingKind::EnumConstant: + return "constant.other.enum.cpp"; case HighlightingKind::Namespace: return "entity.name.namespace.cpp"; case HighlightingKind::NumKinds:
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits