forked from qt-creator/qt-creator
Merge remote-tracking branch 'origin/3.1'
This commit is contained in:
@@ -306,6 +306,8 @@ void CppToolsPlugin::test_completion()
|
||||
expectedCompletions.sort();
|
||||
|
||||
QEXPECT_FAIL("enum_in_function_in_struct_in_function", "doesn't work", Abort);
|
||||
QEXPECT_FAIL("nested_class_in_template_class_QTCREATORBUG-11752",
|
||||
"related to infiniteLoopLocalTypedef_QTCREATORBUG-11999", Abort);
|
||||
QCOMPARE(actualCompletions, expectedCompletions);
|
||||
}
|
||||
|
||||
|
||||
@@ -427,7 +427,10 @@ TextEditor::IAssistInterface *InternalCompletionAssistProvider::createAssistInte
|
||||
Q_UNUSED(project);
|
||||
QTC_ASSERT(editor, return 0);
|
||||
QTC_ASSERT(document, return 0);
|
||||
return new CppTools::Internal::CppCompletionAssistInterface(editor, document, position, reason);
|
||||
|
||||
CppModelManagerInterface *modelManager = CppModelManagerInterface::instance();
|
||||
return new CppTools::Internal::CppCompletionAssistInterface(editor, document, position, reason,
|
||||
modelManager->workingCopy());
|
||||
}
|
||||
|
||||
// -----------------
|
||||
@@ -1954,7 +1957,7 @@ void CppCompletionAssistInterface::getCppSpecifics() const
|
||||
CppModelManagerInterface *modelManager = CppModelManagerInterface::instance();
|
||||
if (CppEditorSupport *supp = modelManager->cppEditorSupport(m_editor)) {
|
||||
if (QSharedPointer<SnapshotUpdater> updater = supp->snapshotUpdater()) {
|
||||
updater->update(modelManager->workingCopy());
|
||||
updater->update(m_workingCopy);
|
||||
m_snapshot = updater->snapshot();
|
||||
m_includePaths = updater->includePaths();
|
||||
m_frameworkPaths = updater->frameworkPaths();
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
#define CPPCOMPLETIONASSIST_H
|
||||
|
||||
#include "cppcompletionassistprovider.h"
|
||||
#include "cppmodelmanagerinterface.h"
|
||||
|
||||
#include <cplusplus/Icons.h>
|
||||
#include <cplusplus/TypeOfExpression.h>
|
||||
@@ -175,11 +176,13 @@ public:
|
||||
CppCompletionAssistInterface(TextEditor::BaseTextEditor *editor,
|
||||
QTextDocument *textDocument,
|
||||
int position,
|
||||
TextEditor::AssistReason reason)
|
||||
TextEditor::AssistReason reason,
|
||||
const CppModelManagerInterface::WorkingCopy &workingCopy)
|
||||
: TextEditor::DefaultAssistInterface(textDocument, position, editor->document()->filePath(),
|
||||
reason)
|
||||
, m_editor(editor)
|
||||
, m_gotCppSpecifics(false)
|
||||
, m_workingCopy(workingCopy)
|
||||
{}
|
||||
|
||||
CppCompletionAssistInterface(QTextDocument *textDocument,
|
||||
@@ -206,6 +209,7 @@ private:
|
||||
|
||||
TextEditor::BaseTextEditor *m_editor;
|
||||
mutable bool m_gotCppSpecifics;
|
||||
CppModelManagerInterface::WorkingCopy m_workingCopy;
|
||||
mutable CPlusPlus::Snapshot m_snapshot;
|
||||
mutable QStringList m_includePaths;
|
||||
mutable QStringList m_frameworkPaths;
|
||||
|
||||
@@ -261,10 +261,10 @@ CppCompletionAssistProvider *CppEditorSupport::completionAssistProvider() const
|
||||
|
||||
QSharedPointer<SnapshotUpdater> CppEditorSupport::snapshotUpdater()
|
||||
{
|
||||
QSharedPointer<SnapshotUpdater> updater = m_snapshotUpdater;
|
||||
QSharedPointer<SnapshotUpdater> updater = snapshotUpdater_internal();
|
||||
if (!updater || updater->fileInEditor() != fileName()) {
|
||||
updater = QSharedPointer<SnapshotUpdater>(new SnapshotUpdater(fileName()));
|
||||
m_snapshotUpdater = updater;
|
||||
setSnapshotUpdater_internal(updater);
|
||||
|
||||
QSharedPointer<CppCodeModelSettings> cms = CppToolsPlugin::instance()->codeModelSettings();
|
||||
updater->setUsePrecompiledHeaders(cms->pchUsage() != CppCodeModelSettings::PchUse_None);
|
||||
@@ -282,7 +282,8 @@ void CppEditorSupport::updateDocument()
|
||||
m_updateDocumentTimer->start(m_updateDocumentInterval);
|
||||
}
|
||||
|
||||
static void parse(QFutureInterface<void> &future, QSharedPointer<SnapshotUpdater> updater)
|
||||
static void parse(QFutureInterface<void> &future, QSharedPointer<SnapshotUpdater> updater,
|
||||
CppModelManagerInterface::WorkingCopy workingCopy)
|
||||
{
|
||||
future.setProgressRange(0, 1);
|
||||
if (future.isCanceled()) {
|
||||
@@ -291,7 +292,7 @@ static void parse(QFutureInterface<void> &future, QSharedPointer<SnapshotUpdater
|
||||
}
|
||||
|
||||
CppModelManager *cmm = qobject_cast<CppModelManager *>(CppModelManager::instance());
|
||||
updater->update(cmm->workingCopy());
|
||||
updater->update(workingCopy);
|
||||
cmm->finishedRefreshingSourceFiles(QStringList(updater->fileInEditor()));
|
||||
|
||||
future.setProgressValue(1);
|
||||
@@ -310,7 +311,8 @@ void CppEditorSupport::updateDocumentNow()
|
||||
if (m_highlightingSupport && !m_highlightingSupport->requiresSemanticInfo())
|
||||
startHighlighting();
|
||||
|
||||
m_documentParser = QtConcurrent::run(&parse, snapshotUpdater());
|
||||
m_documentParser = QtConcurrent::run(&parse, snapshotUpdater(),
|
||||
CppModelManager::instance()->workingCopy());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -518,15 +520,8 @@ SemanticInfo::Source CppEditorSupport::currentSource(bool force)
|
||||
int line = 0, column = 0;
|
||||
m_textEditor->convertPosition(m_textEditor->editorWidget()->position(), &line, &column);
|
||||
|
||||
const Snapshot snapshot = snapshotUpdater()->snapshot();
|
||||
|
||||
QByteArray code;
|
||||
if (force || m_lastSemanticInfo.revision != editorRevision())
|
||||
code = contents(); // get the source code only when needed.
|
||||
|
||||
const unsigned revision = editorRevision();
|
||||
SemanticInfo::Source source(snapshot, fileName(), code, line, column, revision, force);
|
||||
return source;
|
||||
return SemanticInfo::Source(Snapshot(), fileName(), contents(), line, column, editorRevision(),
|
||||
force);
|
||||
}
|
||||
|
||||
void CppEditorSupport::recalculateSemanticInfoNow(const SemanticInfo::Source &source,
|
||||
@@ -541,6 +536,7 @@ void CppEditorSupport::recalculateSemanticInfoNow(const SemanticInfo::Source &so
|
||||
semanticInfo.forced = source.force;
|
||||
|
||||
if (!source.force
|
||||
&& m_lastSemanticInfo.complete
|
||||
&& m_lastSemanticInfo.revision == source.revision
|
||||
&& m_lastSemanticInfo.doc
|
||||
&& m_lastSemanticInfo.doc->translationUnit()->ast()
|
||||
@@ -551,9 +547,13 @@ void CppEditorSupport::recalculateSemanticInfoNow(const SemanticInfo::Source &so
|
||||
}
|
||||
|
||||
if (semanticInfo.doc.isNull()) {
|
||||
semanticInfo.snapshot = source.snapshot;
|
||||
if (source.snapshot.contains(source.fileName)) {
|
||||
Document::Ptr doc = source.snapshot.preprocessedDocument(source.code, source.fileName);
|
||||
const QSharedPointer<SnapshotUpdater> snapshotUpdater = snapshotUpdater_internal();
|
||||
QTC_ASSERT(snapshotUpdater, return);
|
||||
semanticInfo.snapshot = snapshotUpdater->snapshot();
|
||||
|
||||
if (semanticInfo.snapshot.contains(source.fileName)) {
|
||||
Document::Ptr doc = semanticInfo.snapshot.preprocessedDocument(source.code,
|
||||
source.fileName);
|
||||
if (processor)
|
||||
doc->control()->setTopLevelDeclarationProcessor(processor);
|
||||
doc->check();
|
||||
@@ -592,6 +592,18 @@ void CppEditorSupport::recalculateSemanticInfoDetached_helper(QFutureInterface<v
|
||||
recalculateSemanticInfoNow(source, true, &processor);
|
||||
}
|
||||
|
||||
QSharedPointer<SnapshotUpdater> CppEditorSupport::snapshotUpdater_internal() const
|
||||
{
|
||||
QMutexLocker locker(&m_snapshotUpdaterLock);
|
||||
return m_snapshotUpdater;
|
||||
}
|
||||
|
||||
void CppEditorSupport::setSnapshotUpdater_internal(const QSharedPointer<SnapshotUpdater> &updater)
|
||||
{
|
||||
QMutexLocker locker(&m_snapshotUpdaterLock);
|
||||
m_snapshotUpdater = updater;
|
||||
}
|
||||
|
||||
void CppEditorSupport::onMimeTypeChanged()
|
||||
{
|
||||
m_highlighter.cancel();
|
||||
|
||||
@@ -197,6 +197,9 @@ private:
|
||||
void recalculateSemanticInfoDetached_helper(QFutureInterface<void> &future,
|
||||
SemanticInfo::Source source);
|
||||
|
||||
QSharedPointer<SnapshotUpdater> snapshotUpdater_internal() const;
|
||||
void setSnapshotUpdater_internal(const QSharedPointer<SnapshotUpdater> &updater);
|
||||
|
||||
private:
|
||||
Internal::CppModelManager *m_modelManager;
|
||||
QPointer<TextEditor::BaseTextEditor> m_textEditor;
|
||||
@@ -225,6 +228,7 @@ private:
|
||||
mutable QMutex m_lastSemanticInfoLock;
|
||||
SemanticInfo m_lastSemanticInfo;
|
||||
QFuture<void> m_futureSemanticInfo;
|
||||
mutable QMutex m_snapshotUpdaterLock;
|
||||
QSharedPointer<SnapshotUpdater> m_snapshotUpdater;
|
||||
|
||||
// Highlighting:
|
||||
|
||||
Reference in New Issue
Block a user