forked from qt-creator/qt-creator
CPlusPlus: Proliferate FilePath use
The starts with CppDocument::filePath(), plus a bit of the fallout This is one patch of potentially many. It is hard to draw the line where to stop this kind of chunk, this here converts a few additional functions for which including it in the patch looked like less churn than without. Converting is mostly fromString/toString, with a few exceptions for "already seem" like caches, that use cheaper "path()" to avoid likely performance regressions (on Windows FilePath comparison is currently case-insenstive, and more expensive). There should be no difference for local operation with this patch. Change-Id: I7b35f98a0a6f0bfed4ea0f8f987faf586f7a8f2b Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
@@ -18,6 +18,7 @@
|
||||
tests the InsertionPointLocator.
|
||||
*/
|
||||
using namespace CPlusPlus;
|
||||
using namespace Utils;
|
||||
|
||||
using CppEditor::Tests::TemporaryDir;
|
||||
|
||||
@@ -42,10 +43,10 @@ Document::Ptr createDocumentAndFile(TemporaryDir *temporaryDir,
|
||||
int expectedGlobalSymbolCount)
|
||||
{
|
||||
QTC_ASSERT(temporaryDir, return Document::Ptr());
|
||||
const QString absoluteFilePath = temporaryDir->createFile(relativeFilePath, text);
|
||||
const FilePath absoluteFilePath = temporaryDir->createFile(relativeFilePath, text);
|
||||
QTC_ASSERT(!absoluteFilePath.isEmpty(), return Document::Ptr());
|
||||
|
||||
return createDocument(absoluteFilePath, text, expectedGlobalSymbolCount);
|
||||
return createDocument(absoluteFilePath.toString(), text, expectedGlobalSymbolCount);
|
||||
}
|
||||
|
||||
} // anonymous namespace
|
||||
@@ -73,7 +74,7 @@ void CodegenTest::testPublicInEmptyClass()
|
||||
CppRefactoringChanges changes(snapshot);
|
||||
InsertionPointLocator find(changes);
|
||||
InsertionLocation loc = find.methodDeclarationInClass(
|
||||
doc->fileName(),
|
||||
doc->filePath(),
|
||||
foo,
|
||||
InsertionPointLocator::Public);
|
||||
QVERIFY(loc.isValid());
|
||||
@@ -107,7 +108,7 @@ void CodegenTest::testPublicInNonemptyClass()
|
||||
CppRefactoringChanges changes(snapshot);
|
||||
InsertionPointLocator find(changes);
|
||||
InsertionLocation loc = find.methodDeclarationInClass(
|
||||
doc->fileName(),
|
||||
doc->filePath(),
|
||||
foo,
|
||||
InsertionPointLocator::Public);
|
||||
QVERIFY(loc.isValid());
|
||||
@@ -141,7 +142,7 @@ void CodegenTest::testPublicBeforeProtected()
|
||||
CppRefactoringChanges changes(snapshot);
|
||||
InsertionPointLocator find(changes);
|
||||
InsertionLocation loc = find.methodDeclarationInClass(
|
||||
doc->fileName(),
|
||||
doc->filePath(),
|
||||
foo,
|
||||
InsertionPointLocator::Public);
|
||||
QVERIFY(loc.isValid());
|
||||
@@ -176,7 +177,7 @@ void CodegenTest::testPrivateAfterProtected()
|
||||
CppRefactoringChanges changes(snapshot);
|
||||
InsertionPointLocator find(changes);
|
||||
InsertionLocation loc = find.methodDeclarationInClass(
|
||||
doc->fileName(),
|
||||
doc->filePath(),
|
||||
foo,
|
||||
InsertionPointLocator::Private);
|
||||
QVERIFY(loc.isValid());
|
||||
@@ -211,7 +212,7 @@ void CodegenTest::testProtectedInNonemptyClass()
|
||||
CppRefactoringChanges changes(snapshot);
|
||||
InsertionPointLocator find(changes);
|
||||
InsertionLocation loc = find.methodDeclarationInClass(
|
||||
doc->fileName(),
|
||||
doc->filePath(),
|
||||
foo,
|
||||
InsertionPointLocator::Protected);
|
||||
QVERIFY(loc.isValid());
|
||||
@@ -246,7 +247,7 @@ void CodegenTest::testProtectedBetweenPublicAndPrivate()
|
||||
CppRefactoringChanges changes(snapshot);
|
||||
InsertionPointLocator find(changes);
|
||||
InsertionLocation loc = find.methodDeclarationInClass(
|
||||
doc->fileName(),
|
||||
doc->filePath(),
|
||||
foo,
|
||||
InsertionPointLocator::Protected);
|
||||
QVERIFY(loc.isValid());
|
||||
@@ -302,7 +303,7 @@ void CodegenTest::testQtdesignerIntegration()
|
||||
CppRefactoringChanges changes(snapshot);
|
||||
InsertionPointLocator find(changes);
|
||||
InsertionLocation loc = find.methodDeclarationInClass(
|
||||
doc->fileName(),
|
||||
doc->filePath(),
|
||||
foo,
|
||||
InsertionPointLocator::PrivateSlot);
|
||||
QVERIFY(loc.isValid());
|
||||
@@ -351,7 +352,7 @@ void CodegenTest::testDefinitionEmptyClass()
|
||||
QList<InsertionLocation> locList = find.methodDefinition(decl);
|
||||
QVERIFY(locList.size() == 1);
|
||||
InsertionLocation loc = locList.first();
|
||||
QCOMPARE(loc.fileName(), sourceDocument->fileName());
|
||||
QCOMPARE(loc.fileName(), sourceDocument->filePath().toString());
|
||||
QCOMPARE(loc.prefix(), QLatin1String("\n\n"));
|
||||
QCOMPARE(loc.suffix(), QString());
|
||||
QCOMPARE(loc.line(), 3);
|
||||
@@ -387,7 +388,7 @@ void CodegenTest::testDefinitionFirstMember()
|
||||
Document::Ptr sourceDocument = createDocumentAndFile(&temporaryDir, "file.cpp", sourceText, 3);
|
||||
QVERIFY(sourceDocument);
|
||||
sourceDocument->addIncludeFile(Document::Include(QLatin1String("file.h"),
|
||||
headerDocument->fileName(), 1,
|
||||
headerDocument->filePath().toString(), 1,
|
||||
Client::IncludeLocal));
|
||||
|
||||
Snapshot snapshot;
|
||||
@@ -409,7 +410,7 @@ void CodegenTest::testDefinitionFirstMember()
|
||||
QList<InsertionLocation> locList = find.methodDefinition(decl);
|
||||
QVERIFY(locList.size() == 1);
|
||||
InsertionLocation loc = locList.first();
|
||||
QCOMPARE(loc.fileName(), sourceDocument->fileName());
|
||||
QCOMPARE(loc.fileName(), sourceDocument->filePath().toString());
|
||||
QCOMPARE(loc.line(), 4);
|
||||
QCOMPARE(loc.column(), 1);
|
||||
QCOMPARE(loc.suffix(), QLatin1String("\n\n"));
|
||||
@@ -446,7 +447,7 @@ void CodegenTest::testDefinitionLastMember()
|
||||
Document::Ptr sourceDocument = createDocumentAndFile(&temporaryDir, "file.cpp", sourceText, 3);
|
||||
QVERIFY(sourceDocument);
|
||||
sourceDocument->addIncludeFile(Document::Include(QLatin1String("file.h"),
|
||||
headerDocument->fileName(), 1,
|
||||
headerDocument->filePath().toString(), 1,
|
||||
Client::IncludeLocal));
|
||||
|
||||
Snapshot snapshot;
|
||||
@@ -468,7 +469,7 @@ void CodegenTest::testDefinitionLastMember()
|
||||
QList<InsertionLocation> locList = find.methodDefinition(decl);
|
||||
QVERIFY(locList.size() == 1);
|
||||
InsertionLocation loc = locList.first();
|
||||
QCOMPARE(loc.fileName(), sourceDocument->fileName());
|
||||
QCOMPARE(loc.fileName(), sourceDocument->filePath().toString());
|
||||
QCOMPARE(loc.line(), 7);
|
||||
QCOMPARE(loc.column(), 2);
|
||||
QCOMPARE(loc.prefix(), QLatin1String("\n\n"));
|
||||
@@ -512,7 +513,7 @@ void CodegenTest::testDefinitionMiddleMember()
|
||||
Document::Ptr sourceDocument = createDocumentAndFile(&temporaryDir, "file.cpp", sourceText, 4);
|
||||
QVERIFY(sourceDocument);
|
||||
sourceDocument->addIncludeFile(Document::Include(QLatin1String("file.h"),
|
||||
headerDocument->fileName(), 1,
|
||||
headerDocument->filePath().toString(), 1,
|
||||
Client::IncludeLocal));
|
||||
|
||||
Snapshot snapshot;
|
||||
@@ -534,7 +535,7 @@ void CodegenTest::testDefinitionMiddleMember()
|
||||
QList<InsertionLocation> locList = find.methodDefinition(decl);
|
||||
QVERIFY(locList.size() == 1);
|
||||
InsertionLocation loc = locList.first();
|
||||
QCOMPARE(loc.fileName(), sourceDocument->fileName());
|
||||
QCOMPARE(loc.fileName(), sourceDocument->filePath().toString());
|
||||
QCOMPARE(loc.line(), 7);
|
||||
QCOMPARE(loc.column(), 2);
|
||||
QCOMPARE(loc.prefix(), QLatin1String("\n\n"));
|
||||
@@ -572,7 +573,7 @@ void CodegenTest::testDefinitionMiddleMemberSurroundedByUndefined()
|
||||
Document::Ptr sourceDocument = createDocumentAndFile(&temporaryDir, "file.cpp", sourceText, 3);
|
||||
QVERIFY(sourceDocument);
|
||||
sourceDocument->addIncludeFile(Document::Include(QLatin1String("file.h"),
|
||||
headerDocument->fileName(), 1,
|
||||
headerDocument->filePath().toString(), 1,
|
||||
Client::IncludeLocal));
|
||||
|
||||
Snapshot snapshot;
|
||||
@@ -594,7 +595,7 @@ void CodegenTest::testDefinitionMiddleMemberSurroundedByUndefined()
|
||||
QList<InsertionLocation> locList = find.methodDefinition(decl);
|
||||
QVERIFY(locList.size() == 1);
|
||||
InsertionLocation loc = locList.first();
|
||||
QCOMPARE(loc.fileName(), sourceDocument->fileName());
|
||||
QCOMPARE(loc.fileName(), sourceDocument->filePath().toString());
|
||||
QCOMPARE(loc.line(), 4);
|
||||
QCOMPARE(loc.column(), 1);
|
||||
QCOMPARE(loc.prefix(), QString());
|
||||
@@ -635,7 +636,7 @@ void CodegenTest::testDefinitionMemberSpecificFile()
|
||||
Document::Ptr sourceDocument = createDocumentAndFile(&temporaryDir, "file.cpp", sourceText, 3);
|
||||
QVERIFY(sourceDocument);
|
||||
sourceDocument->addIncludeFile(Document::Include(QLatin1String("file.h"),
|
||||
headerDocument->fileName(), 1,
|
||||
headerDocument->filePath().toString(), 1,
|
||||
Client::IncludeLocal));
|
||||
|
||||
Snapshot snapshot;
|
||||
@@ -654,10 +655,11 @@ void CodegenTest::testDefinitionMemberSpecificFile()
|
||||
|
||||
CppRefactoringChanges changes(snapshot);
|
||||
InsertionPointLocator find(changes);
|
||||
QList<InsertionLocation> locList = find.methodDefinition(decl, true, sourceDocument->fileName());
|
||||
QList<InsertionLocation> locList =
|
||||
find.methodDefinition(decl, true, sourceDocument->filePath().toString());
|
||||
QVERIFY(locList.size() == 1);
|
||||
InsertionLocation loc = locList.first();
|
||||
QCOMPARE(loc.fileName(), sourceDocument->fileName());
|
||||
QCOMPARE(loc.fileName(), sourceDocument->filePath().toString());
|
||||
QCOMPARE(loc.line(), 7);
|
||||
QCOMPARE(loc.column(), 2);
|
||||
QCOMPARE(loc.prefix(), QLatin1String("\n\n"));
|
||||
|
||||
Reference in New Issue
Block a user