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