forked from qt-creator/qt-creator
CppEditor: Convert parts of ModelManagerInterface to FilePath
Change-Id: If7503b6d6732e1735eb8d48ece6e80886d10c647 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
@@ -773,7 +773,7 @@ void ClangdClient::updateParserConfig(const Utils::FilePath &filePath,
|
|||||||
const auto projectPart = !config.preferredProjectPartId.isEmpty()
|
const auto projectPart = !config.preferredProjectPartId.isEmpty()
|
||||||
? CppEditor::CppModelManager::instance()->projectPartForId(
|
? CppEditor::CppModelManager::instance()->projectPartForId(
|
||||||
config.preferredProjectPartId)
|
config.preferredProjectPartId)
|
||||||
: projectPartForFile(filePath.toString());
|
: projectPartForFile(filePath);
|
||||||
if (!projectPart)
|
if (!projectPart)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|||||||
@@ -426,8 +426,7 @@ IAssistProposal *CustomAssistProcessor::perform()
|
|||||||
}
|
}
|
||||||
case CustomAssistMode::IncludePath: {
|
case CustomAssistMode::IncludePath: {
|
||||||
HeaderPaths headerPaths;
|
HeaderPaths headerPaths;
|
||||||
const ProjectPart::ConstPtr projectPart
|
const ProjectPart::ConstPtr projectPart = projectPartForFile(interface()->filePath());
|
||||||
= projectPartForFile(interface()->filePath().toString());
|
|
||||||
if (projectPart)
|
if (projectPart)
|
||||||
headerPaths = projectPart->headerPaths;
|
headerPaths = projectPart->headerPaths;
|
||||||
completions = completeInclude(m_endPos, m_completionOperator, interface(), headerPaths);
|
completions = completeInclude(m_endPos, m_completionOperator, interface(), headerPaths);
|
||||||
|
|||||||
@@ -92,7 +92,7 @@ CppEditor::BaseEditorDocumentParser::Configuration ClangEditorDocumentProcessor:
|
|||||||
return parser()->configuration();
|
return parser()->configuration();
|
||||||
}
|
}
|
||||||
|
|
||||||
ClangEditorDocumentProcessor *ClangEditorDocumentProcessor::get(const QString &filePath)
|
ClangEditorDocumentProcessor *ClangEditorDocumentProcessor::get(const Utils::FilePath &filePath)
|
||||||
{
|
{
|
||||||
return qobject_cast<ClangEditorDocumentProcessor*>(
|
return qobject_cast<ClangEditorDocumentProcessor*>(
|
||||||
CppEditor::CppModelManager::cppEditorDocumentProcessor(filePath));
|
CppEditor::CppModelManager::cppEditorDocumentProcessor(filePath));
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ public:
|
|||||||
CppEditor::BaseEditorDocumentParser::Configuration parserConfig();
|
CppEditor::BaseEditorDocumentParser::Configuration parserConfig();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static ClangEditorDocumentProcessor *get(const QString &filePath);
|
static ClangEditorDocumentProcessor *get(const Utils::FilePath &filePath);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void parserConfigChanged(const Utils::FilePath &filePath,
|
void parserConfigChanged(const Utils::FilePath &filePath,
|
||||||
|
|||||||
@@ -162,7 +162,7 @@ static void updateParserConfig(ClangdClient *client)
|
|||||||
if (!client->documentOpen(editor->textDocument()))
|
if (!client->documentOpen(editor->textDocument()))
|
||||||
return;
|
return;
|
||||||
const Utils::FilePath filePath = editor->textDocument()->filePath();
|
const Utils::FilePath filePath = editor->textDocument()->filePath();
|
||||||
if (const auto processor = ClangEditorDocumentProcessor::get(filePath.toString()))
|
if (const auto processor = ClangEditorDocumentProcessor::get(filePath))
|
||||||
client->updateParserConfig(filePath, processor->parserConfig());
|
client->updateParserConfig(filePath, processor->parserConfig());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -395,7 +395,7 @@ void ClangModelManagerSupport::onCurrentEditorChanged(Core::IEditor *editor)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
const ::Utils::FilePath filePath = editor->document()->filePath();
|
const ::Utils::FilePath filePath = editor->document()->filePath();
|
||||||
if (auto processor = ClangEditorDocumentProcessor::get(filePath.toString())) {
|
if (auto processor = ClangEditorDocumentProcessor::get(filePath)) {
|
||||||
processor->semanticRehighlight();
|
processor->semanticRehighlight();
|
||||||
if (const auto client = clientForFile(filePath)) {
|
if (const auto client = clientForFile(filePath)) {
|
||||||
client->updateParserConfig(filePath, processor->parserConfig());
|
client->updateParserConfig(filePath, processor->parserConfig());
|
||||||
@@ -806,7 +806,7 @@ void ClangModelManagerSupport::onTextMarkContextMenuRequested(TextEditor::TextEd
|
|||||||
QTC_ASSERT(lineNumber >= 1, return);
|
QTC_ASSERT(lineNumber >= 1, return);
|
||||||
QTC_ASSERT(menu, return);
|
QTC_ASSERT(menu, return);
|
||||||
|
|
||||||
const auto filePath = widget->textDocument()->filePath().toString();
|
const Utils::FilePath filePath = widget->textDocument()->filePath();
|
||||||
ClangEditorDocumentProcessor *processor = ClangEditorDocumentProcessor::get(filePath);
|
ClangEditorDocumentProcessor *processor = ClangEditorDocumentProcessor::get(filePath);
|
||||||
if (processor) {
|
if (processor) {
|
||||||
const auto assistInterface = createAssistInterface(widget, lineNumber);
|
const auto assistInterface = createAssistInterface(widget, lineNumber);
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ namespace {
|
|||||||
|
|
||||||
Project *projectForCurrentEditor()
|
Project *projectForCurrentEditor()
|
||||||
{
|
{
|
||||||
const QString filePath = currentCppEditorDocumentFilePath();
|
const FilePath filePath = currentCppEditorDocumentFilePath();
|
||||||
if (filePath.isEmpty())
|
if (filePath.isEmpty())
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ using namespace Utils;
|
|||||||
namespace ClangCodeModel {
|
namespace ClangCodeModel {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
ProjectPart::ConstPtr projectPartForFile(const QString &filePath)
|
ProjectPart::ConstPtr projectPartForFile(const FilePath &filePath)
|
||||||
{
|
{
|
||||||
if (const auto parser = CppEditor::BaseEditorDocumentParser::get(filePath))
|
if (const auto parser = CppEditor::BaseEditorDocumentParser::get(filePath))
|
||||||
return parser->projectPartInfo().projectPart;
|
return parser->projectPartInfo().projectPart;
|
||||||
@@ -197,15 +197,14 @@ GenerateCompilationDbResult generateCompilationDB(QList<ProjectInfo::ConstPtr> p
|
|||||||
return GenerateCompilationDbResult(compileCommandsFile.fileName(), QString());
|
return GenerateCompilationDbResult(compileCommandsFile.fileName(), QString());
|
||||||
}
|
}
|
||||||
|
|
||||||
QString currentCppEditorDocumentFilePath()
|
FilePath currentCppEditorDocumentFilePath()
|
||||||
{
|
{
|
||||||
QString filePath;
|
FilePath filePath;
|
||||||
|
|
||||||
const auto currentEditor = Core::EditorManager::currentEditor();
|
const auto currentEditor = Core::EditorManager::currentEditor();
|
||||||
if (currentEditor && CppEditor::CppModelManager::isCppEditor(currentEditor)) {
|
if (currentEditor && CppEditor::CppModelManager::isCppEditor(currentEditor)) {
|
||||||
const auto currentDocument = currentEditor->document();
|
if (const auto currentDocument = currentEditor->document())
|
||||||
if (currentDocument)
|
filePath = currentDocument->filePath();
|
||||||
filePath = currentDocument->filePath().toString();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return filePath;
|
return filePath;
|
||||||
|
|||||||
@@ -47,9 +47,9 @@ QJsonArray clangOptionsForFile(const CppEditor::ProjectFile &file,
|
|||||||
const QJsonArray &generalOptions,
|
const QJsonArray &generalOptions,
|
||||||
CppEditor::UsePrecompiledHeaders usePch, bool clStyle);
|
CppEditor::UsePrecompiledHeaders usePch, bool clStyle);
|
||||||
|
|
||||||
CppEditor::ProjectPart::ConstPtr projectPartForFile(const QString &filePath);
|
CppEditor::ProjectPart::ConstPtr projectPartForFile(const Utils::FilePath &filePath);
|
||||||
|
|
||||||
QString currentCppEditorDocumentFilePath();
|
Utils::FilePath currentCppEditorDocumentFilePath();
|
||||||
|
|
||||||
QString diagnosticCategoryPrefixRemoved(const QString &text);
|
QString diagnosticCategoryPrefixRemoved(const QString &text);
|
||||||
|
|
||||||
|
|||||||
@@ -243,13 +243,13 @@ public:
|
|||||||
static Command::Ptr parse(BatchFileLineTokenizer &arguments, const CommandContext &context);
|
static Command::Ptr parse(BatchFileLineTokenizer &arguments, const CommandContext &context);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QString m_documentFilePath;
|
Utils::FilePath m_documentFilePath;
|
||||||
};
|
};
|
||||||
|
|
||||||
OpenDocumentCommand::OpenDocumentCommand(const CommandContext &context,
|
OpenDocumentCommand::OpenDocumentCommand(const CommandContext &context,
|
||||||
const QString &documentFilePath)
|
const QString &documentFilePath)
|
||||||
: Command(context)
|
: Command(context)
|
||||||
, m_documentFilePath(documentFilePath)
|
, m_documentFilePath(Utils::FilePath::fromString(documentFilePath))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -298,8 +298,7 @@ bool OpenDocumentCommand::run()
|
|||||||
{
|
{
|
||||||
qCDebug(debug) << "line" << context().lineNumber << "OpenDocumentCommand" << m_documentFilePath;
|
qCDebug(debug) << "line" << context().lineNumber << "OpenDocumentCommand" << m_documentFilePath;
|
||||||
|
|
||||||
const bool openEditorSucceeded = Core::EditorManager::openEditor(
|
const bool openEditorSucceeded = Core::EditorManager::openEditor(m_documentFilePath);
|
||||||
Utils::FilePath::fromString(m_documentFilePath));
|
|
||||||
QTC_ASSERT(openEditorSucceeded, return false);
|
QTC_ASSERT(openEditorSucceeded, return false);
|
||||||
|
|
||||||
auto *processor = ClangEditorDocumentProcessor::get(m_documentFilePath);
|
auto *processor = ClangEditorDocumentProcessor::get(m_documentFilePath);
|
||||||
@@ -393,8 +392,8 @@ bool InsertTextCommand::run()
|
|||||||
|
|
||||||
TextEditor::BaseTextEditor *editor = currentTextEditor();
|
TextEditor::BaseTextEditor *editor = currentTextEditor();
|
||||||
QTC_ASSERT(editor, return false);
|
QTC_ASSERT(editor, return false);
|
||||||
const QString documentFilePath = editor->document()->filePath().toString();
|
const Utils::FilePath documentFilePath = editor->document()->filePath();
|
||||||
auto *processor = ClangEditorDocumentProcessor::get(documentFilePath);
|
auto processor = ClangEditorDocumentProcessor::get(documentFilePath);
|
||||||
QTC_ASSERT(processor, return false);
|
QTC_ASSERT(processor, return false);
|
||||||
|
|
||||||
editor->insert(m_textToInsert);
|
editor->insert(m_textToInsert);
|
||||||
|
|||||||
@@ -87,7 +87,7 @@ ProjectPartInfo BaseEditorDocumentParser::projectPartInfo() const
|
|||||||
return state().projectPartInfo;
|
return state().projectPartInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
BaseEditorDocumentParser::Ptr BaseEditorDocumentParser::get(const QString &filePath)
|
BaseEditorDocumentParser::Ptr BaseEditorDocumentParser::get(const FilePath &filePath)
|
||||||
{
|
{
|
||||||
CppModelManager *cmmi = CppModelManager::instance();
|
CppModelManager *cmmi = CppModelManager::instance();
|
||||||
if (CppEditorDocumentHandle *cppEditorDocument = cmmi->cppEditorDocument(filePath)) {
|
if (CppEditorDocumentHandle *cppEditorDocument = cmmi->cppEditorDocument(filePath)) {
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ class CPPEDITOR_EXPORT BaseEditorDocumentParser : public QObject
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
using Ptr = QSharedPointer<BaseEditorDocumentParser>;
|
using Ptr = QSharedPointer<BaseEditorDocumentParser>;
|
||||||
static Ptr get(const QString &filePath);
|
static Ptr get(const Utils::FilePath &filePath);
|
||||||
|
|
||||||
struct Configuration {
|
struct Configuration {
|
||||||
bool usePrecompiledHeaders = false;
|
bool usePrecompiledHeaders = false;
|
||||||
|
|||||||
@@ -239,7 +239,7 @@ ProjectExplorer::HeaderPaths BuiltinEditorDocumentParser::headerPaths() const
|
|||||||
return extraState().headerPaths;
|
return extraState().headerPaths;
|
||||||
}
|
}
|
||||||
|
|
||||||
BuiltinEditorDocumentParser::Ptr BuiltinEditorDocumentParser::get(const QString &filePath)
|
BuiltinEditorDocumentParser::Ptr BuiltinEditorDocumentParser::get(const FilePath &filePath)
|
||||||
{
|
{
|
||||||
if (BaseEditorDocumentParser::Ptr b = BaseEditorDocumentParser::get(filePath))
|
if (BaseEditorDocumentParser::Ptr b = BaseEditorDocumentParser::get(filePath))
|
||||||
return b.objectCast<BuiltinEditorDocumentParser>();
|
return b.objectCast<BuiltinEditorDocumentParser>();
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ signals:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
using Ptr = QSharedPointer<BuiltinEditorDocumentParser>;
|
using Ptr = QSharedPointer<BuiltinEditorDocumentParser>;
|
||||||
static Ptr get(const QString &filePath);
|
static Ptr get(const Utils::FilePath &filePath);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void updateImpl(const QFutureInterface<void> &future,
|
void updateImpl(const QFutureInterface<void> &future,
|
||||||
|
|||||||
@@ -1515,7 +1515,7 @@ void CppCodeModelInspectorDialog::refresh()
|
|||||||
TextEditor::BaseTextEditor *editor = currentEditor();
|
TextEditor::BaseTextEditor *editor = currentEditor();
|
||||||
CppEditorDocumentHandle *cppEditorDocument = nullptr;
|
CppEditorDocumentHandle *cppEditorDocument = nullptr;
|
||||||
if (editor) {
|
if (editor) {
|
||||||
const QString editorFilePath = editor->document()->filePath().toString();
|
const FilePath editorFilePath = editor->document()->filePath();
|
||||||
cppEditorDocument = cmmi->cppEditorDocument(editorFilePath);
|
cppEditorDocument = cmmi->cppEditorDocument(editorFilePath);
|
||||||
if (auto documentProcessor = CppModelManager::cppEditorDocumentProcessor(editorFilePath)) {
|
if (auto documentProcessor = CppModelManager::cppEditorDocumentProcessor(editorFilePath)) {
|
||||||
const Snapshot editorSnapshot = documentProcessor->snapshot();
|
const Snapshot editorSnapshot = documentProcessor->snapshot();
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ public:
|
|||||||
m_textDocument = m_editorWidget->document();
|
m_textDocument = m_editorWidget->document();
|
||||||
|
|
||||||
// Get Document
|
// Get Document
|
||||||
const Document::Ptr document = waitForFileInGlobalSnapshot(filePath.toString());
|
const Document::Ptr document = waitForFileInGlobalSnapshot(filePath);
|
||||||
QVERIFY(document);
|
QVERIFY(document);
|
||||||
QVERIFY(document->diagnosticMessages().isEmpty());
|
QVERIFY(document->diagnosticMessages().isEmpty());
|
||||||
|
|
||||||
|
|||||||
@@ -411,7 +411,7 @@ std::unique_ptr<AssistInterface> InternalCompletionAssistProvider::createAssistI
|
|||||||
return std::make_unique<CppCompletionAssistInterface>(
|
return std::make_unique<CppCompletionAssistInterface>(
|
||||||
filePath,
|
filePath,
|
||||||
textEditorWidget,
|
textEditorWidget,
|
||||||
BuiltinEditorDocumentParser::get(filePath.toString()),
|
BuiltinEditorDocumentParser::get(filePath),
|
||||||
languageFeatures,
|
languageFeatures,
|
||||||
reason,
|
reason,
|
||||||
CppModelManager::instance()->workingCopy());
|
CppModelManager::instance()->workingCopy());
|
||||||
|
|||||||
@@ -197,7 +197,7 @@ void CppIncludeHierarchyItem::fetchMore()
|
|||||||
|
|
||||||
model()->m_seen.insert(m_filePath);
|
model()->m_seen.insert(m_filePath);
|
||||||
|
|
||||||
const QString editorFilePath = model()->editorFilePath();
|
const FilePath editorFilePath = FilePath::fromString(model()->editorFilePath());
|
||||||
|
|
||||||
setChildrenChecked();
|
setChildrenChecked();
|
||||||
if (m_subTree == InIncludes) {
|
if (m_subTree == InIncludes) {
|
||||||
|
|||||||
@@ -69,14 +69,14 @@ class CppCurrentDocumentFilterTestCase
|
|||||||
, public CppEditor::Tests::TestCase
|
, public CppEditor::Tests::TestCase
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CppCurrentDocumentFilterTestCase(const QString &fileName,
|
CppCurrentDocumentFilterTestCase(const FilePath &filePath,
|
||||||
const ResultDataList &expectedResults,
|
const ResultDataList &expectedResults,
|
||||||
const QString &searchText = QString())
|
const QString &searchText = QString())
|
||||||
: BasicLocatorFilterTest(CppModelManager::instance()->currentDocumentFilter())
|
: BasicLocatorFilterTest(CppModelManager::instance()->currentDocumentFilter())
|
||||||
, m_fileName(fileName)
|
, m_filePath(filePath)
|
||||||
{
|
{
|
||||||
QVERIFY(succeededSoFar());
|
QVERIFY(succeededSoFar());
|
||||||
QVERIFY(!m_fileName.isEmpty());
|
QVERIFY(!m_filePath.isEmpty());
|
||||||
|
|
||||||
ResultDataList results = ResultData::fromFilterEntryList(matchesFor(searchText));
|
ResultDataList results = ResultData::fromFilterEntryList(matchesFor(searchText));
|
||||||
if (debug) {
|
if (debug) {
|
||||||
@@ -93,10 +93,10 @@ private:
|
|||||||
QVERIFY(DocumentModel::openedDocuments().isEmpty());
|
QVERIFY(DocumentModel::openedDocuments().isEmpty());
|
||||||
QVERIFY(garbageCollectGlobalSnapshot());
|
QVERIFY(garbageCollectGlobalSnapshot());
|
||||||
|
|
||||||
m_editor = EditorManager::openEditor(FilePath::fromString(m_fileName));
|
m_editor = EditorManager::openEditor(m_filePath);
|
||||||
QVERIFY(m_editor);
|
QVERIFY(m_editor);
|
||||||
|
|
||||||
QVERIFY(waitForFileInGlobalSnapshot(m_fileName));
|
QVERIFY(waitForFileInGlobalSnapshot(m_filePath));
|
||||||
}
|
}
|
||||||
|
|
||||||
void doAfterLocatorRun() override
|
void doAfterLocatorRun() override
|
||||||
@@ -109,7 +109,7 @@ private:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
IEditor *m_editor = nullptr;
|
IEditor *m_editor = nullptr;
|
||||||
const QString m_fileName;
|
const FilePath m_filePath;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // anonymous namespace
|
} // anonymous namespace
|
||||||
@@ -301,7 +301,7 @@ void LocatorFilterTest::testLocatorFilter_data()
|
|||||||
void LocatorFilterTest::testCurrentDocumentFilter()
|
void LocatorFilterTest::testCurrentDocumentFilter()
|
||||||
{
|
{
|
||||||
MyTestDataDir testDirectory("testdata_basic");
|
MyTestDataDir testDirectory("testdata_basic");
|
||||||
const QString testFile = testDirectory.file("file1.cpp");
|
const FilePath testFile = testDirectory.filePath("file1.cpp");
|
||||||
|
|
||||||
auto expectedResults = ResultDataList{
|
auto expectedResults = ResultDataList{
|
||||||
ResultData("int myVariable", ""),
|
ResultData("int myVariable", ""),
|
||||||
@@ -355,7 +355,7 @@ void LocatorFilterTest::testCurrentDocumentFilter()
|
|||||||
void LocatorFilterTest::testCurrentDocumentHighlighting()
|
void LocatorFilterTest::testCurrentDocumentHighlighting()
|
||||||
{
|
{
|
||||||
MyTestDataDir testDirectory("testdata_basic");
|
MyTestDataDir testDirectory("testdata_basic");
|
||||||
const QString testFile = testDirectory.file("file1.cpp");
|
const FilePath testFile = testDirectory.filePath("file1.cpp");
|
||||||
|
|
||||||
const QString searchText = "pos";
|
const QString searchText = "pos";
|
||||||
const ResultDataList expectedResults{
|
const ResultDataList expectedResults{
|
||||||
|
|||||||
@@ -1111,16 +1111,16 @@ void CppModelManager::removeExtraEditorSupport(AbstractEditorSupport *editorSupp
|
|||||||
d->m_extraEditorSupports.remove(editorSupport);
|
d->m_extraEditorSupports.remove(editorSupport);
|
||||||
}
|
}
|
||||||
|
|
||||||
CppEditorDocumentHandle *CppModelManager::cppEditorDocument(const QString &filePath) const
|
CppEditorDocumentHandle *CppModelManager::cppEditorDocument(const FilePath &filePath) const
|
||||||
{
|
{
|
||||||
if (filePath.isEmpty())
|
if (filePath.isEmpty())
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
QMutexLocker locker(&d->m_cppEditorDocumentsMutex);
|
QMutexLocker locker(&d->m_cppEditorDocumentsMutex);
|
||||||
return d->m_cppEditorDocuments.value(filePath, 0);
|
return d->m_cppEditorDocuments.value(filePath.toString(), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
BaseEditorDocumentProcessor *CppModelManager::cppEditorDocumentProcessor(const QString &filePath)
|
BaseEditorDocumentProcessor *CppModelManager::cppEditorDocumentProcessor(const FilePath &filePath)
|
||||||
{
|
{
|
||||||
const auto document = instance()->cppEditorDocument(filePath);
|
const auto document = instance()->cppEditorDocument(filePath);
|
||||||
return document ? document->processor() : nullptr;
|
return document ? document->processor() : nullptr;
|
||||||
@@ -1442,7 +1442,7 @@ void CppModelManager::updateCppEditorDocuments(bool projectsUpdated) const
|
|||||||
const QList<Core::IEditor *> editors = Core::EditorManager::visibleEditors();
|
const QList<Core::IEditor *> editors = Core::EditorManager::visibleEditors();
|
||||||
for (Core::IEditor *editor: editors) {
|
for (Core::IEditor *editor: editors) {
|
||||||
if (Core::IDocument *document = editor->document()) {
|
if (Core::IDocument *document = editor->document()) {
|
||||||
const QString filePath = document->filePath().toString();
|
const FilePath filePath = document->filePath();
|
||||||
if (CppEditorDocumentHandle *theCppEditorDocument = cppEditorDocument(filePath)) {
|
if (CppEditorDocumentHandle *theCppEditorDocument = cppEditorDocument(filePath)) {
|
||||||
visibleCppEditorDocuments.insert(document);
|
visibleCppEditorDocuments.insert(document);
|
||||||
theCppEditorDocument->processor()->run(projectsUpdated);
|
theCppEditorDocument->processor()->run(projectsUpdated);
|
||||||
@@ -1455,7 +1455,7 @@ void CppModelManager::updateCppEditorDocuments(bool projectsUpdated) const
|
|||||||
= Utils::toSet(Core::DocumentModel::openedDocuments());
|
= Utils::toSet(Core::DocumentModel::openedDocuments());
|
||||||
invisibleCppEditorDocuments.subtract(visibleCppEditorDocuments);
|
invisibleCppEditorDocuments.subtract(visibleCppEditorDocuments);
|
||||||
for (Core::IDocument *document : std::as_const(invisibleCppEditorDocuments)) {
|
for (Core::IDocument *document : std::as_const(invisibleCppEditorDocuments)) {
|
||||||
const QString filePath = document->filePath().toString();
|
const FilePath filePath = document->filePath();
|
||||||
if (CppEditorDocumentHandle *theCppEditorDocument = cppEditorDocument(filePath)) {
|
if (CppEditorDocumentHandle *theCppEditorDocument = cppEditorDocument(filePath)) {
|
||||||
const CppEditorDocumentHandle::RefreshReason refreshReason = projectsUpdated
|
const CppEditorDocumentHandle::RefreshReason refreshReason = projectsUpdated
|
||||||
? CppEditorDocumentHandle::ProjectUpdate
|
? CppEditorDocumentHandle::ProjectUpdate
|
||||||
@@ -1708,7 +1708,7 @@ void CppModelManager::onCurrentEditorChanged(Core::IEditor *editor)
|
|||||||
if (!editor || !editor->document())
|
if (!editor || !editor->document())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const QString filePath = editor->document()->filePath().toString();
|
const FilePath filePath = editor->document()->filePath();
|
||||||
if (CppEditorDocumentHandle *theCppEditorDocument = cppEditorDocument(filePath)) {
|
if (CppEditorDocumentHandle *theCppEditorDocument = cppEditorDocument(filePath)) {
|
||||||
const CppEditorDocumentHandle::RefreshReason refreshReason
|
const CppEditorDocumentHandle::RefreshReason refreshReason
|
||||||
= theCppEditorDocument->refreshReason();
|
= theCppEditorDocument->refreshReason();
|
||||||
|
|||||||
@@ -137,8 +137,8 @@ public:
|
|||||||
void removeExtraEditorSupport(AbstractEditorSupport *editorSupport);
|
void removeExtraEditorSupport(AbstractEditorSupport *editorSupport);
|
||||||
|
|
||||||
const QList<CppEditorDocumentHandle *> cppEditorDocuments() const;
|
const QList<CppEditorDocumentHandle *> cppEditorDocuments() const;
|
||||||
CppEditorDocumentHandle *cppEditorDocument(const QString &filePath) const;
|
CppEditorDocumentHandle *cppEditorDocument(const Utils::FilePath &filePath) const;
|
||||||
static BaseEditorDocumentProcessor *cppEditorDocumentProcessor(const QString &filePath);
|
static BaseEditorDocumentProcessor *cppEditorDocumentProcessor(const Utils::FilePath &filePath);
|
||||||
void registerCppEditorDocument(CppEditorDocumentHandle *cppEditorDocument);
|
void registerCppEditorDocument(CppEditorDocumentHandle *cppEditorDocument);
|
||||||
void unregisterCppEditorDocument(const QString &filePath);
|
void unregisterCppEditorDocument(const QString &filePath);
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,6 @@
|
|||||||
|
|
||||||
#include "baseeditordocumentprocessor.h"
|
#include "baseeditordocumentprocessor.h"
|
||||||
#include "builtineditordocumentparser.h"
|
#include "builtineditordocumentparser.h"
|
||||||
#include "cppsourceprocessor.h"
|
|
||||||
#include "cpptoolstestcase.h"
|
#include "cpptoolstestcase.h"
|
||||||
#include "editordocumenthandle.h"
|
#include "editordocumenthandle.h"
|
||||||
#include "modelmanagertesthelper.h"
|
#include "modelmanagertesthelper.h"
|
||||||
@@ -161,15 +160,15 @@ private:
|
|||||||
const Utils::FilePath m_filePath;
|
const Utils::FilePath m_filePath;
|
||||||
};
|
};
|
||||||
|
|
||||||
ProjectPart::ConstPtr projectPartOfEditorDocument(const QString &filePath)
|
} // anonymous namespace
|
||||||
|
|
||||||
|
static ProjectPart::ConstPtr projectPartOfEditorDocument(const FilePath &filePath)
|
||||||
{
|
{
|
||||||
auto *editorDocument = CppModelManager::instance()->cppEditorDocument(filePath);
|
auto *editorDocument = CppModelManager::instance()->cppEditorDocument(filePath);
|
||||||
QTC_ASSERT(editorDocument, return ProjectPart::ConstPtr());
|
QTC_ASSERT(editorDocument, return ProjectPart::ConstPtr());
|
||||||
return editorDocument->processor()->parser()->projectPartInfo().projectPart;
|
return editorDocument->processor()->parser()->projectPartInfo().projectPart;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // anonymous namespace
|
|
||||||
|
|
||||||
/// Check: The preprocessor cleans include and framework paths.
|
/// Check: The preprocessor cleans include and framework paths.
|
||||||
void ModelManagerTest::testPathsAreClean()
|
void ModelManagerTest::testPathsAreClean()
|
||||||
{
|
{
|
||||||
@@ -792,8 +791,8 @@ void ModelManagerTest::testPrecompiledHeaders()
|
|||||||
ModelManagerTestHelper helper;
|
ModelManagerTestHelper helper;
|
||||||
|
|
||||||
MyTestDataDir testDataDirectory(_("testdata_defines"));
|
MyTestDataDir testDataDirectory(_("testdata_defines"));
|
||||||
const QString main1File = testDataDirectory.file(_("main1.cpp"));
|
const FilePath main1File = testDataDirectory.filePath("main1.cpp");
|
||||||
const QString main2File = testDataDirectory.file(_("main2.cpp"));
|
const FilePath main2File = testDataDirectory.filePath("main2.cpp");
|
||||||
const QString header = testDataDirectory.file(_("header.h"));
|
const QString header = testDataDirectory.file(_("header.h"));
|
||||||
const QString pch1File = testDataDirectory.file(_("pch1.h"));
|
const QString pch1File = testDataDirectory.file(_("pch1.h"));
|
||||||
const QString pch2File = testDataDirectory.file(_("pch2.h"));
|
const QString pch2File = testDataDirectory.file(_("pch2.h"));
|
||||||
@@ -809,7 +808,7 @@ void ModelManagerTest::testPrecompiledHeaders()
|
|||||||
rpp1.setPreCompiledHeaders({pch1File});
|
rpp1.setPreCompiledHeaders({pch1File});
|
||||||
rpp1.setHeaderPaths({HeaderPath::makeUser(testDataDirectory.includeDir(false))});
|
rpp1.setHeaderPaths({HeaderPath::makeUser(testDataDirectory.includeDir(false))});
|
||||||
const auto part1 = ProjectPart::create(project->projectFilePath(), rpp1, {},
|
const auto part1 = ProjectPart::create(project->projectFilePath(), rpp1, {},
|
||||||
{{main1File, ProjectFile::CXXSource}, {header, ProjectFile::CXXHeader}});
|
{{main1File.toString(), ProjectFile::CXXSource}, {header, ProjectFile::CXXHeader}});
|
||||||
|
|
||||||
RawProjectPart rpp2;
|
RawProjectPart rpp2;
|
||||||
rpp2.setProjectFileLocation("project2.projectfile");
|
rpp2.setProjectFileLocation("project2.projectfile");
|
||||||
@@ -817,7 +816,7 @@ void ModelManagerTest::testPrecompiledHeaders()
|
|||||||
rpp2.setPreCompiledHeaders({pch2File});
|
rpp2.setPreCompiledHeaders({pch2File});
|
||||||
rpp2.setHeaderPaths({HeaderPath::makeUser(testDataDirectory.includeDir(false))});
|
rpp2.setHeaderPaths({HeaderPath::makeUser(testDataDirectory.includeDir(false))});
|
||||||
const auto part2 = ProjectPart::create(project->projectFilePath(), rpp2, {},
|
const auto part2 = ProjectPart::create(project->projectFilePath(), rpp2, {},
|
||||||
{{main2File, ProjectFile::CXXSource}, {header, ProjectFile::CXXHeader}});
|
{{main2File.toString(), ProjectFile::CXXSource}, {header, ProjectFile::CXXHeader}});
|
||||||
|
|
||||||
const auto pi = ProjectInfo::create({project, KitInfo(nullptr), {}, {}}, {part1, part2});
|
const auto pi = ProjectInfo::create({project, KitInfo(nullptr), {}, {}}, {part1, part2});
|
||||||
|
|
||||||
@@ -830,7 +829,7 @@ void ModelManagerTest::testPrecompiledHeaders()
|
|||||||
struct Data {
|
struct Data {
|
||||||
QString firstDeclarationName;
|
QString firstDeclarationName;
|
||||||
QString firstClassInPchFile;
|
QString firstClassInPchFile;
|
||||||
QString fileName;
|
FilePath filePath;
|
||||||
} d[] = {
|
} d[] = {
|
||||||
{_("one"), _("ClassInPch1"), main1File},
|
{_("one"), _("ClassInPch1"), main1File},
|
||||||
{_("two"), _("ClassInPch2"), main2File}
|
{_("two"), _("ClassInPch2"), main2File}
|
||||||
@@ -838,16 +837,15 @@ void ModelManagerTest::testPrecompiledHeaders()
|
|||||||
for (auto &i : d) {
|
for (auto &i : d) {
|
||||||
const QString firstDeclarationName = i.firstDeclarationName;
|
const QString firstDeclarationName = i.firstDeclarationName;
|
||||||
const QByteArray firstClassInPchFile = i.firstClassInPchFile.toUtf8();
|
const QByteArray firstClassInPchFile = i.firstClassInPchFile.toUtf8();
|
||||||
const QString fileName = i.fileName;
|
const FilePath filePath = i.filePath;
|
||||||
|
|
||||||
Core::IEditor *editor = Core::EditorManager::openEditor(
|
Core::IEditor *editor = Core::EditorManager::openEditor(filePath);
|
||||||
Utils::FilePath::fromString(fileName));
|
|
||||||
EditorCloser closer(editor);
|
EditorCloser closer(editor);
|
||||||
QVERIFY(editor);
|
QVERIFY(editor);
|
||||||
QCOMPARE(Core::DocumentModel::openedDocuments().size(), 1);
|
QCOMPARE(Core::DocumentModel::openedDocuments().size(), 1);
|
||||||
QVERIFY(mm->isCppEditor(editor));
|
QVERIFY(mm->isCppEditor(editor));
|
||||||
|
|
||||||
auto parser = BuiltinEditorDocumentParser::get(fileName);
|
auto parser = BuiltinEditorDocumentParser::get(filePath);
|
||||||
QVERIFY(parser);
|
QVERIFY(parser);
|
||||||
BaseEditorDocumentParser::Configuration config = parser->configuration();
|
BaseEditorDocumentParser::Configuration config = parser->configuration();
|
||||||
config.usePrecompiledHeaders = true;
|
config.usePrecompiledHeaders = true;
|
||||||
@@ -856,7 +854,7 @@ void ModelManagerTest::testPrecompiledHeaders()
|
|||||||
Utils::Language::Cxx, false});
|
Utils::Language::Cxx, false});
|
||||||
|
|
||||||
// Check if defines from pch are considered
|
// Check if defines from pch are considered
|
||||||
Document::Ptr document = mm->document(Utils::FilePath::fromString(fileName));
|
Document::Ptr document = mm->document(filePath);
|
||||||
QCOMPARE(nameOfFirstDeclaration(document), firstDeclarationName);
|
QCOMPARE(nameOfFirstDeclaration(document), firstDeclarationName);
|
||||||
|
|
||||||
// Check if declarations from pch are considered
|
// Check if declarations from pch are considered
|
||||||
@@ -922,7 +920,7 @@ void ModelManagerTest::testDefinesPerEditor()
|
|||||||
QCOMPARE(Core::DocumentModel::openedDocuments().size(), 1);
|
QCOMPARE(Core::DocumentModel::openedDocuments().size(), 1);
|
||||||
QVERIFY(mm->isCppEditor(editor));
|
QVERIFY(mm->isCppEditor(editor));
|
||||||
|
|
||||||
const QString filePath = editor->document()->filePath().toString();
|
const FilePath filePath = editor->document()->filePath();
|
||||||
const auto parser = BaseEditorDocumentParser::get(filePath);
|
const auto parser = BaseEditorDocumentParser::get(filePath);
|
||||||
BaseEditorDocumentParser::Configuration config = parser->configuration();
|
BaseEditorDocumentParser::Configuration config = parser->configuration();
|
||||||
config.editorDefines = editorDefines.toUtf8();
|
config.editorDefines = editorDefines.toUtf8();
|
||||||
@@ -940,11 +938,11 @@ void ModelManagerTest::testUpdateEditorsAfterProjectUpdate()
|
|||||||
ModelManagerTestHelper helper;
|
ModelManagerTestHelper helper;
|
||||||
|
|
||||||
MyTestDataDir testDataDirectory(_("testdata_defines"));
|
MyTestDataDir testDataDirectory(_("testdata_defines"));
|
||||||
const QString fileA = testDataDirectory.file(_("main1.cpp")); // content not relevant
|
const FilePath fileA = testDataDirectory.filePath("main1.cpp"); // content not relevant
|
||||||
const QString fileB = testDataDirectory.file(_("main2.cpp")); // content not relevant
|
const FilePath fileB = testDataDirectory.filePath("main2.cpp"); // content not relevant
|
||||||
|
|
||||||
// Open file A in editor
|
// Open file A in editor
|
||||||
Core::IEditor *editorA = Core::EditorManager::openEditor(Utils::FilePath::fromString(fileA));
|
Core::IEditor *editorA = Core::EditorManager::openEditor(fileA);
|
||||||
QVERIFY(editorA);
|
QVERIFY(editorA);
|
||||||
EditorCloser closerA(editorA);
|
EditorCloser closerA(editorA);
|
||||||
QCOMPARE(Core::DocumentModel::openedDocuments().size(), 1);
|
QCOMPARE(Core::DocumentModel::openedDocuments().size(), 1);
|
||||||
@@ -953,7 +951,7 @@ void ModelManagerTest::testUpdateEditorsAfterProjectUpdate()
|
|||||||
QVERIFY(!documentAProjectPart->hasProject());
|
QVERIFY(!documentAProjectPart->hasProject());
|
||||||
|
|
||||||
// Open file B in editor
|
// Open file B in editor
|
||||||
Core::IEditor *editorB = Core::EditorManager::openEditor(Utils::FilePath::fromString(fileB));
|
Core::IEditor *editorB = Core::EditorManager::openEditor(fileB);
|
||||||
QVERIFY(editorB);
|
QVERIFY(editorB);
|
||||||
EditorCloser closerB(editorB);
|
EditorCloser closerB(editorB);
|
||||||
QCOMPARE(Core::DocumentModel::openedDocuments().size(), 2);
|
QCOMPARE(Core::DocumentModel::openedDocuments().size(), 2);
|
||||||
@@ -971,7 +969,7 @@ void ModelManagerTest::testUpdateEditorsAfterProjectUpdate()
|
|||||||
RawProjectPart rpp;
|
RawProjectPart rpp;
|
||||||
rpp.setQtVersion(Utils::QtMajorVersion::None);
|
rpp.setQtVersion(Utils::QtMajorVersion::None);
|
||||||
const auto part = ProjectPart::create(project->projectFilePath(), rpp, {},
|
const auto part = ProjectPart::create(project->projectFilePath(), rpp, {},
|
||||||
{{fileA, ProjectFile::CXXSource}, {fileB, ProjectFile::CXXSource}});
|
{{fileA.toString(), ProjectFile::CXXSource}, {fileB.toString(), ProjectFile::CXXSource}});
|
||||||
const auto pi = ProjectInfo::create({project, KitInfo(nullptr), {}, {}}, {part});
|
const auto pi = ProjectInfo::create({project, KitInfo(nullptr), {}, {}}, {part});
|
||||||
helper.updateProjectInfo(pi);
|
helper.updateProjectInfo(pi);
|
||||||
|
|
||||||
@@ -1157,7 +1155,7 @@ void ModelManagerTest::testRenameIncludesInEditor()
|
|||||||
QCOMPARE(renamedHeaderContents, originalMalformedGuardContents);
|
QCOMPARE(renamedHeaderContents, originalMalformedGuardContents);
|
||||||
|
|
||||||
// Update the c++ model manager again and check for the new includes
|
// Update the c++ model manager again and check for the new includes
|
||||||
TestCase::waitForProcessedEditorDocument(mainFile.toString());
|
TestCase::waitForProcessedEditorDocument(mainFile);
|
||||||
modelManager->updateSourceFiles(sourceFiles).waitForFinished();
|
modelManager->updateSourceFiles(sourceFiles).waitForFinished();
|
||||||
QCoreApplication::processEvents();
|
QCoreApplication::processEvents();
|
||||||
snapshot = modelManager->snapshot();
|
snapshot = modelManager->snapshot();
|
||||||
@@ -1186,7 +1184,7 @@ void ModelManagerTest::testDocumentsAndRevisions()
|
|||||||
TextEditor::BaseTextEditor *editor1;
|
TextEditor::BaseTextEditor *editor1;
|
||||||
QVERIFY(helper.openCppEditor(filePath1, &editor1));
|
QVERIFY(helper.openCppEditor(filePath1, &editor1));
|
||||||
helper.closeEditorAtEndOfTestCase(editor1);
|
helper.closeEditorAtEndOfTestCase(editor1);
|
||||||
QVERIFY(TestCase::waitForProcessedEditorDocument(filePath1.toString()));
|
QVERIFY(TestCase::waitForProcessedEditorDocument(filePath1));
|
||||||
VERIFY_DOCUMENT_REVISION(modelManager->document(filePath1), 2U);
|
VERIFY_DOCUMENT_REVISION(modelManager->document(filePath1), 2U);
|
||||||
VERIFY_DOCUMENT_REVISION(modelManager->document(filePath2), 1U);
|
VERIFY_DOCUMENT_REVISION(modelManager->document(filePath2), 1U);
|
||||||
|
|
||||||
@@ -1199,7 +1197,7 @@ void ModelManagerTest::testDocumentsAndRevisions()
|
|||||||
TextEditor::BaseTextEditor *editor2;
|
TextEditor::BaseTextEditor *editor2;
|
||||||
QVERIFY(helper.openCppEditor(filePath2, &editor2));
|
QVERIFY(helper.openCppEditor(filePath2, &editor2));
|
||||||
helper.closeEditorAtEndOfTestCase(editor2);
|
helper.closeEditorAtEndOfTestCase(editor2);
|
||||||
QVERIFY(TestCase::waitForProcessedEditorDocument(filePath2.toString()));
|
QVERIFY(TestCase::waitForProcessedEditorDocument(filePath2));
|
||||||
VERIFY_DOCUMENT_REVISION(modelManager->document(filePath1), 3U);
|
VERIFY_DOCUMENT_REVISION(modelManager->document(filePath1), 3U);
|
||||||
VERIFY_DOCUMENT_REVISION(modelManager->document(filePath2), 3U);
|
VERIFY_DOCUMENT_REVISION(modelManager->document(filePath2), 3U);
|
||||||
|
|
||||||
@@ -1209,4 +1207,4 @@ void ModelManagerTest::testDocumentsAndRevisions()
|
|||||||
VERIFY_DOCUMENT_REVISION(modelManager->document(filePath2), 4U);
|
VERIFY_DOCUMENT_REVISION(modelManager->document(filePath2), 4U);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace CppEditor::Internal
|
} // CppEditor::Internal
|
||||||
|
|||||||
@@ -7629,8 +7629,7 @@ void ConvertQt4Connect::match(const CppQuickFixInterface &interface, QuickFixOpe
|
|||||||
void ExtraRefactoringOperations::match(const CppQuickFixInterface &interface,
|
void ExtraRefactoringOperations::match(const CppQuickFixInterface &interface,
|
||||||
QuickFixOperations &result)
|
QuickFixOperations &result)
|
||||||
{
|
{
|
||||||
const auto processor = CppModelManager::cppEditorDocumentProcessor(
|
const auto processor = CppModelManager::cppEditorDocumentProcessor(interface.filePath());
|
||||||
interface.filePath().toString());
|
|
||||||
if (processor) {
|
if (processor) {
|
||||||
const auto clangFixItOperations = processor->extraRefactoringOperations(interface);
|
const auto clangFixItOperations = processor->extraRefactoringOperations(interface);
|
||||||
result.append(clangFixItOperations);
|
result.append(clangFixItOperations);
|
||||||
|
|||||||
@@ -110,8 +110,8 @@ void SourceProcessorTest::testIncludesCyclic()
|
|||||||
testCase.closeEditorAtEndOfTestCase(editor);
|
testCase.closeEditorAtEndOfTestCase(editor);
|
||||||
|
|
||||||
// Check editor snapshot
|
// Check editor snapshot
|
||||||
const QString filePath = editor->document()->filePath().toString();
|
const FilePath filePath = editor->document()->filePath();
|
||||||
auto *processor = CppModelManager::cppEditorDocumentProcessor(filePath);
|
auto processor = CppModelManager::cppEditorDocumentProcessor(filePath);
|
||||||
QVERIFY(processor);
|
QVERIFY(processor);
|
||||||
QVERIFY(TestCase::waitForProcessedEditorDocument(filePath));
|
QVERIFY(TestCase::waitForProcessedEditorDocument(filePath));
|
||||||
Snapshot snapshot = processor->snapshot();
|
Snapshot snapshot = processor->snapshot();
|
||||||
|
|||||||
@@ -268,7 +268,7 @@ static bool waitForProcessedEditorDocument_internal(CppEditorDocumentHandle *edi
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TestCase::waitForProcessedEditorDocument(const QString &filePath, int timeOutInMs)
|
bool TestCase::waitForProcessedEditorDocument(const FilePath &filePath, int timeOutInMs)
|
||||||
{
|
{
|
||||||
auto *editorDocument = CppModelManager::instance()->cppEditorDocument(filePath);
|
auto *editorDocument = CppModelManager::instance()->cppEditorDocument(filePath);
|
||||||
return waitForProcessedEditorDocument_internal(editorDocument, timeOutInMs);
|
return waitForProcessedEditorDocument_internal(editorDocument, timeOutInMs);
|
||||||
@@ -314,21 +314,21 @@ bool TestCase::closeEditorWithoutGarbageCollectorInvocation(Core::IEditor *edito
|
|||||||
return closeEditorsWithoutGarbageCollectorInvocation({editor});
|
return closeEditorsWithoutGarbageCollectorInvocation({editor});
|
||||||
}
|
}
|
||||||
|
|
||||||
CPlusPlus::Document::Ptr TestCase::waitForFileInGlobalSnapshot(const QString &filePath,
|
CPlusPlus::Document::Ptr TestCase::waitForFileInGlobalSnapshot(const FilePath &filePath,
|
||||||
int timeOutInMs)
|
int timeOutInMs)
|
||||||
{
|
{
|
||||||
const auto documents = waitForFilesInGlobalSnapshot(QStringList(filePath), timeOutInMs);
|
const auto documents = waitForFilesInGlobalSnapshot({filePath}, timeOutInMs);
|
||||||
return documents.isEmpty() ? CPlusPlus::Document::Ptr() : documents.first();
|
return documents.isEmpty() ? CPlusPlus::Document::Ptr() : documents.first();
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<CPlusPlus::Document::Ptr> TestCase::waitForFilesInGlobalSnapshot(const QStringList &filePaths,
|
QList<CPlusPlus::Document::Ptr> TestCase::waitForFilesInGlobalSnapshot(const FilePaths &filePaths,
|
||||||
int timeOutInMs)
|
int timeOutInMs)
|
||||||
{
|
{
|
||||||
QElapsedTimer t;
|
QElapsedTimer t;
|
||||||
t.start();
|
t.start();
|
||||||
|
|
||||||
QList<CPlusPlus::Document::Ptr> result;
|
QList<CPlusPlus::Document::Ptr> result;
|
||||||
for (const QString &filePath : filePaths) {
|
for (const FilePath &filePath : filePaths) {
|
||||||
forever {
|
forever {
|
||||||
if (CPlusPlus::Document::Ptr document = globalSnapshot().document(filePath)) {
|
if (CPlusPlus::Document::Ptr document = globalSnapshot().document(filePath)) {
|
||||||
result.append(document);
|
result.append(document);
|
||||||
|
|||||||
@@ -135,19 +135,19 @@ public:
|
|||||||
static CPlusPlus::Snapshot globalSnapshot();
|
static CPlusPlus::Snapshot globalSnapshot();
|
||||||
static bool garbageCollectGlobalSnapshot();
|
static bool garbageCollectGlobalSnapshot();
|
||||||
|
|
||||||
static bool waitForProcessedEditorDocument(const QString &filePath, int timeOutInMs = 5000);
|
static bool waitForProcessedEditorDocument(
|
||||||
|
const Utils::FilePath &filePath, int timeOutInMs = 5000);
|
||||||
|
|
||||||
static CPlusPlus::Document::Ptr waitForRehighlightedSemanticDocument(
|
static CPlusPlus::Document::Ptr waitForRehighlightedSemanticDocument(
|
||||||
CppEditorWidget *editorWidget);
|
CppEditorWidget *editorWidget);
|
||||||
|
|
||||||
enum { defaultTimeOutInMs = 30 * 1000 /*= 30 secs*/ };
|
enum { defaultTimeOutInMs = 30 * 1000 /*= 30 secs*/ };
|
||||||
static bool waitUntilProjectIsFullyOpened(ProjectExplorer::Project *project,
|
static bool waitUntilProjectIsFullyOpened(ProjectExplorer::Project *project,
|
||||||
int timeOutInMs = defaultTimeOutInMs);
|
int timeOutInMs = defaultTimeOutInMs);
|
||||||
static CPlusPlus::Document::Ptr waitForFileInGlobalSnapshot(
|
static CPlusPlus::Document::Ptr waitForFileInGlobalSnapshot(const Utils::FilePath &filePath,
|
||||||
const QString &filePath,
|
|
||||||
int timeOutInMs = defaultTimeOutInMs);
|
int timeOutInMs = defaultTimeOutInMs);
|
||||||
static QList<CPlusPlus::Document::Ptr> waitForFilesInGlobalSnapshot(
|
static QList<CPlusPlus::Document::Ptr> waitForFilesInGlobalSnapshot(
|
||||||
const QStringList &filePaths,
|
const Utils::FilePaths &filePaths, int timeOutInMs = defaultTimeOutInMs);
|
||||||
int timeOutInMs = defaultTimeOutInMs);
|
|
||||||
|
|
||||||
static bool writeFile(const Utils::FilePath &filePath, const QByteArray &contents);
|
static bool writeFile(const Utils::FilePath &filePath, const QByteArray &contents);
|
||||||
|
|
||||||
|
|||||||
@@ -302,8 +302,7 @@ F2TestCase::F2TestCase(CppEditorAction action,
|
|||||||
// The file is "Full Checked" since it is in the working copy now,
|
// The file is "Full Checked" since it is in the working copy now,
|
||||||
// that is the function bodies are processed.
|
// that is the function bodies are processed.
|
||||||
forever {
|
forever {
|
||||||
const Document::Ptr document =
|
const Document::Ptr document = waitForFileInGlobalSnapshot(testFile->filePath());
|
||||||
waitForFileInGlobalSnapshot(testFile->filePath().toString());
|
|
||||||
QVERIFY(document);
|
QVERIFY(document);
|
||||||
if (document->checkMode() == Document::FullCheck) {
|
if (document->checkMode() == Document::FullCheck) {
|
||||||
if (!document->diagnosticMessages().isEmpty())
|
if (!document->diagnosticMessages().isEmpty())
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ using namespace CppEditor;
|
|||||||
using namespace CPlusPlus;
|
using namespace CPlusPlus;
|
||||||
using namespace Designer;
|
using namespace Designer;
|
||||||
using namespace Designer::Internal;
|
using namespace Designer::Internal;
|
||||||
|
using namespace Utils;
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
@@ -125,22 +126,22 @@ bool documentContainsMemberFunctionDeclaration(const Document::Ptr &document,
|
|||||||
class GoToSlotTestCase : public CppEditor::Tests::TestCase
|
class GoToSlotTestCase : public CppEditor::Tests::TestCase
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
GoToSlotTestCase(const QStringList &files)
|
GoToSlotTestCase(const FilePaths &files)
|
||||||
{
|
{
|
||||||
QVERIFY(succeededSoFar());
|
QVERIFY(succeededSoFar());
|
||||||
QCOMPARE(files.size(), 3);
|
QCOMPARE(files.size(), 3);
|
||||||
|
|
||||||
QList<TextEditor::BaseTextEditor *> editors;
|
QList<TextEditor::BaseTextEditor *> editors;
|
||||||
for (const QString &file : files) {
|
for (const FilePath &file : files) {
|
||||||
IEditor *editor = EditorManager::openEditor(Utils::FilePath::fromString(file));
|
IEditor *editor = EditorManager::openEditor(file);
|
||||||
TextEditor::BaseTextEditor *e = qobject_cast<TextEditor::BaseTextEditor *>(editor);
|
TextEditor::BaseTextEditor *e = qobject_cast<TextEditor::BaseTextEditor *>(editor);
|
||||||
QVERIFY(e);
|
QVERIFY(e);
|
||||||
closeEditorAtEndOfTestCase(editor);
|
closeEditorAtEndOfTestCase(editor);
|
||||||
editors << e;
|
editors << e;
|
||||||
}
|
}
|
||||||
|
|
||||||
const QString cppFile = files.at(0);
|
const FilePath cppFile = files.at(0);
|
||||||
const QString hFile = files.at(1);
|
const FilePath hFile = files.at(1);
|
||||||
|
|
||||||
QCOMPARE(DocumentModel::openedDocuments().size(), files.size());
|
QCOMPARE(DocumentModel::openedDocuments().size(), files.size());
|
||||||
waitForFilesInGlobalSnapshot({cppFile, hFile});
|
waitForFilesInGlobalSnapshot({cppFile, hFile});
|
||||||
@@ -150,14 +151,14 @@ public:
|
|||||||
QVERIFY(integration);
|
QVERIFY(integration);
|
||||||
integration->emitNavigateToSlot("pushButton", "clicked()", QStringList());
|
integration->emitNavigateToSlot("pushButton", "clicked()", QStringList());
|
||||||
|
|
||||||
QCOMPARE(EditorManager::currentDocument()->filePath().toString(), cppFile);
|
QCOMPARE(EditorManager::currentDocument()->filePath(), cppFile);
|
||||||
QVERIFY(EditorManager::currentDocument()->isModified());
|
QVERIFY(EditorManager::currentDocument()->isModified());
|
||||||
|
|
||||||
// Wait for updated documents
|
// Wait for updated documents
|
||||||
for (TextEditor::BaseTextEditor *editor : std::as_const(editors)) {
|
for (TextEditor::BaseTextEditor *editor : std::as_const(editors)) {
|
||||||
QElapsedTimer t;
|
QElapsedTimer t;
|
||||||
t.start();
|
t.start();
|
||||||
const QString filePath = editor->document()->filePath().toString();
|
const FilePath filePath = editor->document()->filePath();
|
||||||
if (auto parser = BuiltinEditorDocumentParser::get(filePath)) {
|
if (auto parser = BuiltinEditorDocumentParser::get(filePath)) {
|
||||||
while (t.elapsed() < 2000) {
|
while (t.elapsed() < 2000) {
|
||||||
if (Document::Ptr document = parser->document()) {
|
if (Document::Ptr document = parser->document()) {
|
||||||
@@ -215,7 +216,7 @@ namespace Internal {
|
|||||||
void FormEditorPlugin::test_gotoslot()
|
void FormEditorPlugin::test_gotoslot()
|
||||||
{
|
{
|
||||||
QFETCH(QStringList, files);
|
QFETCH(QStringList, files);
|
||||||
(GoToSlotTestCase(files));
|
(GoToSlotTestCase(Utils::transform(files, FilePath::fromString)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void FormEditorPlugin::test_gotoslot_data()
|
void FormEditorPlugin::test_gotoslot_data()
|
||||||
|
|||||||
Reference in New Issue
Block a user