Commit ec769aea authored by Roberto Raggi's avatar Roberto Raggi

Search in the editor buffers.

parent 3ae43daa
......@@ -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;
}
......
......@@ -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();
......
......@@ -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);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment