clang-tools 24.0.0git
StandaloneTweakExample.cpp
Go to the documentation of this file.
1//===--- StandaloneTweakExample.cpp - Example standalone dynamic Tweak ----===//
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#include "refactor/Tweak.h"
10
11namespace clang::clangd {
12namespace {
13
14/// A standalone tweak registered directly via REGISTER_TWEAK without a
15/// FeatureModule.
16class StandaloneTweak final : public Tweak {
17public:
18 const char *id() const override;
19 bool prepare(const Selection &) override { return true; }
20 Expected<Effect> apply(const Selection &) override {
21 return Effect::showMessage("Standalone tweak executed");
22 }
23 std::string title() const override { return "Execute standalone action"; }
24 llvm::StringLiteral kind() const override {
25 return llvm::StringLiteral("quickfix");
26 }
27};
28
29REGISTER_TWEAK(StandaloneTweak)
30
31} // namespace
32} // namespace clang::clangd
#define REGISTER_TWEAK(Subclass)
Definition Tweak.h:129
An interface base for small context-sensitive refactoring actions.
Definition Tweak.h:46
FIXME: Skip testing on windows temporarily due to the different escaping code mode.
Definition AST.cpp:44