diff --git a/src/plugins/cpptools/cppmodelmanager.cpp b/src/plugins/cpptools/cppmodelmanager.cpp index 82a851fe1e308ece3f78fb112c95ba4b86ca24b0..0e10f9dc3c23656ff8d1cb183fc095d4ead58a5e 100644 --- a/src/plugins/cpptools/cppmodelmanager.cpp +++ b/src/plugins/cpptools/cppmodelmanager.cpp @@ -560,7 +560,7 @@ public: LookupContext lookupContext(Symbol *symbol) const { - LookupContext context(symbol, Document::create("<none>"), _doc, _snapshot); + LookupContext context(symbol, Document::create(QLatin1String("<none>")), _doc, _snapshot); return context; } diff --git a/src/plugins/cpptools/cppmodelmanager.h b/src/plugins/cpptools/cppmodelmanager.h index 5069f039a82014cc8eebeae24028aab0bf763bfb..2ef684878afaa9b4d7422e4c15394eba961eb5a6 100644 --- a/src/plugins/cpptools/cppmodelmanager.h +++ b/src/plugins/cpptools/cppmodelmanager.h @@ -89,6 +89,8 @@ public: CppEditorSupport *editorSupport(TextEditor::ITextEditor *editor) const { return m_editorSupport.value(editor); } + QMap<QString, QByteArray> buildWorkingCopyList(); + void emitDocumentUpdated(CPlusPlus::Document::Ptr doc); void stopEditorSelectionsUpdate() @@ -117,8 +119,6 @@ private Q_SLOTS: void updateEditorSelections(); private: - QMap<QString, QByteArray> buildWorkingCopyList(); - QStringList projectFiles() { ensureUpdated(); diff --git a/src/plugins/cpptools/cppsemanticsearch.cpp b/src/plugins/cpptools/cppsemanticsearch.cpp index b86e963e073ca785b13b75bfe53fb7ae2e688bb4..2782c40fac60c39cf906aeb520a4b7bfdc1f1759 100644 --- a/src/plugins/cpptools/cppsemanticsearch.cpp +++ b/src/plugins/cpptools/cppsemanticsearch.cpp @@ -262,6 +262,7 @@ SemanticSearch *SearchFunctionCallFactory::create(QFutureInterface<Core::Utils:: static void semanticSearch_helper(QFutureInterface<Core::Utils::FileSearchResult> &future, QPointer<CppModelManager> modelManager, + QMap<QString, QByteArray> wl, SemanticSearchFactory::Ptr factory) { const Snapshot snapshot = modelManager->snapshot(); @@ -273,14 +274,20 @@ static void semanticSearch_helper(QFutureInterface<Core::Utils::FileSearchResult foreach (Document::Ptr doc, snapshot) { const QString fileName = doc->fileName(); - QFile file(fileName); - if (! file.open(QFile::ReadOnly)) - continue; + QByteArray source; + + if (wl.contains(fileName)) + source = wl.value(fileName); + else { + QFile file(fileName); + if (! file.open(QFile::ReadOnly)) + continue; + + const QString contents = QTextStream(&file).readAll(); // ### FIXME + source = snapshot.preprocessedCode(contents.toUtf8(), fileName); + } - const QString contents = QTextStream(&file).readAll(); // ### FIXME - const QByteArray source = snapshot.preprocessedCode(contents.toUtf8(), fileName); Document::Ptr newDoc = snapshot.documentFromSource(source, fileName); - newDoc->parse(); if (SemanticSearch *search = factory->create(future, newDoc, snapshot)) { search->setSource(source); @@ -295,5 +302,6 @@ static void semanticSearch_helper(QFutureInterface<Core::Utils::FileSearchResult QFuture<Core::Utils::FileSearchResult> CppTools::Internal::semanticSearch(QPointer<CppModelManager> modelManager, SemanticSearchFactory::Ptr factory) { - return QtConcurrent::run(&semanticSearch_helper, modelManager, factory); + return QtConcurrent::run(&semanticSearch_helper, modelManager, + modelManager->buildWorkingCopyList(), factory); }