clang  9.0.0svn
Namespaces | Functions
clang::tooling::fixit Namespace Reference

Namespaces

 internal
 

Functions

template<typename T >
StringRef getText (const T &Node, const ASTContext &Context)
 Returns a textual representation of Node. More...
 
template<typename T >
CharSourceRange getExtendedRange (const T &Node, tok::TokenKind Next, ASTContext &Context)
 Returns the source range spanning the node, extended to include Next, if it immediately follows Node. More...
 
template<typename T >
StringRef getExtendedText (const T &Node, tok::TokenKind Next, ASTContext &Context)
 Returns the source text of the node, extended to include Next, if it immediately follows the node. More...
 
template<typename T >
FixItHint createRemoval (const T &Node)
 
template<typename D , typename S >
FixItHint createReplacement (const D &Destination, const S &Source, const ASTContext &Context)
 
template<typename D >
FixItHint createReplacement (const D &Destination, StringRef Source)
 

Function Documentation

◆ createRemoval()

template<typename T >
FixItHint clang::tooling::fixit::createRemoval ( const T &  Node)

◆ createReplacement() [1/2]

template<typename D , typename S >
FixItHint clang::tooling::fixit::createReplacement ( const D &  Destination,
const S &  Source,
const ASTContext Context 
)

Definition at line 106 of file FixIt.h.

◆ createReplacement() [2/2]

template<typename D >
FixItHint clang::tooling::fixit::createReplacement ( const D &  Destination,
StringRef  Source 
)

◆ getExtendedRange()

template<typename T >
CharSourceRange clang::tooling::fixit::getExtendedRange ( const T &  Node,
tok::TokenKind  Next,
ASTContext Context 
)

Returns the source range spanning the node, extended to include Next, if it immediately follows Node.

Otherwise, returns the normal range of Node. See comments on getExtendedText() for examples.

Definition at line 64 of file FixIt.h.

◆ getExtendedText()

template<typename T >
StringRef clang::tooling::fixit::getExtendedText ( const T &  Node,
tok::TokenKind  Next,
ASTContext Context 
)

Returns the source text of the node, extended to include Next, if it immediately follows the node.

Otherwise, returns the text of just Node.

For example, given statements S1 and S2 below:

{
// S1:
if (!x) return foo();
// S2:
if (!x) { return 3; }
}

then

getText(S1, Context) = "if (!x) return foo()"
getExtendedText(S1, tok::TokenKind::semi, Context)
= "if (!x) return foo();"
getExtendedText(*S1.getThen(), tok::TokenKind::semi, Context)
= "return foo();"
getExtendedText(*S2.getThen(), tok::TokenKind::semi, Context)
= getText(S2, Context) = "{ return 3; }"

Definition at line 93 of file FixIt.h.

◆ getText()

template<typename T >
StringRef clang::tooling::fixit::getText ( const T &  Node,
const ASTContext Context 
)

Returns a textual representation of Node.

Definition at line 56 of file FixIt.h.