clang API Documentation

Functions
clang::html Namespace Reference

Functions

void HighlightRange (Rewriter &R, SourceLocation B, SourceLocation E, const char *StartTag, const char *EndTag)
void HighlightRange (Rewriter &R, SourceRange Range, const char *StartTag, const char *EndTag)
void HighlightRange (RewriteBuffer &RB, unsigned B, unsigned E, const char *BufferStart, const char *StartTag, const char *EndTag)
void EscapeText (Rewriter &R, FileID FID, bool EscapeSpaces=false, bool ReplaceTabs=false)
std::string EscapeText (StringRef s, bool EscapeSpaces=false, bool ReplaceTabs=false)
void AddLineNumbers (Rewriter &R, FileID FID)
void AddHeaderFooterInternalBuiltinCSS (Rewriter &R, FileID FID, const char *title=nullptr)
void SyntaxHighlight (Rewriter &R, FileID FID, const Preprocessor &PP)
void HighlightMacros (Rewriter &R, FileID FID, const Preprocessor &PP)

Function Documentation

void clang::html::AddHeaderFooterInternalBuiltinCSS ( Rewriter R,
FileID  FID,
const char *  title = nullptr 
)
void clang::html::AddLineNumbers ( Rewriter R,
FileID  FID 
)
void clang::html::EscapeText ( Rewriter R,
FileID  FID,
bool  EscapeSpaces = false,
bool  ReplaceTabs = false 
)

EscapeText - HTMLize a specified file so that special characters are are translated so that they are not interpreted as HTML tags.

Definition at line 106 of file HTMLRewrite.cpp.

References AttributeLangSupport::C, clang::SourceManager::getBuffer(), clang::Rewriter::getEditBuffer(), clang::Rewriter::getSourceMgr(), and clang::RewriteBuffer::ReplaceText().

Referenced by AddHeaderFooterInternalBuiltinCSS(), and HighlightMacros().

std::string clang::html::EscapeText ( StringRef  s,
bool  EscapeSpaces = false,
bool  ReplaceTabs = false 
)

EscapeText - HTMLized the provided string so that special characters in 's' are not interpreted as HTML tags. Unlike the version of EscapeText that rewrites a file, this version by default replaces tabs with spaces.

Definition at line 167 of file HTMLRewrite.cpp.

void clang::html::HighlightMacros ( Rewriter R,
FileID  FID,
const Preprocessor PP 
)

HighlightMacros - This uses the macro table state from the end of the file, to reexpand macros and insert (into the HTML) information about the macro expansions. This won't be perfectly perfect, but it will be reasonably close.

HighlightMacros - This uses the macro table state from the end of the file, to re-expand macros and insert (into the HTML) information about the macro expansions. This won't be perfectly perfect, but it will be reasonably close.

Definition at line 446 of file HTMLRewrite.cpp.

References clang::TokenConcatenation::AvoidConcat(), clang::comments::tok::eof, EscapeText(), clang::SourceManager::getBuffer(), clang::DiagnosticsEngine::getDiagnosticIDs(), clang::DiagnosticsEngine::getDiagnosticOptions(), clang::Preprocessor::getDiagnostics(), clang::SourceManager::getExpansionLoc(), clang::SourceManager::getExpansionRange(), clang::SourceManager::getFileID(), clang::Preprocessor::getLangOpts(), clang::Token::getLocation(), clang::Preprocessor::getSourceManager(), clang::Token::hasLeadingSpace(), HighlightRange(), clang::Token::is(), clang::Token::isAtStartOfLine(), clang::SourceLocation::isMacroID(), clang::Token::isNot(), clang::Preprocessor::LookUpIdentifierInfo(), clang::Token::setKind(), and SM.

Referenced by clang::CreateHTMLPrinter().

void clang::html::HighlightRange ( Rewriter R,
SourceLocation  B,
SourceLocation  E,
const char *  StartTag,
const char *  EndTag 
)

HighlightRange - Highlight a range in the source code with the specified start/end tags. B/E must be in the same file. This ensures that start/end tags are placed at the start/end of each line if the range is multiline.

Definition at line 32 of file HTMLRewrite.cpp.

References clang::SourceManager::getBufferData(), clang::Rewriter::getEditBuffer(), clang::SourceManager::getExpansionLoc(), clang::SourceManager::getFileID(), clang::SourceManager::getFileOffset(), clang::Rewriter::getLangOpts(), clang::Rewriter::getSourceMgr(), clang::Lexer::MeasureTokenLength(), and SM.

Referenced by HighlightMacros(), HighlightRange(), and SyntaxHighlight().

void clang::html::HighlightRange ( Rewriter &  R,
SourceRange  Range,
const char *  StartTag,
const char *  EndTag 
) [inline]

HighlightRange - Highlight a range in the source code with the specified start/end tags. The Start/end of the range must be in the same file. This ensures that start/end tags are placed at the start/end of each line if the range is multiline.

Definition at line 40 of file HTMLRewrite.h.

References clang::SourceRange::getBegin(), clang::SourceRange::getEnd(), and HighlightRange().

void clang::html::HighlightRange ( RewriteBuffer RB,
unsigned  B,
unsigned  E,
const char *  BufferStart,
const char *  StartTag,
const char *  EndTag 
)

HighlightRange - This is the same as the above method, but takes decomposed file locations.

Definition at line 57 of file HTMLRewrite.cpp.

References clang::RewriteBuffer::InsertTextAfter(), and clang::RewriteBuffer::InsertTextBefore().

void clang::html::SyntaxHighlight ( Rewriter R,
FileID  FID,
const Preprocessor PP 
)

SyntaxHighlight - Relex the specified FileID and annotate the HTML with information about keywords, comments, etc.

SyntaxHighlight - Relex the specified FileID and annotate the HTML with information about keywords, macro expansions etc. This uses the macro table state from the end of the file, so it won't be perfectly perfect, but it will be reasonably close.

Definition at line 357 of file HTMLRewrite.cpp.

References clang::comments::tok::eof, clang::Lexer::getBuffer(), clang::SourceManager::getBuffer(), clang::Rewriter::getEditBuffer(), clang::SourceManager::getFileOffset(), clang::Token::getKind(), clang::Preprocessor::getLangOpts(), clang::Token::getLength(), clang::Token::getLocation(), clang::Preprocessor::getSourceManager(), HighlightRange(), clang::Token::isAtStartOfLine(), clang::Token::isNot(), clang::Preprocessor::LookUpIdentifierInfo(), and SM.

Referenced by clang::CreateHTMLPrinter().