2012-07-21 05:34:34 +08:00
|
|
|
//===- CXComment.cpp - libclang APIs for manipulating CXComments ----------===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This file defines all libclang APIs related to walking comment AST.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "clang-c/Index.h"
|
|
|
|
#include "CXComment.h"
|
2012-08-08 01:54:38 +08:00
|
|
|
#include "CXCursor.h"
|
2012-12-04 17:25:21 +08:00
|
|
|
#include "CXString.h"
|
2015-01-14 19:23:58 +08:00
|
|
|
#include "clang-c/Documentation.h"
|
2012-08-08 01:54:38 +08:00
|
|
|
#include "clang/AST/Decl.h"
|
2013-11-14 06:16:51 +08:00
|
|
|
#include "clang/Index/CommentToXML.h"
|
2012-12-19 07:02:59 +08:00
|
|
|
#include "llvm/ADT/StringExtras.h"
|
2012-08-08 01:54:38 +08:00
|
|
|
#include "llvm/ADT/StringSwitch.h"
|
2012-07-21 05:34:34 +08:00
|
|
|
#include "llvm/Support/ErrorHandling.h"
|
2012-07-31 01:49:32 +08:00
|
|
|
#include <climits>
|
|
|
|
|
2012-07-21 05:34:34 +08:00
|
|
|
using namespace clang;
|
|
|
|
using namespace clang::comments;
|
|
|
|
using namespace clang::cxcomment;
|
|
|
|
|
|
|
|
extern "C" {
|
|
|
|
|
2014-04-28 10:39:27 +08:00
|
|
|
CXComment clang_Cursor_getParsedComment(CXCursor C) {
|
|
|
|
using namespace clang::cxcursor;
|
|
|
|
|
|
|
|
if (!clang_isDeclaration(C.kind))
|
2014-06-08 16:38:04 +08:00
|
|
|
return createCXComment(nullptr, nullptr);
|
2014-04-28 10:39:27 +08:00
|
|
|
|
|
|
|
const Decl *D = getCursorDecl(C);
|
|
|
|
const ASTContext &Context = getCursorContext(C);
|
2014-06-08 16:38:04 +08:00
|
|
|
const FullComment *FC = Context.getCommentForDecl(D, /*PP=*/nullptr);
|
2014-04-28 10:39:27 +08:00
|
|
|
|
|
|
|
return createCXComment(FC, getCursorTU(C));
|
|
|
|
}
|
|
|
|
|
2012-07-21 05:34:34 +08:00
|
|
|
enum CXCommentKind clang_Comment_getKind(CXComment CXC) {
|
|
|
|
const Comment *C = getASTNode(CXC);
|
|
|
|
if (!C)
|
|
|
|
return CXComment_Null;
|
|
|
|
|
|
|
|
switch (C->getCommentKind()) {
|
|
|
|
case Comment::NoCommentKind:
|
|
|
|
return CXComment_Null;
|
|
|
|
|
|
|
|
case Comment::TextCommentKind:
|
|
|
|
return CXComment_Text;
|
|
|
|
|
|
|
|
case Comment::InlineCommandCommentKind:
|
|
|
|
return CXComment_InlineCommand;
|
|
|
|
|
|
|
|
case Comment::HTMLStartTagCommentKind:
|
|
|
|
return CXComment_HTMLStartTag;
|
|
|
|
|
|
|
|
case Comment::HTMLEndTagCommentKind:
|
|
|
|
return CXComment_HTMLEndTag;
|
|
|
|
|
|
|
|
case Comment::ParagraphCommentKind:
|
|
|
|
return CXComment_Paragraph;
|
|
|
|
|
|
|
|
case Comment::BlockCommandCommentKind:
|
|
|
|
return CXComment_BlockCommand;
|
|
|
|
|
|
|
|
case Comment::ParamCommandCommentKind:
|
|
|
|
return CXComment_ParamCommand;
|
|
|
|
|
2012-08-01 06:37:06 +08:00
|
|
|
case Comment::TParamCommandCommentKind:
|
|
|
|
return CXComment_TParamCommand;
|
|
|
|
|
2012-07-21 05:34:34 +08:00
|
|
|
case Comment::VerbatimBlockCommentKind:
|
|
|
|
return CXComment_VerbatimBlockCommand;
|
|
|
|
|
|
|
|
case Comment::VerbatimBlockLineCommentKind:
|
|
|
|
return CXComment_VerbatimBlockLine;
|
|
|
|
|
|
|
|
case Comment::VerbatimLineCommentKind:
|
|
|
|
return CXComment_VerbatimLine;
|
|
|
|
|
|
|
|
case Comment::FullCommentKind:
|
|
|
|
return CXComment_FullComment;
|
|
|
|
}
|
|
|
|
llvm_unreachable("unknown CommentKind");
|
|
|
|
}
|
|
|
|
|
|
|
|
unsigned clang_Comment_getNumChildren(CXComment CXC) {
|
|
|
|
const Comment *C = getASTNode(CXC);
|
|
|
|
if (!C)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
return C->child_count();
|
|
|
|
}
|
|
|
|
|
|
|
|
CXComment clang_Comment_getChild(CXComment CXC, unsigned ChildIdx) {
|
|
|
|
const Comment *C = getASTNode(CXC);
|
|
|
|
if (!C || ChildIdx >= C->child_count())
|
2014-06-08 16:38:04 +08:00
|
|
|
return createCXComment(nullptr, nullptr);
|
2012-07-21 05:34:34 +08:00
|
|
|
|
2012-09-11 04:32:42 +08:00
|
|
|
return createCXComment(*(C->child_begin() + ChildIdx), CXC.TranslationUnit);
|
2012-07-21 05:34:34 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
unsigned clang_Comment_isWhitespace(CXComment CXC) {
|
|
|
|
const Comment *C = getASTNode(CXC);
|
|
|
|
if (!C)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if (const TextComment *TC = dyn_cast<TextComment>(C))
|
|
|
|
return TC->isWhitespace();
|
|
|
|
|
|
|
|
if (const ParagraphComment *PC = dyn_cast<ParagraphComment>(C))
|
|
|
|
return PC->isWhitespace();
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
unsigned clang_InlineContentComment_hasTrailingNewline(CXComment CXC) {
|
|
|
|
const InlineContentComment *ICC = getASTNodeAs<InlineContentComment>(CXC);
|
|
|
|
if (!ICC)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
return ICC->hasTrailingNewline();
|
|
|
|
}
|
|
|
|
|
|
|
|
CXString clang_TextComment_getText(CXComment CXC) {
|
|
|
|
const TextComment *TC = getASTNodeAs<TextComment>(CXC);
|
|
|
|
if (!TC)
|
2013-02-01 22:13:32 +08:00
|
|
|
return cxstring::createNull();
|
2012-07-21 05:34:34 +08:00
|
|
|
|
2013-02-02 10:19:29 +08:00
|
|
|
return cxstring::createRef(TC->getText());
|
2012-07-21 05:34:34 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
CXString clang_InlineCommandComment_getCommandName(CXComment CXC) {
|
|
|
|
const InlineCommandComment *ICC = getASTNodeAs<InlineCommandComment>(CXC);
|
|
|
|
if (!ICC)
|
2013-02-01 22:13:32 +08:00
|
|
|
return cxstring::createNull();
|
2012-07-21 05:34:34 +08:00
|
|
|
|
2012-09-11 04:32:42 +08:00
|
|
|
const CommandTraits &Traits = getCommandTraits(CXC);
|
2013-02-02 10:19:29 +08:00
|
|
|
return cxstring::createRef(ICC->getCommandName(Traits));
|
2012-07-21 05:34:34 +08:00
|
|
|
}
|
|
|
|
|
2012-07-24 00:43:01 +08:00
|
|
|
enum CXCommentInlineCommandRenderKind
|
|
|
|
clang_InlineCommandComment_getRenderKind(CXComment CXC) {
|
|
|
|
const InlineCommandComment *ICC = getASTNodeAs<InlineCommandComment>(CXC);
|
|
|
|
if (!ICC)
|
|
|
|
return CXCommentInlineCommandRenderKind_Normal;
|
|
|
|
|
|
|
|
switch (ICC->getRenderKind()) {
|
|
|
|
case InlineCommandComment::RenderNormal:
|
|
|
|
return CXCommentInlineCommandRenderKind_Normal;
|
|
|
|
|
|
|
|
case InlineCommandComment::RenderBold:
|
|
|
|
return CXCommentInlineCommandRenderKind_Bold;
|
|
|
|
|
|
|
|
case InlineCommandComment::RenderMonospaced:
|
|
|
|
return CXCommentInlineCommandRenderKind_Monospaced;
|
|
|
|
|
|
|
|
case InlineCommandComment::RenderEmphasized:
|
|
|
|
return CXCommentInlineCommandRenderKind_Emphasized;
|
|
|
|
}
|
|
|
|
llvm_unreachable("unknown InlineCommandComment::RenderKind");
|
|
|
|
}
|
|
|
|
|
2012-07-21 05:34:34 +08:00
|
|
|
unsigned clang_InlineCommandComment_getNumArgs(CXComment CXC) {
|
|
|
|
const InlineCommandComment *ICC = getASTNodeAs<InlineCommandComment>(CXC);
|
|
|
|
if (!ICC)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
return ICC->getNumArgs();
|
|
|
|
}
|
|
|
|
|
|
|
|
CXString clang_InlineCommandComment_getArgText(CXComment CXC,
|
|
|
|
unsigned ArgIdx) {
|
|
|
|
const InlineCommandComment *ICC = getASTNodeAs<InlineCommandComment>(CXC);
|
|
|
|
if (!ICC || ArgIdx >= ICC->getNumArgs())
|
2013-02-01 22:13:32 +08:00
|
|
|
return cxstring::createNull();
|
2012-07-21 05:34:34 +08:00
|
|
|
|
2013-02-02 10:19:29 +08:00
|
|
|
return cxstring::createRef(ICC->getArgText(ArgIdx));
|
2012-07-21 05:34:34 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
CXString clang_HTMLTagComment_getTagName(CXComment CXC) {
|
|
|
|
const HTMLTagComment *HTC = getASTNodeAs<HTMLTagComment>(CXC);
|
|
|
|
if (!HTC)
|
2013-02-01 22:13:32 +08:00
|
|
|
return cxstring::createNull();
|
2012-07-21 05:34:34 +08:00
|
|
|
|
2013-02-02 10:19:29 +08:00
|
|
|
return cxstring::createRef(HTC->getTagName());
|
2012-07-21 05:34:34 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
unsigned clang_HTMLStartTagComment_isSelfClosing(CXComment CXC) {
|
|
|
|
const HTMLStartTagComment *HST = getASTNodeAs<HTMLStartTagComment>(CXC);
|
|
|
|
if (!HST)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
return HST->isSelfClosing();
|
|
|
|
}
|
|
|
|
|
|
|
|
unsigned clang_HTMLStartTag_getNumAttrs(CXComment CXC) {
|
|
|
|
const HTMLStartTagComment *HST = getASTNodeAs<HTMLStartTagComment>(CXC);
|
|
|
|
if (!HST)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
return HST->getNumAttrs();
|
|
|
|
}
|
|
|
|
|
|
|
|
CXString clang_HTMLStartTag_getAttrName(CXComment CXC, unsigned AttrIdx) {
|
|
|
|
const HTMLStartTagComment *HST = getASTNodeAs<HTMLStartTagComment>(CXC);
|
|
|
|
if (!HST || AttrIdx >= HST->getNumAttrs())
|
2013-02-01 22:13:32 +08:00
|
|
|
return cxstring::createNull();
|
2012-07-21 05:34:34 +08:00
|
|
|
|
2013-02-02 10:19:29 +08:00
|
|
|
return cxstring::createRef(HST->getAttr(AttrIdx).Name);
|
2012-07-21 05:34:34 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
CXString clang_HTMLStartTag_getAttrValue(CXComment CXC, unsigned AttrIdx) {
|
|
|
|
const HTMLStartTagComment *HST = getASTNodeAs<HTMLStartTagComment>(CXC);
|
|
|
|
if (!HST || AttrIdx >= HST->getNumAttrs())
|
2013-02-01 22:13:32 +08:00
|
|
|
return cxstring::createNull();
|
2012-07-21 05:34:34 +08:00
|
|
|
|
2013-02-02 10:19:29 +08:00
|
|
|
return cxstring::createRef(HST->getAttr(AttrIdx).Value);
|
2012-07-21 05:34:34 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
CXString clang_BlockCommandComment_getCommandName(CXComment CXC) {
|
|
|
|
const BlockCommandComment *BCC = getASTNodeAs<BlockCommandComment>(CXC);
|
|
|
|
if (!BCC)
|
2013-02-01 22:13:32 +08:00
|
|
|
return cxstring::createNull();
|
2012-07-21 05:34:34 +08:00
|
|
|
|
2012-09-11 04:32:42 +08:00
|
|
|
const CommandTraits &Traits = getCommandTraits(CXC);
|
2013-02-02 10:19:29 +08:00
|
|
|
return cxstring::createRef(BCC->getCommandName(Traits));
|
2012-07-21 05:34:34 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
unsigned clang_BlockCommandComment_getNumArgs(CXComment CXC) {
|
|
|
|
const BlockCommandComment *BCC = getASTNodeAs<BlockCommandComment>(CXC);
|
|
|
|
if (!BCC)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
return BCC->getNumArgs();
|
|
|
|
}
|
|
|
|
|
|
|
|
CXString clang_BlockCommandComment_getArgText(CXComment CXC,
|
|
|
|
unsigned ArgIdx) {
|
|
|
|
const BlockCommandComment *BCC = getASTNodeAs<BlockCommandComment>(CXC);
|
|
|
|
if (!BCC || ArgIdx >= BCC->getNumArgs())
|
2013-02-01 22:13:32 +08:00
|
|
|
return cxstring::createNull();
|
2012-07-21 05:34:34 +08:00
|
|
|
|
2013-02-02 10:19:29 +08:00
|
|
|
return cxstring::createRef(BCC->getArgText(ArgIdx));
|
2012-07-21 05:34:34 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
CXComment clang_BlockCommandComment_getParagraph(CXComment CXC) {
|
|
|
|
const BlockCommandComment *BCC = getASTNodeAs<BlockCommandComment>(CXC);
|
|
|
|
if (!BCC)
|
2014-06-08 16:38:04 +08:00
|
|
|
return createCXComment(nullptr, nullptr);
|
2012-07-21 05:34:34 +08:00
|
|
|
|
2012-09-11 04:32:42 +08:00
|
|
|
return createCXComment(BCC->getParagraph(), CXC.TranslationUnit);
|
2012-07-21 05:34:34 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
CXString clang_ParamCommandComment_getParamName(CXComment CXC) {
|
|
|
|
const ParamCommandComment *PCC = getASTNodeAs<ParamCommandComment>(CXC);
|
2012-07-24 03:41:49 +08:00
|
|
|
if (!PCC || !PCC->hasParamName())
|
2013-02-01 22:13:32 +08:00
|
|
|
return cxstring::createNull();
|
2012-07-21 05:34:34 +08:00
|
|
|
|
2013-02-02 10:19:29 +08:00
|
|
|
return cxstring::createRef(PCC->getParamNameAsWritten());
|
2012-07-21 05:34:34 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
unsigned clang_ParamCommandComment_isParamIndexValid(CXComment CXC) {
|
|
|
|
const ParamCommandComment *PCC = getASTNodeAs<ParamCommandComment>(CXC);
|
|
|
|
if (!PCC)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
return PCC->isParamIndexValid();
|
|
|
|
}
|
|
|
|
|
|
|
|
unsigned clang_ParamCommandComment_getParamIndex(CXComment CXC) {
|
|
|
|
const ParamCommandComment *PCC = getASTNodeAs<ParamCommandComment>(CXC);
|
2013-06-24 12:41:32 +08:00
|
|
|
if (!PCC || !PCC->isParamIndexValid() || PCC->isVarArgParam())
|
2012-07-21 05:34:34 +08:00
|
|
|
return ParamCommandComment::InvalidParamIndex;
|
|
|
|
|
|
|
|
return PCC->getParamIndex();
|
|
|
|
}
|
|
|
|
|
|
|
|
unsigned clang_ParamCommandComment_isDirectionExplicit(CXComment CXC) {
|
|
|
|
const ParamCommandComment *PCC = getASTNodeAs<ParamCommandComment>(CXC);
|
|
|
|
if (!PCC)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
return PCC->isDirectionExplicit();
|
|
|
|
}
|
|
|
|
|
|
|
|
enum CXCommentParamPassDirection clang_ParamCommandComment_getDirection(
|
|
|
|
CXComment CXC) {
|
|
|
|
const ParamCommandComment *PCC = getASTNodeAs<ParamCommandComment>(CXC);
|
|
|
|
if (!PCC)
|
|
|
|
return CXCommentParamPassDirection_In;
|
|
|
|
|
|
|
|
switch (PCC->getDirection()) {
|
|
|
|
case ParamCommandComment::In:
|
|
|
|
return CXCommentParamPassDirection_In;
|
|
|
|
|
|
|
|
case ParamCommandComment::Out:
|
|
|
|
return CXCommentParamPassDirection_Out;
|
|
|
|
|
|
|
|
case ParamCommandComment::InOut:
|
|
|
|
return CXCommentParamPassDirection_InOut;
|
|
|
|
}
|
|
|
|
llvm_unreachable("unknown ParamCommandComment::PassDirection");
|
|
|
|
}
|
|
|
|
|
2012-08-01 06:37:06 +08:00
|
|
|
CXString clang_TParamCommandComment_getParamName(CXComment CXC) {
|
|
|
|
const TParamCommandComment *TPCC = getASTNodeAs<TParamCommandComment>(CXC);
|
|
|
|
if (!TPCC || !TPCC->hasParamName())
|
2013-02-01 22:13:32 +08:00
|
|
|
return cxstring::createNull();
|
2012-08-01 06:37:06 +08:00
|
|
|
|
2013-02-02 10:19:29 +08:00
|
|
|
return cxstring::createRef(TPCC->getParamNameAsWritten());
|
2012-08-01 06:37:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
unsigned clang_TParamCommandComment_isParamPositionValid(CXComment CXC) {
|
|
|
|
const TParamCommandComment *TPCC = getASTNodeAs<TParamCommandComment>(CXC);
|
|
|
|
if (!TPCC)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
return TPCC->isPositionValid();
|
|
|
|
}
|
|
|
|
|
|
|
|
unsigned clang_TParamCommandComment_getDepth(CXComment CXC) {
|
|
|
|
const TParamCommandComment *TPCC = getASTNodeAs<TParamCommandComment>(CXC);
|
|
|
|
if (!TPCC || !TPCC->isPositionValid())
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
return TPCC->getDepth();
|
|
|
|
}
|
|
|
|
|
|
|
|
unsigned clang_TParamCommandComment_getIndex(CXComment CXC, unsigned Depth) {
|
|
|
|
const TParamCommandComment *TPCC = getASTNodeAs<TParamCommandComment>(CXC);
|
|
|
|
if (!TPCC || !TPCC->isPositionValid() || Depth >= TPCC->getDepth())
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
return TPCC->getIndex(Depth);
|
|
|
|
}
|
|
|
|
|
2012-07-21 05:34:34 +08:00
|
|
|
CXString clang_VerbatimBlockLineComment_getText(CXComment CXC) {
|
|
|
|
const VerbatimBlockLineComment *VBL =
|
|
|
|
getASTNodeAs<VerbatimBlockLineComment>(CXC);
|
|
|
|
if (!VBL)
|
2013-02-01 22:13:32 +08:00
|
|
|
return cxstring::createNull();
|
2012-07-21 05:34:34 +08:00
|
|
|
|
2013-02-02 10:19:29 +08:00
|
|
|
return cxstring::createRef(VBL->getText());
|
2012-07-21 05:34:34 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
CXString clang_VerbatimLineComment_getText(CXComment CXC) {
|
|
|
|
const VerbatimLineComment *VLC = getASTNodeAs<VerbatimLineComment>(CXC);
|
|
|
|
if (!VLC)
|
2013-02-01 22:13:32 +08:00
|
|
|
return cxstring::createNull();
|
2012-07-21 05:34:34 +08:00
|
|
|
|
2013-02-02 10:19:29 +08:00
|
|
|
return cxstring::createRef(VLC->getText());
|
2012-07-21 05:34:34 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
2013-11-14 06:16:51 +08:00
|
|
|
// Converting comments to XML.
|
2012-07-21 05:34:34 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
CXString clang_HTMLTagComment_getAsString(CXComment CXC) {
|
|
|
|
const HTMLTagComment *HTC = getASTNodeAs<HTMLTagComment>(CXC);
|
|
|
|
if (!HTC)
|
2013-02-01 22:13:32 +08:00
|
|
|
return cxstring::createNull();
|
2012-07-21 05:34:34 +08:00
|
|
|
|
2013-11-14 06:16:51 +08:00
|
|
|
CXTranslationUnit TU = CXC.TranslationUnit;
|
|
|
|
if (!TU->CommentToXML)
|
2013-11-14 08:36:24 +08:00
|
|
|
TU->CommentToXML = new clang::index::CommentToXMLConverter();
|
2013-11-14 06:16:51 +08:00
|
|
|
|
|
|
|
SmallString<128> Text;
|
|
|
|
TU->CommentToXML->convertHTMLTagNodeToText(
|
|
|
|
HTC, Text, cxtu::getASTUnit(TU)->getASTContext());
|
|
|
|
return cxstring::createDup(Text.str());
|
2012-07-21 05:34:34 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
CXString clang_FullComment_getAsHTML(CXComment CXC) {
|
|
|
|
const FullComment *FC = getASTNodeAs<FullComment>(CXC);
|
|
|
|
if (!FC)
|
2013-02-01 22:13:32 +08:00
|
|
|
return cxstring::createNull();
|
2012-07-21 05:34:34 +08:00
|
|
|
|
2013-11-14 06:16:51 +08:00
|
|
|
CXTranslationUnit TU = CXC.TranslationUnit;
|
|
|
|
if (!TU->CommentToXML)
|
2013-11-14 08:36:24 +08:00
|
|
|
TU->CommentToXML = new clang::index::CommentToXMLConverter();
|
2013-11-14 06:16:51 +08:00
|
|
|
|
2012-07-21 09:47:43 +08:00
|
|
|
SmallString<1024> HTML;
|
2013-11-14 06:16:51 +08:00
|
|
|
TU->CommentToXML
|
|
|
|
->convertCommentToHTML(FC, HTML, cxtu::getASTUnit(TU)->getASTContext());
|
2013-02-02 10:19:29 +08:00
|
|
|
return cxstring::createDup(HTML.str());
|
2012-07-21 05:34:34 +08:00
|
|
|
}
|
|
|
|
|
2012-09-11 04:32:42 +08:00
|
|
|
CXString clang_FullComment_getAsXML(CXComment CXC) {
|
2012-08-08 01:54:38 +08:00
|
|
|
const FullComment *FC = getASTNodeAs<FullComment>(CXC);
|
|
|
|
if (!FC)
|
2013-02-01 22:13:32 +08:00
|
|
|
return cxstring::createNull();
|
2013-11-14 06:16:51 +08:00
|
|
|
|
2012-09-11 04:32:42 +08:00
|
|
|
CXTranslationUnit TU = CXC.TranslationUnit;
|
2013-11-14 06:16:51 +08:00
|
|
|
if (!TU->CommentToXML)
|
2013-11-14 08:36:24 +08:00
|
|
|
TU->CommentToXML = new clang::index::CommentToXMLConverter();
|
2012-08-08 01:54:38 +08:00
|
|
|
|
|
|
|
SmallString<1024> XML;
|
2013-11-14 06:16:51 +08:00
|
|
|
TU->CommentToXML
|
|
|
|
->convertCommentToXML(FC, XML, cxtu::getASTUnit(TU)->getASTContext());
|
2013-02-02 10:19:29 +08:00
|
|
|
return cxstring::createDup(XML.str());
|
2012-08-08 01:54:38 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
} // end extern "C"
|
|
|
|
|