clang-tools 20.0.0git
Classes | Public Member Functions | List of all members
clang::clangd::Tweak Class Referenceabstract

An interface base for small context-sensitive refactoring actions. More...

#include <Tweak.h>

Classes

struct  Effect
 
struct  Selection
 Input to prepare and apply tweaks. More...
 

Public Member Functions

virtual ~Tweak ()=default
 
virtual const char * id () const =0
 A unique id of the action, it is always equal to the name of the class defining the Tweak.
 
virtual bool prepare (const Selection &Sel)=0
 Run the first stage of the action.
 
virtual Expected< Effectapply (const Selection &Sel)=0
 Run the second stage of the action that would produce the actual effect.
 
virtual std::string title () const =0
 A one-line title of the action that should be shown to the users in the UI.
 
virtual llvm::StringLiteral kind () const =0
 Describes what kind of action this is.
 
virtual bool hidden () const
 Is this a 'hidden' tweak, which are off by default.
 

Detailed Description

An interface base for small context-sensitive refactoring actions.

To implement a new tweak use the following pattern in a .cpp file: class MyTweak : public Tweak { public: const char* id() const override final; // defined by REGISTER_TWEAK. // implement other methods here. }; REGISTER_TWEAK(MyTweak);

Definition at line 46 of file Tweak.h.

Constructor & Destructor Documentation

◆ ~Tweak()

virtual clang::clangd::Tweak::~Tweak ( )
virtualdefault

Member Function Documentation

◆ apply()

virtual Expected< Effect > clang::clangd::Tweak::apply ( const Selection Sel)
pure virtual

Run the second stage of the action that would produce the actual effect.

EXPECTS: prepare() was called and returned true.

◆ hidden()

virtual bool clang::clangd::Tweak::hidden ( ) const
inlinevirtual

Is this a 'hidden' tweak, which are off by default.

Definition at line 125 of file Tweak.h.

◆ id()

virtual const char * clang::clangd::Tweak::id ( ) const
pure virtual

A unique id of the action, it is always equal to the name of the class defining the Tweak.

Definition is provided automatically by REGISTER_TWEAK.

◆ kind()

virtual llvm::StringLiteral clang::clangd::Tweak::kind ( ) const
pure virtual

Describes what kind of action this is.

EXPECTS: prepare() was called and returned true.

◆ prepare()

virtual bool clang::clangd::Tweak::prepare ( const Selection Sel)
pure virtual

Run the first stage of the action.

Returns true indicating that the action is available and should be shown to the user. Returns false if the action is not available. This function should be fast, if the action requires non-trivial work it should be moved into 'apply'. Returns true iff the action is available and apply() can be called on it.

◆ title()

virtual std::string clang::clangd::Tweak::title ( ) const
pure virtual

A one-line title of the action that should be shown to the users in the UI.

EXPECTS: prepare() was called and returned true.


The documentation for this class was generated from the following file: