File tree Expand file tree Collapse file tree 4 files changed +42
-40
lines changed Expand file tree Collapse file tree 4 files changed +42
-40
lines changed Original file line number Diff line number Diff line change @@ -257,6 +257,23 @@ bool isVirtual(const Decl *D) {
257257 return false ;
258258}
259259
260+ bool isUniqueDefinition (const NamedDecl *Decl) {
261+ if (auto *Func = dyn_cast<FunctionDecl>(Decl))
262+ return Func->isThisDeclarationADefinition ();
263+ if (auto *Klass = dyn_cast<CXXRecordDecl>(Decl))
264+ return Klass->isThisDeclarationADefinition ();
265+ if (auto *Iface = dyn_cast<ObjCInterfaceDecl>(Decl))
266+ return Iface->isThisDeclarationADefinition ();
267+ if (auto *Proto = dyn_cast<ObjCProtocolDecl>(Decl))
268+ return Proto->isThisDeclarationADefinition ();
269+ if (auto *Var = dyn_cast<VarDecl>(Decl))
270+ return Var->isThisDeclarationADefinition ();
271+ return isa<TemplateTypeParmDecl>(Decl) ||
272+ isa<NonTypeTemplateParmDecl>(Decl) ||
273+ isa<TemplateTemplateParmDecl>(Decl) || isa<ObjCCategoryDecl>(Decl) ||
274+ isa<ObjCImplDecl>(Decl);
275+ }
276+
260277SourceLocation nameLocation (const clang::Decl &D, const SourceManager &SM) {
261278 auto L = D.getLocation ();
262279 // For `- (void)foo` we want `foo` not the `-`.
Original file line number Diff line number Diff line change @@ -184,7 +184,7 @@ bool isConst(const Decl *D);
184184bool isStatic (const Decl *D);
185185bool isAbstract (const Decl *D);
186186bool isVirtual (const Decl *D);
187-
187+ bool isUniqueDefinition ( const NamedDecl *Decl);
188188// / Returns a nested name specifier loc of \p ND if it was present in the
189189// / source, e.g.
190190// / void ns::something::foo() -> returns 'ns::something'
Original file line number Diff line number Diff line change @@ -188,34 +188,36 @@ std::string getSymbolName(ASTContext &Ctx, const NamedDecl &ND) {
188188 return printName (Ctx, ND);
189189}
190190
191- std::vector<SymbolTag> getSymbolTags (const NamedDecl &ND)
192- {
191+ std::vector<SymbolTag> getSymbolTags (const NamedDecl &ND) {
193192 std::vector<SymbolTag> Tags;
194- if (ND.isDeprecated ())
193+ if (ND.isDeprecated ())
195194 Tags.push_back (SymbolTag::Deprecated);
196- if (isConst (&ND))
197- Tags.push_back (SymbolTag::Constant);
198- if (isStatic (&ND))
199- Tags.push_back (SymbolTag::Static);
195+ if (isConst (&ND))
196+ Tags.push_back (SymbolTag::Constant);
197+ if (isStatic (&ND))
198+ Tags.push_back (SymbolTag::Static);
200199 if (isVirtual (&ND))
201- Tags.push_back (SymbolTag::Virtual);
202-
200+ Tags.push_back (SymbolTag::Virtual);
201+ if (!isa<UnresolvedUsingValueDecl>(ND))
202+ Tags.push_back (SymbolTag::Declaration);
203+ if (isUniqueDefinition (&ND))
204+ Tags.push_back (SymbolTag::Definition);
203205 if (const FieldDecl *FD = dyn_cast<FieldDecl>(&ND)) {
204206 switch (FD->getAccess ()) {
205- case AS_public:
206- Tags.push_back (SymbolTag::Public);
207- break ;
208- case AS_protected:
209- Tags.push_back (SymbolTag::Protected);
210- break ;
211- case AS_private:
212- Tags.push_back (SymbolTag::Private);
213- break ;
214- default :
215- break ;
207+ case AS_public:
208+ Tags.push_back (SymbolTag::Public);
209+ break ;
210+ case AS_protected:
211+ Tags.push_back (SymbolTag::Protected);
212+ break ;
213+ case AS_private:
214+ Tags.push_back (SymbolTag::Private);
215+ break ;
216+ default :
217+ break ;
216218 }
217- }
218-
219+ }
220+
219221 return Tags;
220222}
221223
Original file line number Diff line number Diff line change @@ -78,23 +78,6 @@ bool canHighlightName(DeclarationName Name) {
7878 llvm_unreachable (" invalid name kind" );
7979}
8080
81- bool isUniqueDefinition (const NamedDecl *Decl) {
82- if (auto *Func = dyn_cast<FunctionDecl>(Decl))
83- return Func->isThisDeclarationADefinition ();
84- if (auto *Klass = dyn_cast<CXXRecordDecl>(Decl))
85- return Klass->isThisDeclarationADefinition ();
86- if (auto *Iface = dyn_cast<ObjCInterfaceDecl>(Decl))
87- return Iface->isThisDeclarationADefinition ();
88- if (auto *Proto = dyn_cast<ObjCProtocolDecl>(Decl))
89- return Proto->isThisDeclarationADefinition ();
90- if (auto *Var = dyn_cast<VarDecl>(Decl))
91- return Var->isThisDeclarationADefinition ();
92- return isa<TemplateTypeParmDecl>(Decl) ||
93- isa<NonTypeTemplateParmDecl>(Decl) ||
94- isa<TemplateTemplateParmDecl>(Decl) || isa<ObjCCategoryDecl>(Decl) ||
95- isa<ObjCImplDecl>(Decl);
96- }
97-
9881std::optional<HighlightingKind> kindForType (const Type *TP,
9982 const HeuristicResolver *Resolver);
10083std::optional<HighlightingKind> kindForDecl (const NamedDecl *D,
You can’t perform that action at this time.
0 commit comments