MCPcopy Create free account
hub / github.com/KDE/kdevelop / testClassRename

Method testClassRename

plugins/clang/tests/test_refactoring.cpp:50–121  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

48}
49
50void TestRefactoring::testClassRename()
51{
52 const QString codeBefore(QStringLiteral(R"(
53class Foo {
54public:
55 Foo();
56 ~Foo();
57};
58Foo::Foo() {
59}
60Foo::~Foo() {
61}
62 )"));
63
64 const QString codeAfter(QStringLiteral(R"(
65class FooNew {
66public:
67 FooNew();
68 ~FooNew();
69};
70FooNew::FooNew() {
71}
72FooNew::~FooNew() {
73}
74 )"));
75
76 QTemporaryDir dir;
77 auto project = new TestProject(Path(dir.path()), this);
78 m_projectController->addProject(project);
79
80 TestFile file(codeBefore, QStringLiteral("cpp"), project, dir.path());
81 QVERIFY(file.parseAndWait(TopDUContext::AllDeclarationsContextsAndUses));
82
83 DUChainReadLocker lock;
84
85 auto top = file.topContext();
86 QVERIFY(top);
87
88 auto declaration = top->localDeclarations().first();
89 QVERIFY(declaration);
90
91 const QString originalName = declaration->identifier().identifier().str();
92 const QString newName = QStringLiteral("FooNew");
93
94 QSharedPointer<BasicRefactoringCollector> collector(new BasicRefactoringCollector(declaration));
95
96 // TODO: Do this without GUI?
97 UsesWidget uses(declaration, collector);
98 lock.unlock();
99
100 for (int i = 0; i < 30000; i += 1000) {
101 if (collector->isReady()) {
102 break;
103 }
104 QTest::qWait(1000);
105 }
106 QVERIFY(collector->isReady());
107

Callers

nothing calls this directly

Calls 15

parseAndWaitMethod · 0.80
localDeclarationsMethod · 0.80
strMethod · 0.80
languagesForUrlMethod · 0.80
languageControllerMethod · 0.80
fileContentsMethod · 0.80
closeAllProjectsMethod · 0.80
PathClass · 0.50
pathMethod · 0.45
addProjectMethod · 0.45
topContextMethod · 0.45

Tested by

no test coverage detected