libclang - How to get tokens for a declaration using Clang C++ API? -
i have own recursive ast visitor class clang::astcontext
object inside:
class visitor : public clang::recursiveastvisitor<visitor> { public: visitor(const clang::astcontext& context) : context_(context) {} private: const clang::astcontext& context_; };
then want visit, example, namespace declarations , colorify names:
bool visitnamespacedecl(clang::namespacedecl* decl) { const auto& sm = context_.getsourcemanager(); auto loc = decl->getlocstart(); if (!sm.isinmainfile(loc)) { return true; } if (!sm.ismacrobodyexpansion(loc)) { auto line = sm.getspellinglinenumber(loc); auto column = sm.getspellingcolumnnumber(loc); // colorify "namespace" keyword itself. // todo: how location of name token after "namespace" keyword? } return true; }
it's example. if there way location of namespace's name without tokens, i'm interested in more global approach.
is there way "jump" tokens within declaration source range , traverse them?
Comments
Post a Comment