summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/clangd/SemanticHighlighting.cpp
diff options
context:
space:
mode:
authorJohan Vikstrom <jvikstrom@google.com>2019-08-19 07:51:39 +0000
committerJohan Vikstrom <jvikstrom@google.com>2019-08-19 07:51:39 +0000
commit17587b36d1928c3399d4d9af6daa052c0cdd6327 (patch)
tree2b196b25d654af654b834477b958448d77d5cf8a /clang-tools-extra/clangd/SemanticHighlighting.cpp
parent21599876be328ff6b5c6cf09544ade7e337cb48d (diff)
downloadbcm5719-llvm-17587b36d1928c3399d4d9af6daa052c0cdd6327.tar.gz
bcm5719-llvm-17587b36d1928c3399d4d9af6daa052c0cdd6327.zip
[clangd] Added special HighlightingKind for function parameters.
Summary: This means that function parameters are no longer highlighted as variable.other.cpp but instead as variable.parameter.cpp which is the more "correct" TextMate scope for them. Reviewers: hokein, ilya-biryukov Subscribers: MaskRay, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D66335 llvm-svn: 369238
Diffstat (limited to 'clang-tools-extra/clangd/SemanticHighlighting.cpp')
-rw-r--r--clang-tools-extra/clangd/SemanticHighlighting.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/clang-tools-extra/clangd/SemanticHighlighting.cpp b/clang-tools-extra/clangd/SemanticHighlighting.cpp
index babab5e66ce..f51e868e7a0 100644
--- a/clang-tools-extra/clangd/SemanticHighlighting.cpp
+++ b/clang-tools-extra/clangd/SemanticHighlighting.cpp
@@ -11,6 +11,7 @@
#include "Protocol.h"
#include "SourceCode.h"
#include "clang/AST/ASTContext.h"
+#include "clang/AST/Decl.h"
#include "clang/AST/DeclCXX.h"
#include "clang/AST/RecursiveASTVisitor.h"
#include <algorithm>
@@ -200,6 +201,10 @@ private:
addToken(Loc, HighlightingKind::EnumConstant);
return;
}
+ if (isa<ParmVarDecl>(D)) {
+ addToken(Loc, HighlightingKind::Parameter);
+ return;
+ }
if (isa<VarDecl>(D)) {
addToken(Loc, HighlightingKind::Variable);
return;
@@ -406,6 +411,8 @@ llvm::StringRef toTextMateScope(HighlightingKind Kind) {
return "entity.name.function.method.cpp";
case HighlightingKind::Variable:
return "variable.other.cpp";
+ case HighlightingKind::Parameter:
+ return "variable.parameter.cpp";
case HighlightingKind::Field:
return "variable.other.field.cpp";
case HighlightingKind::Class:
OpenPOWER on IntegriCloud