mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2025-01-20 15:14:45 +00:00
[clangd] Do not highlight keywords in semantic highlighting
Summary: Editors are good at highlightings the keywords themselves. Note that this only affects highlightings of builtin types spelled out as keywords in the source code. Highlightings of typedefs to builtin types are unchanged. Reviewers: hokein Reviewed By: hokein Subscribers: merge_guards_bot, MaskRay, jkorous, arphaman, kadircet, usaxena95, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D69431
This commit is contained in:
parent
5d35b7d9e1
commit
c814f4c459
@ -49,7 +49,7 @@ llvm::Optional<HighlightingKind> kindForDecl(const NamedDecl *D) {
|
||||
return HighlightingKind::Typedef;
|
||||
}
|
||||
// We highlight class decls, constructor decls and destructor decls as
|
||||
// `Class` type. The destructor decls are handled in `VisitTypeLoc` (we
|
||||
// `Class` type. The destructor decls are handled in `VisitTagTypeLoc` (we
|
||||
// will visit a TypeLoc where the underlying Type is a CXXRecordDecl).
|
||||
if (auto *RD = llvm::dyn_cast<RecordDecl>(D)) {
|
||||
// We don't want to highlight lambdas like classes.
|
||||
@ -214,25 +214,27 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
bool WalkUpFromTagTypeLoc(TagTypeLoc L) {
|
||||
bool VisitTagTypeLoc(TagTypeLoc L) {
|
||||
if (L.isDefinition())
|
||||
return true; // Definition will be highligthed by VisitNamedDecl.
|
||||
return RecursiveASTVisitor::WalkUpFromTagTypeLoc(L);
|
||||
}
|
||||
|
||||
bool WalkUpFromElaboratedTypeLoc(ElaboratedTypeLoc L) {
|
||||
// Avoid highlighting 'struct' or 'enum' keywords.
|
||||
if (auto K = kindForType(L.getTypePtr()))
|
||||
addToken(L.getBeginLoc(), *K);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool WalkUpFromDependentNameTypeLoc(DependentNameTypeLoc L) {
|
||||
bool VisitDecltypeTypeLoc(DecltypeTypeLoc L) {
|
||||
if (auto K = kindForType(L.getTypePtr()))
|
||||
addToken(L.getBeginLoc(), *K);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool VisitDependentNameTypeLoc(DependentNameTypeLoc L) {
|
||||
addToken(L.getNameLoc(), HighlightingKind::DependentType);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool VisitTypeLoc(TypeLoc TL) {
|
||||
if (auto K = kindForType(TL.getTypePtr()))
|
||||
addToken(TL.getBeginLoc(), *K);
|
||||
bool VisitTemplateTypeParmTypeLoc(TemplateTypeParmTypeLoc TL) {
|
||||
addToken(TL.getBeginLoc(), HighlightingKind::TemplateParameter);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -67,7 +67,7 @@
|
||||
# CHECK-NEXT: "lines": [
|
||||
# CHECK-NEXT: {
|
||||
# CHECK-NEXT: "line": 0,
|
||||
# CHECK-NEXT: "tokens": "AAAAAAADABAAAAAEAAEAAA=="
|
||||
# CHECK-NEXT: "tokens": "AAAABAABAAA="
|
||||
# CHECK-NEXT: }
|
||||
# CHECK-NEXT: ],
|
||||
# CHECK-NEXT: "textDocument": {
|
||||
@ -82,11 +82,11 @@
|
||||
# CHECK-NEXT: "lines": [
|
||||
# CHECK-NEXT: {
|
||||
# CHECK-NEXT: "line": 0,
|
||||
# CHECK-NEXT: "tokens": "AAAAAAADABAAAAAEAAEAAA=="
|
||||
# CHECK-NEXT: "tokens": "AAAABAABAAA="
|
||||
# CHECK-NEXT: }
|
||||
# CHECK-NEXT: {
|
||||
# CHECK-NEXT: "line": 1,
|
||||
# CHECK-NEXT: "tokens": "AAAAAAADABAAAAAEAAEAAA=="
|
||||
# CHECK-NEXT: "tokens": "AAAABAABAAA="
|
||||
# CHECK-NEXT: }
|
||||
# CHECK-NEXT: ],
|
||||
# CHECK-NEXT: "textDocument": {
|
||||
@ -101,7 +101,7 @@
|
||||
# CHECK-NEXT: "lines": [
|
||||
# CHECK-NEXT: {
|
||||
# CHECK-NEXT: "line": 1,
|
||||
# CHECK-NEXT: "tokens": "AAAAAAADABAAAAAEAAEAAA=="
|
||||
# CHECK-NEXT: "tokens": "AAAABAABAAA="
|
||||
# CHECK-NEXT: }
|
||||
# CHECK-NEXT: ],
|
||||
# CHECK-NEXT: "textDocument": {
|
||||
|
@ -153,26 +153,26 @@ TEST(SemanticHighlighting, GetsCorrectTokens) {
|
||||
const char *TestCases[] = {
|
||||
R"cpp(
|
||||
struct $Class[[AS]] {
|
||||
$Primitive[[double]] $Field[[SomeMember]];
|
||||
double $Field[[SomeMember]];
|
||||
};
|
||||
struct {
|
||||
} $Variable[[S]];
|
||||
$Primitive[[void]] $Function[[foo]]($Primitive[[int]] $Parameter[[A]], $Class[[AS]] $Parameter[[As]]) {
|
||||
void $Function[[foo]](int $Parameter[[A]], $Class[[AS]] $Parameter[[As]]) {
|
||||
$Primitive[[auto]] $LocalVariable[[VeryLongVariableName]] = 12312;
|
||||
$Class[[AS]] $LocalVariable[[AA]];
|
||||
$Primitive[[auto]] $LocalVariable[[L]] = $LocalVariable[[AA]].$Field[[SomeMember]] + $Parameter[[A]];
|
||||
auto $LocalVariable[[FN]] = [ $LocalVariable[[AA]]]($Primitive[[int]] $Parameter[[A]]) -> $Primitive[[void]] {};
|
||||
auto $LocalVariable[[FN]] = [ $LocalVariable[[AA]]](int $Parameter[[A]]) -> void {};
|
||||
$LocalVariable[[FN]](12312);
|
||||
}
|
||||
)cpp",
|
||||
R"cpp(
|
||||
$Primitive[[void]] $Function[[foo]]($Primitive[[int]]);
|
||||
$Primitive[[void]] $Function[[Gah]]();
|
||||
$Primitive[[void]] $Function[[foo]]() {
|
||||
void $Function[[foo]](int);
|
||||
void $Function[[Gah]]();
|
||||
void $Function[[foo]]() {
|
||||
auto $LocalVariable[[Bou]] = $Function[[Gah]];
|
||||
}
|
||||
struct $Class[[A]] {
|
||||
$Primitive[[void]] $Method[[abc]]();
|
||||
void $Method[[abc]]();
|
||||
};
|
||||
)cpp",
|
||||
R"cpp(
|
||||
@ -186,17 +186,17 @@ TEST(SemanticHighlighting, GetsCorrectTokens) {
|
||||
struct $Class[[C]] : $Namespace[[abc]]::$Class[[A]]<$TemplateParameter[[T]]> {
|
||||
typename $TemplateParameter[[T]]::$DependentType[[A]]* $Field[[D]];
|
||||
};
|
||||
$Namespace[[abc]]::$Class[[A]]<$Primitive[[int]]> $Variable[[AA]];
|
||||
typedef $Namespace[[abc]]::$Class[[A]]<$Primitive[[int]]> $Class[[AAA]];
|
||||
$Namespace[[abc]]::$Class[[A]]<int> $Variable[[AA]];
|
||||
typedef $Namespace[[abc]]::$Class[[A]]<int> $Class[[AAA]];
|
||||
struct $Class[[B]] {
|
||||
$Class[[B]]();
|
||||
~$Class[[B]]();
|
||||
$Primitive[[void]] operator<<($Class[[B]]);
|
||||
void operator<<($Class[[B]]);
|
||||
$Class[[AAA]] $Field[[AA]];
|
||||
};
|
||||
$Class[[B]]::$Class[[B]]() {}
|
||||
$Class[[B]]::~$Class[[B]]() {}
|
||||
$Primitive[[void]] $Function[[f]] () {
|
||||
void $Function[[f]] () {
|
||||
$Class[[B]] $LocalVariable[[BB]] = $Class[[B]]();
|
||||
$LocalVariable[[BB]].~$Class[[B]]();
|
||||
$Class[[B]]();
|
||||
@ -214,7 +214,7 @@ TEST(SemanticHighlighting, GetsCorrectTokens) {
|
||||
$Enum[[E]] $Field[[EEE]];
|
||||
$Enum[[EE]] $Field[[EEEE]];
|
||||
};
|
||||
$Primitive[[int]] $Variable[[I]] = $EnumConstant[[Hi]];
|
||||
int $Variable[[I]] = $EnumConstant[[Hi]];
|
||||
$Enum[[E]] $Variable[[L]] = $Enum[[E]]::$EnumConstant[[B]];
|
||||
)cpp",
|
||||
R"cpp(
|
||||
@ -242,14 +242,14 @@ TEST(SemanticHighlighting, GetsCorrectTokens) {
|
||||
)cpp",
|
||||
R"cpp(
|
||||
struct $Class[[D]] {
|
||||
$Primitive[[double]] $Field[[C]];
|
||||
double $Field[[C]];
|
||||
};
|
||||
struct $Class[[A]] {
|
||||
$Primitive[[double]] $Field[[B]];
|
||||
double $Field[[B]];
|
||||
$Class[[D]] $Field[[E]];
|
||||
static $Primitive[[double]] $StaticField[[S]];
|
||||
static $Primitive[[void]] $StaticMethod[[bar]]() {}
|
||||
$Primitive[[void]] $Method[[foo]]() {
|
||||
static double $StaticField[[S]];
|
||||
static void $StaticMethod[[bar]]() {}
|
||||
void $Method[[foo]]() {
|
||||
$Field[[B]] = 123;
|
||||
this->$Field[[B]] = 156;
|
||||
this->$Method[[foo]]();
|
||||
@ -258,7 +258,7 @@ TEST(SemanticHighlighting, GetsCorrectTokens) {
|
||||
$StaticField[[S]] = 90.1;
|
||||
}
|
||||
};
|
||||
$Primitive[[void]] $Function[[foo]]() {
|
||||
void $Function[[foo]]() {
|
||||
$Class[[A]] $LocalVariable[[AA]];
|
||||
$LocalVariable[[AA]].$Field[[B]] += 2;
|
||||
$LocalVariable[[AA]].$Method[[foo]]();
|
||||
@ -268,15 +268,15 @@ TEST(SemanticHighlighting, GetsCorrectTokens) {
|
||||
)cpp",
|
||||
R"cpp(
|
||||
struct $Class[[AA]] {
|
||||
$Primitive[[int]] $Field[[A]];
|
||||
int $Field[[A]];
|
||||
}
|
||||
$Primitive[[int]] $Variable[[B]];
|
||||
int $Variable[[B]];
|
||||
$Class[[AA]] $Variable[[A]]{$Variable[[B]]};
|
||||
)cpp",
|
||||
R"cpp(
|
||||
namespace $Namespace[[a]] {
|
||||
struct $Class[[A]] {};
|
||||
typedef $Primitive[[char]] $Primitive[[C]];
|
||||
typedef char $Primitive[[C]];
|
||||
}
|
||||
typedef $Namespace[[a]]::$Class[[A]] $Class[[B]];
|
||||
using $Class[[BB]] = $Namespace[[a]]::$Class[[A]];
|
||||
@ -287,10 +287,10 @@ TEST(SemanticHighlighting, GetsCorrectTokens) {
|
||||
$Enum[[CC]] $Function[[f]]($Class[[B]]);
|
||||
$Enum[[CD]] $Function[[f]]($Class[[BB]]);
|
||||
typedef $Namespace[[a]]::$Primitive[[C]] $Primitive[[PC]];
|
||||
typedef $Primitive[[float]] $Primitive[[F]];
|
||||
typedef float $Primitive[[F]];
|
||||
)cpp",
|
||||
R"cpp(
|
||||
template<typename $TemplateParameter[[T]], typename = $Primitive[[void]]>
|
||||
template<typename $TemplateParameter[[T]], typename = void>
|
||||
class $Class[[A]] {
|
||||
$TemplateParameter[[T]] $Field[[AA]];
|
||||
$TemplateParameter[[T]] $Method[[foo]]();
|
||||
@ -302,7 +302,7 @@ TEST(SemanticHighlighting, GetsCorrectTokens) {
|
||||
template<class $TemplateParameter[[TT]], class $TemplateParameter[[GG]]>
|
||||
class $Class[[BB]] {};
|
||||
template<class $TemplateParameter[[T]]>
|
||||
class $Class[[BB]]<$TemplateParameter[[T]], $Primitive[[int]]> {};
|
||||
class $Class[[BB]]<$TemplateParameter[[T]], int> {};
|
||||
template<class $TemplateParameter[[T]]>
|
||||
class $Class[[BB]]<$TemplateParameter[[T]], $TemplateParameter[[T]]*> {};
|
||||
|
||||
@ -313,13 +313,13 @@ TEST(SemanticHighlighting, GetsCorrectTokens) {
|
||||
class $Class[[Foo]] {};
|
||||
|
||||
template<typename $TemplateParameter[[T]]>
|
||||
$Primitive[[void]] $Function[[foo]]($TemplateParameter[[T]] ...);
|
||||
void $Function[[foo]]($TemplateParameter[[T]] ...);
|
||||
)cpp",
|
||||
R"cpp(
|
||||
template <class $TemplateParameter[[T]]>
|
||||
struct $Class[[Tmpl]] {$TemplateParameter[[T]] $Field[[x]] = 0;};
|
||||
extern template struct $Class[[Tmpl]]<$Primitive[[float]]>;
|
||||
template struct $Class[[Tmpl]]<$Primitive[[double]]>;
|
||||
extern template struct $Class[[Tmpl]]<float>;
|
||||
template struct $Class[[Tmpl]]<double>;
|
||||
)cpp",
|
||||
// This test is to guard against highlightings disappearing when using
|
||||
// conversion operators as their behaviour in the clang AST differ from
|
||||
@ -328,14 +328,14 @@ TEST(SemanticHighlighting, GetsCorrectTokens) {
|
||||
class $Class[[Foo]] {};
|
||||
struct $Class[[Bar]] {
|
||||
explicit operator $Class[[Foo]]*() const;
|
||||
explicit operator $Primitive[[int]]() const;
|
||||
explicit operator int() const;
|
||||
operator $Class[[Foo]]();
|
||||
};
|
||||
$Primitive[[void]] $Function[[f]]() {
|
||||
void $Function[[f]]() {
|
||||
$Class[[Bar]] $LocalVariable[[B]];
|
||||
$Class[[Foo]] $LocalVariable[[F]] = $LocalVariable[[B]];
|
||||
$Class[[Foo]] *$LocalVariable[[FP]] = ($Class[[Foo]]*)$LocalVariable[[B]];
|
||||
$Primitive[[int]] $LocalVariable[[I]] = ($Primitive[[int]])$LocalVariable[[B]];
|
||||
int $LocalVariable[[I]] = (int)$LocalVariable[[B]];
|
||||
}
|
||||
)cpp"
|
||||
R"cpp(
|
||||
@ -355,7 +355,7 @@ TEST(SemanticHighlighting, GetsCorrectTokens) {
|
||||
class $Class[[Bar]] {
|
||||
$Class[[Foo]] $Field[[Fo]];
|
||||
$Enum[[En]] $Field[[E]];
|
||||
$Primitive[[int]] $Field[[I]];
|
||||
int $Field[[I]];
|
||||
$Class[[Bar]] ($Class[[Foo]] $Parameter[[F]],
|
||||
$Enum[[En]] $Parameter[[E]])
|
||||
: $Field[[Fo]] ($Parameter[[F]]), $Field[[E]] ($Parameter[[E]]),
|
||||
@ -377,7 +377,7 @@ TEST(SemanticHighlighting, GetsCorrectTokens) {
|
||||
$Enum[[auto]] &$Variable[[AER]] = $Variable[[AE]];
|
||||
$Primitive[[auto]] $Variable[[Form]] = 10.2 + 2 * 4;
|
||||
$Primitive[[decltype]]($Variable[[Form]]) $Variable[[F]] = 10;
|
||||
auto $Variable[[Fun]] = []()->$Primitive[[void]]{};
|
||||
auto $Variable[[Fun]] = []()->void{};
|
||||
)cpp",
|
||||
R"cpp(
|
||||
class $Class[[G]] {};
|
||||
@ -385,22 +385,22 @@ TEST(SemanticHighlighting, GetsCorrectTokens) {
|
||||
class $Class[[GP]] {};
|
||||
template<$Class[[G]] &$TemplateParameter[[U]]>
|
||||
class $Class[[GR]] {};
|
||||
template<$Primitive[[int]] *$TemplateParameter[[U]]>
|
||||
template<int *$TemplateParameter[[U]]>
|
||||
class $Class[[IP]] {
|
||||
$Primitive[[void]] $Method[[f]]() {
|
||||
void $Method[[f]]() {
|
||||
*$TemplateParameter[[U]] += 5;
|
||||
}
|
||||
};
|
||||
template<$Primitive[[unsigned]] $TemplateParameter[[U]] = 2>
|
||||
template<unsigned $TemplateParameter[[U]] = 2>
|
||||
class $Class[[Foo]] {
|
||||
$Primitive[[void]] $Method[[f]]() {
|
||||
for($Primitive[[int]] $LocalVariable[[I]] = 0;
|
||||
void $Method[[f]]() {
|
||||
for(int $LocalVariable[[I]] = 0;
|
||||
$LocalVariable[[I]] < $TemplateParameter[[U]];) {}
|
||||
}
|
||||
};
|
||||
|
||||
$Class[[G]] $Variable[[L]];
|
||||
$Primitive[[void]] $Function[[f]]() {
|
||||
void $Function[[f]]() {
|
||||
$Class[[Foo]]<123> $LocalVariable[[F]];
|
||||
$Class[[GP]]<&$Variable[[L]]> $LocalVariable[[LL]];
|
||||
$Class[[GR]]<$Variable[[L]]> $LocalVariable[[LLL]];
|
||||
@ -408,24 +408,24 @@ TEST(SemanticHighlighting, GetsCorrectTokens) {
|
||||
)cpp",
|
||||
R"cpp(
|
||||
template<typename $TemplateParameter[[T]],
|
||||
$Primitive[[void]] (T::*$TemplateParameter[[method]])($Primitive[[int]])>
|
||||
void (T::*$TemplateParameter[[method]])(int)>
|
||||
struct $Class[[G]] {
|
||||
$Primitive[[void]] $Method[[foo]](
|
||||
void $Method[[foo]](
|
||||
$TemplateParameter[[T]] *$Parameter[[O]]) {
|
||||
($Parameter[[O]]->*$TemplateParameter[[method]])(10);
|
||||
}
|
||||
};
|
||||
struct $Class[[F]] {
|
||||
$Primitive[[void]] $Method[[f]]($Primitive[[int]]);
|
||||
void $Method[[f]](int);
|
||||
};
|
||||
template<$Primitive[[void]] (*$TemplateParameter[[Func]])()>
|
||||
template<void (*$TemplateParameter[[Func]])()>
|
||||
struct $Class[[A]] {
|
||||
$Primitive[[void]] $Method[[f]]() {
|
||||
void $Method[[f]]() {
|
||||
(*$TemplateParameter[[Func]])();
|
||||
}
|
||||
};
|
||||
|
||||
$Primitive[[void]] $Function[[foo]]() {
|
||||
void $Function[[foo]]() {
|
||||
$Class[[F]] $LocalVariable[[FF]];
|
||||
$Class[[G]]<$Class[[F]], &$Class[[F]]::$Method[[f]]> $LocalVariable[[GG]];
|
||||
$LocalVariable[[GG]].$Method[[foo]](&$LocalVariable[[FF]]);
|
||||
@ -449,21 +449,21 @@ TEST(SemanticHighlighting, GetsCorrectTokens) {
|
||||
#define $Macro[[SOME_NAME]] variable
|
||||
#define $Macro[[SOME_NAME_SET]] variable2 = 123
|
||||
#define $Macro[[INC_VAR]](X) X += 2
|
||||
$Primitive[[void]] $Function[[foo]]() {
|
||||
void $Function[[foo]]() {
|
||||
$Macro[[DEF_VAR]]($LocalVariable[[X]], 123);
|
||||
$Macro[[DEF_VAR_REV]](908, $LocalVariable[[XY]]);
|
||||
$Primitive[[int]] $Macro[[CPY]]( $LocalVariable[[XX]] );
|
||||
int $Macro[[CPY]]( $LocalVariable[[XX]] );
|
||||
$Macro[[DEF_VAR_TYPE]]($Class[[A]], $LocalVariable[[AA]]);
|
||||
$Primitive[[double]] $Macro[[SOME_NAME]];
|
||||
$Primitive[[int]] $Macro[[SOME_NAME_SET]];
|
||||
double $Macro[[SOME_NAME]];
|
||||
int $Macro[[SOME_NAME_SET]];
|
||||
$LocalVariable[[variable]] = 20.1;
|
||||
$Macro[[MACRO_CONCAT]](var, 2, $Primitive[[float]]);
|
||||
$Macro[[MACRO_CONCAT]](var, 2, float);
|
||||
$Macro[[DEF_VAR_T]]($Class[[A]], $Macro[[CPY]](
|
||||
$Macro[[CPY]]($LocalVariable[[Nested]])),
|
||||
$Macro[[CPY]]($Class[[A]]()));
|
||||
$Macro[[INC_VAR]]($LocalVariable[[variable]]);
|
||||
}
|
||||
$Primitive[[void]] $Macro[[SOME_NAME]]();
|
||||
void $Macro[[SOME_NAME]]();
|
||||
$Macro[[DEF_VAR]]($Variable[[XYZ]], 567);
|
||||
$Macro[[DEF_VAR_REV]](756, $Variable[[AB]]);
|
||||
|
||||
@ -477,10 +477,10 @@ TEST(SemanticHighlighting, GetsCorrectTokens) {
|
||||
#define $Macro[[fail]](expr) expr
|
||||
#define $Macro[[assert]](COND) if (!(COND)) { fail("assertion failed" #COND); }
|
||||
// Preamble ends.
|
||||
$Primitive[[int]] $Variable[[x]];
|
||||
$Primitive[[int]] $Variable[[y]];
|
||||
$Primitive[[int]] $Function[[f]]();
|
||||
$Primitive[[void]] $Function[[foo]]() {
|
||||
int $Variable[[x]];
|
||||
int $Variable[[y]];
|
||||
int $Function[[f]]();
|
||||
void $Function[[foo]]() {
|
||||
$Macro[[assert]]($Variable[[x]] != $Variable[[y]]);
|
||||
$Macro[[assert]]($Variable[[x]] != $Function[[f]]());
|
||||
}
|
||||
@ -501,12 +501,12 @@ TEST(SemanticHighlighting, GetsCorrectTokens) {
|
||||
)cpp",
|
||||
R"cpp(
|
||||
struct $Class[[S]] {
|
||||
$Primitive[[float]] $Field[[Value]];
|
||||
float $Field[[Value]];
|
||||
$Class[[S]] *$Field[[Next]];
|
||||
};
|
||||
$Class[[S]] $Variable[[Global]][2] = {$Class[[S]](), $Class[[S]]()};
|
||||
$Primitive[[void]] $Function[[f]]($Class[[S]] $Parameter[[P]]) {
|
||||
$Primitive[[int]] $LocalVariable[[A]][2] = {1,2};
|
||||
void $Function[[f]]($Class[[S]] $Parameter[[P]]) {
|
||||
int $LocalVariable[[A]][2] = {1,2};
|
||||
auto [$Variable[[B1]], $Variable[[B2]]] = $LocalVariable[[A]];
|
||||
auto [$Variable[[G1]], $Variable[[G2]]] = $Variable[[Global]];
|
||||
$Class[[auto]] [$Variable[[P1]], $Variable[[P2]]] = $Parameter[[P]];
|
||||
@ -519,25 +519,25 @@ TEST(SemanticHighlighting, GetsCorrectTokens) {
|
||||
class $Class[[A]] {
|
||||
using $TemplateParameter[[TemplateParam1]] = $TemplateParameter[[T]];
|
||||
typedef $TemplateParameter[[T]] $TemplateParameter[[TemplateParam2]];
|
||||
using $Primitive[[IntType]] = $Primitive[[int]];
|
||||
using $Primitive[[IntType]] = int;
|
||||
|
||||
using $Typedef[[Pointer]] = $TemplateParameter[[T]] *;
|
||||
using $Typedef[[LVReference]] = $TemplateParameter[[T]] &;
|
||||
using $Typedef[[RVReference]] = $TemplateParameter[[T]]&&;
|
||||
using $Typedef[[Array]] = $TemplateParameter[[T]]*[3];
|
||||
using $Typedef[[MemberPointer]] = $Primitive[[int]] (A::*)($Primitive[[int]]);
|
||||
using $Typedef[[MemberPointer]] = int (A::*)(int);
|
||||
|
||||
// Use various previously defined typedefs in a function type.
|
||||
$Primitive[[void]] $Method[[func]](
|
||||
void $Method[[func]](
|
||||
$Typedef[[Pointer]], $Typedef[[LVReference]], $Typedef[[RVReference]],
|
||||
$Typedef[[Array]], $Typedef[[MemberPointer]]);
|
||||
};
|
||||
)cpp",
|
||||
R"cpp(
|
||||
template <class $TemplateParameter[[T]]>
|
||||
$Primitive[[void]] $Function[[phase1]]($TemplateParameter[[T]]);
|
||||
void $Function[[phase1]]($TemplateParameter[[T]]);
|
||||
template <class $TemplateParameter[[T]]>
|
||||
$Primitive[[void]] $Function[[foo]]($TemplateParameter[[T]] $Parameter[[P]]) {
|
||||
void $Function[[foo]]($TemplateParameter[[T]] $Parameter[[P]]) {
|
||||
$Function[[phase1]]($Parameter[[P]]);
|
||||
$DependentName[[phase2]]($Parameter[[P]]);
|
||||
}
|
||||
@ -545,42 +545,42 @@ TEST(SemanticHighlighting, GetsCorrectTokens) {
|
||||
R"cpp(
|
||||
class $Class[[A]] {
|
||||
template <class $TemplateParameter[[T]]>
|
||||
$Primitive[[void]] $Method[[bar]]($TemplateParameter[[T]]);
|
||||
void $Method[[bar]]($TemplateParameter[[T]]);
|
||||
};
|
||||
|
||||
template <class $TemplateParameter[[U]]>
|
||||
$Primitive[[void]] $Function[[foo]]($TemplateParameter[[U]] $Parameter[[P]]) {
|
||||
void $Function[[foo]]($TemplateParameter[[U]] $Parameter[[P]]) {
|
||||
$Class[[A]]().$Method[[bar]]($Parameter[[P]]);
|
||||
}
|
||||
)cpp",
|
||||
R"cpp(
|
||||
struct $Class[[A]] {
|
||||
template <class $TemplateParameter[[T]]>
|
||||
static $Primitive[[void]] $StaticMethod[[foo]]($TemplateParameter[[T]]);
|
||||
static void $StaticMethod[[foo]]($TemplateParameter[[T]]);
|
||||
};
|
||||
|
||||
template <class $TemplateParameter[[T]]>
|
||||
struct $Class[[B]] {
|
||||
$Primitive[[void]] $Method[[bar]]() {
|
||||
void $Method[[bar]]() {
|
||||
$Class[[A]]::$StaticMethod[[foo]]($TemplateParameter[[T]]());
|
||||
}
|
||||
};
|
||||
)cpp",
|
||||
R"cpp(
|
||||
template <class $TemplateParameter[[T]]>
|
||||
$Primitive[[void]] $Function[[foo]](typename $TemplateParameter[[T]]::$DependentType[[Type]]
|
||||
void $Function[[foo]](typename $TemplateParameter[[T]]::$DependentType[[Type]]
|
||||
= $TemplateParameter[[T]]::$DependentName[[val]]);
|
||||
)cpp",
|
||||
R"cpp(
|
||||
template <class $TemplateParameter[[T]]>
|
||||
$Primitive[[void]] $Function[[foo]]($TemplateParameter[[T]] $Parameter[[P]]) {
|
||||
void $Function[[foo]]($TemplateParameter[[T]] $Parameter[[P]]) {
|
||||
$Parameter[[P]].$DependentName[[Field]];
|
||||
}
|
||||
)cpp",
|
||||
R"cpp(
|
||||
template <class $TemplateParameter[[T]]>
|
||||
class $Class[[A]] {
|
||||
$Primitive[[int]] $Method[[foo]]() {
|
||||
int $Method[[foo]]() {
|
||||
return $TemplateParameter[[T]]::$DependentName[[Field]];
|
||||
}
|
||||
};
|
||||
|
@ -442,20 +442,15 @@ TWEAK_TEST(AnnotateHighlightings);
|
||||
TEST_F(AnnotateHighlightingsTest, Test) {
|
||||
EXPECT_AVAILABLE("^vo^id^ ^f(^) {^}^"); // available everywhere.
|
||||
EXPECT_AVAILABLE("[[int a; int b;]]");
|
||||
EXPECT_EQ("/* storage.type.primitive.cpp */void "
|
||||
"/* entity.name.function.cpp */f() {}",
|
||||
apply("void ^f() {}"));
|
||||
EXPECT_EQ("void /* entity.name.function.cpp */f() {}", apply("void ^f() {}"));
|
||||
|
||||
EXPECT_EQ(apply("[[void f1(); void f2();]]"),
|
||||
"/* storage.type.primitive.cpp */void "
|
||||
"/* entity.name.function.cpp */f1(); "
|
||||
"/* storage.type.primitive.cpp */void "
|
||||
"/* entity.name.function.cpp */f2();");
|
||||
"void /* entity.name.function.cpp */f1(); "
|
||||
"void /* entity.name.function.cpp */f2();");
|
||||
|
||||
EXPECT_EQ(apply("void f1(); void f2() {^}"),
|
||||
"void f1(); "
|
||||
"/* storage.type.primitive.cpp */void "
|
||||
"/* entity.name.function.cpp */f2() {}");
|
||||
"void /* entity.name.function.cpp */f2() {}");
|
||||
}
|
||||
|
||||
TWEAK_TEST(ExpandMacro);
|
||||
|
Loading…
x
Reference in New Issue
Block a user