| 153 | } |
| 154 | |
| 155 | struct CommentHandler::CommentVisitor : clang::comments::ConstCommentVisitor<CommentVisitor> { |
| 156 | typedef clang::comments::ConstCommentVisitor<CommentVisitor> Base; |
| 157 | CommentVisitor(Annotator &annotator, Generator &generator, const clang::comments::CommandTraits &traits, clang::Sema &Sema) |
| 158 | : annotator(annotator), generator(generator) , traits(traits), Sema(Sema) {} |
| 159 | Annotator &annotator; |
| 160 | Generator &generator; |
| 161 | const clang::comments::CommandTraits &traits; |
| 162 | clang::Sema &Sema; |
| 163 | |
| 164 | clang::NamedDecl *Decl = nullptr; |
| 165 | std::string DeclRef; |
| 166 | std::vector<std::pair<std::string, Doc>> SubDocs; // typically for enum values |
| 167 | |
| 168 | void visit(const clang::comments::Comment *C) { |
| 169 | Base::visit(C); |
| 170 | for (auto it = C->child_begin(); it != C->child_end(); ++it) |
| 171 | visit(*it); |
| 172 | } |
| 173 | |
| 174 | // Inline content. |
| 175 | //void visitTextComment(const clang::comments::TextComment *C); |
| 176 | void visitInlineCommandComment(const clang::comments::InlineCommandComment *C) { |
| 177 | tag("command", C->getCommandNameRange()); |
| 178 | for (unsigned int i = 0; i < C->getNumArgs(); ++i) |
| 179 | tag("arg", C->getArgRange(i)); |
| 180 | } |
| 181 | void visitHTMLStartTagComment(const clang::comments::HTMLStartTagComment *C) { |
| 182 | tag("tag", C->getSourceRange()); |
| 183 | /*for (int i = 0; i < C->getNumAttrs(); ++i) { |
| 184 | auto attr = C->getAttr(i); |
| 185 | tag("attr", attr.getNameRange()); |
| 186 | }*/ |
| 187 | } |
| 188 | void visitHTMLEndTagComment(const clang::comments::HTMLEndTagComment *C) { |
| 189 | tag("tag", C->getSourceRange()); |
| 190 | } |
| 191 | |
| 192 | // Block content. |
| 193 | //void visitParagraphComment(const clang::comments::ParagraphComment *C); |
| 194 | void visitBlockCommandComment(const clang::comments::BlockCommandComment *C) { |
| 195 | auto nameRange = C->getCommandNameRange(traits); |
| 196 | tag("command", {C->getLocStart(), nameRange.getEnd().getLocWithOffset(-1)}); |
| 197 | for (unsigned int i = 0; i < C->getNumArgs(); ++i) |
| 198 | tag("arg", C->getArgRange(i)); |
| 199 | if (C->getCommandName(traits) == "value") |
| 200 | parseEnumValue(C); |
| 201 | } |
| 202 | //void visitParamCommandComment(const clang::comments::ParamCommandComment *C); |
| 203 | //void visitTParamCommandComment(const clang::comments::TParamCommandComment *C); |
| 204 | /*void visitVerbatimBlockComment(const clang::comments::VerbatimBlockComment *C) { |
| 205 | Base::visitVerbatimBlockComment(C); |
| 206 | FIXME |
| 207 | // highlight the closing command |
| 208 | auto end = C->getLocEnd(); |
| 209 | tag("arg", {end.getLocWithOffset(-C->getCloseName().size()) ,end}); |
| 210 | }*/ |
| 211 | void visitVerbatimBlockLineComment(const clang::comments::VerbatimBlockLineComment *C) { |
| 212 | tag("verb", C->getSourceRange()); |
nothing calls this directly
no outgoing calls
no test coverage detected