clang 10.0.0git

HTMLRewrite.h
Go to the documentation of this file.
1 //==- HTMLRewrite.h - Translate source code into prettified HTML ---*- C++ -*-//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file defines a set of functions used for translating source code
10 // into beautified HTML.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #ifndef LLVM_CLANG_REWRITE_CORE_HTMLREWRITE_H
15 #define LLVM_CLANG_REWRITE_CORE_HTMLREWRITE_H
16
17 #include "clang/Basic/SourceLocation.h"
18 #include <string>
19
20 namespace clang {
21
22 class Rewriter;
23 class RewriteBuffer;
24 class Preprocessor;
25
26 namespace html {
27
28 /// HighlightRange - Highlight a range in the source code with the specified
29 /// start/end tags. B/E must be in the same file. This ensures that
30 /// start/end tags are placed at the start/end of each line if the range is
31 /// multiline.
32 void HighlightRange(Rewriter &R, SourceLocation B, SourceLocation E,
33 const char *StartTag, const char *EndTag,
34 bool IsTokenRange = true);
35
36 /// HighlightRange - Highlight a range in the source code with the specified
37 /// start/end tags. The Start/end of the range must be in the same file.
38 /// This ensures that start/end tags are placed at the start/end of each line
39 /// if the range is multiline.
40 inline void HighlightRange(Rewriter &R, SourceRange Range,
41 const char *StartTag, const char *EndTag) {
42 HighlightRange(R, Range.getBegin(), Range.getEnd(), StartTag, EndTag);
43 }
44
45 /// HighlightRange - This is the same as the above method, but takes
46 /// decomposed file locations.
47 void HighlightRange(RewriteBuffer &RB, unsigned B, unsigned E,
48 const char *BufferStart,
49 const char *StartTag, const char *EndTag);
50
51 /// EscapeText - HTMLize a specified file so that special characters are
52 /// are translated so that they are not interpreted as HTML tags.
53 void EscapeText(Rewriter& R, FileID FID,
54 bool EscapeSpaces = false, bool ReplaceTabs = false);
55
56 /// EscapeText - HTMLized the provided string so that special characters
57 /// in 's' are not interpreted as HTML tags. Unlike the version of
58 /// EscapeText that rewrites a file, this version by default replaces tabs
59 /// with spaces.
60 std::string EscapeText(StringRef s,
61 bool EscapeSpaces = false, bool ReplaceTabs = false);
62
63 void AddLineNumbers(Rewriter& R, FileID FID);
64
65 void AddHeaderFooterInternalBuiltinCSS(Rewriter &R, FileID FID,
66 StringRef title);
67
68 /// SyntaxHighlight - Relex the specified FileID and annotate the HTML with
69 /// information about keywords, comments, etc.
70 void SyntaxHighlight(Rewriter &R, FileID FID, const Preprocessor &PP);
71
72 /// HighlightMacros - This uses the macro table state from the end of the
73 /// file, to reexpand macros and insert (into the HTML) information about the
74 /// macro expansions. This won't be perfectly perfect, but it will be
75 /// reasonably close.
76 void HighlightMacros(Rewriter &R, FileID FID, const Preprocessor &PP);
77
78 } // end html namespace
79 } // end clang namespace
80
81 #endif
clang::RewriteBuffer
RewriteBuffer - As code is rewritten, SourceBuffer&#39;s from the original input with modifications get a...
Definition: RewriteBuffer.h:25
clang::html::HighlightMacros
void 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 in...
Definition: HTMLRewrite.cpp:534
clang::html::AddLineNumbers
void AddLineNumbers(Rewriter &R, FileID FID)
Definition: HTMLRewrite.cpp:227
clang::html::SyntaxHighlight
void SyntaxHighlight(Rewriter &R, FileID FID, const Preprocessor &PP)
SyntaxHighlight - Relex the specified FileID and annotate the HTML with information about keywords...
Definition: HTMLRewrite.cpp:444
clang::SourceRange::getEnd
SourceLocation getEnd() const
Definition: SourceLocation.h:217
clang::SourceLocation
Encodes a location in the source.
Definition: SourceLocation.h:86
clang::html::EscapeText
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 ...
Definition: HTMLRewrite.cpp:107
clang::FileID
An opaque identifier used by SourceManager which refers to a source file (MemoryBuffer) along with it...
Definition: SourceLocation.h:38
clang
Dataflow Directional Tag Classes.
Definition: CFGReachabilityAnalysis.h:21
clang::html::AddHeaderFooterInternalBuiltinCSS
void AddHeaderFooterInternalBuiltinCSS(Rewriter &R, FileID FID, StringRef title)
Definition: HTMLRewrite.cpp:274
clang::Rewriter
Rewriter - This is the main interface to the rewrite buffers.
Definition: Rewriter.h:32
SourceLocation.h
Defines the clang::SourceLocation class and associated facilities.
clang::html::HighlightRange
void HighlightRange(Rewriter &R, SourceLocation B, SourceLocation E, const char *StartTag, const char *EndTag, bool IsTokenRange=true)
HighlightRange - Highlight a range in the source code with the specified start/end tags...
Definition: HTMLRewrite.cpp:31
clang::SourceRange
A trivial tuple used to represent a source range.
Definition: SourceLocation.h:207
clang::SourceRange::getBegin
SourceLocation getBegin() const
Definition: SourceLocation.h:216
clang::Preprocessor
Engages in a tight little dance with the lexer to efficiently preprocess tokens.
Definition: Preprocessor.h:128