22#include "llvm/ADT/RewriteBuffer.h"
23#include "llvm/Support/raw_ostream.h"
25using llvm::RewriteBuffer;
34 std::unique_ptr<raw_ostream> Out;
36 bool SyntaxHighlight, HighlightMacros;
39 HTMLPrinter(std::unique_ptr<raw_ostream> OS, Preprocessor &pp,
40 bool _SyntaxHighlight,
bool _HighlightMacros)
41 : Out(std::move(
OS)), PP(pp), SyntaxHighlight(_SyntaxHighlight),
42 HighlightMacros(_HighlightMacros) {}
44 void Initialize(ASTContext &context)
override;
45 void HandleTranslationUnit(ASTContext &Ctx)
override;
49std::unique_ptr<ASTConsumer>
51 bool SyntaxHighlight,
bool HighlightMacros) {
52 return std::make_unique<HTMLPrinter>(std::move(OS), PP, SyntaxHighlight,
56void HTMLPrinter::Initialize(
ASTContext &context) {
60void HTMLPrinter::HandleTranslationUnit(ASTContext &Ctx) {
89 std::unique_ptr<char[]> Buffer(
new char[RewriteBuf.size()]);
90 std::copy(RewriteBuf.begin(), RewriteBuf.end(), Buffer.get());
91 Out->write(Buffer.get(), RewriteBuf.size());
Defines the clang::ASTContext interface.
Defines the Diagnostic-related interfaces.
Defines the clang::Preprocessor interface.
Defines the SourceManager interface.
ASTConsumer - This is an abstract interface that should be implemented by clients that read ASTs.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
SourceManager & getSourceManager()
const LangOptions & getLangOpts() const
bool hasErrorOccurred() const
StringRef getName() const
The name of this FileEntry.
Engages in a tight little dance with the lexer to efficiently preprocess tokens.
DiagnosticsEngine & getDiagnostics() const
void setSourceMgr(SourceManager &SM, const LangOptions &LO)
SourceManager & getSourceMgr() const
llvm::RewriteBuffer & getEditBuffer(FileID FID)
getEditBuffer - This is like getRewriteBufferFor, but always returns a buffer, and allows you to writ...
OptionalFileEntryRef getFileEntryRefForID(FileID FID) const
Returns the FileEntryRef for the provided FileID.
FileID getMainFileID() const
Returns the FileID of the main source file.
llvm::MemoryBufferRef getBufferOrFake(FileID FID, SourceLocation Loc=SourceLocation()) const
Return the buffer for the specified FileID.
@ OS
Indicates that the tracking object is a descendant of a referenced-counted OSObject,...
void AddHeaderFooterInternalBuiltinCSS(Rewriter &R, FileID FID, StringRef title)
void AddLineNumbers(Rewriter &R, FileID FID)
void SyntaxHighlight(Rewriter &R, FileID FID, const Preprocessor &PP, RelexRewriteCacheRef Cache=nullptr)
SyntaxHighlight - Relex the specified FileID and annotate the HTML with information about keywords,...
void HighlightMacros(Rewriter &R, FileID FID, const Preprocessor &PP, RelexRewriteCacheRef Cache=nullptr)
HighlightMacros - This uses the macro table state from the end of the file, to reexpand macros and in...
void 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 ...
The JSON file list parser is used to communicate input to InstallAPI.
CustomizableOptional< FileEntryRef > OptionalFileEntryRef
std::unique_ptr< ASTConsumer > CreateHTMLPrinter(std::unique_ptr< raw_ostream > OS, Preprocessor &PP, bool SyntaxHighlight=true, bool HighlightMacros=true)
CreateHTMLPrinter - Create an AST consumer which rewrites source code to HTML with syntax highlightin...