diff options
author | Erik Verbruggen <erik.verbruggen@digia.com> | 2014-11-27 12:11:46 +0100 |
---|---|---|
committer | Erik Verbruggen <erik.verbruggen@theqtcompany.com> | 2014-12-17 14:32:17 +0100 |
commit | a48adcf9be144eff9f22f30195e834f869fe19b4 (patch) | |
tree | e80ea9ea39345dbdeb060a04b95b1c46919396cc /src/plugins/cpptools/cppfindreferences.cpp | |
parent | a8ece5e9b0b92b36a4b513696afcc8ca6781e447 (diff) | |
download | qt-creator-a48adcf9be144eff9f22f30195e834f869fe19b4.tar.gz |
C++: handle case-insensitive file names in the CPlusPlus::Snapshot
... by keying on Utils::FileName
Task-number: QTCREATORBUG-12390
Change-Id: Ia98afb5a9160a7fd9225a2f9e02539ff3c35ae86
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
Diffstat (limited to 'src/plugins/cpptools/cppfindreferences.cpp')
-rw-r--r-- | src/plugins/cpptools/cppfindreferences.cpp | 36 |
1 files changed, 20 insertions, 16 deletions
diff --git a/src/plugins/cpptools/cppfindreferences.cpp b/src/plugins/cpptools/cppfindreferences.cpp index 9b18b689fd..2c8856c4b8 100644 --- a/src/plugins/cpptools/cppfindreferences.cpp +++ b/src/plugins/cpptools/cppfindreferences.cpp @@ -55,7 +55,7 @@ using namespace CppTools::Internal; using namespace CppTools; using namespace CPlusPlus; -static QByteArray getSource(const QString &fileName, +static QByteArray getSource(const Utils::FileName &fileName, const WorkingCopy &workingCopy) { if (workingCopy.contains(fileName)) { @@ -66,7 +66,7 @@ static QByteArray getSource(const QString &fileName, QString error; QTextCodec *defaultCodec = EditorManager::defaultTextCodec(); Utils::TextFileFormat::ReadResult result = Utils::TextFileFormat::readFile( - fileName, defaultCodec, &fileContents, &format, &error); + fileName.toString(), defaultCodec, &fileContents, &format, &error); if (result != Utils::TextFileFormat::ReadSuccess) qWarning() << "Could not read " << fileName << ". Error: " << error; @@ -188,7 +188,7 @@ public: future(future) { } - QList<Usage> operator()(const QString &fileName) + QList<Usage> operator()(const Utils::FileName &fileName) { QList<Usage> usages; if (future->isPaused()) @@ -205,7 +205,7 @@ public: Document::Ptr doc; const QByteArray unpreprocessedSource = getSource(fileName, workingCopy); - if (symbolDocument && fileName == symbolDocument->fileName()) { + if (symbolDocument && fileName == Utils::FileName::fromString(symbolDocument->fileName())) { doc = symbolDocument; } else { doc = snapshot.preprocessedDocument(unpreprocessedSource, fileName); @@ -278,22 +278,24 @@ static void find_helper(QFutureInterface<Usage> &future, const Snapshot snapshot = context.snapshot(); - const QString sourceFile = QString::fromUtf8(symbol->fileName(), symbol->fileNameLength()); - QStringList files(sourceFile); + const Utils::FileName sourceFile = Utils::FileName::fromUtf8(symbol->fileName(), + symbol->fileNameLength()); + Utils::FileNameList files(sourceFile); if (symbol->isClass() || symbol->isForwardClassDeclaration() || (symbol->enclosingScope() && !symbol->isStatic() && symbol->enclosingScope()->isNamespace())) { - foreach (const Document::Ptr &doc, context.snapshot()) { - if (doc->fileName() == sourceFile) + const Snapshot snapshotFromContext = context.snapshot(); + for (auto i = snapshotFromContext.begin(), ei = snapshotFromContext.end(); i != ei; ++i) { + if (i.key() == sourceFile) continue; - Control *control = doc->control(); + const Control *control = i.value()->control(); if (control->findIdentifier(symbolId->chars(), symbolId->size())) - files.append(doc->fileName()); + files.append(i.key()); } } else { files += snapshot.filesDependingOn(sourceFile); @@ -452,7 +454,8 @@ CPlusPlus::Symbol *CppFindReferences::findSymbol(const CppFindReferencesParamete Document::Ptr newSymbolDocument = snapshot.document(symbolFile); // document is not parsed and has no bindings yet, do it - QByteArray source = getSource(newSymbolDocument->fileName(), m_modelManager->workingCopy()); + QByteArray source = getSource(Utils::FileName::fromString(newSymbolDocument->fileName()), + m_modelManager->workingCopy()); Document::Ptr doc = snapshot.preprocessedDocument(source, newSymbolDocument->fileName()); doc->check(); @@ -543,7 +546,7 @@ public: : workingCopy(workingCopy), snapshot(snapshot), macro(macro), future(future) { } - QList<Usage> operator()(const QString &fileName) + QList<Usage> operator()(const Utils::FileName &fileName) { QList<Usage> usages; Document::Ptr doc = snapshot.document(fileName); @@ -573,7 +576,7 @@ restart_search: if (macro.name() == useMacro.name()) { unsigned column; const QString &lineSource = matchingLine(use.bytesBegin(), source, &column); - usages.append(Usage(fileName, lineSource, use.beginLine(), column, + usages.append(Usage(fileName.toString(), lineSource, use.beginLine(), column, useMacro.nameToQString().size())); } } @@ -614,8 +617,8 @@ static void findMacroUses_helper(QFutureInterface<Usage> &future, const Snapshot snapshot, const Macro macro) { - const QString& sourceFile = macro.fileName(); - QStringList files(sourceFile); + const Utils::FileName sourceFile = Utils::FileName::fromString(macro.fileName()); + Utils::FileNameList files(sourceFile); files += snapshot.filesDependingOn(sourceFile); files.removeDuplicates(); @@ -662,7 +665,8 @@ void CppFindReferences::findMacroUses(const Macro ¯o, const QString &replace // add the macro definition itself { - const QByteArray &source = getSource(macro.fileName(), workingCopy); + const QByteArray &source = getSource(Utils::FileName::fromString(macro.fileName()), + workingCopy); unsigned column; const QString line = FindMacroUsesInFile::matchingLine(macro.bytesOffset(), source, &column); |