Clang: Remove project tracking on clangbackend side

...as it is not needed. Just provide the compilation arguments as part
of the Document.

As a side effect, re-initializing the backend after a crash is cheaper
and will not freeze the UI anymore (referenced bug).

Task-number: QTCREATORBUG-21097
Change-Id: I866e25ef1fd5e4d318df16612a7564469e6baa11
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
This commit is contained in:
Nikolai Kosjar
2018-09-25 09:41:32 +02:00
parent 25ea9a4d24
commit aa290912b8
102 changed files with 394 additions and 2388 deletions

View File

@@ -39,8 +39,6 @@ class DocumentsClosedMessage;
class DocumentsOpenedMessage;
class EchoMessage;
class FollowSymbolMessage;
class ProjectPartsRemovedMessage;
class ProjectPartsUpdatedMessage;
class ReferencesMessage;
class RequestAnnotationsMessage;
class RequestCompletionsMessage;

View File

@@ -50,12 +50,6 @@ void ClangCodeModelServerInterface::dispatch(const MessageEnvelop &messageEnvelo
case MessageType::DocumentVisibilityChangedMessage:
documentVisibilityChanged(messageEnvelop.message<DocumentVisibilityChangedMessage>());
break;
case MessageType::ProjectPartsUpdatedMessage:
projectPartsUpdated(messageEnvelop.message<ProjectPartsUpdatedMessage>());
break;
case MessageType::ProjectPartsRemovedMessage:
projectPartsRemoved(messageEnvelop.message<ProjectPartsRemovedMessage>());
break;
case MessageType::UnsavedFilesUpdatedMessage:
unsavedFilesUpdated(messageEnvelop.message<UnsavedFilesUpdatedMessage>());
break;

View File

@@ -47,9 +47,6 @@ public:
virtual void documentsClosed(const DocumentsClosedMessage &message) = 0;
virtual void documentVisibilityChanged(const DocumentVisibilityChangedMessage &message) = 0;
virtual void projectPartsUpdated(const ProjectPartsUpdatedMessage &message) = 0;
virtual void projectPartsRemoved(const ProjectPartsRemovedMessage &message) = 0;
virtual void unsavedFilesUpdated(const UnsavedFilesUpdatedMessage &message) = 0;
virtual void unsavedFilesRemoved(const UnsavedFilesRemovedMessage &message) = 0;

View File

@@ -33,9 +33,6 @@
#include "documentschangedmessage.h"
#include "documentvisibilitychangedmessage.h"
#include "projectpartsupdatedmessage.h"
#include "projectpartsremovedmessage.h"
#include "unsavedfilesupdatedmessage.h"
#include "unsavedfilesremovedmessage.h"

View File

@@ -57,16 +57,6 @@ void ClangCodeModelServerProxy::documentsClosed(const DocumentsClosedMessage &me
m_writeMessageBlock.write(message);
}
void ClangCodeModelServerProxy::projectPartsUpdated(const ProjectPartsUpdatedMessage &message)
{
m_writeMessageBlock.write(message);
}
void ClangCodeModelServerProxy::projectPartsRemoved(const ProjectPartsRemovedMessage &message)
{
m_writeMessageBlock.write(message);
}
void ClangCodeModelServerProxy::unsavedFilesUpdated(const UnsavedFilesUpdatedMessage &message)
{
m_writeMessageBlock.write(message);

View File

@@ -55,9 +55,6 @@ public:
void documentsClosed(const DocumentsClosedMessage &message) override;
void documentVisibilityChanged(const DocumentVisibilityChangedMessage &message) override;
void projectPartsUpdated(const ProjectPartsUpdatedMessage &message) override;
void projectPartsRemoved(const ProjectPartsRemovedMessage &message) override;
void unsavedFilesUpdated(const UnsavedFilesUpdatedMessage &message) override;
void unsavedFilesRemoved(const UnsavedFilesRemovedMessage &message) override;

View File

@@ -21,9 +21,7 @@ SOURCES += \
$$PWD/requestcompletionsmessage.cpp \
$$PWD/echomessage.cpp \
$$PWD/endmessage.cpp \
$$PWD/projectpartsupdatedmessage.cpp \
$$PWD/documentsopenedmessage.cpp \
$$PWD/projectpartsremovedmessage.cpp \
$$PWD/documentsclosedmessage.cpp \
$$PWD/codecompletionchunk.cpp \
$$PWD/codecompletion.cpp \
@@ -46,7 +44,6 @@ SOURCES += \
$$PWD/pchmanagerserverinterface.cpp \
$$PWD/pchmanagerserverproxy.cpp \
$$PWD/precompiledheadersupdatedmessage.cpp \
$$PWD/projectpartcontainer.cpp \
$$PWD/projectpartcontainerv2.cpp \
$$PWD/projectpartpch.cpp \
$$PWD/readmessageblock.cpp \
@@ -114,9 +111,7 @@ HEADERS += \
$$PWD/requestcompletionsmessage.h \
$$PWD/echomessage.h \
$$PWD/endmessage.h \
$$PWD/projectpartsupdatedmessage.h \
$$PWD/documentsopenedmessage.h \
$$PWD/projectpartsremovedmessage.h \
$$PWD/documentsclosedmessage.h \
$$PWD/codecompletionchunk.h \
$$PWD/codecompletion.h \
@@ -143,7 +138,6 @@ HEADERS += \
$$PWD/pchmanagerserverinterface.h \
$$PWD/pchmanagerserverproxy.h \
$$PWD/precompiledheadersupdatedmessage.h \
$$PWD/projectpartcontainer.h \
$$PWD/projectpartcontainerv2.h \
$$PWD/projectpartpch.h \
$$PWD/readmessageblock.h \

View File

@@ -149,9 +149,6 @@ enum class MessageType : quint8 {
UnsavedFilesUpdatedMessage,
UnsavedFilesRemovedMessage,
ProjectPartsUpdatedMessage,
ProjectPartsRemovedMessage,
RequestAnnotationsMessage,
AnnotationsMessage,

View File

@@ -35,8 +35,7 @@ QDebug operator<<(QDebug debug, const FileContainer &container)
{
debug.nospace() << "FileContainer("
<< container.filePath << ", "
<< container.projectPartId << ", "
<< container.fileArguments << ", "
<< container.compilationArguments << ", "
<< container.documentRevision << ", "
<< container.textCodecName;

View File

@@ -39,13 +39,11 @@ class FileContainer
public:
FileContainer() = default;
FileContainer(const Utf8String &filePath,
const Utf8String &projectPartId,
const Utf8String &unsavedFileContent = Utf8String(),
bool hasUnsavedFileContent = false,
quint32 documentRevision = 0,
const Utf8String &textCodecName = Utf8String())
: filePath(filePath),
projectPartId(projectPartId),
unsavedFileContent(unsavedFileContent),
textCodecName(textCodecName),
documentRevision(documentRevision),
@@ -54,14 +52,12 @@ public:
}
FileContainer(const Utf8String &filePath,
const Utf8String &projectPartId,
const Utf8StringVector &fileArguments,
const Utf8StringVector &compilationArguments,
const Utf8String &unsavedFileContent = Utf8String(),
bool hasUnsavedFileContent = false,
quint32 documentRevision = 0)
: filePath(filePath),
projectPartId(projectPartId),
fileArguments(fileArguments),
compilationArguments(compilationArguments),
unsavedFileContent(unsavedFileContent),
documentRevision(documentRevision),
hasUnsavedFileContent(hasUnsavedFileContent)
@@ -69,12 +65,10 @@ public:
}
FileContainer(const Utf8String &filePath,
const Utf8String &projectPartId,
const Utf8StringVector &fileArguments,
const Utf8StringVector &compilationArguments,
quint32 documentRevision)
: filePath(filePath),
projectPartId(projectPartId),
fileArguments(fileArguments),
compilationArguments(compilationArguments),
documentRevision(documentRevision),
hasUnsavedFileContent(false)
{
@@ -83,8 +77,7 @@ public:
friend QDataStream &operator<<(QDataStream &out, const FileContainer &container)
{
out << container.filePath;
out << container.projectPartId;
out << container.fileArguments;
out << container.compilationArguments;
out << container.unsavedFileContent;
out << container.textCodecName;
out << container.documentRevision;
@@ -96,8 +89,7 @@ public:
friend QDataStream &operator>>(QDataStream &in, FileContainer &container)
{
in >> container.filePath;
in >> container.projectPartId;
in >> container.fileArguments;
in >> container.compilationArguments;
in >> container.unsavedFileContent;
in >> container.textCodecName;
in >> container.documentRevision;
@@ -108,13 +100,12 @@ public:
friend bool operator==(const FileContainer &first, const FileContainer &second)
{
return first.filePath == second.filePath && first.projectPartId == second.projectPartId;
return first.filePath == second.filePath;
}
public:
Utf8String filePath;
Utf8String projectPartId;
Utf8StringVector fileArguments;
Utf8StringVector compilationArguments;
Utf8String unsavedFileContent;
Utf8String textCodecName;
quint32 documentRevision = 0;

View File

@@ -50,12 +50,6 @@ QDebug operator<<(QDebug debug, const MessageEnvelop &messageEnvelop)
case MessageType::DocumentVisibilityChangedMessage:
qDebug() << messageEnvelop.message<DocumentVisibilityChangedMessage>();
break;
case MessageType::ProjectPartsUpdatedMessage:
qDebug() << messageEnvelop.message<ProjectPartsUpdatedMessage>();
break;
case MessageType::ProjectPartsRemovedMessage:
qDebug() << messageEnvelop.message<ProjectPartsRemovedMessage>();
break;
case MessageType::UnsavedFilesUpdatedMessage:
qDebug() << messageEnvelop.message<UnsavedFilesUpdatedMessage>();
break;

View File

@@ -1,58 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3 as published by the Free Software
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
**
****************************************************************************/
#include "projectpartcontainer.h"
#include "clangsupportdebugutils.h"
#include <QDebug>
namespace ClangBackEnd {
static Utf8String quotedArguments(const Utf8StringVector &arguments)
{
const Utf8String quote = Utf8String::fromUtf8("\"");
const Utf8String joined = arguments.join(quote + Utf8String::fromUtf8(" ") + quote);
return quote + joined + quote;
}
QDebug operator<<(QDebug debug, const ProjectPartContainer &container)
{
const Utf8String arguments = quotedArguments(container.arguments);
const Utf8String fileWithArguments = debugWriteFileForInspection(
arguments,
Utf8StringLiteral("projectpartargs-"));
debug.nospace() << "ProjectPartContainer("
<< container.projectPartId
<< ","
<< "<" << fileWithArguments << ">"
<< ")";
return debug;
}
} // namespace ClangBackEnd

View File

@@ -1,75 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3 as published by the Free Software
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
**
****************************************************************************/
#pragma once
#include "clangsupport_global.h"
#include <utf8stringvector.h>
#include <QDataStream>
namespace ClangBackEnd {
class ProjectPartContainer
{
public:
ProjectPartContainer() = default;
ProjectPartContainer(const Utf8String &projectPartId,
const Utf8StringVector &arguments = Utf8StringVector())
: projectPartId(projectPartId),
arguments(arguments)
{
}
friend QDataStream &operator<<(QDataStream &out, const ProjectPartContainer &container)
{
out << container.projectPartId;
out << container.arguments;
return out;
}
friend QDataStream &operator>>(QDataStream &in, ProjectPartContainer &container)
{
in >> container.projectPartId;
in >> container.arguments;
return in;
}
friend bool operator==(const ProjectPartContainer &first, const ProjectPartContainer &second)
{
return first.projectPartId == second.projectPartId;
}
public:
Utf8String projectPartId;
Utf8StringVector arguments;
};
QDebug operator<<(QDebug debug, const ProjectPartContainer &container);
} // namespace ClangBackEnd

View File

@@ -1,45 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3 as published by the Free Software
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
**
****************************************************************************/
#include "projectpartsremovedmessage.h"
#include <QDebug>
namespace ClangBackEnd {
QDebug operator<<(QDebug debug, const ProjectPartsRemovedMessage &message)
{
debug.nospace() << "ProjectPartsRemovedMessage(";
for (const Utf8String &fileNames_ : message.projectPartIds)
debug.nospace() << fileNames_ << ", ";
debug.nospace() << ")";
return debug;
}
} // namespace ClangBackEnd

View File

@@ -1,72 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3 as published by the Free Software
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
**
****************************************************************************/
#pragma once
#include "clangsupport_global.h"
#include <utf8stringvector.h>
#include <QDataStream>
namespace ClangBackEnd {
class CLANGSUPPORT_EXPORT ProjectPartsRemovedMessage
{
public:
ProjectPartsRemovedMessage() = default;
ProjectPartsRemovedMessage(const Utf8StringVector &projectPartIds)
: projectPartIds(projectPartIds)
{
}
friend QDataStream &operator<<(QDataStream &out, const ProjectPartsRemovedMessage &message)
{
out << message.projectPartIds;
return out;
}
friend QDataStream &operator>>(QDataStream &in, ProjectPartsRemovedMessage &message)
{
in >> message.projectPartIds;
return in;
}
friend bool operator==(const ProjectPartsRemovedMessage &first,
const ProjectPartsRemovedMessage &second)
{
return first.projectPartIds == second.projectPartIds;
}
public:
Utf8StringVector projectPartIds;
};
CLANGSUPPORT_EXPORT QDebug operator<<(QDebug debug, const ProjectPartsRemovedMessage &message);
DECLARE_MESSAGE(ProjectPartsRemovedMessage);
} // namespace ClangBackEnd

View File

@@ -1,45 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3 as published by the Free Software
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
**
****************************************************************************/
#include "projectpartsupdatedmessage.h"
#include <QDebug>
namespace ClangBackEnd {
QDebug operator<<(QDebug debug, const ProjectPartsUpdatedMessage &message)
{
debug.nospace() << "ProjectPartsUpdatedMessage(";
for (const ProjectPartContainer &projectContainer : message.projectContainers)
debug.nospace() << projectContainer<< ", ";
debug.nospace() << ")";
return debug;
}
} // namespace ClangBackEnd

View File

@@ -1,71 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3 as published by the Free Software
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
**
****************************************************************************/
#pragma once
#include "projectpartcontainer.h"
#include <QDataStream>
#include <QVector>
namespace ClangBackEnd {
class ProjectPartsUpdatedMessage
{
public:
ProjectPartsUpdatedMessage() = default;
ProjectPartsUpdatedMessage(const QVector<ProjectPartContainer> &projectContainers)
: projectContainers(projectContainers)
{
}
friend QDataStream &operator<<(QDataStream &out, const ProjectPartsUpdatedMessage &message)
{
out << message.projectContainers;
return out;
}
friend QDataStream &operator>>(QDataStream &in, ProjectPartsUpdatedMessage &message)
{
in >> message.projectContainers;
return in;
}
friend bool operator==(const ProjectPartsUpdatedMessage &first,
const ProjectPartsUpdatedMessage &second)
{
return first.projectContainers == second.projectContainers;
}
public:
QVector<ProjectPartContainer> projectContainers;
};
CLANGSUPPORT_EXPORT QDebug operator<<(QDebug debug, const ProjectPartsUpdatedMessage &message);
DECLARE_MESSAGE(ProjectPartsUpdatedMessage);
} // namespace ClangBackEnd

View File

@@ -40,11 +40,9 @@ public:
RequestCompletionsMessage(const Utf8String &filePath,
quint32 line,
quint32 column,
const Utf8String &projectPartId,
qint32 funcNameStartLine = -1,
qint32 funcNameStartColumn = -1)
: filePath(filePath)
, projectPartId(projectPartId)
, ticketNumber(++ticketCounter)
, line(line)
, column(column)
@@ -56,7 +54,6 @@ public:
friend QDataStream &operator<<(QDataStream &out, const RequestCompletionsMessage &message)
{
out << message.filePath;
out << message.projectPartId;
out << message.ticketNumber;
out << message.line;
out << message.column;
@@ -69,7 +66,6 @@ public:
friend QDataStream &operator>>(QDataStream &in, RequestCompletionsMessage &message)
{
in >> message.filePath;
in >> message.projectPartId;
in >> message.ticketNumber;
in >> message.line;
in >> message.column;
@@ -84,7 +80,6 @@ public:
{
return first.ticketNumber == second.ticketNumber
&& first.filePath == second.filePath
&& first.projectPartId == second.projectPartId
&& first.line == second.line
&& first.column == second.column
&& first.funcNameStartLine == second.funcNameStartLine

View File

@@ -80,9 +80,6 @@ public:
void documentsClosed(const DocumentsClosedMessage &) override {}
void documentVisibilityChanged(const DocumentVisibilityChangedMessage &) override {}
void projectPartsUpdated(const ProjectPartsUpdatedMessage &) override {}
void projectPartsRemoved(const ProjectPartsRemovedMessage &) override {}
void unsavedFilesUpdated(const UnsavedFilesUpdatedMessage &) override {}
void unsavedFilesRemoved(const UnsavedFilesRemovedMessage &) override {}
@@ -137,42 +134,6 @@ void BackendCommunicator::initializeBackend()
m_backendStartTimeOut.start(backEndStartTimeOutInMs);
}
static QStringList projectPartOptions(const CppTools::ProjectPart::Ptr &projectPart)
{
const QStringList options = ClangCodeModel::Utils::createClangOptions(projectPart,
CppTools::ProjectFile::Unsupported); // No language option
return options;
}
static ProjectPartContainer toProjectPartContainer(
const CppTools::ProjectPart::Ptr &projectPart)
{
const QStringList options = projectPartOptions(projectPart);
return ProjectPartContainer(projectPart->id(), Utf8StringVector(options));
}
static QVector<ProjectPartContainer> toProjectPartContainers(
const QVector<CppTools::ProjectPart::Ptr> projectParts)
{
QVector<ProjectPartContainer> projectPartContainers;
projectPartContainers.reserve(projectParts.size());
foreach (const CppTools::ProjectPart::Ptr &projectPart, projectParts)
projectPartContainers << toProjectPartContainer(projectPart);
return projectPartContainers;
}
void BackendCommunicator::projectPartsUpdatedForFallback()
{
const auto projectPart = CppTools::CppModelManager::instance()->fallbackProjectPart();
const auto projectPartContainer = toProjectPartContainer(projectPart);
projectPartsUpdated({projectPartContainer});
}
namespace {
Utf8String currentCppEditorDocumentFilePath()
{
@@ -253,15 +214,6 @@ void BackendCommunicator::documentVisibilityChanged(const Utf8String &currentEdi
m_sender->documentVisibilityChanged(message);
}
void BackendCommunicator::projectPartsUpdatedForCurrentProjects()
{
using namespace CppTools;
const QList<ProjectInfo> projectInfos = CppModelManager::instance()->projectInfos();
foreach (const ProjectInfo &projectInfo, projectInfos)
projectPartsUpdated(projectInfo.projectParts());
}
void BackendCommunicator::restoreCppEditorDocuments()
{
resetCppEditorDocumentProcessors();
@@ -289,12 +241,6 @@ void BackendCommunicator::unsavedFilesUpdatedForUiHeaders()
}
}
void BackendCommunicator::projectPartsUpdated(const QVector<CppTools::ProjectPart::Ptr> projectParts)
{
const auto projectPartContainers = toProjectPartContainers(projectParts);
projectPartsUpdated(projectPartContainers);
}
void BackendCommunicator::documentsChangedFromCppEditorDocument(const QString &filePath)
{
const CppTools::CppEditorDocumentHandle *document = ClangCodeModel::Utils::cppDocument(filePath);
@@ -316,7 +262,6 @@ void BackendCommunicator::documentsChanged(const QString &filePath,
const bool hasUnsavedContent = true;
documentsChanged({{filePath,
Utf8String(),
Utf8String::fromByteArray(contents),
hasUnsavedContent,
documentRevision}});
@@ -330,7 +275,6 @@ void BackendCommunicator::unsavedFilesUpdated(const QString &filePath,
// TODO: Send new only if changed
unsavedFilesUpdated({{filePath,
Utf8String(),
Utf8String::fromByteArray(contents),
hasUnsavedContent,
documentRevision}});
@@ -412,10 +356,8 @@ void BackendCommunicator::documentsChangedWithRevisionCheck(Core::IDocument *doc
{
const auto textDocument = qobject_cast<TextDocument*>(document);
const auto filePath = textDocument->filePath().toString();
const QString projectPartId = CppTools::CppToolsBridge::projectPartIdForFile(filePath);
documentsChangedWithRevisionCheck(FileContainer(filePath,
projectPartId,
Utf8StringVector(),
textDocument->document()->revision()));
}
@@ -510,8 +452,6 @@ void BackendCommunicator::logError(const QString &text)
void BackendCommunicator::initializeBackendWithCurrentData()
{
projectPartsUpdatedForFallback();
projectPartsUpdatedForCurrentProjects();
unsavedFilesUpdatedForUiHeaders();
restoreCppEditorDocuments();
documentVisibilityChanged();
@@ -537,19 +477,6 @@ void BackendCommunicator::documentsClosed(const FileContainers &fileContainers)
m_sender->documentsClosed(message);
}
void BackendCommunicator::projectPartsUpdated(
const ProjectPartContainers &projectPartContainers)
{
const ProjectPartsUpdatedMessage message(projectPartContainers);
m_sender->projectPartsUpdated(message);
}
void BackendCommunicator::projectPartsRemoved(const QStringList &projectPartIds)
{
const ProjectPartsRemovedMessage message((Utf8StringVector(projectPartIds)));
m_sender->projectPartsRemoved(message);
}
void BackendCommunicator::unsavedFilesUpdated(const FileContainers &fileContainers)
{
const UnsavedFilesUpdatedMessage message(fileContainers);
@@ -566,14 +493,12 @@ void BackendCommunicator::requestCompletions(ClangCompletionAssistProcessor *ass
const QString &filePath,
quint32 line,
quint32 column,
const QString &projectFilePath,
qint32 funcNameStartLine,
qint32 funcNameStartColumn)
{
const RequestCompletionsMessage message(filePath,
line,
column,
projectFilePath,
funcNameStartLine,
funcNameStartColumn);
m_sender->requestCompletions(message);

View File

@@ -32,7 +32,6 @@
#include <clangsupport/clangcodemodelconnectionclient.h>
#include <clangsupport/filecontainer.h>
#include <clangsupport/projectpartcontainer.h>
#include <QFuture>
#include <QObject>
@@ -56,7 +55,6 @@ class BackendCommunicator : public QObject
public:
using FileContainer = ClangBackEnd::FileContainer;
using FileContainers = QVector<ClangBackEnd::FileContainer>;
using ProjectPartContainers = QVector<ClangBackEnd::ProjectPartContainer>;
using LocalUseMap = CppTools::SemanticInfo::LocalUseMap;
public:
@@ -76,11 +74,6 @@ public:
void documentsClosed(const FileContainers &fileContainers);
void documentVisibilityChanged();
void projectPartsUpdated(const QVector<CppTools::ProjectPart::Ptr> projectParts);
void projectPartsUpdated(const ProjectPartContainers &projectPartContainers);
void projectPartsUpdatedForFallback();
void projectPartsRemoved(const QStringList &projectPartIds);
void unsavedFilesUpdated(Core::IDocument *document);
void unsavedFilesUpdated(const QString &filePath,
const QByteArray &contents,
@@ -93,7 +86,6 @@ public:
const QString &filePath,
quint32 line,
quint32 column,
const QString &projectFilePath,
qint32 funcNameStartLine = -1,
qint32 funcNameStartColumn = -1);
void requestAnnotations(const ClangBackEnd::FileContainer &fileContainer);
@@ -119,7 +111,6 @@ public:
private:
void initializeBackend();
void initializeBackendWithCurrentData();
void projectPartsUpdatedForCurrentProjects();
void restoreCppEditorDocuments();
void resetCppEditorDocumentProcessors();
void unsavedFilesUpdatedForUiHeaders();

View File

@@ -199,16 +199,9 @@ void BackendReceiver::annotations(const AnnotationsMessage &message)
<< message.skippedPreprocessorRanges.size() << "skipped preprocessor ranges";
auto processor = ClangEditorDocumentProcessor::get(message.fileContainer.filePath);
if (!processor)
return;
const QString projectPartId = message.fileContainer.projectPartId;
const QString filePath = message.fileContainer.filePath;
const QString documentProjectPartId = CppTools::CppToolsBridge::projectPartIdForFile(filePath);
if (projectPartId != documentProjectPartId)
return;
const quint32 documentRevision = message.fileContainer.documentRevision;
if (message.onlyTokenInfos) {
processor->updateTokenInfos(message.tokenInfos, documentRevision);

View File

@@ -71,20 +71,6 @@ void BackendSender::documentsClosed(const DocumentsClosedMessage &message)
m_connection->serverProxy().documentsClosed(message);
}
void BackendSender::projectPartsUpdated(const ProjectPartsUpdatedMessage &message)
{
QTC_CHECK(m_connection->isConnected());
qCDebugIpc() << message;
m_connection->serverProxy().projectPartsUpdated(message);
}
void BackendSender::projectPartsRemoved(const ProjectPartsRemovedMessage &message)
{
QTC_CHECK(m_connection->isConnected());
qCDebugIpc() << message;
m_connection->serverProxy().projectPartsRemoved(message);
}
void BackendSender::unsavedFilesUpdated(const UnsavedFilesUpdatedMessage &message)
{
QTC_CHECK(m_connection->isConnected());

View File

@@ -44,9 +44,6 @@ public:
void documentsClosed(const ClangBackEnd::DocumentsClosedMessage &message) override;
void documentVisibilityChanged(const ClangBackEnd::DocumentVisibilityChangedMessage &message) override;
void projectPartsUpdated(const ClangBackEnd::ProjectPartsUpdatedMessage &message) override;
void projectPartsRemoved(const ClangBackEnd::ProjectPartsRemovedMessage &message) override;
void unsavedFilesUpdated(const ClangBackEnd::UnsavedFilesUpdatedMessage &message) override;
void unsavedFilesRemoved(const ClangBackEnd::UnsavedFilesRemovedMessage &message) override;

View File

@@ -577,7 +577,6 @@ void ClangCompletionAssistProcessor::sendFileContent(const QByteArray &customFil
BackendCommunicator &communicator = m_interface->communicator();
communicator.documentsChanged({{m_interface->fileName(),
Utf8String(),
Utf8String::fromByteArray(info.unsavedContent),
info.isDocumentModified,
uint(m_interface->textDocument()->revision())}});
@@ -658,12 +657,10 @@ bool ClangCompletionAssistProcessor::sendCompletionRequest(int position,
const Position cursorPosition = extractLineColumn(position);
const Position functionNameStart = extractLineColumn(functionNameStartPosition);
const QString projectPartId = CppTools::CppToolsBridge::projectPartIdForFile(filePath);
communicator.requestCompletions(this,
filePath,
uint(cursorPosition.line),
uint(cursorPosition.column),
projectPartId,
functionNameStart.line,
functionNameStart.column);
setLastCompletionPosition(filePath, position);

View File

@@ -143,7 +143,7 @@ void ClangEditorDocumentProcessor::semanticRehighlight()
m_semanticHighlighter.updateFormatMapFromFontSettings();
if (m_projectPart)
requestAnnotationsFromBackend(m_projectPart->id());
requestAnnotationsFromBackend();
}
CppTools::SemanticInfo ClangEditorDocumentProcessor::recalculateSemanticInfo()
@@ -588,8 +588,7 @@ private:
};
} // namespace
void ClangEditorDocumentProcessor::updateBackendDocument(
CppTools::ProjectPart &projectPart)
void ClangEditorDocumentProcessor::updateBackendDocument(CppTools::ProjectPart &projectPart)
{
// On registration we send the document content immediately as an unsaved
// file, because
@@ -605,10 +604,17 @@ void ClangEditorDocumentProcessor::updateBackendDocument(
return;
}
const QStringList projectPartOptions = ClangCodeModel::Utils::createClangOptions(
projectPart,
CppTools::ProjectFile::Unsupported); // No language option as FileOptionsBuilder adds it.
const FileOptionsBuilder fileOptions(filePath(), projectPart);
m_diagnosticConfigId = fileOptions.diagnosticConfigId();
const QStringList compilationArguments = projectPartOptions + fileOptions.options();
m_communicator.documentsOpened(
{fileContainerWithOptionsAndDocumentContent(projectPart, fileOptions.options())});
{fileContainerWithOptionsAndDocumentContent(compilationArguments)});
ClangCodeModel::Utils::setLastSentDocumentRevision(filePath(), revision());
}
@@ -621,16 +627,14 @@ void ClangEditorDocumentProcessor::closeBackendDocument()
void ClangEditorDocumentProcessor::updateBackendDocumentIfProjectPartExists()
{
if (m_projectPart) {
const ClangBackEnd::FileContainer fileContainer = fileContainerWithDocumentContent(
m_projectPart->id());
const ClangBackEnd::FileContainer fileContainer = fileContainerWithDocumentContent();
m_communicator.documentsChangedWithRevisionCheck(fileContainer);
}
}
void ClangEditorDocumentProcessor::requestAnnotationsFromBackend(const QString &projectpartId)
void ClangEditorDocumentProcessor::requestAnnotationsFromBackend()
{
const auto fileContainer = fileContainerWithDocumentContent(projectpartId);
const auto fileContainer = fileContainerWithDocumentContent();
m_communicator.requestAnnotations(fileContainer);
}
@@ -660,12 +664,7 @@ ClangEditorDocumentProcessor::creatorForHeaderErrorDiagnosticWidget(
ClangBackEnd::FileContainer ClangEditorDocumentProcessor::simpleFileContainer(
const QByteArray &codecName) const
{
Utf8String projectPartId;
if (m_projectPart)
projectPartId = m_projectPart->id();
return ClangBackEnd::FileContainer(filePath(),
projectPartId,
Utf8String(),
false,
revision(),
@@ -673,21 +672,19 @@ ClangBackEnd::FileContainer ClangEditorDocumentProcessor::simpleFileContainer(
}
ClangBackEnd::FileContainer ClangEditorDocumentProcessor::fileContainerWithOptionsAndDocumentContent(
CppTools::ProjectPart &projectPart, const QStringList &fileOptions) const
const QStringList &compilationArguments) const
{
return ClangBackEnd::FileContainer(filePath(),
projectPart.id(),
Utf8StringVector(fileOptions),
Utf8StringVector(compilationArguments),
textDocument()->toPlainText(),
true,
revision());
}
ClangBackEnd::FileContainer
ClangEditorDocumentProcessor::fileContainerWithDocumentContent(const QString &projectpartId) const
ClangEditorDocumentProcessor::fileContainerWithDocumentContent() const
{
return ClangBackEnd::FileContainer(filePath(),
projectpartId,
textDocument()->toPlainText(),
true,
revision());

View File

@@ -118,14 +118,14 @@ private:
void updateBackendProjectPartAndDocument();
void updateBackendDocument(CppTools::ProjectPart &projectPart);
void updateBackendDocumentIfProjectPartExists();
void requestAnnotationsFromBackend(const QString &projectpartId);
void requestAnnotationsFromBackend();
HeaderErrorDiagnosticWidgetCreator creatorForHeaderErrorDiagnosticWidget(
const ClangBackEnd::DiagnosticContainer &firstHeaderErrorDiagnostic);
ClangBackEnd::FileContainer simpleFileContainer(const QByteArray &codecName = QByteArray()) const;
ClangBackEnd::FileContainer fileContainerWithOptionsAndDocumentContent(
CppTools::ProjectPart &projectPart, const QStringList &fileOptions) const;
ClangBackEnd::FileContainer fileContainerWithDocumentContent(const QString &projectpartId) const;
const QStringList &compilationArguments) const;
ClangBackEnd::FileContainer fileContainerWithDocumentContent() const;
private:
TextEditor::TextDocument &m_document;

View File

@@ -50,8 +50,6 @@
#include <projectexplorer/session.h>
#include <clangsupport/filecontainer.h>
#include <clangsupport/projectpartcontainer.h>
#include <clangsupport/projectpartsupdatedmessage.h>
#include <utils/algorithm.h>
#include <utils/qtcassert.h>
@@ -107,8 +105,6 @@ ModelManagerSupportClang::ModelManagerSupportClang()
CppTools::CppCodeModelSettings *settings = CppTools::codeModelSettings().data();
connect(settings, &CppTools::CppCodeModelSettings::clangDiagnosticConfigsInvalidated,
this, &ModelManagerSupportClang::onDiagnosticConfigsInvalidated);
m_communicator.projectPartsUpdatedForFallback();
}
ModelManagerSupportClang::~ModelManagerSupportClang()
@@ -411,17 +407,16 @@ void ModelManagerSupportClang::onProjectPartsUpdated(ProjectExplorer::Project *p
const CppTools::ProjectInfo projectInfo = cppModelManager()->projectInfo(project);
QTC_ASSERT(projectInfo.isValid(), return);
m_communicator.projectPartsUpdated(projectInfo.projectParts());
m_communicator.projectPartsUpdatedForFallback();
QStringList projectPartIds;
for (const CppTools::ProjectPart::Ptr &projectPart : projectInfo.projectParts())
projectPartIds.append(projectPart->id());
onProjectPartsRemoved(projectPartIds);
}
void ModelManagerSupportClang::onProjectPartsRemoved(const QStringList &projectPartIds)
{
if (!projectPartIds.isEmpty()) {
closeBackendDocumentsWithProjectParts(projectPartIds);
m_communicator.projectPartsRemoved(projectPartIds);
m_communicator.projectPartsUpdatedForFallback();
}
if (!projectPartIds.isEmpty())
reinitializeBackendDocuments(projectPartIds);
}
static ClangEditorDocumentProcessors clangProcessorsWithDiagnosticConfig(
@@ -445,8 +440,7 @@ clangProcessorsWithProjectParts(const QStringList &projectPartIds)
});
}
void ModelManagerSupportClang::closeBackendDocumentsWithProjectParts(
const QStringList &projectPartIds)
void ModelManagerSupportClang::reinitializeBackendDocuments(const QStringList &projectPartIds)
{
const auto processors = clangProcessorsWithProjectParts(projectPartIds);
foreach (ClangEditorDocumentProcessor *processor, processors) {

View File

@@ -109,7 +109,7 @@ private:
void onDiagnosticConfigsInvalidated(const QVector<Core::Id> &configIds);
void closeBackendDocumentsWithProjectParts(const QStringList &projectPartIds);
void reinitializeBackendDocuments(const QStringList &projectPartIds);
void connectTextDocumentToTranslationUnit(TextEditor::TextDocument *textDocument);
void connectTextDocumentToUnsavedFiles(TextEditor::TextDocument *textDocument);

View File

@@ -63,26 +63,6 @@ using namespace CppTools;
namespace ClangCodeModel {
namespace Utils {
/**
* @brief Creates list of message-line arguments required for correct parsing
* @param pPart Null if file isn't part of any project
* @param fileName Path to file, non-empty
*/
QStringList createClangOptions(const ProjectPart::Ptr &pPart, const QString &fileName)
{
ProjectFile::Kind fileKind = ProjectFile::Unclassified;
if (!pPart.isNull())
foreach (const ProjectFile &file, pPart->files)
if (file.path == fileName) {
fileKind = file.kind;
break;
}
if (fileKind == ProjectFile::Unclassified)
fileKind = ProjectFile::classify(fileName);
return createClangOptions(pPart, fileKind);
}
class LibClangOptionsBuilder final : public CompilerOptionsBuilder
{
public:
@@ -122,16 +102,10 @@ private:
}
};
/**
* @brief Creates list of message-line arguments required for correct parsing
* @param pPart Null if file isn't part of any project
* @param fileKind Determines language and source/header state
*/
QStringList createClangOptions(const ProjectPart::Ptr &pPart, ProjectFile::Kind fileKind)
QStringList createClangOptions(const ProjectPart &projectPart, ProjectFile::Kind fileKind)
{
if (!pPart)
return QStringList();
return LibClangOptionsBuilder(*pPart).build(fileKind, CompilerOptionsBuilder::PchUsage::None);
return LibClangOptionsBuilder(projectPart)
.build(fileKind, CompilerOptionsBuilder::PchUsage::None);
}
ProjectPart::Ptr projectPartForFile(const QString &filePath)

View File

@@ -50,10 +50,8 @@ namespace Utils {
CppTools::CppEditorDocumentHandle *cppDocument(const QString &filePath);
void setLastSentDocumentRevision(const QString &filePath, uint revision);
QStringList createClangOptions(const CppTools::ProjectPart::Ptr &pPart,
QStringList createClangOptions(const CppTools::ProjectPart &projectPart,
CppTools::ProjectFile::Kind fileKind);
QStringList createClangOptions(const CppTools::ProjectPart::Ptr &pPart,
const QString &fileName = QString());
CppTools::ProjectPart::Ptr projectPartForFile(const QString &filePath);
CppTools::ProjectPart::Ptr projectPartForFileBasedOnProcessor(const QString &filePath);

View File

@@ -50,8 +50,6 @@ HEADERS += \
$$PWD/diagnosticsetiterator.h \
$$PWD/fixit.h \
$$PWD/fulltokeninfo.h \
$$PWD/projectpart.h \
$$PWD/projects.h \
$$PWD/skippedsourceranges.h \
$$PWD/sourcelocation.h \
$$PWD/sourcerange.h \
@@ -106,8 +104,6 @@ SOURCES += \
$$PWD/diagnosticset.cpp \
$$PWD/fixit.cpp \
$$PWD/fulltokeninfo.cpp \
$$PWD/projectpart.cpp \
$$PWD/projects.cpp \
$$PWD/skippedsourceranges.cpp \
$$PWD/sourcelocation.cpp \
$$PWD/sourcerange.cpp \

View File

@@ -55,7 +55,7 @@ static bool useSupportiveTranslationUnit()
namespace ClangBackEnd {
ClangCodeModelServer::ClangCodeModelServer()
: documents(projects, unsavedFiles)
: documents(unsavedFiles)
{
updateAnnotationsTimer.setSingleShot(true);
QObject::connect(&updateAnnotationsTimer,
@@ -74,7 +74,7 @@ ClangCodeModelServer::ClangCodeModelServer()
QObject::connect(documents.clangFileSystemWatcher(),
&ClangFileSystemWatcher::fileChanged,
[this](const Utf8String &filePath) {
if (!documents.hasDocumentWithFilePath(filePath))
if (!documents.hasDocument(filePath))
updateAnnotationsTimer.start(0);
});
}
@@ -161,43 +161,6 @@ void ClangCodeModelServer::documentsClosed(const ClangBackEnd::DocumentsClosedMe
}
}
static DocumentResetInfos toDocumentResetInfos(const std::vector<Document> &documents)
{
DocumentResetInfos infos;
for (const auto &d : documents)
infos.push_back(DocumentResetInfo{d, d.fileContainer()});
return infos;
}
void ClangCodeModelServer::projectPartsUpdated(const ProjectPartsUpdatedMessage &message)
{
qCDebug(serverLog) << "########## projectPartsUpdated";
TIME_SCOPE_DURATION("ClangCodeModelServer::projectPartsUpdated");
try {
projects.createOrUpdate(message.projectContainers);
std::vector<Document> affectedDocuments = documents.setDocumentsDirtyIfProjectPartChanged();
resetDocuments(toDocumentResetInfos(affectedDocuments));
processJobsForVisibleDocuments();
} catch (const std::exception &exception) {
qWarning() << "Error in ClangCodeModelServer::projectPartsUpdated:" << exception.what();
}
}
void ClangCodeModelServer::projectPartsRemoved(const ProjectPartsRemovedMessage &message)
{
qCDebug(serverLog) << "########## projectPartsRemoved";
TIME_SCOPE_DURATION("ClangCodeModelServer::projectPartsRemoved");
try {
projects.remove(message.projectPartIds);
} catch (const std::exception &exception) {
qWarning() << "Error in ClangCodeModelServer::projectPartsRemoved:" << exception.what();
}
}
void ClangCodeModelServer::unsavedFilesUpdated(const UnsavedFilesUpdatedMessage &message)
{
qCDebug(serverLog) << "########## unsavedFilesUpdated";
@@ -232,7 +195,7 @@ void ClangCodeModelServer::requestCompletions(const ClangBackEnd::RequestComplet
TIME_SCOPE_DURATION("ClangCodeModelServer::requestCompletions");
try {
Document document = documents.document(message.filePath, message.projectPartId);
Document document = documents.document(message.filePath);
DocumentProcessor processor = documentProcessors().processor(document);
JobRequest jobRequest = processor.createJobRequest(JobRequest::Type::RequestCompletions);
@@ -255,8 +218,7 @@ void ClangCodeModelServer::requestAnnotations(const RequestAnnotationsMessage &m
TIME_SCOPE_DURATION("ClangCodeModelServer::requestAnnotations");
try {
auto document = documents.document(message.fileContainer.filePath,
message.fileContainer.projectPartId);
auto document = documents.document(message.fileContainer.filePath);
DocumentProcessor processor = documentProcessors().processor(document);
processor.addJob(JobRequest::Type::RequestAnnotations);
@@ -285,8 +247,7 @@ void ClangCodeModelServer::requestReferences(const RequestReferencesMessage &mes
TIME_SCOPE_DURATION("ClangCodeModelServer::requestReferences");
try {
const Document document = documents.document(message.fileContainer.filePath,
message.fileContainer.projectPartId);
const Document document = documents.document(message.fileContainer.filePath);
DocumentProcessor processor = documentProcessors().processor(document);
JobRequest jobRequest = processor.createJobRequest(JobRequest::Type::RequestReferences);
@@ -305,8 +266,7 @@ void ClangCodeModelServer::requestFollowSymbol(const RequestFollowSymbolMessage
TIME_SCOPE_DURATION("ClangCodeModelServer::requestFollowSymbol");
try {
const Utf8String &projectPartId = message.fileContainer.projectPartId;
Document document = documents.document(message.fileContainer.filePath, projectPartId);
Document document = documents.document(message.fileContainer.filePath);
DocumentProcessor processor = documentProcessors().processor(document);
JobRequest jobRequest = processor.createJobRequest(JobRequest::Type::RequestFollowSymbol);
@@ -323,8 +283,7 @@ void ClangCodeModelServer::requestToolTip(const RequestToolTipMessage &message)
TIME_SCOPE_DURATION("ClangCodeModelServer::requestToolTip");
try {
const Document document = documents.document(message.fileContainer.filePath,
message.fileContainer.projectPartId);
const Document document = documents.document(message.fileContainer.filePath);
DocumentProcessor processor = documentProcessors().processor(document);
JobRequest jobRequest = processor.createJobRequest(JobRequest::Type::RequestToolTip);
@@ -504,7 +463,7 @@ DocumentProcessors &ClangCodeModelServer::documentProcessors()
// DocumentProcessors needs a reference to the client, but the client
// is not known at construction time of ClangCodeModelServer, so
// construct DocumentProcessors in a lazy manner.
documentProcessors_.reset(new DocumentProcessors(documents, unsavedFiles, projects, *client()));
documentProcessors_.reset(new DocumentProcessors(documents, unsavedFiles, *client()));
}
return *documentProcessors_.data();

View File

@@ -25,8 +25,6 @@
#pragma once
#include "projectpart.h"
#include "projects.h"
#include "clangdocument.h"
#include "clangdocuments.h"
#include "clangdocumentprocessors.h"
@@ -61,9 +59,6 @@ public:
void documentsClosed(const DocumentsClosedMessage &message) override;
void documentVisibilityChanged(const DocumentVisibilityChangedMessage &message) override;
void projectPartsUpdated(const ProjectPartsUpdatedMessage &message) override;
void projectPartsRemoved(const ProjectPartsRemovedMessage &message) override;
void unsavedFilesUpdated(const UnsavedFilesUpdatedMessage &message) override;
void unsavedFilesRemoved(const UnsavedFilesRemovedMessage &message) override;
@@ -97,7 +92,6 @@ private:
void addAndRunUpdateJobs(std::vector<Document> documents);
private:
ProjectParts projects;
UnsavedFiles unsavedFiles;
Documents documents;

View File

@@ -29,7 +29,6 @@
#include "clangstring.h"
#include "clangunsavedfilesshallowarguments.h"
#include "codecompleter.h"
#include "projectpart.h"
#include "clangexceptions.h"
#include "clangtranslationunit.h"
#include "clangtranslationunits.h"
@@ -51,8 +50,7 @@ class DocumentData
{
public:
DocumentData(const Utf8String &filePath,
const ProjectPart &projectPart,
const Utf8StringVector &fileArguments,
const Utf8StringVector &compilationArguments,
Documents &documents);
~DocumentData();
@@ -60,10 +58,7 @@ public:
Documents &documents;
const Utf8String filePath;
const Utf8StringVector fileArguments;
ProjectPart projectPart;
TimePoint lastProjectPartChangeTimePoint;
const Utf8StringVector compilationArguments;
TranslationUnits translationUnits;
@@ -84,16 +79,13 @@ public:
};
DocumentData::DocumentData(const Utf8String &filePath,
const ProjectPart &projectPart,
const Utf8StringVector &fileArguments,
const Utf8StringVector &compilationArguments,
Documents &documents)
: documents(documents),
filePath(filePath),
fileArguments(fileArguments),
projectPart(projectPart),
lastProjectPartChangeTimePoint(Clock::now()),
compilationArguments(compilationArguments),
translationUnits(filePath),
isDirtyChangeTimePoint(lastProjectPartChangeTimePoint)
isDirtyChangeTimePoint(Clock::now())
{
dependedFilePaths.insert(filePath);
translationUnits.createAndAppend();
@@ -104,13 +96,11 @@ DocumentData::~DocumentData()
}
Document::Document(const Utf8String &filePath,
const ProjectPart &projectPart,
const Utf8StringVector &fileArguments,
const Utf8StringVector &compilationArguments,
Documents &documents,
FileExistsCheck fileExistsCheck)
: d(std::make_shared<DocumentData>(filePath,
projectPart,
fileArguments,
compilationArguments,
documents))
{
if (fileExistsCheck == FileExistsCheck::Check)
@@ -167,11 +157,11 @@ Utf8String Document::filePath() const
return d->filePath;
}
Utf8StringVector Document::fileArguments() const
Utf8StringVector Document::compilationArguments() const
{
checkIfNull();
return d->fileArguments;
return d->compilationArguments;
}
FileContainer Document::fileContainer() const
@@ -179,34 +169,12 @@ FileContainer Document::fileContainer() const
checkIfNull();
return FileContainer(d->filePath,
d->projectPart.id(),
d->fileArguments,
d->compilationArguments,
Utf8String(),
false,
d->documentRevision);
}
const ProjectPart &Document::projectPart() const
{
checkIfNull();
return d->projectPart;
}
const TimePoint Document::lastProjectPartChangeTimePoint() const
{
checkIfNull();
return d->lastProjectPartChangeTimePoint;
}
bool Document::isProjectPartOutdated() const
{
checkIfNull();
return d->projectPart.lastChangeTimePoint() >= d->lastProjectPartChangeTimePoint;
}
uint Document::documentRevision() const
{
checkIfNull();
@@ -303,16 +271,6 @@ TimePoint Document::isDirtyTimeChangePoint() const
return d->isDirtyChangeTimePoint;
}
bool Document::setDirtyIfProjectPartIsOutdated()
{
if (isProjectPartOutdated()) {
setDirty();
return true;
}
return false;
}
void Document::setDirtyIfDependencyIsMet(const Utf8String &filePath)
{
if (d->dependedFilePaths.contains(filePath) && isMainFileAndExistsOrIsOtherFile(filePath))
@@ -322,14 +280,11 @@ void Document::setDirtyIfDependencyIsMet(const Utf8String &filePath)
TranslationUnitUpdateInput Document::createUpdateInput() const
{
TranslationUnitUpdateInput updateInput;
updateInput.parseNeeded = isProjectPartOutdated();
updateInput.reparseNeeded = d->isDirty;
updateInput.needsToBeReparsedChangeTimePoint = d->isDirtyChangeTimePoint;
updateInput.filePath = filePath();
updateInput.fileArguments = fileArguments();
updateInput.filePath = d->filePath;
updateInput.compilationArguments = d->compilationArguments;
updateInput.unsavedFiles = d->documents.unsavedFiles();
updateInput.projectId = projectPart().id();
updateInput.projectArguments = projectPart().arguments();
return updateInput;
}
@@ -360,9 +315,6 @@ void Document::incorporateUpdaterResult(const TranslationUnitUpdateResult &resul
return;
}
if (result.hasParsed())
d->lastProjectPartChangeTimePoint = result.parseTimePoint;
if (result.hasParsed() || result.hasReparsed()) {
d->dependedFilePaths = result.dependedOnFilePaths;
@@ -456,15 +408,13 @@ bool Document::isMainFileAndExistsOrIsOtherFile(const Utf8String &filePath) cons
bool operator==(const Document &first, const Document &second)
{
return first.filePath() == second.filePath()
&& first.projectPart().id() == second.projectPart().id();
return first.filePath() == second.filePath();
}
std::ostream &operator<<(std::ostream &os, const Document &document)
{
os << "("
<< document.filePath() << ", "
<< document.projectPart().id() << ", "
<< document.documentRevision()
<< ")";

View File

@@ -47,7 +47,6 @@ class TranslationUnit;
class TranslationUnits;
class DocumentData;
class TranslationUnitUpdateResult;
class ProjectPart;
class FileContainer;
class Documents;
@@ -61,8 +60,7 @@ public:
Document() = default;
Document(const Utf8String &filePath,
const ProjectPart &projectPart,
const Utf8StringVector &fileArguments,
const Utf8StringVector &compilationArguments,
Documents &documents,
FileExistsCheck fileExistsCheck = FileExistsCheck::Check);
~Document();
@@ -81,13 +79,9 @@ public:
long useCount() const;
Utf8String filePath() const;
Utf8StringVector fileArguments() const;
Utf8StringVector compilationArguments() const;
FileContainer fileContainer() const;
const ProjectPart &projectPart() const;
const TimePoint lastProjectPartChangeTimePoint() const;
bool isProjectPartOutdated() const;
uint documentRevision() const;
void setDocumentRevision(uint revision);
@@ -107,7 +101,6 @@ public:
bool isDirty() const;
TimePoint isDirtyTimeChangePoint() const;
bool setDirtyIfProjectPartIsOutdated();
void setDirtyIfDependencyIsMet(const Utf8String &filePath);
TranslationUnitUpdateInput createUpdateInput() const;

View File

@@ -45,16 +45,14 @@ public:
DocumentProcessorData(const Document &document,
Documents &documents,
UnsavedFiles &unsavedFiles,
ProjectParts &projects,
ClangCodeModelClientInterface &client)
: document(document)
, documents(documents)
, jobs(documents, unsavedFiles, projects, client, QFileInfo(document.filePath()).fileName())
, jobs(documents, unsavedFiles, client, QFileInfo(document.filePath()).fileName())
, supportiveTranslationUnitInitializer(document, jobs)
{
const auto isDocumentClosedChecker = [this](const Utf8String &filePath,
const Utf8String &projectPartId) {
return !this->documents.hasDocument(filePath, projectPartId);
const auto isDocumentClosedChecker = [this](const Utf8String &filePath) {
return !this->documents.hasDocument(filePath);
};
supportiveTranslationUnitInitializer.setIsDocumentClosedChecker(isDocumentClosedChecker);
}
@@ -70,12 +68,10 @@ public:
DocumentProcessor::DocumentProcessor(const Document &document,
Documents &documents,
UnsavedFiles &unsavedFiles,
ProjectParts &projects,
ClangCodeModelClientInterface &client)
: d(std::make_shared<DocumentProcessorData>(document,
documents,
unsavedFiles,
projects,
client))
{
}

View File

@@ -37,7 +37,6 @@ class Document;
class Documents;
class DocumentProcessorData;
class JobRequest;
class ProjectParts;
class UnsavedFiles;
class DocumentProcessor
@@ -46,7 +45,6 @@ public:
DocumentProcessor(const Document &document,
Documents &documents,
UnsavedFiles &unsavedFiles,
ProjectParts &projects,
ClangCodeModelClientInterface &client);
JobRequest createJobRequest(JobRequest::Type type,

View File

@@ -26,7 +26,6 @@
#include "clangdocumentprocessors.h"
#include "clangdocument.h"
#include "clangexceptions.h"
#include "projectpart.h"
#include <utils/algorithm.h>
@@ -34,40 +33,31 @@ namespace ClangBackEnd {
DocumentProcessors::DocumentProcessors(Documents &documents,
UnsavedFiles &unsavedFiles,
ProjectParts &projects,
ClangCodeModelClientInterface &client)
: m_documents(documents)
, m_unsavedFiles(unsavedFiles)
, m_projects(projects)
, m_client(client)
{
}
static bool operator<(const DocumentId &lhs, const DocumentId &rhs)
{
return lhs.filePath < rhs.filePath
|| (lhs.filePath == rhs.filePath && lhs.projectPartId < lhs.projectPartId);
}
DocumentProcessor DocumentProcessors::create(const Document &document)
{
const DocumentId id{document.filePath(), document.projectPart().id()};
if (m_processors.contains(id))
throw DocumentProcessorAlreadyExists(document.filePath(), document.projectPart().id());
const Utf8String filePath{document.filePath()};
if (m_processors.contains(filePath))
throw DocumentProcessorAlreadyExists(document.filePath());
const DocumentProcessor element(document, m_documents, m_unsavedFiles, m_projects, m_client);
m_processors.insert(id, element);
const DocumentProcessor element(document, m_documents, m_unsavedFiles, m_client);
m_processors.insert(filePath, element);
return element;
}
DocumentProcessor DocumentProcessors::processor(const Document &document)
{
const DocumentId id{document.filePath(), document.projectPart().id()};
const auto it = m_processors.find(id);
const Utf8String filePath = document.filePath();
const auto it = m_processors.find(filePath);
if (it == m_processors.end())
throw DocumentProcessorDoesNotExist(document.filePath(), document.projectPart().id());
throw DocumentProcessorDoesNotExist(filePath);
return *it;
}
@@ -79,24 +69,9 @@ QList<DocumentProcessor> DocumentProcessors::processors() const
void DocumentProcessors::remove(const Document &document)
{
const DocumentId id{document.filePath(), document.projectPart().id()};
const int itemsRemoved = m_processors.remove(id);
const int itemsRemoved = m_processors.remove(document.filePath());
if (itemsRemoved != 1)
throw DocumentProcessorDoesNotExist(document.filePath(), document.projectPart().id());
}
static JobRequests jobsToTakeOver(const JobRequests &jobsStillInQueue,
const Utf8String &updatedProjectPartId)
{
JobRequests jobs = Utils::filtered(jobsStillInQueue, [](const JobRequest &job) {
return job.isTakeOverable();
});
for (JobRequest &job : jobs)
job.projectPartId = updatedProjectPartId;
return jobs;
throw DocumentProcessorDoesNotExist(document.filePath());
}
void DocumentProcessors::reset(const Document &oldDocument, const Document &newDocument)
@@ -105,8 +80,10 @@ void DocumentProcessors::reset(const Document &oldDocument, const Document &newD
// processed job requests for the new processor...
const JobRequests jobsStillInQueue = processor(oldDocument).stop();
// ...but do not take over irrelevant ones.
const JobRequests jobsForNewProcessor = jobsToTakeOver(jobsStillInQueue,
newDocument.projectPart().id());
const JobRequests jobsForNewProcessor = Utils::filtered(jobsStillInQueue,
[](const JobRequest &job) {
return job.isTakeOverable();
});
// Remove current processor
remove(oldDocument);

View File

@@ -37,18 +37,11 @@ namespace ClangBackEnd {
class Document;
class DocumentProcessor;
class DocumentId {
public:
Utf8String filePath;
Utf8String projectPartId;
};
class DocumentProcessors
{
public:
DocumentProcessors(Documents &documents,
UnsavedFiles &unsavedFiles,
ProjectParts &projects,
ClangCodeModelClientInterface &client);
DocumentProcessor create(const Document &document);
@@ -66,10 +59,9 @@ public: // for tests
private:
Documents &m_documents;
UnsavedFiles &m_unsavedFiles;
ProjectParts &m_projects;
ClangCodeModelClientInterface &m_client;
QMap<DocumentId, DocumentProcessor> m_processors;
QMap<Utf8String, DocumentProcessor> m_processors;
};
} // namespace ClangBackEnd

View File

@@ -28,7 +28,6 @@
#include <diagnosticset.h>
#include <tokenprocessor.h>
#include <clangexceptions.h>
#include <projects.h>
#include <skippedsourceranges.h>
#include <unsavedfiles.h>
@@ -42,8 +41,7 @@ namespace ClangBackEnd {
bool operator==(const FileContainer &fileContainer, const Document &document)
{
return fileContainer.filePath == document.filePath()
&& fileContainer.projectPartId == document.projectPart().id();
return fileContainer.filePath == document.filePath();
}
bool operator==(const Document &document, const FileContainer &fileContainer)
@@ -51,9 +49,8 @@ bool operator==(const Document &document, const FileContainer &fileContainer)
return fileContainer == document;
}
Documents::Documents(ProjectParts &projects, UnsavedFiles &unsavedFiles)
Documents::Documents(UnsavedFiles &unsavedFiles)
: fileSystemWatcher(*this),
projectParts(projects),
unsavedFiles_(unsavedFiles)
{
}
@@ -103,8 +100,6 @@ static bool removeFromFileContainer(QVector<FileContainer> &fileContainers, cons
void Documents::remove(const QVector<FileContainer> &fileContainers)
{
checkIfProjectPartsExists(fileContainers);
removeDocuments(fileContainers);
updateDocumentsWithChangedDependencies(fileContainers);
}
@@ -122,26 +117,19 @@ void Documents::setVisibleInEditors(const Utf8StringVector &filePaths)
document.setIsVisibleInEditor(filePaths.contains(document.filePath()), timePoint);
}
const Document &Documents::document(const Utf8String &filePath, const Utf8String &projectPartId) const
const Document &Documents::document(const Utf8String &filePath) const
{
checkIfProjectPartExists(projectPartId);
auto findIterator = findDocument(filePath, projectPartId);
auto findIterator = findDocument(filePath);
if (findIterator == documents_.end())
throw DocumentDoesNotExistException(filePath, projectPartId);
throw DocumentDoesNotExistException(filePath);
return *findIterator;
}
const Document &Documents::document(const FileContainer &fileContainer) const
{
return document(fileContainer.filePath, fileContainer.projectPartId);
}
bool Documents::hasDocument(const Utf8String &filePath, const Utf8String &projectPartId) const
{
return hasDocument(FileContainer(filePath, projectPartId));
return document(fileContainer.filePath);
}
const std::vector<Document> &Documents::documents() const
@@ -185,18 +173,6 @@ void Documents::updateDocumentsWithChangedDependencies(const QVector<FileContain
updateDocumentsWithChangedDependency(fileContainer.filePath);
}
std::vector<Document> Documents::setDocumentsDirtyIfProjectPartChanged()
{
std::vector<Document> affectedDocuments;
for (auto &document : documents_) {
if (document.setDirtyIfProjectPartIsOutdated())
affectedDocuments.push_back(document);
}
return affectedDocuments;
}
QVector<FileContainer> Documents::newerFileContainers(const QVector<FileContainer> &fileContainers) const
{
QVector<FileContainer> newerContainers;
@@ -229,8 +205,7 @@ Document Documents::createDocument(const FileContainer &fileContainer)
: Document::FileExistsCheck::Check;
documents_.emplace_back(fileContainer.filePath,
projectParts.project(fileContainer.projectPartId),
fileContainer.fileArguments,
fileContainer.compilationArguments,
*this,
checkIfFileExists);
@@ -249,7 +224,7 @@ std::vector<Document> Documents::updateDocument(const FileContainer &fileContain
return documents;
}
std::vector<Document>::iterator Documents::findDocument(const FileContainer &fileContainer)
std::vector<Document>::const_iterator Documents::findDocument(const FileContainer &fileContainer) const
{
return std::find(documents_.begin(), documents_.end(), fileContainer);
}
@@ -269,20 +244,7 @@ std::vector<Document> Documents::findAllDocumentsWithFilePath(const Utf8String &
return documents;
}
std::vector<Document>::const_iterator Documents::findDocument(const Utf8String &filePath, const Utf8String &projectPartId) const
{
FileContainer fileContainer(filePath, projectPartId);
return std::find(documents_.begin(), documents_.end(), fileContainer);
}
bool Documents::hasDocument(const FileContainer &fileContainer) const
{
auto findIterator = std::find(documents_.begin(), documents_.end(), fileContainer);
return findIterator != documents_.end();
}
bool Documents::hasDocumentWithFilePath(const Utf8String &filePath) const
bool Documents::hasDocument(const Utf8String &filePath) const
{
auto filePathCompare = [&filePath] (const Document &document) {
return document.filePath() == filePath;
@@ -293,42 +255,19 @@ bool Documents::hasDocumentWithFilePath(const Utf8String &filePath) const
return findIterator != documents_.end();
}
void Documents::checkIfProjectPartExists(const Utf8String &projectFileName) const
{
projectParts.project(projectFileName);
}
void Documents::checkIfProjectPartsExists(const QVector<FileContainer> &fileContainers) const
{
Utf8StringVector notExistingProjectParts;
for (const FileContainer &fileContainer : fileContainers) {
if (!projectParts.hasProjectPart(fileContainer.projectPartId))
notExistingProjectParts.push_back(fileContainer.projectPartId);
}
if (!notExistingProjectParts.isEmpty())
throw ProjectPartDoNotExistException(notExistingProjectParts);
}
void Documents::checkIfDocumentsDoNotExist(const QVector<FileContainer> &fileContainers) const
{
for (const FileContainer &fileContainer : fileContainers) {
if (hasDocument(fileContainer)) {
throw DocumentAlreadyExistsException(fileContainer.filePath,
fileContainer.projectPartId);
}
if (hasDocument(fileContainer.filePath))
throw DocumentAlreadyExistsException(fileContainer.filePath);
}
}
void Documents::checkIfDocumentsForFilePathsExist(const QVector<FileContainer> &fileContainers) const
{
for (const FileContainer &fileContainer : fileContainers) {
if (!hasDocumentWithFilePath(fileContainer.filePath)) {
throw DocumentDoesNotExistException(fileContainer.filePath,
fileContainer.projectPartId);
}
if (!hasDocument(fileContainer.filePath))
throw DocumentDoesNotExistException(fileContainer.filePath);
}
}
@@ -344,8 +283,7 @@ void Documents::removeDocuments(const QVector<FileContainer> &fileContainers)
if (!processedFileContainers.isEmpty()) {
const FileContainer fileContainer = processedFileContainers.first();
throw DocumentDoesNotExistException(fileContainer.filePath,
fileContainer.projectPartId);
throw DocumentDoesNotExistException(fileContainer.filePath);
}
}

View File

@@ -37,13 +37,12 @@
namespace ClangBackEnd {
class ProjectParts;
class UnsavedFiles;
class Documents
{
public:
Documents(ProjectParts &projectParts, UnsavedFiles &unsavedFiles);
Documents(UnsavedFiles &unsavedFiles);
std::vector<Document> create(const QVector<FileContainer> &fileContainers);
std::vector<Document> update(const QVector<FileContainer> &fileContainers);
@@ -52,10 +51,9 @@ public:
void setUsedByCurrentEditor(const Utf8String &filePath);
void setVisibleInEditors(const Utf8StringVector &filePaths);
const Document &document(const Utf8String &filePath, const Utf8String &projectPartId) const;
const Document &document(const Utf8String &filePath) const;
const Document &document(const FileContainer &fileContainer) const;
bool hasDocument(const Utf8String &filePath, const Utf8String &projectPartId) const;
bool hasDocumentWithFilePath(const Utf8String &filePath) const;
bool hasDocument(const Utf8String &filePath) const;
const std::vector<Document> &documents() const;
using IsMatchingDocument = std::function<bool(const Document &document)>;
@@ -68,7 +66,6 @@ public:
void updateDocumentsWithChangedDependency(const Utf8String &filePath);
void updateDocumentsWithChangedDependencies(const QVector<FileContainer> &fileContainers);
std::vector<Document> setDocumentsDirtyIfProjectPartChanged();
QVector<FileContainer> newerFileContainers(const QVector<FileContainer> &fileContainers) const;
@@ -77,12 +74,8 @@ public:
private:
Document createDocument(const FileContainer &fileContainer);
std::vector<Document> updateDocument(const FileContainer &fileContainer);
std::vector<Document>::iterator findDocument(const FileContainer &fileContainer);
std::vector<Document>::const_iterator findDocument(const FileContainer &fileContainer) const;
std::vector<Document> findAllDocumentsWithFilePath(const Utf8String &filePath);
std::vector<Document>::const_iterator findDocument(const Utf8String &filePath, const Utf8String &projectPartId) const;
bool hasDocument(const FileContainer &fileContainer) const;
void checkIfProjectPartExists(const Utf8String &projectFileName) const;
void checkIfProjectPartsExists(const QVector<FileContainer> &fileContainers) const;
void checkIfDocumentsDoNotExist(const QVector<FileContainer> &fileContainers) const;
void checkIfDocumentsForFilePathsExist(const QVector<FileContainer> &fileContainers) const;
@@ -91,7 +84,6 @@ private:
private:
ClangFileSystemWatcher fileSystemWatcher;
std::vector<Document> documents_;
ProjectParts &projectParts;
UnsavedFiles &unsavedFiles_;
};

View File

@@ -32,33 +32,18 @@ const char *ClangBaseException::what() const noexcept
return m_info.constData();
}
ProjectPartDoNotExistException::ProjectPartDoNotExistException(
const Utf8StringVector &projectPartIds)
{
m_info += Utf8StringLiteral("ProjectPart files ")
+ projectPartIds.join(Utf8StringLiteral(", "))
+ Utf8StringLiteral(" does not exist!");
}
DocumentAlreadyExistsException::DocumentAlreadyExistsException(
const Utf8String &filePath,
const Utf8String &projectPartId)
DocumentAlreadyExistsException::DocumentAlreadyExistsException(const Utf8String &filePath)
{
m_info += Utf8StringLiteral("Document '")
+ filePath
+ Utf8StringLiteral("' with the project part id '")
+ projectPartId
+ Utf8StringLiteral("' already exists!");
}
DocumentDoesNotExistException::DocumentDoesNotExistException(const Utf8String &filePath,
const Utf8String &projectPartId)
DocumentDoesNotExistException::DocumentDoesNotExistException(const Utf8String &filePath)
{
m_info += Utf8StringLiteral("Document '")
+ filePath
+ Utf8StringLiteral("' with the project part id '")
+ projectPartId
+ Utf8StringLiteral("' does not exist!");
+ Utf8StringLiteral("' does not exists!");
}
DocumentFileDoesNotExistException::DocumentFileDoesNotExistException(
@@ -74,23 +59,17 @@ DocumentIsNullException::DocumentIsNullException()
m_info = Utf8String::fromUtf8("Tried to access a null Document!");
}
DocumentProcessorAlreadyExists::DocumentProcessorAlreadyExists(const Utf8String &filePath,
const Utf8String &projectPartId)
DocumentProcessorAlreadyExists::DocumentProcessorAlreadyExists(const Utf8String &filePath)
{
m_info = Utf8StringLiteral("Document processor for file '")
+ filePath
+ Utf8StringLiteral("' and project part id '")
+ projectPartId
+ Utf8StringLiteral("' already exists!");
}
DocumentProcessorDoesNotExist::DocumentProcessorDoesNotExist(const Utf8String &filePath,
const Utf8String &projectPartId)
DocumentProcessorDoesNotExist::DocumentProcessorDoesNotExist(const Utf8String &filePath)
{
m_info = Utf8StringLiteral("Document processor for file '")
+ filePath
+ Utf8StringLiteral("' and project part id '")
+ projectPartId
+ Utf8StringLiteral("' does not exist!");
}

View File

@@ -42,24 +42,16 @@ protected:
Utf8String m_info;
};
class ProjectPartDoNotExistException : public ClangBaseException
{
public:
ProjectPartDoNotExistException(const Utf8StringVector &projectPartIds);
};
class DocumentAlreadyExistsException : public ClangBaseException
{
public:
DocumentAlreadyExistsException(const Utf8String &filePath,
const Utf8String &projectPartId);
DocumentAlreadyExistsException(const Utf8String &filePath);
};
class DocumentDoesNotExistException : public ClangBaseException
{
public:
DocumentDoesNotExistException(const Utf8String &filePath,
const Utf8String &projectPartId);
DocumentDoesNotExistException(const Utf8String &filePath);
};
class DocumentFileDoesNotExistException : public ClangBaseException
@@ -77,15 +69,13 @@ public:
class DocumentProcessorAlreadyExists : public ClangBaseException
{
public:
DocumentProcessorAlreadyExists(const Utf8String &filePath,
const Utf8String &projectPartId);
DocumentProcessorAlreadyExists(const Utf8String &filePath);
};
class DocumentProcessorDoesNotExist : public ClangBaseException
{
public:
DocumentProcessorDoesNotExist(const Utf8String &filePath,
const Utf8String &projectPartId);
DocumentProcessorDoesNotExist(const Utf8String &filePath);
};
class TranslationUnitDoesNotExist : public ClangBaseException

View File

@@ -42,7 +42,7 @@ JobContext::JobContext(const JobRequest &jobRequest,
Document JobContext::documentForJobRequest() const
{
return documents->document(jobRequest.filePath, jobRequest.projectPartId);
return documents->document(jobRequest.filePath);
}
bool JobContext::isOutdated() const
@@ -52,7 +52,7 @@ bool JobContext::isOutdated() const
bool JobContext::isDocumentOpen() const
{
const bool hasDocument = documents->hasDocument(jobRequest.filePath, jobRequest.projectPartId);
const bool hasDocument = documents->hasDocument(jobRequest.filePath);
if (!hasDocument)
qCDebug(jobsLog) << "Document already closed for results of" << jobRequest;
@@ -61,7 +61,7 @@ bool JobContext::isDocumentOpen() const
bool JobContext::documentRevisionChanged() const
{
const Document &document = documents->document(jobRequest.filePath, jobRequest.projectPartId);
const Document &document = documents->document(jobRequest.filePath);
const bool revisionChanged = document.documentRevision() != jobRequest.documentRevision;
if (revisionChanged)

View File

@@ -28,16 +28,14 @@
#include "clangdocument.h"
#include "clangdocuments.h"
#include "clangtranslationunits.h"
#include "projects.h"
#include "unsavedfiles.h"
#include <utils/algorithm.h>
namespace ClangBackEnd {
JobQueue::JobQueue(Documents &documents, ProjectParts &projectParts, const Utf8String &logTag)
JobQueue::JobQueue(Documents &documents, const Utf8String &logTag)
: m_documents(documents)
, m_projectParts(projectParts)
, m_logTag(logTag)
{
}
@@ -104,12 +102,12 @@ bool JobQueue::isJobRequestAddable(const JobRequest &jobRequest, QString &notAdd
return false;
}
if (!m_documents.hasDocument(jobRequest.filePath, jobRequest.projectPartId)) {
if (!m_documents.hasDocument(jobRequest.filePath)) {
notAddableReason = "document already closed";
return false;
}
const Document document = m_documents.document(jobRequest.filePath, jobRequest.projectPartId);
const Document document = m_documents.document(jobRequest.filePath);
if (!document.isIntact()) {
notAddableReason = "document not intact";
return false;
@@ -131,22 +129,14 @@ bool JobQueue::isJobRequestExpired(const JobRequest &jobRequest, QString &expira
}
}
bool projectCheckedAndItExists = false;
if (conditions.testFlag(Condition::DocumentClosed)) {
if (!m_documents.hasDocument(jobRequest.filePath, jobRequest.projectPartId)) {
if (!m_documents.hasDocument(jobRequest.filePath)) {
expirationReason = "document already closed";
return true;
}
if (!m_projectParts.hasProjectPart(jobRequest.projectPartId)) {
expirationReason = "project already closed";
return true;
}
projectCheckedAndItExists = true;
const Document document
= m_documents.document(jobRequest.filePath, jobRequest.projectPartId);
= m_documents.document(jobRequest.filePath);
if (!document.isIntact()) {
expirationReason = "document not intact";
return true;
@@ -160,19 +150,6 @@ bool JobQueue::isJobRequestExpired(const JobRequest &jobRequest, QString &expira
}
}
if (conditions.testFlag(Condition::ProjectChanged)) {
if (!projectCheckedAndItExists && !m_projectParts.hasProjectPart(jobRequest.projectPartId)) {
expirationReason = "project already closed";
return true;
}
const ProjectPart &project = m_projectParts.project(jobRequest.projectPartId);
if (project.lastChangeTimePoint() != jobRequest.projectChangeTimePoint) {
expirationReason = "outdated project";
return true;
}
}
return false;
}
@@ -193,8 +170,8 @@ void JobQueue::prioritizeRequests()
{
const auto lessThan = [this] (const JobRequest &r1, const JobRequest &r2) {
// TODO: Getting the TU is O(n) currently, so this might become expensive for large n.
const Document &t1 = m_documents.document(r1.filePath, r1.projectPartId);
const Document &t2 = m_documents.document(r2.filePath, r2.projectPartId);
const Document &t1 = m_documents.document(r1.filePath);
const Document &t2 = m_documents.document(r2.filePath);
return priority(t1) > priority(t2);
};
@@ -267,8 +244,7 @@ JobRequests JobQueue::takeJobRequestsToRunNow()
const JobRequest &request = i.next();
try {
const Document &document = m_documents.document(request.filePath,
request.projectPartId);
const Document &document = m_documents.document(request.filePath);
if (!areRunConditionsMet(request, document))
continue;

View File

@@ -31,13 +31,12 @@
namespace ClangBackEnd {
class ProjectParts;
class Documents;
class JobQueue
{
public:
JobQueue(Documents &documents, ProjectParts &projects, const Utf8String &logTag = Utf8String());
JobQueue(Documents &documents, const Utf8String &logTag = Utf8String());
bool add(const JobRequest &job);
@@ -72,7 +71,6 @@ private:
private:
Documents &m_documents;
ProjectParts &m_projectParts;
Utf8String m_logTag;
IsJobRunningForTranslationUnitHandler m_isJobRunningForTranslationUnitHandler;

View File

@@ -284,9 +284,7 @@ bool JobRequest::operator==(const JobRequest &other) const
&& runConditions == other.runConditions
&& filePath == other.filePath
&& projectPartId == other.projectPartId
&& unsavedFilesChangeTimePoint == other.unsavedFilesChangeTimePoint
&& projectChangeTimePoint == other.projectChangeTimePoint
&& documentRevision == other.documentRevision
&& preferredTranslationUnit == other.preferredTranslationUnit

View File

@@ -81,12 +81,10 @@ public:
DocumentClosed = 1 << 1,
DocumentRevisionChanged = 1 << 2, // Only effective if DocumentIsClosed is also set
UnsavedFilesChanged = 1 << 3,
ProjectChanged = 1 << 4,
AnythingChanged = DocumentClosed
| DocumentRevisionChanged
| UnsavedFilesChanged
| ProjectChanged,
| UnsavedFilesChanged,
};
Q_DECLARE_FLAGS(ExpirationConditions, ExpirationCondition)
@@ -107,9 +105,7 @@ public:
// General
Utf8String filePath;
Utf8String projectPartId;
TimePoint unsavedFilesChangeTimePoint;
TimePoint projectChangeTimePoint;
uint documentRevision = 0;
PreferredTranslationUnit preferredTranslationUnit = PreferredTranslationUnit::RecentlyParsed;

View File

@@ -27,7 +27,6 @@
#include "clangdocument.h"
#include "clangiasyncjob.h"
#include "projects.h"
#include <QDebug>
#include <QFutureSynchronizer>
@@ -40,15 +39,13 @@ namespace ClangBackEnd {
Jobs::Jobs(Documents &documents,
UnsavedFiles &unsavedFiles,
ProjectParts &projectParts,
ClangCodeModelClientInterface &client,
const Utf8String &logTag)
: m_documents(documents)
, m_unsavedFiles(unsavedFiles)
, m_projectParts(projectParts)
, m_client(client)
, m_logTag(logTag)
, m_queue(documents, projectParts, logTag)
, m_queue(documents, logTag)
{
m_queue.setIsJobRunningForTranslationUnitHandler([this](const Utf8String &translationUnitId) {
return isJobRunningForTranslationUnit(translationUnitId);
@@ -80,12 +77,9 @@ JobRequest Jobs::createJobRequest(const Document &document,
{
JobRequest jobRequest(type);
jobRequest.filePath = document.filePath();
jobRequest.projectPartId = document.projectPart().id();
jobRequest.unsavedFilesChangeTimePoint = m_unsavedFiles.lastChangeTimePoint();
jobRequest.documentRevision = document.documentRevision();
jobRequest.preferredTranslationUnit = preferredTranslationUnit;
const ProjectPart &projectPart = m_projectParts.project(document.projectPart().id());
jobRequest.projectChangeTimePoint = projectPart.lastChangeTimePoint();
return jobRequest;
}

View File

@@ -55,7 +55,6 @@ public:
public:
Jobs(Documents &documents,
UnsavedFiles &unsavedFiles,
ProjectParts &projects,
ClangCodeModelClientInterface &client,
const Utf8String &logTag = Utf8String());
~Jobs();
@@ -91,7 +90,6 @@ private:
private:
Documents &m_documents;
UnsavedFiles &m_unsavedFiles;
ProjectParts &m_projectParts;
ClangCodeModelClientInterface &m_client;
Utf8String m_logTag;

View File

@@ -27,14 +27,11 @@
#include "clangjobs.h"
#include "clangtranslationunits.h"
#include "projectpart.h"
#include <utils/qtcassert.h>
namespace ClangBackEnd {
// TODO: Check translation unit id?
SupportiveTranslationUnitInitializer::SupportiveTranslationUnitInitializer(
const Document &document,
Jobs &jobs)
@@ -101,7 +98,7 @@ bool SupportiveTranslationUnitInitializer::checkStateAndDocument(State currentEx
}
QTC_CHECK(m_isDocumentClosedChecker);
if (m_isDocumentClosedChecker(m_document.filePath(), m_document.projectPart().id())) {
if (m_isDocumentClosedChecker(m_document.filePath())) {
m_state = State::Aborted;
return false;
}

View File

@@ -35,7 +35,7 @@ namespace ClangBackEnd {
class SupportiveTranslationUnitInitializer
{
public:
using IsDocumentClosedChecker = std::function<bool(const Utf8String &, const Utf8String &)>;
using IsDocumentClosedChecker = std::function<bool(const Utf8String &)>;
enum class State {
NotInitialized,

View File

@@ -221,8 +221,7 @@ bool TranslationUnitUpdater::reparseWasSuccessful() const
CommandLineArguments TranslationUnitUpdater::commandLineArguments() const
{
return CommandLineArguments(m_in.filePath.constData(),
m_in.projectArguments,
m_in.fileArguments,
m_in.compilationArguments,
isVerboseModeEnabled());
}

View File

@@ -43,13 +43,11 @@ public:
bool reparseNeeded = false;
TimePoint needsToBeReparsedChangeTimePoint;
Utf8String filePath;
Utf8StringVector fileArguments;
Utf8StringVector compilationArguments;
UnsavedFiles unsavedFiles;
Utf8String projectId;
Utf8StringVector projectArguments;
};
class TranslationUnitUpdateResult {

View File

@@ -73,24 +73,20 @@ static QList<QByteArray> extraClangCodeModelAppendOptions() {
namespace ClangBackEnd {
CommandLineArguments::CommandLineArguments(const char *filePath,
const Utf8StringVector &projectPartArguments,
const Utf8StringVector &fileArguments,
const Utf8StringVector &compilationArguments,
bool addVerboseOption)
: m_prependArgs(extraClangCodeModelPrependOptions()),
m_appendArgs(extraClangCodeModelAppendOptions())
{
const int elementsToReserve = m_prependArgs.size()
+ projectPartArguments.size()
+ fileArguments.size()
+ compilationArguments.size()
+ (addVerboseOption ? 1 : 0)
+ m_appendArgs.size();
m_arguments.reserve(static_cast<size_t>(elementsToReserve));
for (const auto &argument : m_prependArgs)
m_arguments.push_back(argument.constData());
for (const auto &argument : projectPartArguments)
m_arguments.push_back(argument.constData());
for (const auto &argument : fileArguments)
for (const auto &argument : compilationArguments)
m_arguments.push_back(argument.constData());
if (addVerboseOption)
m_arguments.push_back("-v");

View File

@@ -35,8 +35,7 @@ class CommandLineArguments
{
public:
CommandLineArguments(const char *filePath,
const Utf8StringVector &projectPartArguments,
const Utf8StringVector &fileArguments,
const Utf8StringVector &compilationArguments,
bool addVerboseOption);
const char * const *data() const;

View File

@@ -1,130 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3 as published by the Free Software
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
**
****************************************************************************/
#include "projectpart.h"
#include <projectpartcontainer.h>
#include <utf8stringvector.h>
#include <cstring>
namespace ClangBackEnd {
class ProjectPartData {
public:
ProjectPartData(const Utf8String &projectPartId);
~ProjectPartData();
public:
TimePoint lastChangeTimePoint;
Utf8StringVector arguments;
Utf8String projectPartId;
};
ProjectPartData::ProjectPartData(const Utf8String &projectPartId)
: lastChangeTimePoint(Clock::now()),
projectPartId(projectPartId)
{
}
ProjectPartData::~ProjectPartData()
{
}
ProjectPart::ProjectPart(const Utf8String &projectPartId)
: d(std::make_shared<ProjectPartData>(projectPartId))
{
}
ProjectPart::ProjectPart(const Utf8String &projectPartId,
const Utf8StringVector &arguments)
: d(std::make_shared<ProjectPartData>(projectPartId))
{
setArguments(arguments);
}
ProjectPart::ProjectPart(const ProjectPartContainer &projectContainer)
: d(std::make_shared<ProjectPartData>(projectContainer.projectPartId))
{
setArguments(projectContainer.arguments);
}
ProjectPart::~ProjectPart() = default;
ProjectPart::ProjectPart(const ProjectPart &) = default;
ProjectPart &ProjectPart::operator=(const ProjectPart &) = default;
ProjectPart::ProjectPart(ProjectPart &&other)
: d(std::move(other.d))
{
}
ProjectPart &ProjectPart::operator=(ProjectPart &&other)
{
d = std::move(other.d);
return *this;
}
void ProjectPart::clear()
{
d->projectPartId.clear();
d->arguments.clear();
updateLastChangeTimePoint();
}
Utf8String ProjectPart::id() const
{
return d->projectPartId;
}
void ProjectPart::setArguments(const Utf8StringVector &arguments)
{
d->arguments = arguments;
updateLastChangeTimePoint();
}
const Utf8StringVector ProjectPart::arguments() const
{
return d->arguments;
}
const TimePoint &ProjectPart::lastChangeTimePoint() const
{
return d->lastChangeTimePoint;
}
void ProjectPart::updateLastChangeTimePoint()
{
d->lastChangeTimePoint = Clock::now();
}
bool operator==(const ProjectPart &first, const ProjectPart &second)
{
return first.id() == second.id();
}
} // namespace ClangBackEnd

View File

@@ -1,73 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3 as published by the Free Software
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
**
****************************************************************************/
#pragma once
#include "clangclock.h"
#include <utf8string.h>
#include <memory>
class Utf8StringVector;
namespace ClangBackEnd {
class ProjectPartContainer;
class ProjectPartData;
class ProjectPart
{
public:
ProjectPart(const Utf8String &id = Utf8String());
ProjectPart(const Utf8String &id, const Utf8StringVector &arguments);
ProjectPart(const ProjectPartContainer &projectContainer);
~ProjectPart();
ProjectPart(const ProjectPart &project);
ProjectPart &operator=(const ProjectPart &project);
ProjectPart(ProjectPart &&project);
ProjectPart &operator=(ProjectPart &&project);
void clear();
Utf8String id() const;
void setArguments(const Utf8StringVector &arguments_);
const Utf8StringVector arguments() const;
const TimePoint &lastChangeTimePoint() const;
private:
void updateLastChangeTimePoint();
private:
std::shared_ptr<ProjectPartData> d;
};
bool operator==(const ProjectPart &first, const ProjectPart &second);
} // namespace ClangBackEnd

View File

@@ -1,105 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3 as published by the Free Software
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
**
****************************************************************************/
#include "projects.h"
#include "clangexceptions.h"
#include <QtGlobal>
namespace ClangBackEnd {
void ProjectParts::createOrUpdate(const QVector<ProjectPartContainer> &projectContainers)
{
for (const ProjectPartContainer &projectContainer : projectContainers)
createOrUpdateProjectPart(projectContainer);
}
void ProjectParts::remove(const Utf8StringVector &projectPartIds)
{
Utf8StringVector processedProjectPartFilePaths = projectPartIds;
const auto removeBeginIterator = std::remove_if(projects_.begin(), projects_.end(),
[&processedProjectPartFilePaths] (ProjectPart &project) {
const bool isRemoved = processedProjectPartFilePaths.removeFast(project.id());
if (isRemoved)
project.clear();
return isRemoved;
});
projects_.erase(removeBeginIterator, projects_.end());
if (!processedProjectPartFilePaths.isEmpty())
throw ProjectPartDoNotExistException(processedProjectPartFilePaths);
}
bool ProjectParts::hasProjectPart(const Utf8String &projectPartId) const
{
return findProjectPart(projectPartId) != projects_.cend();
}
const ProjectPart &ProjectParts::project(const Utf8String &projectPartId) const
{
const auto findIterator = findProjectPart(projectPartId);
if (findIterator == projects_.cend())
throw ProjectPartDoNotExistException({projectPartId});
return *findIterator;
}
std::vector<ProjectPart>::const_iterator ProjectParts::findProjectPart(const Utf8String &projectPartId) const
{
return std::find_if(projects_.begin(), projects_.end(), [projectPartId] (const ProjectPart &project) {
return project.id() == projectPartId;
});
}
std::vector<ProjectPart>::iterator ProjectParts::findProjectPart(const Utf8String &projectPartId)
{
return std::find_if(projects_.begin(), projects_.end(), [projectPartId] (const ProjectPart &project) {
return project.id() == projectPartId;
});
}
const std::vector<ProjectPart> &ProjectParts::projects() const
{
return projects_;
}
void ProjectParts::createOrUpdateProjectPart(const ProjectPartContainer &projectContainer)
{
auto findIterator = findProjectPart(projectContainer.projectPartId);
if (findIterator == projects_.cend())
projects_.push_back(ProjectPart(projectContainer));
else
findIterator->setArguments(projectContainer.arguments);
}
} // namespace ClangBackEnd

View File

@@ -1,58 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3 as published by the Free Software
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
**
****************************************************************************/
#pragma once
#include "projectpart.h"
#include <projectpartcontainer.h>
#include <vector>
namespace ClangBackEnd {
class ProjectParts
{
public:
void createOrUpdate(const QVector<ProjectPartContainer> &projectConainers);
void remove(const Utf8StringVector &projectPartIds);
bool hasProjectPart(const Utf8String &projectPartId) const;
const ProjectPart &project(const Utf8String &projectPartId) const;
std::vector<ProjectPart>::const_iterator findProjectPart(const Utf8String &projectPartId) const;
std::vector<ProjectPart>::iterator findProjectPart(const Utf8String &projectPartId);
const std::vector<ProjectPart> &projects() const;
private:
void createOrUpdateProjectPart(const ProjectPartContainer &projectConainer);
private:
std::vector<ProjectPart> projects_;
};
} // namespace ClangBackEnd

View File

@@ -58,16 +58,6 @@ void EchoClangCodeModelServer::documentsClosed(const DocumentsClosedMessage &mes
echoMessage(message);
}
void EchoClangCodeModelServer::projectPartsUpdated(const ProjectPartsUpdatedMessage &message)
{
echoMessage(message);
}
void EchoClangCodeModelServer::projectPartsRemoved(const ProjectPartsRemovedMessage &message)
{
echoMessage(message);
}
void EchoClangCodeModelServer::unsavedFilesUpdated(const UnsavedFilesUpdatedMessage &message)
{
echoMessage(message);

View File

@@ -42,9 +42,6 @@ public:
void documentsClosed(const DocumentsClosedMessage &message) override;
void documentVisibilityChanged(const DocumentVisibilityChangedMessage &message) override;
void projectPartsUpdated(const ProjectPartsUpdatedMessage &message) override;
void projectPartsRemoved(const ProjectPartsRemovedMessage &message) override;
void unsavedFilesUpdated(const UnsavedFilesUpdatedMessage &message) override;
void unsavedFilesRemoved(const UnsavedFilesRemovedMessage &message) override;

View File

@@ -33,9 +33,7 @@ using namespace ClangBackEnd;
void ClangAsyncJobTest::BaseSetUp(ClangBackEnd::JobRequest::Type jobRequestType,
IAsyncJob &asyncJob)
{
projects.createOrUpdate({ProjectPartContainer(projectPartId)});
const QVector<FileContainer> fileContainer{FileContainer(filePath, projectPartId)};
const QVector<FileContainer> fileContainer{FileContainer(filePath)};
document = documents.create(fileContainer).front();
documents.setVisibleInEditors({filePath});
documents.setUsedByCurrentEditor(filePath);
@@ -51,10 +49,8 @@ JobRequest ClangAsyncJobTest::createJobRequest(const Utf8String &filePath,
{
JobRequest jobRequest(type);
jobRequest.filePath = filePath;
jobRequest.projectPartId = projectPartId;
jobRequest.unsavedFilesChangeTimePoint = unsavedFiles.lastChangeTimePoint();
jobRequest.documentRevision = document.documentRevision();
jobRequest.projectChangeTimePoint = projects.project(projectPartId).lastChangeTimePoint();
return jobRequest;
}

View File

@@ -33,7 +33,6 @@
#include <clangdocument.h>
#include <clangiasyncjob.h>
#include <clangjobrequest.h>
#include <projects.h>
#include <clangdocuments.h>
#include <unsavedfiles.h>
@@ -50,16 +49,14 @@ protected:
int timeOutInMs = 10000) const;
protected:
ClangBackEnd::ProjectParts projects;
ClangBackEnd::UnsavedFiles unsavedFiles;
ClangBackEnd::Documents documents{projects, unsavedFiles};
ClangBackEnd::Documents documents{unsavedFiles};
ClangBackEnd::Document document;
MockClangCodeModelClient mockIpcClient;
DummyIpcClient dummyIpcClient;
Utf8String filePath{Utf8StringLiteral(TESTDATA_DIR"/translationunits.cpp")};
Utf8String projectPartId{Utf8StringLiteral("/path/to/projectfile")};
ClangBackEnd::JobRequest jobRequest;
ClangBackEnd::JobContext jobContext;

View File

@@ -29,8 +29,6 @@
#include <clangdocument.h>
#include <clangfilepath.h>
#include <clangtranslationunitupdater.h>
#include <projectpart.h>
#include <projects.h>
#include <clangtranslationunit.h>
#include <clangdocuments.h>
#include <unsavedfiles.h>
@@ -44,7 +42,6 @@ using ClangBackEnd::ClangCodeCompleteResults;
using ClangBackEnd::FilePath;
using ClangBackEnd::Document;
using ClangBackEnd::UnsavedFiles;
using ClangBackEnd::ProjectPart;
static unsigned completionOptions()
{
@@ -56,12 +53,9 @@ static unsigned completionOptions()
TEST(ClangCodeCompleteResultsSlowTest, GetData)
{
ProjectPart projectPart(Utf8StringLiteral("projectPartId"));
ClangBackEnd::ProjectParts projects;
ClangBackEnd::UnsavedFiles unsavedFiles;
ClangBackEnd::Documents documents{projects, unsavedFiles};
ClangBackEnd::Documents documents{unsavedFiles};
Document document(Utf8StringLiteral(TESTDATA_DIR"/complete_testfile_1.cpp"),
projectPart,
Utf8StringVector(),
documents);
Utf8String nativeFilePath = FilePath::toNativeSeparators(document.filePath());
@@ -88,12 +82,9 @@ TEST(ClangCodeCompleteResults, GetInvalidData)
TEST(ClangCodeCompleteResultsSlowTest, MoveClangCodeCompleteResults)
{
ProjectPart projectPart(Utf8StringLiteral("projectPartId"));
ClangBackEnd::ProjectParts projects;
ClangBackEnd::UnsavedFiles unsavedFiles;
ClangBackEnd::Documents documents{projects, unsavedFiles};
ClangBackEnd::Documents documents{unsavedFiles};
Document document(Utf8StringLiteral(TESTDATA_DIR"/complete_testfile_1.cpp"),
projectPart,
Utf8StringVector(),
documents);
Utf8String nativeFilePath = FilePath::toNativeSeparators(document.filePath());

View File

@@ -53,15 +53,13 @@ namespace {
using namespace ClangBackEnd;
MATCHER_P5(HasDirtyDocument,
MATCHER_P4(HasDirtyDocument,
filePath,
projectPartId,
documentRevision,
isDirty,
hasNewDiagnostics,
std::string(negation ? "isn't" : "is")
+ " document with file path "+ PrintToString(filePath)
+ " and project " + PrintToString(projectPartId)
+ " and document revision " + PrintToString(documentRevision)
+ " and isDirty = " + PrintToString(isDirty)
+ " and hasNewDiagnostics = " + PrintToString(hasNewDiagnostics)
@@ -69,7 +67,7 @@ MATCHER_P5(HasDirtyDocument,
{
auto &&documents = arg.documentsForTestOnly();
try {
auto document = documents.document(filePath, projectPartId);
auto document = documents.document(filePath);
if (document.documentRevision() == documentRevision) {
if (document.isDirty() && !isDirty) {
@@ -114,21 +112,13 @@ protected:
protected:
bool waitUntilAllJobsFinished(int timeOutInMs = 10000);
void updateProjectPart();
void updateProjectPart(const Utf8String &projectPartId);
void updateProjectPartWithArguments();
void updateProjectAndOpenDocument(const Utf8String &filePath,
int expectedAnnotationsMessages = AnnotationJobsMultiplier);
void updateProjectAndOpenDocumentAndWaitForFinished(
void openDocumentAndWaitForFinished(
const Utf8String &filePath, int expectedAnnotationsMessages = AnnotationJobsMultiplier);
void updateProjectAndOpenDocumentsAndWaitForFinished(
int expectedAnnotationsdMessages = 2 * AnnotationJobsMultiplier);
void openDocument(const Utf8String &filePath,
int expectedAnnotationsMessages = AnnotationJobsMultiplier);
void openDocument(const Utf8String &filePath,
const Utf8String &projectPartId,
const Utf8StringVector &compilationArguments,
int expectedAnnotationsMessages = AnnotationJobsMultiplier);
void openDocuments(int expectedAnnotationsMessages);
void openDocumentWithUnsavedContent(const Utf8String &filePath, const Utf8String &content);
@@ -146,10 +136,8 @@ protected:
void requestFollowSymbol(quint32 documentRevision = 0);
void requestCompletions(const Utf8String &filePath,
uint line = 1,
uint column = 1,
const Utf8String &projectPartId = Utf8String());
uint column = 1);
void requestCompletionsInFileA();
void requestCompletionsInFileB();
bool isSupportiveTranslationUnitInitialized(const Utf8String &filePath);
@@ -158,7 +146,6 @@ protected:
void expectAnnotations(int count);
void expectCompletion(const CodeCompletion &completion);
void expectCompletionFromFileA();
void expectCompletionFromFileBEnabledByMacro();
void expectCompletionFromFileAUnsavedMethodVersion1();
void expectCompletionFromFileAUnsavedMethodVersion2();
void expectNoCompletionWithUnsavedMethod();
@@ -172,8 +159,6 @@ protected:
MockClangCodeModelClient mockClangCodeModelClient;
ClangBackEnd::ClangCodeModelServer clangServer;
const ClangBackEnd::Documents &documents = clangServer.documentsForTestOnly();
const Utf8String projectPartId = Utf8StringLiteral("pathToProjectPart.pro");
const Utf8String projectPartId2 = Utf8StringLiteral("otherPathToProjectPart.pro");
const Utf8String filePathA = Utf8StringLiteral(TESTDATA_DIR"/complete_extractor_function.cpp");
const QString filePathAUnsavedVersion1
@@ -187,14 +172,13 @@ protected:
const Utf8String aFilePath = Utf8StringLiteral("afile.cpp");
const Utf8String anExistingFilePath
= Utf8StringLiteral(TESTDATA_DIR"/complete_translationunit_parse_error.cpp");
const Utf8String aProjectPartId = Utf8StringLiteral("aproject.pro");
};
using ClangCodeModelServerSlowTest = ClangCodeModelServer;
TEST_F(ClangCodeModelServerSlowTest, GetCodeCompletion)
{
updateProjectAndOpenDocument(filePathA);
openDocument(filePathA);
expectCompletionFromFileA();
requestCompletionsInFileA();
@@ -202,7 +186,7 @@ TEST_F(ClangCodeModelServerSlowTest, GetCodeCompletion)
TEST_F(ClangCodeModelServerSlowTest, RequestAnnotations)
{
updateProjectAndOpenDocumentAndWaitForFinished(filePathB);
openDocumentAndWaitForFinished(filePathB);
expectAnnotationsForFileBWithSpecificHighlightingMark();
requestAnnotations(filePathB);
@@ -210,7 +194,7 @@ TEST_F(ClangCodeModelServerSlowTest, RequestAnnotations)
TEST_F(ClangCodeModelServerSlowTest, RequestReferencesForCurrentDocumentRevision)
{
updateProjectAndOpenDocumentAndWaitForFinished(filePathC);
openDocumentAndWaitForFinished(filePathC);
expectReferences();
requestReferences();
@@ -218,7 +202,7 @@ TEST_F(ClangCodeModelServerSlowTest, RequestReferencesForCurrentDocumentRevision
TEST_F(ClangCodeModelServerSlowTest, RequestReferencesTakesRevisionFromMessage)
{
updateProjectAndOpenDocumentAndWaitForFinished(filePathC);
openDocumentAndWaitForFinished(filePathC);
requestReferences(/*documentRevision=*/ 99);
@@ -231,7 +215,7 @@ TEST_F(ClangCodeModelServerSlowTest, RequestReferencesTakesRevisionFromMessage)
TEST_F(ClangCodeModelServerSlowTest, RequestFollowSymbolForCurrentDocumentRevision)
{
updateProjectAndOpenDocumentAndWaitForFinished(filePathC);
openDocumentAndWaitForFinished(filePathC);
expectFollowSymbol();
requestFollowSymbol();
@@ -239,7 +223,7 @@ TEST_F(ClangCodeModelServerSlowTest, RequestFollowSymbolForCurrentDocumentRevisi
TEST_F(ClangCodeModelServerSlowTest, RequestFollowSymbolTakesRevisionFromMessage)
{
updateProjectAndOpenDocumentAndWaitForFinished(filePathC);
openDocumentAndWaitForFinished(filePathC);
requestFollowSymbol(/*documentRevision=*/ 99);
@@ -253,7 +237,7 @@ TEST_F(ClangCodeModelServerSlowTest, RequestFollowSymbolTakesRevisionFromMessage
TEST_F(ClangCodeModelServerSlowTest, NoInitialAnnotationsForClosedDocument)
{
const int expectedAnnotationsCount = 0;
updateProjectAndOpenDocument(filePathA, expectedAnnotationsCount);
openDocument(filePathA, expectedAnnotationsCount);
closeDocument(filePathA);
}
@@ -261,11 +245,10 @@ TEST_F(ClangCodeModelServerSlowTest, NoInitialAnnotationsForClosedDocument)
TEST_F(ClangCodeModelServerSlowTest, AnnotationsForInitiallyNotVisibleDocument)
{
const int expectedAnnotationsCount = 2;
updateProjectPart();
updateVisibilty(filePathA, filePathA);
expectAnnotations(expectedAnnotationsCount);
clangServer.documentsOpened( // Open document while another is still visible
DocumentsOpenedMessage({FileContainer(filePathB, projectPartId, Utf8String(), false, 1)},
DocumentsOpenedMessage({FileContainer(filePathB, Utf8String(), false, 1)},
filePathA, {filePathA}));
clangServer.unsavedFilesUpdated( // Invalidate added jobs
UnsavedFilesUpdatedMessage({FileContainer(Utf8StringLiteral("aFile"), Utf8String())}));
@@ -276,7 +259,7 @@ TEST_F(ClangCodeModelServerSlowTest, AnnotationsForInitiallyNotVisibleDocument)
TEST_F(ClangCodeModelServerSlowTest, NoAnnotationsForClosedDocument)
{
const int expectedAnnotationsCount = AnnotationJobsMultiplier; // Only for registration.
updateProjectAndOpenDocumentAndWaitForFinished(filePathA, expectedAnnotationsCount);
openDocumentAndWaitForFinished(filePathA, expectedAnnotationsCount);
updateUnsavedContent(filePathA, Utf8String(), 1);
closeDocument(filePathA);
@@ -285,7 +268,7 @@ TEST_F(ClangCodeModelServerSlowTest, NoAnnotationsForClosedDocument)
TEST_F(ClangCodeModelServerSlowTest, NoInitialAnnotationsForOutdatedDocumentRevision)
{
const int expectedAnnotationsCount = AnnotationJobsMultiplier; // Only for registration.
updateProjectAndOpenDocument(filePathA, expectedAnnotationsCount);
openDocument(filePathA, expectedAnnotationsCount);
updateUnsavedContent(filePathA, Utf8String(), 1);
}
@@ -293,25 +276,14 @@ TEST_F(ClangCodeModelServerSlowTest, NoInitialAnnotationsForOutdatedDocumentRevi
TEST_F(ClangCodeModelServerSlowTest, NoCompletionsForClosedDocument)
{
const int expectedAnnotationsCount = AnnotationJobsMultiplier; // Only for registration.
updateProjectAndOpenDocumentAndWaitForFinished(filePathA, expectedAnnotationsCount);
openDocumentAndWaitForFinished(filePathA, expectedAnnotationsCount);
requestCompletionsInFileA();
closeDocument(filePathA);
}
TEST_F(ClangCodeModelServerSlowTest, CodeCompletionDependingOnProject)
{
const int expectedAnnotationsCount = 2 * AnnotationJobsMultiplier; // For registration and due to project change.
updateProjectAndOpenDocumentAndWaitForFinished(filePathB, expectedAnnotationsCount);
expectCompletionFromFileBEnabledByMacro();
updateProjectPartWithArguments();
requestCompletionsInFileB();
}
TEST_F(ClangCodeModelServerSlowTest, GetCodeCompletionForUnsavedFile)
{
updateProjectPart();
expectAnnotations(AnnotationJobsMultiplier);
openDocumentWithUnsavedContent(filePathA, unsavedContent(filePathAUnsavedVersion1));
expectCompletionFromFileAUnsavedMethodVersion1();
@@ -322,7 +294,7 @@ TEST_F(ClangCodeModelServerSlowTest, GetCodeCompletionForUnsavedFile)
TEST_F(ClangCodeModelServerSlowTest, GetNoCodeCompletionAfterRemovingUnsavedFile)
{
const int expectedAnnotationsCount = 2 * AnnotationJobsMultiplier; // For registration and update/removal.
updateProjectAndOpenDocumentAndWaitForFinished(filePathA, expectedAnnotationsCount);
openDocumentAndWaitForFinished(filePathA, expectedAnnotationsCount);
removeUnsavedFile(filePathA);
expectNoCompletionWithUnsavedMethod();
@@ -332,7 +304,7 @@ TEST_F(ClangCodeModelServerSlowTest, GetNoCodeCompletionAfterRemovingUnsavedFile
TEST_F(ClangCodeModelServerSlowTest, GetNewCodeCompletionAfterUpdatingUnsavedFile)
{
const int expectedAnnotationsCount = 2 * AnnotationJobsMultiplier; // For registration and update/removal.
updateProjectAndOpenDocumentAndWaitForFinished(filePathA, expectedAnnotationsCount);
openDocumentAndWaitForFinished(filePathA, expectedAnnotationsCount);
updateUnsavedContent(filePathA, unsavedContent(filePathAUnsavedVersion2), 1);
expectCompletionFromFileAUnsavedMethodVersion2();
@@ -341,16 +313,17 @@ TEST_F(ClangCodeModelServerSlowTest, GetNewCodeCompletionAfterUpdatingUnsavedFil
TEST_F(ClangCodeModelServerSlowTest, TranslationUnitAfterCreationIsNotDirty)
{
updateProjectAndOpenDocument(filePathA, AnnotationJobsMultiplier);
openDocument(filePathA, AnnotationJobsMultiplier);
ASSERT_THAT(clangServer, HasDirtyDocument(filePathA, projectPartId, 0U, false, false));
ASSERT_THAT(clangServer, HasDirtyDocument(filePathA, 0U, false, false));
}
TEST_F(ClangCodeModelServerSlowTest, SetCurrentAndVisibleEditor)
{
updateProjectAndOpenDocumentsAndWaitForFinished();
auto functionDocument = documents.document(filePathA, projectPartId);
auto variableDocument = documents.document(filePathB, projectPartId);
openDocuments(2 * AnnotationJobsMultiplier);
ASSERT_TRUE(waitUntilAllJobsFinished());
auto functionDocument = documents.document(filePathA);
auto variableDocument = documents.document(filePathB);
updateVisibilty(filePathB, filePathA);
@@ -361,7 +334,7 @@ TEST_F(ClangCodeModelServerSlowTest, SetCurrentAndVisibleEditor)
TEST_F(ClangCodeModelServerSlowTest, StartCompletionJobFirstOnEditThatTriggersCompletion)
{
updateProjectAndOpenDocument(filePathA, 2 * AnnotationJobsMultiplier);
openDocument(filePathA, 2 * AnnotationJobsMultiplier);
ASSERT_TRUE(waitUntilAllJobsFinished());
expectCompletionFromFileA();
@@ -375,7 +348,7 @@ TEST_F(ClangCodeModelServerSlowTest, StartCompletionJobFirstOnEditThatTriggersCo
TEST_F(ClangCodeModelServerSlowTest, SupportiveTranslationUnitNotInitializedAfterRegister)
{
updateProjectAndOpenDocument(filePathA, AnnotationJobsMultiplier);
openDocument(filePathA, AnnotationJobsMultiplier);
ASSERT_TRUE(waitUntilAllJobsFinished());
ASSERT_FALSE(isSupportiveTranslationUnitInitialized(filePathA));
@@ -383,7 +356,7 @@ TEST_F(ClangCodeModelServerSlowTest, SupportiveTranslationUnitNotInitializedAfte
TEST_F(ClangCodeModelServerSlowTest, SupportiveTranslationUnitIsSetupAfterFirstEdit)
{
updateProjectAndOpenDocument(filePathA, 2 * AnnotationJobsMultiplier);
openDocument(filePathA, 2 * AnnotationJobsMultiplier);
ASSERT_TRUE(waitUntilAllJobsFinished());
updateUnsavedContent(filePathA, unsavedContent(filePathAUnsavedVersion2), 1);
@@ -394,7 +367,7 @@ TEST_F(ClangCodeModelServerSlowTest, SupportiveTranslationUnitIsSetupAfterFirstE
TEST_F(ClangCodeModelServerSlowTest, DoNotRunDuplicateJobs)
{
updateProjectAndOpenDocument(filePathA, 3 * AnnotationJobsMultiplier);
openDocument(filePathA, 3 * AnnotationJobsMultiplier);
ASSERT_TRUE(waitUntilAllJobsFinished());
updateUnsavedContent(filePathA, unsavedContent(filePathAUnsavedVersion2), 1);
ASSERT_TRUE(waitUntilAllJobsFinished());
@@ -408,7 +381,7 @@ TEST_F(ClangCodeModelServerSlowTest, DoNotRunDuplicateJobs)
TEST_F(ClangCodeModelServerSlowTest, OpenDocumentAndEdit)
{
updateProjectAndOpenDocument(filePathA, 4 * AnnotationJobsMultiplier);
openDocument(filePathA, 4 * AnnotationJobsMultiplier);
ASSERT_TRUE(waitUntilAllJobsFinished());
for (unsigned revision = 1; revision <= 3; ++revision) {
@@ -419,9 +392,11 @@ TEST_F(ClangCodeModelServerSlowTest, OpenDocumentAndEdit)
TEST_F(ClangCodeModelServerSlowTest, IsNotCurrentCurrentAndVisibleEditorAnymore)
{
updateProjectAndOpenDocumentsAndWaitForFinished();
auto functionDocument = documents.document(filePathA, projectPartId);
auto variableDocument = documents.document(filePathB, projectPartId);
const int expectedAnnotationsCount = 2 * AnnotationJobsMultiplier;
openDocuments(expectedAnnotationsCount);
ASSERT_TRUE(waitUntilAllJobsFinished());
auto functionDocument = documents.document(filePathA);
auto variableDocument = documents.document(filePathB);
updateVisibilty(filePathB, filePathA);
updateVisibilty(filePathB, Utf8String());
@@ -434,36 +409,25 @@ TEST_F(ClangCodeModelServerSlowTest, IsNotCurrentCurrentAndVisibleEditorAnymore)
TEST_F(ClangCodeModelServerSlowTest, TranslationUnitAfterUpdateNeedsReparse)
{
updateProjectAndOpenDocumentAndWaitForFinished(filePathA, 2 * AnnotationJobsMultiplier);
openDocumentAndWaitForFinished(filePathA, 2 * AnnotationJobsMultiplier);
updateUnsavedContent(filePathA, unsavedContent(filePathAUnsavedVersion1), 1U);
ASSERT_THAT(clangServer, HasDirtyDocument(filePathA, projectPartId, 1U, true, true));
ASSERT_THAT(clangServer, HasDirtyDocument(filePathA, 1U, true, true));
}
TEST_F(ClangCodeModelServerSlowTest, TakeOverJobsOnProjectPartChange)
TEST_F(ClangCodeModelServerSlowTest, TakeOverJobsOnDocumentChange)
{
updateProjectAndOpenDocumentAndWaitForFinished(filePathC, 2 * AnnotationJobsMultiplier);
openDocument(filePathC, AnnotationJobsMultiplier);
ASSERT_TRUE(waitUntilAllJobsFinished());
updateVisibilty(filePathB, filePathB); // Disable processing jobs
requestReferences();
expectReferences();
updateProjectPartWithArguments(); // Here we do not want to loose the RequestReferences job
openDocument(filePathC, AnnotationJobsMultiplier); // Do not loose jobs
updateVisibilty(filePathC, filePathC); // Enable processing jobs
}
TEST_F(ClangCodeModelServerSlowTest, TakeOverJobsOnProjectPartIdChange)
{
updateProjectPart(projectPartId);
updateProjectPart(projectPartId2);
openDocument(filePathC, projectPartId, 0);
requestReferences();
expectReferences();
openDocument(filePathC, projectPartId2); // Here we do not want to loose the RequestReferences job
}
void ClangCodeModelServer::SetUp()
{
clangServer.setClient(&mockClangCodeModelClient);
@@ -487,25 +451,17 @@ bool ClangCodeModelServer::waitUntilAllJobsFinished(int timeOutInMs)
return ProcessEventUtilities::processEventsUntilTrue(noJobsRunningAnymore, timeOutInMs);
}
void ClangCodeModelServer::updateProjectAndOpenDocumentsAndWaitForFinished(int expectedAnnotationsdMessages)
{
updateProjectPart();
openDocuments(expectedAnnotationsdMessages);
ASSERT_TRUE(waitUntilAllJobsFinished());
}
void ClangCodeModelServer::openDocument(const Utf8String &filePath,
int expectedAnnotationsMessages)
{
openDocument(filePath, projectPartId, expectedAnnotationsMessages);
openDocument(filePath, {}, expectedAnnotationsMessages);
}
void ClangCodeModelServer::openDocument(const Utf8String &filePath,
const Utf8String &projectPartId,
const Utf8StringVector &compilationArguments,
int expectedAnnotationsMessages)
{
const FileContainer fileContainer(filePath, projectPartId);
const FileContainer fileContainer(filePath, compilationArguments);
const DocumentsOpenedMessage message({fileContainer}, filePath, {filePath});
expectAnnotations(expectedAnnotationsMessages);
@@ -515,8 +471,8 @@ void ClangCodeModelServer::openDocument(const Utf8String &filePath,
void ClangCodeModelServer::openDocuments(int expectedAnnotationsMessages)
{
const FileContainer fileContainerA(filePathA, projectPartId);
const FileContainer fileContainerB(filePathB, projectPartId);
const FileContainer fileContainerA(filePathA);
const FileContainer fileContainerB(filePathB);
const DocumentsOpenedMessage message({fileContainerA, fileContainerB},
filePathA,
{filePathA, filePathB});
@@ -534,22 +490,15 @@ void ClangCodeModelServer::expectAnnotations(int count)
void ClangCodeModelServer::openDocumentWithUnsavedContent(const Utf8String &filePath,
const Utf8String &unsavedContent)
{
const FileContainer fileContainer(filePath, projectPartId, unsavedContent, true);
const FileContainer fileContainer(filePath, unsavedContent, true);
const DocumentsOpenedMessage message({fileContainer}, filePath, {filePath});
clangServer.documentsOpened(message);
}
void ClangCodeModelServer::requestCompletions(const Utf8String &filePath,
uint line,
uint column,
const Utf8String &projectPartId)
void ClangCodeModelServer::requestCompletions(const Utf8String &filePath, uint line, uint column)
{
Utf8String theProjectPartId = projectPartId;
if (theProjectPartId.isEmpty())
theProjectPartId = this->projectPartId;
const RequestCompletionsMessage message(filePath, line, column, theProjectPartId);
const RequestCompletionsMessage message(filePath, line, column);
clangServer.requestCompletions(message);
}
@@ -559,14 +508,9 @@ void ClangCodeModelServer::requestCompletionsInFileA()
requestCompletions(filePathA, 20, 1);
}
void ClangCodeModelServer::requestCompletionsInFileB()
{
requestCompletions(filePathB, 35, 1);
}
bool ClangCodeModelServer::isSupportiveTranslationUnitInitialized(const Utf8String &filePath)
{
Document document = clangServer.documentsForTestOnly().document(filePath, projectPartId);
Document document = clangServer.documentsForTestOnly().document(filePath);
DocumentProcessor documentProcessor = clangServer.documentProcessors().processor(document);
return document.translationUnits().size() == 2
@@ -576,7 +520,7 @@ bool ClangCodeModelServer::isSupportiveTranslationUnitInitialized(const Utf8Stri
DocumentProcessor ClangCodeModelServer::documentProcessorForFile(const Utf8String &filePath)
{
Document document = clangServer.documentsForTestOnly().document(filePath, projectPartId);
Document document = clangServer.documentsForTestOnly().document(filePath);
DocumentProcessor documentProcessor = clangServer.documentProcessors().processor(document);
return documentProcessor;
@@ -590,15 +534,6 @@ void ClangCodeModelServer::expectCompletion(const CodeCompletion &completion)
.Times(1);
}
void ClangCodeModelServer::expectCompletionFromFileBEnabledByMacro()
{
const CodeCompletion completion(Utf8StringLiteral("ArgumentDefinitionVariable"),
34,
CodeCompletion::VariableCompletionKind);
expectCompletion(completion);
}
void ClangCodeModelServer::expectCompletionFromFileAUnsavedMethodVersion1()
{
const CodeCompletion completion(Utf8StringLiteral("Method2"),
@@ -666,15 +601,14 @@ void ClangCodeModelServer::expectCompletionFromFileA()
void ClangCodeModelServer::requestAnnotations(const Utf8String &filePath)
{
const RequestAnnotationsMessage message({filePath, projectPartId});
const RequestAnnotationsMessage message(FileContainer{filePath});
clangServer.requestAnnotations(message);
}
void ClangCodeModelServer::requestReferences(quint32 documentRevision)
{
const FileContainer fileContainer{filePathC, projectPartId, Utf8StringVector(),
documentRevision};
const FileContainer fileContainer{filePathC, Utf8StringVector(), documentRevision};
const RequestReferencesMessage message{fileContainer, 3, 9};
clangServer.requestReferences(message);
@@ -682,8 +616,7 @@ void ClangCodeModelServer::requestReferences(quint32 documentRevision)
void ClangCodeModelServer::requestFollowSymbol(quint32 documentRevision)
{
const FileContainer fileContainer{filePathC, projectPartId, Utf8StringVector(),
documentRevision};
const FileContainer fileContainer{filePathC, Utf8StringVector(), documentRevision};
const RequestFollowSymbolMessage message{fileContainer, 43, 9};
clangServer.requestFollowSymbol(message);
@@ -706,7 +639,7 @@ void ClangCodeModelServer::updateUnsavedContent(const Utf8String &filePath,
const Utf8String &fileContent,
quint32 revisionNumber)
{
const FileContainer fileContainer(filePath, projectPartId, fileContent, true, revisionNumber);
const FileContainer fileContainer(filePath, fileContent, true, revisionNumber);
const DocumentsChangedMessage message({fileContainer});
clangServer.documentsChanged(message);
@@ -714,7 +647,7 @@ void ClangCodeModelServer::updateUnsavedContent(const Utf8String &filePath,
void ClangCodeModelServer::removeUnsavedFile(const Utf8String &filePath)
{
const FileContainer fileContainer(filePath, projectPartId, Utf8StringVector(), 74);
const FileContainer fileContainer(filePath, Utf8StringVector(), 74);
const DocumentsChangedMessage message({fileContainer});
clangServer.documentsChanged(message);
@@ -722,47 +655,19 @@ void ClangCodeModelServer::removeUnsavedFile(const Utf8String &filePath)
void ClangCodeModelServer::closeDocument(const Utf8String &filePath)
{
const QVector<FileContainer> fileContainers = {FileContainer(filePath, projectPartId)};
const QVector<FileContainer> fileContainers = {FileContainer(filePath)};
const DocumentsClosedMessage message(fileContainers);
clangServer.documentsClosed(message);
}
void ClangCodeModelServer::updateProjectPart()
{
updateProjectPart(projectPartId);
}
void ClangCodeModelServer::updateProjectPart(const Utf8String &projectPartId)
{
ProjectPartsUpdatedMessage message({ProjectPartContainer(projectPartId)});
clangServer.projectPartsUpdated(message);
}
void ClangCodeModelServer::updateProjectAndOpenDocument(const Utf8String &filePath,
int expectedAnnotationsMessages)
{
updateProjectPart();
openDocument(filePath, expectedAnnotationsMessages);
}
void ClangCodeModelServer::updateProjectAndOpenDocumentAndWaitForFinished(
void ClangCodeModelServer::openDocumentAndWaitForFinished(
const Utf8String &filePath, int expectedAnnotationsMessages)
{
updateProjectAndOpenDocument(filePath, expectedAnnotationsMessages);
openDocument(filePath, expectedAnnotationsMessages);
ASSERT_TRUE(waitUntilAllJobsFinished());
}
void ClangCodeModelServer::updateProjectPartWithArguments()
{
const ProjectPartContainer projectPartContainer(projectPartId,
{Utf8StringLiteral("-DArgumentDefinition")});
const ProjectPartsUpdatedMessage message({projectPartContainer});
clangServer.projectPartsUpdated(message);
}
void ClangCodeModelServer::updateVisibilty(const Utf8String &currentEditor,
const Utf8String &additionalVisibleEditor)
{

View File

@@ -95,7 +95,7 @@ TEST_F(CompleteCodeJob, DontSendCompletionsIfDocumentWasClosed)
EXPECT_CALL(mockIpcClient, completions(_)).Times(0);
job.runAsync();
documents.remove({FileContainer{filePath, projectPartId}});
documents.remove({FileContainer{filePath}});
ASSERT_TRUE(waitUntilJobFinished(job));
}

View File

@@ -34,9 +34,6 @@
#include <diagnosticset.h>
#include <tokenprocessor.h>
#include <filecontainer.h>
#include <projectpart.h>
#include <projectpartcontainer.h>
#include <projects.h>
#include <clangexceptions.h>
#include <clangdocument.h>
#include <clangtranslationunit.h>
@@ -56,8 +53,6 @@ using ClangBackEnd::FileContainer;
using ClangBackEnd::FilePath;
using ClangBackEnd::Document;
using ClangBackEnd::UnsavedFiles;
using ClangBackEnd::ProjectPart;
using ClangBackEnd::ProjectPartContainer;
using ClangBackEnd::Documents;
using ClangBackEnd::TranslationUnitUpdateResult;
using ClangBackEnd::TranslationUnit;
@@ -81,12 +76,9 @@ protected:
QByteArray readContentFromDocumentFile() const;
protected:
ClangBackEnd::ProjectParts projects;
Utf8String projectPartId{Utf8StringLiteral("/path/to/projectfile")};
ProjectPart projectPart;
Utf8String documentFilePath = Utf8StringLiteral(TESTDATA_DIR"/translationunits.cpp");
ClangBackEnd::UnsavedFiles unsavedFiles;
ClangBackEnd::Documents documents{projects, unsavedFiles};
ClangBackEnd::Documents documents{unsavedFiles};
::Document document;
};
@@ -108,14 +100,14 @@ TEST_F(Document, DefaultDocumentIsNotIntact)
TEST_F(Document, ThrowExceptionForNonExistingFilePath)
{
ASSERT_THROW(::Document(Utf8StringLiteral("file.cpp"), projectPart, Utf8StringVector(),
ASSERT_THROW(::Document(Utf8StringLiteral("file.cpp"), Utf8StringVector(),
documents),
ClangBackEnd::DocumentFileDoesNotExistException);
}
TEST_F(Document, ThrowNoExceptionForNonExistingFilePathIfDoNotCheckIfFileExistsIsSet)
{
ASSERT_NO_THROW(::Document(Utf8StringLiteral("file.cpp"), projectPart, Utf8StringVector(),
ASSERT_NO_THROW(::Document(Utf8StringLiteral("file.cpp"), Utf8StringVector(),
documents, ::Document::FileExistsCheck::DoNotCheck));
}
@@ -168,29 +160,6 @@ TEST_F(Document, LastCommandLineArgumentIsFilePath)
ASSERT_THAT(arguments.at(arguments.count() - 1), Eq(nativeFilePath));
}
TEST_F(DocumentSlowTest, TimeStampForProjectPartChangeIsUpdatedAsNewCxTranslationUnitIsGenerated)
{
auto lastChangeTimePoint = document.lastProjectPartChangeTimePoint();
std::this_thread::sleep_for(Duration(1));
document.parse();
ASSERT_THAT(document.lastProjectPartChangeTimePoint(), Gt(lastChangeTimePoint));
}
TEST_F(DocumentSlowTest, TimeStampForProjectPartChangeIsUpdatedAsProjectPartIsCleared)
{
ProjectPart projectPart = document.projectPart();
document.parse();
auto lastChangeTimePoint = document.lastProjectPartChangeTimePoint();
std::this_thread::sleep_for(Duration(1));
projectPart.clear();
document.parse();
ASSERT_THAT(document.lastProjectPartChangeTimePoint(), Gt(lastChangeTimePoint));
}
TEST_F(Document, DocumentRevisionInFileContainerGetter)
{
document.setDocumentRevision(74);
@@ -316,28 +285,6 @@ TEST_F(DocumentSlowTest, DoesNotNeedReparseAfterReparse)
ASSERT_FALSE(document.isDirty());
}
TEST_F(Document, SetDirtyIfProjectPartIsOutdated)
{
projects.createOrUpdate({ProjectPartContainer(projectPartId)});
document.parse();
projects.createOrUpdate({ProjectPartContainer(projectPartId, {Utf8StringLiteral("-DNEW")})});
const bool wasOutdated = document.setDirtyIfProjectPartIsOutdated();
ASSERT_TRUE(wasOutdated);
ASSERT_TRUE(document.isDirty());
}
TEST_F(DocumentSlowTest, SetNotDirtyIfProjectPartIsNotOutdated)
{
document.parse();
const bool wasOutdated = document.setDirtyIfProjectPartIsOutdated();
ASSERT_FALSE(wasOutdated);
ASSERT_FALSE(document.isDirty());
}
TEST_F(Document, IncorporateUpdaterResultResetsDirtyness)
{
document.setDirtyIfDependencyIsMet(document.filePath());
@@ -385,10 +332,7 @@ TEST_F(Document, IncorporateUpdaterResultUpdatesTranslationUnitsReparseTimePoint
void Document::SetUp()
{
projects.createOrUpdate({ProjectPartContainer(projectPartId)});
projectPart = *projects.findProjectPart(projectPartId);
const QVector<FileContainer> fileContainer{FileContainer(documentFilePath, projectPartId)};
const QVector<FileContainer> fileContainer{FileContainer(documentFilePath)};
const auto createdDocuments = documents.create(fileContainer);
document = createdDocuments.front();
}
@@ -398,10 +342,7 @@ void Document::SetUp()
QTemporaryFile temporaryFile;
EXPECT_TRUE(temporaryFile.open());
EXPECT_TRUE(temporaryFile.write(readContentFromDocumentFile()));
::Document document(temporaryFile.fileName(),
projectPart,
Utf8StringVector(),
documents);
::Document document(temporaryFile.fileName(), Utf8StringVector(), documents);
return document;
}

View File

@@ -34,7 +34,6 @@
#include <clangdocuments.h>
#include <clangjobrequest.h>
#include <clangjobs.h>
#include <projects.h>
#include <unsavedfiles.h>
using namespace ClangBackEnd;
@@ -49,14 +48,12 @@ protected:
bool waitUntilAllJobsFinished(int timeOutInMs = 10000) const;
protected:
ClangBackEnd::ProjectParts projects;
ClangBackEnd::UnsavedFiles unsavedFiles;
ClangBackEnd::Documents documents{projects, unsavedFiles};
ClangBackEnd::Documents documents{unsavedFiles};
DummyIpcClient dummyIpcClient;
Utf8String filePath{Utf8StringLiteral(TESTDATA_DIR"/translationunits.cpp")};
Utf8String projectPartId{Utf8StringLiteral("/path/to/projectfile")};
std::unique_ptr<ClangBackEnd::DocumentProcessor> documentProcessor;
};
@@ -82,14 +79,13 @@ TEST_F(DocumentProcessorSlowTest, ProcessSingleJob)
void DocumentProcessor::SetUp()
{
const QVector<FileContainer> fileContainer{FileContainer(filePath, projectPartId)};
const QVector<FileContainer> fileContainer{FileContainer(filePath)};
projects.createOrUpdate({ProjectPartContainer(projectPartId)});
ClangBackEnd::Document document = {documents.create(fileContainer).front()};
documents.setVisibleInEditors({filePath});
documents.setUsedByCurrentEditor(filePath);
documentProcessor = std::make_unique<ClangBackEnd::DocumentProcessor>(
document, documents, unsavedFiles, projects, dummyIpcClient);
document, documents, unsavedFiles, dummyIpcClient);
}
void DocumentProcessor::TearDown()

View File

@@ -36,7 +36,6 @@
#include <clangexceptions.h>
#include <clangjobrequest.h>
#include <clangjobs.h>
#include <projects.h>
#include <unsavedfiles.h>
using testing::Eq;
@@ -54,22 +53,19 @@ protected:
bool waitUntilAllJobsFinished(int timeOutInMs = 10000) const;
protected:
ClangBackEnd::ProjectParts projects;
ClangBackEnd::UnsavedFiles unsavedFiles;
ClangBackEnd::Documents documents{projects, unsavedFiles};
ClangBackEnd::Documents documents{unsavedFiles};
ClangBackEnd::Document document;
DummyIpcClient dummyIpcClient;
Utf8String filePath{Utf8StringLiteral(TESTDATA_DIR"/translationunits.cpp")};
Utf8String projectPartId{Utf8StringLiteral("/path/to/projectfile")};
ClangBackEnd::JobRequest jobRequest;
ClangBackEnd::JobContext jobContext;
ClangBackEnd::DocumentProcessors documentProcessors{documents,
unsavedFiles,
projects,
dummyIpcClient};
};
@@ -166,9 +162,7 @@ TEST_F(DocumentProcessorsSlowTest, ProcessSingle)
void DocumentProcessors::SetUp()
{
projects.createOrUpdate({ProjectPartContainer(projectPartId)});
const QVector<FileContainer> fileContainer{FileContainer(filePath, projectPartId)};
const QVector<FileContainer> fileContainer{FileContainer(filePath)};
document = documents.create(fileContainer).front();
documents.setVisibleInEditors({filePath});
documents.setUsedByCurrentEditor(filePath);

View File

@@ -25,9 +25,7 @@
#include "googletest.h"
#include <projectpart.h>
#include <clangexceptions.h>
#include <projects.h>
#include <clangdocument.h>
#include <clangdocuments.h>
#include <unsavedfiles.h>
@@ -37,8 +35,6 @@
using ClangBackEnd::Document;
using ClangBackEnd::UnsavedFiles;
using ClangBackEnd::ProjectPart;
using ClangBackEnd::ProjectPartContainer;
using testing::IsNull;
using testing::NotNull;
@@ -51,15 +47,13 @@ namespace {
using ::testing::PrintToString;
MATCHER_P3(IsDocument, filePath, projectPartId, documentRevision,
MATCHER_P2(IsDocument, filePath, documentRevision,
std::string(negation ? "isn't" : "is")
+ " document with file path "+ PrintToString(filePath)
+ " and project " + PrintToString(projectPartId)
+ " and document revision " + PrintToString(documentRevision)
)
{
return arg.filePath() == filePath
&& arg.projectPart().id() == projectPartId
&& arg.documentRevision() == documentRevision;
}
@@ -69,39 +63,28 @@ protected:
void SetUp() override;
protected:
ClangBackEnd::ProjectParts projects;
ClangBackEnd::UnsavedFiles unsavedFiles;
ClangBackEnd::Documents documents{projects, unsavedFiles};
ClangBackEnd::Documents documents{unsavedFiles};
const Utf8String filePath = Utf8StringLiteral(TESTDATA_DIR"/translationunits.cpp");
const Utf8String otherFilePath = Utf8StringLiteral(TESTDATA_DIR"/translationunits.h");
const Utf8String headerPath = Utf8StringLiteral(TESTDATA_DIR"/translationunits.h");
const Utf8String nonExistingFilePath = Utf8StringLiteral("foo.cpp");
const Utf8String projectPartId = Utf8StringLiteral("projectPartId");
const Utf8String otherProjectPartId = Utf8StringLiteral("otherProjectPartId");
const Utf8String nonExistingProjectPartId = Utf8StringLiteral("nonExistingProjectPartId");
const ClangBackEnd::FileContainer fileContainer{filePath, projectPartId};
const ClangBackEnd::FileContainer headerContainer{headerPath, projectPartId};
const ClangBackEnd::FileContainer fileContainer{filePath};
const ClangBackEnd::FileContainer headerContainer{headerPath};
};
using DocumentsSlowTest = Documents;
TEST_F(Documents, ThrowForGettingWithWrongFilePath)
{
ASSERT_THROW(documents.document(nonExistingFilePath, projectPartId),
ASSERT_THROW(documents.document(nonExistingFilePath),
ClangBackEnd::DocumentDoesNotExistException);
}
TEST_F(Documents, ThrowForGettingWithWrongProjectPartFilePath)
{
ASSERT_THROW(documents.document(filePath, nonExistingProjectPartId),
ClangBackEnd::ProjectPartDoNotExistException);
}
TEST_F(Documents, ThrowForAddingNonExistingFile)
{
ClangBackEnd::FileContainer fileContainer(nonExistingFilePath, projectPartId);
ClangBackEnd::FileContainer fileContainer(nonExistingFilePath);
ASSERT_THROW(documents.create({fileContainer}),
ClangBackEnd::DocumentFileDoesNotExistException);
@@ -109,25 +92,25 @@ TEST_F(Documents, ThrowForAddingNonExistingFile)
TEST_F(Documents, DoNotThrowForAddingNonExistingFileWithUnsavedContent)
{
ClangBackEnd::FileContainer fileContainer(nonExistingFilePath, projectPartId, Utf8String(), true);
ClangBackEnd::FileContainer fileContainer(nonExistingFilePath, Utf8String(), true);
ASSERT_NO_THROW(documents.create({fileContainer}));
}
TEST_F(Documents, Add)
{
ClangBackEnd::FileContainer fileContainer(filePath, projectPartId, Utf8StringVector(), 74u);
ClangBackEnd::FileContainer fileContainer(filePath, Utf8StringVector(), 74u);
documents.create({fileContainer});
ASSERT_THAT(documents.document(filePath, projectPartId),
IsDocument(filePath, projectPartId, 74u));
ASSERT_THAT(documents.document(filePath),
IsDocument(filePath, 74u));
}
TEST_F(Documents, CreateWithUnsavedContentSetsDependenciesDirty)
{
ClangBackEnd::FileContainer fileContainer(filePath, projectPartId, Utf8StringVector(), 74u);
ClangBackEnd::FileContainer fileContainerWithUnsavedContent(otherFilePath, projectPartId, Utf8StringVector(), Utf8String(), true, 2u);
ClangBackEnd::FileContainer fileContainer(filePath, Utf8StringVector(), 74u);
ClangBackEnd::FileContainer fileContainerWithUnsavedContent(otherFilePath, Utf8StringVector(), Utf8String(), true, 2u);
auto dependentDocument = documents.create({fileContainer}).at(0);
dependentDocument.setDependedFilePaths(QSet<Utf8String>() << filePath << otherFilePath);
@@ -138,46 +121,43 @@ TEST_F(Documents, CreateWithUnsavedContentSetsDependenciesDirty)
TEST_F(Documents, AddAndTestCreatedTranslationUnit)
{
ClangBackEnd::FileContainer fileContainer(filePath, projectPartId, Utf8StringVector(), 74u);
ClangBackEnd::FileContainer fileContainer(filePath, Utf8StringVector(), 74u);
auto createdDocuments = documents.create({fileContainer});
ASSERT_THAT(createdDocuments.front(),
IsDocument(filePath, projectPartId, 74u));
ASSERT_THAT(createdDocuments.front(), IsDocument(filePath, 74u));
}
TEST_F(Documents, ThrowForCreatingAnExistingDocument)
{
ClangBackEnd::FileContainer fileContainer(filePath, projectPartId, Utf8StringVector(), 74u);
ClangBackEnd::FileContainer fileContainer(filePath, Utf8StringVector(), 74u);
documents.create({fileContainer});
ASSERT_THROW(documents.create({fileContainer}),
ClangBackEnd::DocumentAlreadyExistsException);
ASSERT_THROW(documents.create({fileContainer}), ClangBackEnd::DocumentAlreadyExistsException);
}
TEST_F(Documents, ThrowForUpdatingANonExistingDocument)
{
ClangBackEnd::FileContainer fileContainer(filePath, projectPartId, Utf8StringVector(), 74u);
ClangBackEnd::FileContainer fileContainer(filePath, Utf8StringVector(), 74u);
ASSERT_THROW(documents.update({fileContainer}),
ClangBackEnd::DocumentDoesNotExistException);
}
TEST_F(Documents, UpdateSingle)
{
ClangBackEnd::FileContainer createFileContainer(filePath, projectPartId, Utf8StringVector(), 74u);
ClangBackEnd::FileContainer updateFileContainer(filePath, Utf8String(), Utf8StringVector(), 75u);
ClangBackEnd::FileContainer createFileContainer(filePath, Utf8StringVector(), 74u);
ClangBackEnd::FileContainer updateFileContainer(filePath, Utf8StringVector(), 75u);
documents.create({createFileContainer});
documents.update({updateFileContainer});
ASSERT_THAT(documents.document(filePath, projectPartId),
IsDocument(filePath, projectPartId, 75u));
ASSERT_THAT(documents.document(filePath), IsDocument(filePath, 75u));
}
TEST_F(Documents, UpdateReturnsUpdatedDocument)
{
ClangBackEnd::FileContainer createFileContainer(filePath, projectPartId, Utf8StringVector(), 74u);
ClangBackEnd::FileContainer updateFileContainer(filePath, Utf8String(), Utf8StringVector(), 75u);
ClangBackEnd::FileContainer createFileContainer(filePath, Utf8StringVector(), 74u);
ClangBackEnd::FileContainer updateFileContainer(filePath, Utf8StringVector(), 75u);
documents.create({createFileContainer});
const std::vector<Document> updatedDocuments = documents.update({updateFileContainer});
@@ -186,52 +166,50 @@ TEST_F(Documents, UpdateReturnsUpdatedDocument)
ASSERT_THAT(updatedDocuments.front().documentRevision(), Eq(75u));
}
// TODO: Does this test still makes sense?
TEST_F(Documents, UpdateMultiple)
{
ClangBackEnd::FileContainer fileContainer(filePath, projectPartId, Utf8StringVector(), 74u);
ClangBackEnd::FileContainer fileContainerWithOtherProject(filePath, otherProjectPartId, Utf8StringVector(), 74u);
ClangBackEnd::FileContainer updatedFileContainer(filePath, Utf8String(), Utf8StringVector(), 75u);
ClangBackEnd::FileContainer fileContainer(filePath, Utf8StringVector(), 74u);
ClangBackEnd::FileContainer fileContainerWithOtherProject(filePath, Utf8StringVector(), 74u);
ClangBackEnd::FileContainer updatedFileContainer(filePath, Utf8StringVector(), 75u);
documents.create({fileContainer, fileContainerWithOtherProject});
documents.update({updatedFileContainer});
ASSERT_THAT(documents.document(filePath, projectPartId),
IsDocument(filePath, projectPartId, 75u));
ASSERT_THAT(documents.document(filePath, otherProjectPartId),
IsDocument(filePath, otherProjectPartId, 75u));
ASSERT_THAT(documents.document(filePath), IsDocument(filePath, 75u));
}
TEST_F(DocumentsSlowTest, UpdateUnsavedFileAndCheckForReparse)
{
ClangBackEnd::FileContainer fileContainer(filePath, projectPartId, Utf8StringVector(), 74u);
ClangBackEnd::FileContainer headerContainer(headerPath, projectPartId, Utf8StringVector(), 74u);
ClangBackEnd::FileContainer headerContainerWithUnsavedContent(headerPath, projectPartId, Utf8String(), true, 75u);
ClangBackEnd::FileContainer fileContainer(filePath, Utf8StringVector(), 74u);
ClangBackEnd::FileContainer headerContainer(headerPath, Utf8StringVector(), 74u);
ClangBackEnd::FileContainer headerContainerWithUnsavedContent(headerPath, Utf8String(), true, 75u);
documents.create({fileContainer, headerContainer});
Document document = documents.document(filePath, projectPartId);
Document document = documents.document(filePath);
document.parse();
documents.update({headerContainerWithUnsavedContent});
ASSERT_TRUE(documents.document(filePath, projectPartId).isDirty());
ASSERT_TRUE(documents.document(filePath).isDirty());
}
TEST_F(DocumentsSlowTest, RemoveFileAndCheckForReparse)
{
ClangBackEnd::FileContainer fileContainer(filePath, projectPartId, Utf8StringVector(), 74u);
ClangBackEnd::FileContainer headerContainer(headerPath, projectPartId, Utf8StringVector(), 74u);
ClangBackEnd::FileContainer headerContainerWithUnsavedContent(headerPath, projectPartId, Utf8String(), true, 75u);
ClangBackEnd::FileContainer fileContainer(filePath, Utf8StringVector(), 74u);
ClangBackEnd::FileContainer headerContainer(headerPath, Utf8StringVector(), 74u);
ClangBackEnd::FileContainer headerContainerWithUnsavedContent(headerPath, Utf8String(), true, 75u);
documents.create({fileContainer, headerContainer});
Document document = documents.document(filePath, projectPartId);
Document document = documents.document(filePath);
document.parse();
documents.remove({headerContainerWithUnsavedContent});
ASSERT_TRUE(documents.document(filePath, projectPartId).isDirty());
ASSERT_TRUE(documents.document(filePath).isDirty());
}
TEST_F(Documents, DontGetNewerFileContainerIfRevisionIsTheSame)
{
ClangBackEnd::FileContainer fileContainer(filePath, projectPartId, Utf8StringVector(), 74u);
ClangBackEnd::FileContainer fileContainer(filePath, Utf8StringVector(), 74u);
documents.create({fileContainer});
auto newerFileContainers = documents.newerFileContainers({fileContainer});
@@ -241,8 +219,8 @@ TEST_F(Documents, DontGetNewerFileContainerIfRevisionIsTheSame)
TEST_F(Documents, GetNewerFileContainerIfRevisionIsDifferent)
{
ClangBackEnd::FileContainer fileContainer(filePath, projectPartId, Utf8StringVector(), 74u);
ClangBackEnd::FileContainer newerContainer(filePath, projectPartId, Utf8StringVector(), 75u);
ClangBackEnd::FileContainer fileContainer(filePath, Utf8StringVector(), 74u);
ClangBackEnd::FileContainer newerContainer(filePath, Utf8StringVector(), 75u);
documents.create({fileContainer});
auto newerFileContainers = documents.newerFileContainers({newerContainer});
@@ -252,61 +230,50 @@ TEST_F(Documents, GetNewerFileContainerIfRevisionIsDifferent)
TEST_F(Documents, ThrowForRemovingWithWrongFilePath)
{
ClangBackEnd::FileContainer fileContainer(nonExistingFilePath, projectPartId);
ClangBackEnd::FileContainer fileContainer(nonExistingFilePath);
ASSERT_THROW(documents.remove({fileContainer}),
ClangBackEnd::DocumentDoesNotExistException);
}
TEST_F(Documents, ThrowForRemovingWithWrongProjectPartFilePath)
{
ClangBackEnd::FileContainer fileContainer(filePath, nonExistingProjectPartId);
ASSERT_THROW(documents.remove({fileContainer}),
ClangBackEnd::ProjectPartDoNotExistException);
}
TEST_F(Documents, Remove)
{
ClangBackEnd::FileContainer fileContainer(filePath, projectPartId);
ClangBackEnd::FileContainer fileContainer(filePath);
documents.create({fileContainer});
documents.remove({fileContainer});
ASSERT_THROW(documents.document(filePath, projectPartId),
ASSERT_THROW(documents.document(filePath),
ClangBackEnd::DocumentDoesNotExistException);
}
TEST_F(Documents, RemoveAllValidIfExceptionIsThrown)
{
ClangBackEnd::FileContainer fileContainer(filePath, projectPartId);
ClangBackEnd::FileContainer fileContainer(filePath);
documents.create({fileContainer});
ASSERT_THROW(documents.remove({ClangBackEnd::FileContainer(Utf8StringLiteral("dontextist.pro"), projectPartId), fileContainer}),
ASSERT_THROW(documents.remove({ClangBackEnd::FileContainer(Utf8StringLiteral("dontextist.pro")), fileContainer}),
ClangBackEnd::DocumentDoesNotExistException);
ASSERT_THAT(documents.documents(),
Not(Contains(Document(filePath,
projects.project(projectPartId),
Utf8StringVector(),
documents))));
Not(Contains(Document(filePath, Utf8StringVector(), documents))));
}
TEST_F(Documents, HasDocument)
{
documents.create({{filePath, projectPartId}});
documents.create({{filePath}});
ASSERT_TRUE(documents.hasDocument(filePath, projectPartId));
ASSERT_TRUE(documents.hasDocument(filePath));
}
TEST_F(Documents, HasNotDocument)
{
ASSERT_FALSE(documents.hasDocument(filePath, projectPartId));
ASSERT_FALSE(documents.hasDocument(filePath));
}
TEST_F(Documents, FilteredPositive)
{
documents.create({{filePath, projectPartId}});
documents.create({{filePath}});
const auto isMatchingFilePath = [this](const Document &document) {
return document.filePath() == filePath;
};
@@ -318,7 +285,7 @@ TEST_F(Documents, FilteredPositive)
TEST_F(Documents, FilteredNegative)
{
documents.create({{filePath, projectPartId}});
documents.create({{filePath}});
const auto isMatchingNothing = [](const Document &) {
return false;
};
@@ -330,7 +297,7 @@ TEST_F(Documents, FilteredNegative)
TEST_F(Documents, DirtyAndVisibleButNotCurrentDocuments)
{
documents.create({{filePath, projectPartId}});
documents.create({{filePath}});
documents.updateDocumentsWithChangedDependency(filePath);
documents.setVisibleInEditors({filePath});
documents.setUsedByCurrentEditor(Utf8String());
@@ -402,45 +369,9 @@ TEST_F(Documents, IsNotVisibleEditorAfterBeingVisible)
ASSERT_FALSE(document.isVisibleInEditor());
}
TEST_F(Documents, SetDocumentsDirtyIfProjectPartChanged)
{
ClangBackEnd::FileContainer fileContainer(filePath, projectPartId, Utf8StringVector(), 74u);
const auto createdDocuments = documents.create({fileContainer});
ClangBackEnd::FileContainer fileContainerWithOtherProject(filePath, otherProjectPartId, Utf8StringVector(), 74u);
documents.create({fileContainerWithOtherProject});
projects.createOrUpdate({ProjectPartContainer(projectPartId)});
const auto affectedDocuments = documents.setDocumentsDirtyIfProjectPartChanged();
ASSERT_THAT(affectedDocuments, createdDocuments);
}
TEST_F(Documents, SetDocumentsDirtyIfProjectPartChanged_EvenIfAlreadyDirty)
{
ClangBackEnd::FileContainer fileContainer(filePath, projectPartId, Utf8StringVector(), 74u);
auto createdDocuments = documents.create({fileContainer});
projects.createOrUpdate({ProjectPartContainer(projectPartId)});
documents.setDocumentsDirtyIfProjectPartChanged(); // Make already dirty
const auto affectedDocuments = documents.setDocumentsDirtyIfProjectPartChanged();
ASSERT_THAT(affectedDocuments, createdDocuments);
}
TEST_F(Documents, SetDocumentsDirtyIfProjectPartChanged_ReturnsEmpty)
{
ClangBackEnd::FileContainer fileContainer(filePath, projectPartId, Utf8StringVector(), 74u);
documents.create({fileContainer});
const auto affectedDocuments = documents.setDocumentsDirtyIfProjectPartChanged();
ASSERT_TRUE(affectedDocuments.empty());
}
// TODO: Remove?
void Documents::SetUp()
{
projects.createOrUpdate({ProjectPartContainer(projectPartId)});
projects.createOrUpdate({ProjectPartContainer(otherProjectPartId)});
}
}

View File

@@ -33,7 +33,6 @@
#include <clangdocuments.h>
#include <clangdocumentsuspenderresumer.h>
#include <clangtranslationunits.h>
#include <projects.h>
#include <unsavedfiles.h>
#include <utf8string.h>
@@ -69,30 +68,25 @@ namespace {
class DocumentSuspenderResumer : public ::testing::Test
{
protected:
void SetUp() override;
Document getDocument(const Utf8String &filePath);
void categorizeDocuments(int hotDocumentsSize);
SuspendResumeJobs createSuspendResumeJobs(int hotDocumentsSize = -1);
static void setParsed(Document &document);
protected:
ClangBackEnd::ProjectParts projects;
ClangBackEnd::UnsavedFiles unsavedFiles;
ClangBackEnd::Documents documents{projects, unsavedFiles};
ClangBackEnd::Documents documents{unsavedFiles};
DummyIpcClient dummyIpcClient;
ClangBackEnd::DocumentProcessors documentProcessors{documents, unsavedFiles, projects,
dummyIpcClient};
const Utf8String projectPartId = Utf8StringLiteral("projectPartId");
ClangBackEnd::DocumentProcessors documentProcessors{documents, unsavedFiles, dummyIpcClient};
const Utf8String filePath1 = Utf8StringLiteral(TESTDATA_DIR"/empty1.cpp");
const ClangBackEnd::FileContainer fileContainer1{filePath1, projectPartId, Utf8String(), true};
const ClangBackEnd::FileContainer fileContainer1{filePath1, Utf8String(), true};
const Utf8String filePath2 = Utf8StringLiteral(TESTDATA_DIR"/empty2.cpp");
const ClangBackEnd::FileContainer fileContainer2{filePath2, projectPartId, Utf8String(), true};
const ClangBackEnd::FileContainer fileContainer2{filePath2, Utf8String(), true};
const Utf8String filePath3 = Utf8StringLiteral(TESTDATA_DIR"/empty3.cpp");
const ClangBackEnd::FileContainer fileContainer3{filePath3, projectPartId, Utf8String(), true};
const ClangBackEnd::FileContainer fileContainer3{filePath3, Utf8String(), true};
std::vector<Document> hotDocuments;
std::vector<Document> coldDocuments;
@@ -286,14 +280,9 @@ TEST_F(DocumentSuspenderResumer, CreateSuspendAndResumeJobs)
ASSERT_THAT(jobs, ContainerEq(expectedJobs));
}
void DocumentSuspenderResumer::SetUp()
{
projects.createOrUpdate({ClangBackEnd::ProjectPartContainer(projectPartId)});
}
ClangBackEnd::Document DocumentSuspenderResumer::getDocument(const Utf8String &filePath)
{
return documents.document(filePath, projectPartId);
return documents.document(filePath);
}
void DocumentSuspenderResumer::categorizeDocuments(int hotDocumentsSize)

View File

@@ -33,8 +33,6 @@
#include <clangtranslationunit.h>
#include <fixitcontainer.h>
#include <followsymbolmessage.h>
#include <projectpart.h>
#include <projects.h>
#include <sourcelocationcontainer.h>
#include <sourcerangecontainer.h>
#include <unsavedfiles.h>
@@ -50,7 +48,6 @@ using ::testing::ContainerEq;
using ::testing::Eq;
using ::testing::PrintToString;
using ::ClangBackEnd::ProjectPart;
using ::ClangBackEnd::SourceLocationContainer;
using ::ClangBackEnd::Document;
using ::ClangBackEnd::UnsavedFiles;
@@ -113,20 +110,12 @@ MATCHER_P4(MatchesFileSourceRange, filename, line, column, length,
class Data {
public:
ProjectPart projectPart{
Utf8StringLiteral("projectPartId"),
TestEnvironment::addPlatformArguments({Utf8StringLiteral("-std=c++14")})};
ClangBackEnd::ProjectParts projects;
ClangBackEnd::UnsavedFiles unsavedFiles;
ClangBackEnd::Documents documents{projects, unsavedFiles};
Document document = {sourceFilePath,
projectPart,
Utf8StringVector(),
documents};
Document headerDocument = {headerFilePath,
projectPart,
Utf8StringVector(),
documents};
ClangBackEnd::Documents documents{unsavedFiles};
Utf8StringVector compilationArguments{
TestEnvironment::addPlatformArguments({Utf8StringLiteral("-std=c++14")})};
Document document = {sourceFilePath, compilationArguments, documents};
Document headerDocument = {headerFilePath, compilationArguments, documents};
QVector<Utf8String> deps{sourceFilePath, cursorPath};
};

View File

@@ -32,8 +32,6 @@
#include <clangtranslationunits.h>
#include <clangjobs.h>
#include <filecontainer.h>
#include <projectpart.h>
#include <projects.h>
#include <unsavedfiles.h>
#include <clang-c/Index.h>
@@ -70,21 +68,17 @@ protected:
void updateDocumentRevision();
void updateUnsavedFiles();
void updateProject();
void removeProject();
void removeDocument();
protected:
ClangBackEnd::ProjectParts projects;
ClangBackEnd::UnsavedFiles unsavedFiles;
ClangBackEnd::Documents documents{projects, unsavedFiles};
ClangBackEnd::Documents documents{unsavedFiles};
ClangBackEnd::Document document;
Utf8String filePath1 = Utf8StringLiteral(TESTDATA_DIR"/translationunits.cpp");
Utf8String filePath2 = Utf8StringLiteral(TESTDATA_DIR"/skippedsourceranges.cpp");
Utf8String projectPartId{Utf8StringLiteral("/path/to/projectfile")};
ClangBackEnd::JobQueue jobQueue{documents, projects};
ClangBackEnd::JobQueue jobQueue{documents};
};
TEST_F(JobQueue, AddJob)
@@ -200,17 +194,6 @@ TEST_F(JobQueue, RemoveRequestsForClosedDocuments)
ASSERT_THAT(jobsToRun.size(), Eq(0));
}
TEST_F(JobQueue, RemoveRequestsForClosedProject)
{
jobQueue.add(createJobRequest(filePath1, JobRequest::Type::UpdateAnnotations));
removeProject();
const JobRequests jobsToRun = jobQueue.processQueue();
ASSERT_THAT(jobQueue.size(), Eq(0));
ASSERT_THAT(jobsToRun.size(), Eq(0));
}
TEST_F(JobQueue, RemoveRequestsForOudatedUnsavedFiles)
{
jobQueue.add(createJobRequest(filePath1, JobRequest::Type::UpdateAnnotations));
@@ -233,17 +216,6 @@ TEST_F(JobQueue, RemoveRequestsForChangedDocumentRevision)
ASSERT_THAT(jobsToRun.size(), Eq(0));
}
TEST_F(JobQueue, RemoveRequestsForOudatedProject)
{
jobQueue.add(createJobRequest(filePath1, JobRequest::Type::UpdateAnnotations));
updateProject();
const JobRequests jobsToRun = jobQueue.processQueue();
ASSERT_THAT(jobQueue.size(), Eq(0));
ASSERT_THAT(jobsToRun.size(), Eq(0));
}
TEST_F(JobQueue, RemoveRequestsForNotIntactDocuments)
{
const Utf8String filePath = createTranslationUnitForDeletedFile();
@@ -369,26 +341,6 @@ TEST_F(JobQueue, RequestUpdateAnnotationsOutdatableByUnsavedFileChange)
ASSERT_THAT(jobsToStart.size(), Eq(0));
}
TEST_F(JobQueue, RequestUpdateAnnotationsOutdatableByProjectRemoval)
{
jobQueue.add(createJobRequest(filePath1, JobRequest::Type::UpdateAnnotations));
removeProject();
const JobRequests jobsToStart = jobQueue.processQueue();
ASSERT_THAT(jobsToStart.size(), Eq(0));
}
TEST_F(JobQueue, RequestUpdateAnnotationsOutdatableByProjectChange)
{
jobQueue.add(createJobRequest(filePath1, JobRequest::Type::UpdateAnnotations));
updateProject();
const JobRequests jobsToStart = jobQueue.processQueue();
ASSERT_THAT(jobsToStart.size(), Eq(0));
}
TEST_F(JobQueue, RequestUpdateAnnotationsOutdatableByDocumentClose)
{
jobQueue.add(createJobRequest(filePath1, JobRequest::Type::UpdateAnnotations));
@@ -496,10 +448,8 @@ TEST_F(JobQueue, ResumeDocumentDoesNotRunOnUnsuspended)
void JobQueue::SetUp()
{
projects.createOrUpdate({ProjectPartContainer(projectPartId)});
const QVector<FileContainer> fileContainer{FileContainer(filePath1, projectPartId),
FileContainer(filePath2, projectPartId)};
const QVector<FileContainer> fileContainer{FileContainer(filePath1),
FileContainer(filePath2)};
document = documents.create(fileContainer).front();
documents.setVisibleInEditors({filePath1});
documents.setUsedByCurrentEditor(filePath1);
@@ -517,8 +467,7 @@ Utf8String JobQueue::createTranslationUnitForDeletedFile()
EXPECT_TRUE(temporaryFile.open());
const QString temporaryFilePath = Utf8String::fromString(temporaryFile.fileName());
ClangBackEnd::FileContainer fileContainer(temporaryFilePath,
projectPartId, Utf8String(), true);
ClangBackEnd::FileContainer fileContainer(temporaryFilePath, Utf8String(), true);
documents.create({fileContainer});
auto document = documents.document(fileContainer);
document.setIsUsedByCurrentEditor(true);
@@ -533,11 +482,9 @@ JobRequest JobQueue::createJobRequest(
{
JobRequest jobRequest(type);
jobRequest.filePath = filePath;
jobRequest.projectPartId = projectPartId;
jobRequest.unsavedFilesChangeTimePoint = unsavedFiles.lastChangeTimePoint();
jobRequest.documentRevision = document.documentRevision();
jobRequest.preferredTranslationUnit = preferredTranslationUnit;
jobRequest.projectChangeTimePoint = projects.project(projectPartId).lastChangeTimePoint();
return jobRequest;
}
@@ -549,27 +496,17 @@ void JobQueue::pretendParsedTranslationUnit()
void JobQueue::updateDocumentRevision()
{
documents.update({FileContainer(filePath1, projectPartId, Utf8String(), true, 1)});
documents.update({FileContainer(filePath1, Utf8String(), true, 1)});
}
void JobQueue::updateUnsavedFiles()
{
unsavedFiles.createOrUpdate({FileContainer(filePath1, projectPartId, Utf8String(), true, 1)});
}
void JobQueue::updateProject()
{
projects.createOrUpdate({projectPartId});
}
void JobQueue::removeProject()
{
projects.remove({projectPartId});
unsavedFiles.createOrUpdate({FileContainer(filePath1, Utf8String(), true, 1)});
}
void JobQueue::removeDocument()
{
documents.remove({FileContainer(filePath1, projectPartId)});
documents.remove({FileContainer(filePath1)});
}
} // anonymous

View File

@@ -30,8 +30,6 @@
#include <clangdocument.h>
#include <clangjobs.h>
#include <filecontainer.h>
#include <projectpart.h>
#include <projects.h>
#include <clangdocuments.h>
#include <unsavedfiles.h>
@@ -59,16 +57,14 @@ protected:
bool waitUntilJobChainFinished(int timeOutInMs = 10000);
protected:
ClangBackEnd::ProjectParts projects;
ClangBackEnd::UnsavedFiles unsavedFiles;
ClangBackEnd::Documents documents{projects, unsavedFiles};
ClangBackEnd::Documents documents{unsavedFiles};
ClangBackEnd::Document document;
DummyIpcClient dummyClientInterface;
Utf8String filePath1 = Utf8StringLiteral(TESTDATA_DIR"/translationunits.cpp");
Utf8String projectPartId{Utf8StringLiteral("/path/to/projectfile")};
ClangBackEnd::Jobs jobs{documents, unsavedFiles, projects, dummyClientInterface};
ClangBackEnd::Jobs jobs{documents, unsavedFiles, dummyClientInterface};
};
using JobsSlowTest = Jobs;
@@ -114,9 +110,7 @@ TEST_F(JobsSlowTest, IsJobRunning)
void Jobs::SetUp()
{
projects.createOrUpdate({ProjectPartContainer(projectPartId)});
const QVector<FileContainer> fileContainer{FileContainer(filePath1, projectPartId)};
const QVector<FileContainer> fileContainer{FileContainer(filePath1)};
document = documents.create(fileContainer).front();
documents.setVisibleInEditors({filePath1});
documents.setUsedByCurrentEditor(filePath1);

View File

@@ -32,8 +32,6 @@
#include <clangdocuments.h>
#include <clangtranslationunit.h>
#include <fixitcontainer.h>
#include <projectpart.h>
#include <projects.h>
#include <sourcelocationcontainer.h>
#include <sourcerangecontainer.h>
#include <unsavedfiles.h>
@@ -47,7 +45,6 @@ using ::testing::Not;
using ::testing::ContainerEq;
using ::testing::Eq;
using ::ClangBackEnd::ProjectPart;
using ::ClangBackEnd::SourceLocationContainer;
using ::ClangBackEnd::Document;
using ::ClangBackEnd::UnsavedFiles;
@@ -59,15 +56,10 @@ using References = QVector<SourceRangeContainer>;
namespace {
struct Data {
ProjectPart projectPart{
Utf8StringLiteral("projectPartId"),
TestEnvironment::addPlatformArguments({Utf8StringLiteral("-std=c++14")})};
ClangBackEnd::ProjectParts projects;
ClangBackEnd::UnsavedFiles unsavedFiles;
ClangBackEnd::Documents documents{projects, unsavedFiles};
ClangBackEnd::Documents documents{unsavedFiles};
Document document{Utf8StringLiteral(TESTDATA_DIR"/references.cpp"),
projectPart,
Utf8StringVector(),
TestEnvironment::addPlatformArguments({Utf8StringLiteral("-std=c++14")}),
documents};
};

View File

@@ -77,7 +77,7 @@ TEST_F(RequestAnnotationsJob, DontSendAnnotationsIfDocumentWasClosed)
EXPECT_CALL(mockIpcClient, annotations(_)).Times(0);
job.runAsync();
documents.remove({FileContainer{filePath, projectPartId}});
documents.remove({FileContainer{filePath}});
ASSERT_TRUE(waitUntilJobFinished(job));
}

View File

@@ -94,7 +94,7 @@ TEST_F(RequestReferencesJob, DontSendReferencesIfDocumentWasClosed)
EXPECT_CALL(mockIpcClient, references(_)).Times(0);
job.runAsync();
documents.remove({FileContainer{filePath, projectPartId}});
documents.remove({FileContainer{filePath}});
ASSERT_TRUE(waitUntilJobFinished(job));
}
@@ -106,7 +106,7 @@ TEST_F(RequestReferencesJob, DontSendReferencesIfDocumentRevisionChanged)
EXPECT_CALL(mockIpcClient, references(_)).Times(0);
job.runAsync();
documents.update({FileContainer(filePath, projectPartId, Utf8String(), true, 99)});
documents.update({FileContainer(filePath, Utf8String(), true, 99)});
ASSERT_TRUE(waitUntilJobFinished(job));
}

View File

@@ -27,7 +27,6 @@
#include "dummyclangipcclient.h"
#include "processevents-utilities.h"
#include "runprojectcreateorupdate-utility.h"
#include <clangbackend_global.h>
#include <clangdocuments.h>
@@ -35,7 +34,6 @@
#include <clangsupportivetranslationunitinitializer.cpp>
#include <clangtranslationunit.h>
#include <clangtranslationunits.h>
#include <projects.h>
#include <utf8string.h>
#include <clang-c/Index.h>
@@ -62,17 +60,14 @@ protected:
protected:
Utf8String filePath{Utf8StringLiteral(TESTDATA_DIR"/translationunits.cpp")};
Utf8String projectPartId{Utf8StringLiteral("/path/to/projectfile")};
ProjectParts projects;
UnitTest::RunProjectCreateOrUpdate _1{projects, {ProjectPartContainer(projectPartId)}};
UnsavedFiles unsavedFiles;
const QVector<FileContainer> fileContainer{FileContainer(filePath, projectPartId)};
Documents documents{projects, unsavedFiles};
const QVector<FileContainer> fileContainer{FileContainer(filePath)};
Documents documents{unsavedFiles};
Document document{documents.create(fileContainer).front()};
DummyIpcClient dummyClientInterface;
Jobs jobs{documents, unsavedFiles, projects, dummyClientInterface};
Jobs jobs{documents, unsavedFiles, dummyClientInterface};
ClangBackEnd::SupportiveTranslationUnitInitializer initializer{document, jobs};
};
@@ -86,7 +81,7 @@ TEST_F(SupportiveTranslationUnitInitializer, HasInitiallyNotInitializedState)
TEST_F(SupportiveTranslationUnitInitializer, StartInitializingAbortsIfDocumentIsClosed)
{
documents.remove({FileContainer(filePath, projectPartId)});
documents.remove({FileContainer(filePath)});
initializer.startInitializing();
@@ -125,7 +120,7 @@ TEST_F(SupportiveTranslationUnitInitializerSlowTest, Abort)
TEST_F(SupportiveTranslationUnitInitializer, CheckIfParseJobFinishedAbortsIfDocumentIsClosed)
{
documents.remove({FileContainer(filePath, projectPartId)});
documents.remove({FileContainer(filePath)});
initializer.setState(ClangBackEnd::SupportiveTranslationUnitInitializer::State::WaitingForParseJob);
const Jobs::RunningJob runningJob = createRunningJob(JobRequest::Type::ParseSupportiveTranslationUnit);
@@ -162,16 +157,14 @@ void SupportiveTranslationUnitInitializer::SetUp()
documents.setVisibleInEditors({filePath});
documents.setUsedByCurrentEditor(filePath);
const auto isDocumentClosed = [this](const Utf8String &filePath,
const Utf8String &projectPartId) {
return !documents.hasDocument(filePath, projectPartId);
const auto isDocumentClosed = [this](const Utf8String &filePath) {
return !documents.hasDocument(filePath);
};
initializer.setIsDocumentClosedChecker(isDocumentClosed);
}
void SupportiveTranslationUnitInitializer::parse()
{
projects.createOrUpdate({ProjectPartContainer{projectPartId, Utf8StringVector()}});
document.parse();
}

View File

@@ -32,8 +32,6 @@
#include <clangtooltipinfocollector.h>
#include <clangtranslationunit.h>
#include <fixitcontainer.h>
#include <projectpart.h>
#include <projects.h>
#include <sourcelocationcontainer.h>
#include <sourcerangecontainer.h>
#include <unsavedfiles.h>
@@ -42,7 +40,6 @@
#include <clang-c/Index.h>
using ::ClangBackEnd::ProjectPart;
using ::ClangBackEnd::SourceLocationContainer;
using ::ClangBackEnd::Document;
using ::ClangBackEnd::UnsavedFiles;
@@ -84,13 +81,10 @@ MATCHER_P(IsQdocToolTip, expected, std::string(negation ? "isn't" : "is") + Pri
#undef CHECK_MEMBER
struct Data {
ProjectPart projectPart{Utf8StringLiteral("projectPartId"), {Utf8StringLiteral("-std=c++14")}};
ClangBackEnd::ProjectParts projects;
ClangBackEnd::UnsavedFiles unsavedFiles;
ClangBackEnd::Documents documents{projects, unsavedFiles};
ClangBackEnd::Documents documents{unsavedFiles};
Document document{Utf8StringLiteral(TESTDATA_DIR "/tooltipinfo.cpp"),
projectPart,
{},
{Utf8StringLiteral("-std=c++14")},
documents};
UnitTest::RunDocumentParse _1{document};
};

View File

@@ -80,7 +80,7 @@ TEST_F(UpdateAnnotationsJobSlowTest, DontSendAnnotationsIfDocumentWasClosed)
EXPECT_CALL(mockIpcClient, annotations(_)).Times(0);
job.runAsync();
documents.remove({FileContainer{filePath, projectPartId}});
documents.remove({FileContainer{filePath}});
ASSERT_TRUE(waitUntilJobFinished(job));
}
@@ -92,14 +92,13 @@ TEST_F(UpdateAnnotationsJobSlowTest, DontSendAnnotationsIfDocumentRevisionChange
EXPECT_CALL(mockIpcClient, annotations(_)).Times(0);
job.runAsync();
documents.update({FileContainer(filePath, projectPartId, Utf8String(), true, 99)});
documents.update({FileContainer(filePath, Utf8String(), true, 99)});
ASSERT_TRUE(waitUntilJobFinished(job));
}
TEST_F(UpdateAnnotationsJobSlowTest, UpdatesTranslationUnit)
{
const TimePoint timePointBefore = document.lastProjectPartChangeTimePoint();
const QSet<Utf8String> dependendOnFilesBefore = document.dependedFilePaths();
job.setContext(jobContext);
job.prepareAsyncRun();
@@ -107,7 +106,6 @@ TEST_F(UpdateAnnotationsJobSlowTest, UpdatesTranslationUnit)
job.runAsync();
ASSERT_TRUE(waitUntilJobFinished(job));
ASSERT_THAT(timePointBefore, Not(document.lastProjectPartChangeTimePoint()));
ASSERT_THAT(dependendOnFilesBefore, Not(document.dependedFilePaths()));
}

View File

@@ -65,7 +65,6 @@ protected:
protected:
Utf8String filePath{Utf8StringLiteral(TESTDATA_DIR"/complete_extractor_function.cpp")};
ClangBackEnd::FileContainer fileContainer{filePath,
Utf8StringLiteral("projectPartId"),
Utf8StringLiteral("unsaved content"),
true,
1};
@@ -152,7 +151,7 @@ TEST_F(ClientServerInProcess, SendUnregisterUnsavedFilesForEditorMessage)
TEST_F(ClientServerInProcess, SendCompleteCodeMessage)
{
ClangBackEnd::RequestCompletionsMessage message(Utf8StringLiteral("foo.cpp"), 24, 33, Utf8StringLiteral("do what I want"));
ClangBackEnd::RequestCompletionsMessage message(Utf8StringLiteral("foo.cpp"), 24, 33);
EXPECT_CALL(mockClangCodeModelServer, requestCompletions(message))
.Times(1);
@@ -185,29 +184,6 @@ TEST_F(ClientServerInProcess, SendCompletionsMessage)
scheduleClientMessages();
}
TEST_F(ClientServerInProcess, SendProjectPartsUpdatedMessage)
{
ClangBackEnd::ProjectPartContainer projectContainer(Utf8StringLiteral(TESTDATA_DIR"/complete.pro"));
ClangBackEnd::ProjectPartsUpdatedMessage message({projectContainer});
EXPECT_CALL(mockClangCodeModelServer, projectPartsUpdated(message))
.Times(1);
serverProxy.projectPartsUpdated(message);
scheduleServerMessages();
}
TEST_F(ClientServerInProcess, SendProjectPartsRemovedMessage)
{
ClangBackEnd::ProjectPartsRemovedMessage message({Utf8StringLiteral(TESTDATA_DIR"/complete.pro")});
EXPECT_CALL(mockClangCodeModelServer, projectPartsRemoved(message))
.Times(1);
serverProxy.projectPartsRemoved(message);
scheduleServerMessages();
}
TEST_F(ClientServerInProcess, DocumentVisibilityChangedMessage)
{
ClangBackEnd::DocumentVisibilityChangedMessage

View File

@@ -121,7 +121,7 @@ TEST_F(ClientServerOutsideProcess, SendDocumentsClosedMessage)
TEST_F(ClientServerOutsideProcess, SendCompleteCodeMessage)
{
RequestCompletionsMessage codeCompleteMessage(Utf8StringLiteral("foo.cpp"), 24, 33, Utf8StringLiteral("do what I want"));
RequestCompletionsMessage codeCompleteMessage(Utf8StringLiteral("foo.cpp"), 24, 33);
EchoMessage echoMessage(codeCompleteMessage);
EXPECT_CALL(mockClangCodeModelClient, echo(echoMessage));
@@ -130,29 +130,6 @@ TEST_F(ClientServerOutsideProcess, SendCompleteCodeMessage)
ASSERT_TRUE(client.waitForEcho());
}
TEST_F(ClientServerOutsideProcess, SendProjectPartsUpdatedMessage)
{
ClangBackEnd::ProjectPartContainer projectContainer(Utf8StringLiteral(TESTDATA_DIR"/complete.pro"));
ClangBackEnd::ProjectPartsUpdatedMessage projectPartsUpdatedMessage({projectContainer});
EchoMessage echoMessage(projectPartsUpdatedMessage);
EXPECT_CALL(mockClangCodeModelClient, echo(echoMessage));
client.serverProxy().projectPartsUpdated(projectPartsUpdatedMessage);
ASSERT_TRUE(client.waitForEcho());
}
TEST_F(ClientServerOutsideProcess, SendProjectPartsRemovedMessage)
{
ClangBackEnd::ProjectPartsRemovedMessage projectPartsRemovedMessage({Utf8StringLiteral(TESTDATA_DIR"/complete.pro")});
EchoMessage echoMessage(projectPartsRemovedMessage);
EXPECT_CALL(mockClangCodeModelClient, echo(echoMessage));
client.serverProxy().projectPartsRemoved(projectPartsRemovedMessage);
ASSERT_TRUE(client.waitForEcho());
}
void ClientServerOutsideProcess::SetUp()
{
QSignalSpy clientSpy(&client, &ConnectionClient::connectedToLocalSocket);

View File

@@ -28,8 +28,6 @@
#include <codecompleter.h>
#include <clangdocument.h>
#include <filecontainer.h>
#include <projectpart.h>
#include <projects.h>
#include <clangdocuments.h>
#include <unsavedfiles.h>
#include <utf8stringvector.h>
@@ -83,119 +81,117 @@ protected:
protected:
QTemporaryDir includeDirectory;
Utf8String includePath{QStringLiteral("-I") + includeDirectory.path()};
Utf8String includePathArgument{QStringLiteral("-I") + includeDirectory.path()};
QString targetHeaderPath{includeDirectory.path() + QStringLiteral("/complete_target_header.h")};
ClangBackEnd::ProjectPartContainer projectPart{Utf8StringLiteral("projectPartId"), {includePath}};
ClangBackEnd::FileContainer mainFileContainer{Utf8StringLiteral(TESTDATA_DIR"/complete_completer_main.cpp"),
projectPart.projectPartId};
ClangBackEnd::ProjectParts projects;
ClangBackEnd::FileContainer mainFileContainer{Utf8StringLiteral(TESTDATA_DIR
"/complete_completer_main.cpp"),
Utf8StringVector{includePathArgument}};
ClangBackEnd::UnsavedFiles unsavedFiles;
ClangBackEnd::Documents documents{projects, unsavedFiles};
ClangBackEnd::Documents documents{unsavedFiles};
ClangBackEnd::Document document;
QScopedPointer<ClangBackEnd::CodeCompleter> completer;
ClangBackEnd::FileContainer unsavedMainFileContainer{mainFileContainer.filePath,
projectPart.projectPartId,
{includePathArgument},
readFileContent("/complete_completer_main_unsaved.cpp"),
true};
ClangBackEnd::FileContainer unsavedTargetHeaderFileContainer{targetHeaderPath,
projectPart.projectPartId,
{includePathArgument},
readFileContent("/complete_target_header_unsaved.h"),
true};
ClangBackEnd::FileContainer arrowFileContainer{
Utf8StringLiteral(TESTDATA_DIR"/complete_arrow.cpp"),
projectPart.projectPartId,
{includePathArgument},
readFileContent("/complete_arrow.cpp"),
true
};
ClangBackEnd::FileContainer dotArrowCorrectionForPointerFileContainer{
Utf8StringLiteral(TESTDATA_DIR"/complete_withDotArrowCorrectionForPointer.cpp"),
projectPart.projectPartId,
{includePathArgument},
readFileContent("/complete_withDotArrowCorrectionForPointer.cpp"),
true
};
ClangBackEnd::FileContainer dotArrowCorrectionForPointerFileContainerBeforeTyping{
Utf8StringLiteral(TESTDATA_DIR"/complete_withDotArrowCorrectionForPointer.cpp"),
projectPart.projectPartId,
{includePathArgument},
readFileContent("/complete_withDotArrowCorrectionForPointer_beforeTyping.cpp"),
true
};
ClangBackEnd::FileContainer dotArrowCorrectionForPointerFileContainerAfterTyping{
Utf8StringLiteral(TESTDATA_DIR"/complete_withDotArrowCorrectionForPointer.cpp"),
projectPart.projectPartId,
{includePathArgument},
readFileContent("/complete_withDotArrowCorrectionForPointer_afterTyping.cpp"),
true
};
ClangBackEnd::FileContainer dotArrowCorrectionForPointerFileContainerInitial{
Utf8StringLiteral(TESTDATA_DIR"/complete_withDotArrowCorrectionForPointer.cpp"),
projectPart.projectPartId,
{includePathArgument},
readFileContent("/complete_withDotArrowCorrectionForPointerInitial.cpp"),
true
};
ClangBackEnd::FileContainer dotArrowCorrectionForPointerFileContainerUpdated{
Utf8StringLiteral(TESTDATA_DIR"/complete_withDotArrowCorrectionForPointer.cpp"),
projectPart.projectPartId,
{includePathArgument},
readFileContent("/complete_withDotArrowCorrectionForPointerUpdated.cpp"),
true
};
ClangBackEnd::FileContainer noDotArrowCorrectionForObjectFileContainer{
Utf8StringLiteral(TESTDATA_DIR"/complete_withNoDotArrowCorrectionForObject.cpp"),
projectPart.projectPartId,
{includePathArgument},
readFileContent("/complete_withNoDotArrowCorrectionForObject.cpp"),
true
};
ClangBackEnd::FileContainer noDotArrowCorrectionForFloatFileContainer{
Utf8StringLiteral(TESTDATA_DIR"/complete_withNoDotArrowCorrectionForFloat.cpp"),
projectPart.projectPartId,
{includePathArgument},
readFileContent("/complete_withNoDotArrowCorrectionForFloat.cpp"),
true
};
ClangBackEnd::FileContainer noDotArrowCorrectionForObjectWithArrowOperatortFileContainer{
Utf8StringLiteral(TESTDATA_DIR"/complete_withNoDotArrowCorrectionForObjectWithArrowOperator.cpp"),
projectPart.projectPartId,
{includePathArgument},
readFileContent("/complete_withNoDotArrowCorrectionForObjectWithArrowOperator.cpp"),
true
};
ClangBackEnd::FileContainer noDotArrowCorrectionForDotDotFileContainer{
Utf8StringLiteral(TESTDATA_DIR"/complete_withNoDotArrowCorrectionForDotDot.cpp"),
projectPart.projectPartId,
{includePathArgument},
readFileContent("/complete_withNoDotArrowCorrectionForDotDot.cpp"),
true
};
ClangBackEnd::FileContainer noDotArrowCorrectionForArrowDotFileContainer{
Utf8StringLiteral(TESTDATA_DIR"/complete_withNoDotArrowCorrectionForArrowDot.cpp"),
projectPart.projectPartId,
{includePathArgument},
readFileContent("/complete_withNoDotArrowCorrectionForArrowDot.cpp"),
true
};
ClangBackEnd::FileContainer noDotArrowCorrectionForOnlyDotFileContainer{
Utf8StringLiteral(TESTDATA_DIR"/complete_withNoDotArrowCorrectionForOnlyDot.cpp"),
projectPart.projectPartId,
{includePathArgument},
readFileContent("/complete_withNoDotArrowCorrectionForOnlyDot.cpp"),
true
};
ClangBackEnd::FileContainer noDotArrowCorrectionForColonColonFileContainer{
Utf8StringLiteral(TESTDATA_DIR"/complete_withNoDotArrowCorrectionForColonColon.cpp"),
projectPart.projectPartId,
{includePathArgument},
readFileContent("/complete_withNoDotArrowCorrectionForColonColon.cpp"),
true
};
ClangBackEnd::FileContainer dotArrowCorrectionForForwardDeclaredClassPointer{
Utf8StringLiteral(TESTDATA_DIR"/complete_withDotArrowCorrectionForForwardDeclaredClassPointer.cpp"),
projectPart.projectPartId,
{includePathArgument},
readFileContent("/complete_withDotArrowCorrectionForForwardDeclaredClassPointer.cpp"),
true
};
ClangBackEnd::FileContainer globalCompletionAfterForwardDeclaredClassPointer{
Utf8StringLiteral(TESTDATA_DIR"/complete_withGlobalCompletionAfterForwardDeclaredClassPointer.cpp"),
projectPart.projectPartId,
{includePathArgument},
readFileContent("/complete_withGlobalCompletionAfterForwardDeclaredClassPointer.cpp"),
true
};
ClangBackEnd::FileContainer smartPointerCompletion{
Utf8StringLiteral(TESTDATA_DIR"/complete_smartpointer.cpp"),
projectPart.projectPartId,
{includePathArgument},
readFileContent("/complete_smartpointer.cpp"),
true
};
@@ -232,11 +228,9 @@ void CodeCompleter::copyChangedTargetHeaderToTemporaryIncludeDirecory()
void CodeCompleter::SetUp()
{
EXPECT_TRUE(includeDirectory.isValid());
projects.createOrUpdate({projectPart});
documents.create({mainFileContainer});
document = documents.document(mainFileContainer);
completer.reset(new ClangBackEnd::CodeCompleter(document.translationUnit(),
unsavedFiles));
completer.reset(new ClangBackEnd::CodeCompleter(document.translationUnit(), unsavedFiles));
copyTargetHeaderToTemporaryIncludeDirecory();
document.parse();
@@ -397,8 +391,7 @@ TEST_F(CodeCompleterSlowTest, DotToArrowCompletionForPointerInOutdatedDocument)
auto fileContainerBeforeTyping = dotArrowCorrectionForPointerFileContainerBeforeTyping;
documents.create({fileContainerBeforeTyping});
unsavedFiles.createOrUpdate({fileContainerBeforeTyping});
auto document = documents.document(fileContainerBeforeTyping.filePath,
fileContainerBeforeTyping.projectPartId);
auto document = documents.document(fileContainerBeforeTyping.filePath);
document.parse();
unsavedFiles.createOrUpdate({dotArrowCorrectionForPointerFileContainerAfterTyping});
ClangBackEnd::CodeCompleter myCompleter(documents.document(dotArrowCorrectionForPointerFileContainerAfterTyping).translationUnit(),

View File

@@ -31,8 +31,6 @@
#include <clangfilepath.h>
#include <codecompletionsextractor.h>
#include <filecontainer.h>
#include <projectpart.h>
#include <projects.h>
#include <clangunsavedfilesshallowarguments.h>
#include <clangtranslationunit.h>
#include <clangdocuments.h>
@@ -135,7 +133,6 @@ const ClangBackEnd::FileContainer unsavedDataFileContainer(const char *filePath,
const char *unsavedFilePath)
{
return ClangBackEnd::FileContainer(Utf8String::fromUtf8(filePath),
Utf8String(),
unsavedFileContent(unsavedFilePath),
true);
}
@@ -149,18 +146,17 @@ protected:
bool needsReparse = false);
protected:
ClangBackEnd::ProjectPart project{Utf8StringLiteral("/path/to/projectfile"), TestEnvironment::addPlatformArguments()};
ClangBackEnd::ProjectParts projects;
ClangBackEnd::UnsavedFiles unsavedFiles;
ClangBackEnd::Documents documents{projects, unsavedFiles};
Document functionDocument{Utf8StringLiteral(TESTDATA_DIR"/complete_extractor_function.cpp"), project, Utf8StringVector(), documents};
Document functionOverloadDocument{Utf8StringLiteral(TESTDATA_DIR"/complete_extractor_functionoverload.cpp"), project, Utf8StringVector(), documents};
Document variableDocument{Utf8StringLiteral(TESTDATA_DIR"/complete_extractor_variable.cpp"), project, Utf8StringVector(), documents};
Document classDocument{Utf8StringLiteral(TESTDATA_DIR"/complete_extractor_class.cpp"), project, Utf8StringVector(), documents};
Document namespaceDocument{Utf8StringLiteral(TESTDATA_DIR"/complete_extractor_namespace.cpp"), project, Utf8StringVector(), documents};
Document enumerationDocument{Utf8StringLiteral(TESTDATA_DIR"/complete_extractor_enumeration.cpp"), project, Utf8StringVector(), documents};
Document constructorDocument{Utf8StringLiteral(TESTDATA_DIR"/complete_extractor_constructor.cpp"), project, Utf8StringVector(), documents};
Document briefCommentDocument{Utf8StringLiteral(TESTDATA_DIR"/complete_extractor_brief_comment.cpp"), project, Utf8StringVector(), documents};
ClangBackEnd::Documents documents{unsavedFiles};
Utf8StringVector compilationArguments{TestEnvironment::addPlatformArguments()};
Document functionDocument{Utf8StringLiteral(TESTDATA_DIR"/complete_extractor_function.cpp"), compilationArguments, documents};
Document functionOverloadDocument{Utf8StringLiteral(TESTDATA_DIR"/complete_extractor_functionoverload.cpp"), compilationArguments, documents};
Document variableDocument{Utf8StringLiteral(TESTDATA_DIR"/complete_extractor_variable.cpp"), compilationArguments, documents};
Document classDocument{Utf8StringLiteral(TESTDATA_DIR"/complete_extractor_class.cpp"), compilationArguments, documents};
Document namespaceDocument{Utf8StringLiteral(TESTDATA_DIR"/complete_extractor_namespace.cpp"), compilationArguments, documents};
Document enumerationDocument{Utf8StringLiteral(TESTDATA_DIR"/complete_extractor_enumeration.cpp"), compilationArguments, documents};
Document constructorDocument{Utf8StringLiteral(TESTDATA_DIR"/complete_extractor_constructor.cpp"), compilationArguments, documents};
Document briefCommentDocument{Utf8StringLiteral(TESTDATA_DIR"/complete_extractor_brief_comment.cpp"), compilationArguments, documents};
};
using CodeCompletionsExtractorSlowTest = CodeCompletionsExtractor;
@@ -612,9 +608,12 @@ TEST_F(CodeCompletionsExtractorSlowTest, NotAvailableFunction)
TEST_F(CodeCompletionsExtractorSlowTest, UnsavedFile)
{
Document document(Utf8String::fromUtf8(TESTDATA_DIR"/complete_extractor_function.cpp"), project, Utf8StringVector(), documents);
unsavedFiles.createOrUpdate({unsavedDataFileContainer(TESTDATA_DIR"/complete_extractor_function.cpp",
TESTDATA_DIR"/complete_extractor_function_unsaved.cpp")});
Document document(Utf8String::fromUtf8(TESTDATA_DIR "/complete_extractor_function.cpp"),
compilationArguments,
documents);
unsavedFiles.createOrUpdate(
{unsavedDataFileContainer(TESTDATA_DIR "/complete_extractor_function.cpp",
TESTDATA_DIR "/complete_extractor_function_unsaved.cpp")});
ClangCodeCompleteResults completeResults(getResults(document, 20));
::CodeCompletionsExtractor extractor(
@@ -628,9 +627,12 @@ TEST_F(CodeCompletionsExtractorSlowTest, UnsavedFile)
TEST_F(CodeCompletionsExtractorSlowTest, ChangeUnsavedFile)
{
Document document(Utf8String::fromUtf8(TESTDATA_DIR"/complete_extractor_function.cpp"), project, Utf8StringVector(), documents);
unsavedFiles.createOrUpdate({unsavedDataFileContainer(TESTDATA_DIR"/complete_extractor_function.cpp",
TESTDATA_DIR"/complete_extractor_function_unsaved.cpp")});
Document document(Utf8String::fromUtf8(TESTDATA_DIR "/complete_extractor_function.cpp"),
compilationArguments,
documents);
unsavedFiles.createOrUpdate(
{unsavedDataFileContainer(TESTDATA_DIR "/complete_extractor_function.cpp",
TESTDATA_DIR "/complete_extractor_function_unsaved.cpp")});
ClangCodeCompleteResults completeResults(getResults(document, 20));
unsavedFiles.createOrUpdate({unsavedDataFileContainer(TESTDATA_DIR"/complete_extractor_function.cpp",
TESTDATA_DIR"/complete_extractor_function_unsaved_2.cpp")});
@@ -647,7 +649,10 @@ TEST_F(CodeCompletionsExtractorSlowTest, ChangeUnsavedFile)
TEST_F(CodeCompletionsExtractorSlowTest, ArgumentDefinition)
{
project.setArguments({Utf8StringLiteral("-DArgumentDefinition"), Utf8StringLiteral("-std=gnu++14")});
Document variableDocument{Utf8StringLiteral(TESTDATA_DIR "/complete_extractor_variable.cpp"),
{Utf8StringLiteral("-DArgumentDefinition"),
Utf8StringLiteral("-std=gnu++14")},
documents};
ClangCodeCompleteResults completeResults(getResults(variableDocument, 35));
::CodeCompletionsExtractor extractor(
@@ -661,7 +666,9 @@ TEST_F(CodeCompletionsExtractorSlowTest, ArgumentDefinition)
TEST_F(CodeCompletionsExtractorSlowTest, NoArgumentDefinition)
{
project.setArguments({Utf8StringLiteral("-std=gnu++14")});
Document variableDocument{Utf8StringLiteral(TESTDATA_DIR "/complete_extractor_variable.cpp"),
{Utf8StringLiteral("-std=gnu++14")},
documents};
ClangCodeCompleteResults completeResults(getResults(variableDocument, 35));
::CodeCompletionsExtractor extractor(

View File

@@ -32,8 +32,6 @@
#include <clangdocuments.h>
#include <clangstring.h>
#include <cursor.h>
#include <projectpart.h>
#include <projects.h>
#include <sourcelocation.h>
#include <sourcerange.h>
#include <clangtranslationunit.h>
@@ -43,7 +41,6 @@ using ClangBackEnd::Cursor;
using ClangBackEnd::Document;
using ClangBackEnd::TranslationUnit;
using ClangBackEnd::UnsavedFiles;
using ClangBackEnd::ProjectPart;
using ClangBackEnd::Documents;
using ClangBackEnd::ClangString;
using ClangBackEnd::SourceRange;
@@ -62,14 +59,11 @@ using testing::Eq;
namespace {
struct Data {
ClangBackEnd::ProjectParts projects;
ClangBackEnd::UnsavedFiles unsavedFiles;
ClangBackEnd::Documents documents{projects, unsavedFiles};
ClangBackEnd::Documents documents{unsavedFiles};
Utf8String filePath{Utf8StringLiteral(TESTDATA_DIR"/cursor.cpp")};
Document document{filePath,
ProjectPart(Utf8StringLiteral("projectPartId"),
TestEnvironment::addPlatformArguments({Utf8StringLiteral("-std=c++11")})),
{},
TestEnvironment::addPlatformArguments({Utf8StringLiteral("-std=c++11")}),
documents};
TranslationUnit translationUnit{filePath,
filePath,

View File

@@ -32,11 +32,9 @@
#include <diagnosticcontainer.h>
#include <diagnosticset.h>
#include <fixitcontainer.h>
#include <projectpart.h>
#include <clangdocument.h>
#include <clangdocuments.h>
#include <clangtranslationunit.h>
#include <projects.h>
#include <unsavedfiles.h>
#include <sourcelocation.h>
#include <sourcerange.h>
@@ -52,7 +50,6 @@ using ClangBackEnd::DiagnosticSet;
using ClangBackEnd::DiagnosticContainer;
using ClangBackEnd::Document;
using ClangBackEnd::Documents;
using ClangBackEnd::ProjectPart;
using ClangBackEnd::UnsavedFiles;
using ClangBackEnd::Diagnostic;
using ClangBackEnd::SourceLocation;
@@ -87,14 +84,10 @@ protected:
DiagnosticContainer expectedDiagnostic(ChildMode childMode) const;
protected:
ProjectPart projectPart{Utf8StringLiteral("projectPartId"),
TestEnvironment::addPlatformArguments({Utf8StringLiteral("-std=c++11")})};
ClangBackEnd::ProjectParts projects;
ClangBackEnd::UnsavedFiles unsavedFiles;
ClangBackEnd::Documents documents{projects, unsavedFiles};
ClangBackEnd::Documents documents{unsavedFiles};
Document document{Utf8StringLiteral(TESTDATA_DIR"/diagnostic_diagnostic.cpp"),
projectPart,
Utf8StringVector(),
TestEnvironment::addPlatformArguments({Utf8StringLiteral("-std=c++11")}),
documents};
UnitTest::RunDocumentParse _1{document};
DiagnosticSet diagnosticSet{document.translationUnit().diagnostics()};

View File

@@ -32,8 +32,6 @@
#include <diagnosticcontainer.h>
#include <diagnosticset.h>
#include <fixitcontainer.h>
#include <projectpart.h>
#include <projects.h>
#include <sourcelocation.h>
#include <sourcelocationcontainer.h>
#include <sourcerangecontainer.h>
@@ -51,7 +49,6 @@ using ::ClangBackEnd::Diagnostic;
using ::ClangBackEnd::DiagnosticSet;
using ::ClangBackEnd::DiagnosticContainer;
using ::ClangBackEnd::FixItContainer;
using ::ClangBackEnd::ProjectPart;
using ::ClangBackEnd::SourceLocation;
using ::ClangBackEnd::SourceLocationContainer;
using ::ClangBackEnd::Document;
@@ -64,18 +61,15 @@ const Utf8String headerFilePath = Utf8StringLiteral(TESTDATA_DIR"/diagnostic_dia
class DiagnosticSet : public ::testing::Test
{
protected:
ProjectPart projectPart{Utf8StringLiteral("projectPartId"),
TestEnvironment::addPlatformArguments({Utf8StringLiteral("-pedantic")})};
ClangBackEnd::ProjectParts projects;
ClangBackEnd::UnsavedFiles unsavedFiles;
ClangBackEnd::Documents documents{projects, unsavedFiles};
Document document{Utf8StringLiteral(TESTDATA_DIR"/diagnostic_diagnosticset.cpp"),
projectPart,
Utf8StringVector(),
ClangBackEnd::Documents documents{unsavedFiles};
Utf8StringVector compilationArguments{
TestEnvironment::addPlatformArguments({Utf8StringLiteral("-pedantic")})};
Document document{Utf8StringLiteral(TESTDATA_DIR "/diagnostic_diagnosticset.cpp"),
compilationArguments,
documents};
Document documentMainFile{Utf8StringLiteral(TESTDATA_DIR"/diagnostic_diagnosticset_mainfile.cpp"),
projectPart,
Utf8StringVector(),
compilationArguments,
documents};
protected:

View File

@@ -28,8 +28,6 @@
#include <diagnostic.h>
#include <diagnosticset.h>
#include <projectpart.h>
#include <projects.h>
#include <clangdocument.h>
#include <clangdocuments.h>
#include <clangtranslationunit.h>
@@ -43,7 +41,6 @@
using ClangBackEnd::DiagnosticSet;
using ClangBackEnd::Document;
using ClangBackEnd::TranslationUnit;
using ClangBackEnd::ProjectPart;
using ClangBackEnd::UnsavedFiles;
using ClangBackEnd::Diagnostic;
using ClangBackEnd::FixIt;
@@ -70,12 +67,9 @@ MATCHER_P4(IsSourceLocation, filePath, line, column, offset,
struct Data
{
ProjectPart projectPart{Utf8StringLiteral("projectPartId")};
ClangBackEnd::ProjectParts projects;
ClangBackEnd::UnsavedFiles unsavedFiles;
ClangBackEnd::Documents documents{projects, unsavedFiles};
ClangBackEnd::Documents documents{unsavedFiles};
Document document{Utf8StringLiteral(TESTDATA_DIR"/diagnostic_semicolon_fixit.cpp"),
projectPart,
Utf8StringVector(),
documents};
UnitTest::RunDocumentParse _1{document};

View File

@@ -237,15 +237,6 @@ std::ostream &operator<<(std::ostream &os, const SourceLocationsContainer &conta
return os;
}
std::ostream &operator<<(std::ostream &os, const ProjectPartsUpdatedMessage &message)
{
os << "("
<< message.projectContainers
<< ")";
return os;
}
std::ostream &operator<<(std::ostream &os, const FollowSymbolResult &result)
{
os << "("
@@ -360,15 +351,6 @@ std::ostream &operator<<(std::ostream &os, const EchoMessage &/*message*/)
return os << "()";
}
std::ostream &operator<<(std::ostream &os, const ProjectPartsRemovedMessage &message)
{
os << "("
<< message.projectPartIds
<< ")";
return os;
}
std::ostream &operator<<(std::ostream &os, const DocumentsClosedMessage &message)
{
os << "("
@@ -469,8 +451,7 @@ std::ostream &operator<<(std::ostream &os, const FileContainer &container)
{
os << "("
<< container.filePath << ", "
<< container.projectPartId << ", "
<< container.fileArguments << ", "
<< container.compilationArguments << ", "
<< container.documentRevision << ", "
<< container.textCodecName;
@@ -606,17 +587,6 @@ std::ostream &operator<<(std::ostream &out, const PrecompiledHeadersUpdatedMessa
return out;
}
std::ostream &operator<<(std::ostream &os, const ProjectPartContainer &container)
{
os << "("
<< container.projectPartId
<< ","
<< container.arguments
<< ")";
return os;
}
std::ostream &operator<<(std::ostream &out, const ProjectPartPch &projectPartPch)
{
out << "("
@@ -640,7 +610,6 @@ std::ostream &operator<<(std::ostream &os, const RequestAnnotationsMessage &mess
{
os << "("
<< message.fileContainer.filePath << ","
<< message.fileContainer.projectPartId
<< ")";
return os;

View File

@@ -99,7 +99,6 @@ class FilePathId;
class FilePath;
class WatcherEntry;
class SourceLocationsContainer;
class ProjectPartsUpdatedMessage;
class CancelMessage;
class AliveMessage;
class CompletionsMessage;
@@ -112,7 +111,6 @@ class FollowSymbolMessage;
class RequestCompletionsMessage;
class EndMessage;
class DocumentsOpenedMessage;
class ProjectPartsRemovedMessage;
class DocumentsClosedMessage;
class CodeCompletion;
class CodeCompletionChunk;
@@ -126,7 +124,6 @@ class FullTokenInfo;
class HighlightingMarkContainer;
class NativeFilePath;
class PrecompiledHeadersUpdatedMessage;
class ProjectPartContainer;
class ProjectPartPch;
class UnsavedFilesUpdatedMessage;
class RemoveProjectPartsMessage;
@@ -177,7 +174,6 @@ std::ostream &operator<<(std::ostream &out, const SourceLocationEntry &entry);
std::ostream &operator<<(std::ostream &out, const IdPaths &idPaths);
std::ostream &operator<<(std::ostream &out, const WatcherEntry &entry);
std::ostream &operator<<(std::ostream &out, const SourceLocationsContainer &container);
std::ostream &operator<<(std::ostream &out, const ProjectPartsUpdatedMessage &message);
std::ostream &operator<<(std::ostream &out, const CancelMessage &message);
std::ostream &operator<<(std::ostream &out, const AliveMessage &message);
std::ostream &operator<<(std::ostream &out, const CompletionsMessage &message);
@@ -190,7 +186,6 @@ std::ostream &operator<<(std::ostream &out, const FollowSymbolMessage &message);
std::ostream &operator<<(std::ostream &out, const RequestCompletionsMessage &message);
std::ostream &operator<<(std::ostream &out, const EndMessage &message);
std::ostream &operator<<(std::ostream &out, const DocumentsOpenedMessage &message);
std::ostream &operator<<(std::ostream &out, const ProjectPartsRemovedMessage &message);
std::ostream &operator<<(std::ostream &out, const DocumentsClosedMessage &message);
std::ostream &operator<<(std::ostream &out, const CodeCompletion &message);
std::ostream &operator<<(std::ostream &out, const CodeCompletionChunk &chunk);
@@ -205,7 +200,6 @@ std::ostream &operator<<(std::ostream &out, HighlightingTypes types);
std::ostream &operator<<(std::ostream &out, const HighlightingMarkContainer &container);
std::ostream &operator<<(std::ostream &out, const NativeFilePath &filePath);
std::ostream &operator<<(std::ostream &out, const PrecompiledHeadersUpdatedMessage &message);
std::ostream &operator<<(std::ostream &out, const ProjectPartContainer &container);
std::ostream &operator<<(std::ostream &out, const ProjectPartPch &projectPartPch);
std::ostream &operator<<(std::ostream &out, const UnsavedFilesUpdatedMessage &message);
std::ostream &operator<<(std::ostream &out, const RemoveProjectPartsMessage &message);

View File

@@ -33,8 +33,6 @@
#include <tokeninfocontainer.h>
#include <tokenprocessor.h>
#include <clanghighlightingresultreporter.h>
#include <projectpart.h>
#include <projects.h>
#include <unsavedfiles.h>
using ClangBackEnd::Cursor;
@@ -44,20 +42,15 @@ using ClangBackEnd::HighlightingType;
using ClangBackEnd::Document;
using ClangBackEnd::Documents;
using ClangBackEnd::UnsavedFiles;
using ClangBackEnd::ProjectPart;
using ClangBackEnd::ProjectParts;
using ClangBackEnd::ChunksReportedMonitor;
namespace {
struct Data {
ProjectParts projects;
UnsavedFiles unsavedFiles;
Documents documents{projects, unsavedFiles};
Document document{Utf8StringLiteral(TESTDATA_DIR"/highlightingmarks.cpp"),
ProjectPart(Utf8StringLiteral("projectPartId"),
TestEnvironment::addPlatformArguments({Utf8StringLiteral("-std=c++14")})),
{},
Documents documents{unsavedFiles};
Document document{Utf8StringLiteral(TESTDATA_DIR "/highlightingmarks.cpp"),
TestEnvironment::addPlatformArguments({Utf8StringLiteral("-std=c++14")}),
documents};
};

View File

@@ -43,11 +43,6 @@ public:
MOCK_METHOD1(documentVisibilityChanged,
void(const ClangBackEnd::DocumentVisibilityChangedMessage &message));
MOCK_METHOD1(projectPartsUpdated,
void(const ClangBackEnd::ProjectPartsUpdatedMessage &message));
MOCK_METHOD1(projectPartsRemoved,
void(const ClangBackEnd::ProjectPartsRemovedMessage &message));
MOCK_METHOD1(unsavedFilesUpdated,
void(const ClangBackEnd::UnsavedFilesUpdatedMessage &message));
MOCK_METHOD1(unsavedFilesRemoved,

View File

@@ -1,193 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3 as published by the Free Software
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
**
****************************************************************************/
#include "googletest.h"
#include <clangclock.h>
#include <projectpart.h>
#include <clangexceptions.h>
#include <projects.h>
#include <utf8stringvector.h>
#include <thread>
using testing::ElementsAre;
using testing::Pointwise;
using testing::Contains;
using testing::Gt;
using testing::Not;
namespace {
TEST(ProjectPart, CreateProjectPart)
{
Utf8String projectPath(Utf8StringLiteral("/tmp/blah.pro"));
ClangBackEnd::ProjectPart project(projectPath);
ASSERT_THAT(project.id(), projectPath);
}
TEST(ProjectPart, CreateProjectPartWithProjectPartContainer)
{
ClangBackEnd::ProjectPartContainer projectContainer(Utf8StringLiteral("pathToProjectPart.pro"), {Utf8StringLiteral("-O")});
ClangBackEnd::ProjectPart project(projectContainer);
ASSERT_THAT(project.id(), Utf8StringLiteral("pathToProjectPart.pro"));
ASSERT_THAT(project.arguments(), Contains(Utf8StringLiteral("-O")));
}
TEST(ProjectPart, SetArguments)
{
ClangBackEnd::ProjectPart project(Utf8StringLiteral("/tmp/blah.pro"));
project.setArguments(Utf8StringVector({Utf8StringLiteral("-O"), Utf8StringLiteral("-fast")}));
ASSERT_THAT(project.arguments(), ElementsAre(Utf8StringLiteral("-O"), Utf8StringLiteral("-fast")));
}
TEST(ProjectPart, ArgumentCount)
{
ClangBackEnd::ProjectPart project(Utf8StringLiteral("/tmp/blah.pro"));
project.setArguments(Utf8StringVector({Utf8StringLiteral("-O"), Utf8StringLiteral("-fast")}));
ASSERT_THAT(project.arguments().count(), 2);
}
TEST(ProjectPart, TimeStampIsUpdatedAsArgumentChanged)
{
ClangBackEnd::ProjectPart project(Utf8StringLiteral("/tmp/blah.pro"));
auto lastChangeTimePoint = project.lastChangeTimePoint();
std::this_thread::sleep_for(ClangBackEnd::Duration(1));
project.setArguments(Utf8StringVector({Utf8StringLiteral("-O"), Utf8StringLiteral("-fast")}));
ASSERT_THAT(project.lastChangeTimePoint(), Gt(lastChangeTimePoint));
}
TEST(ProjectPart, GetNonExistingPoject)
{
ClangBackEnd::ProjectParts projects;
ASSERT_THROW(projects.project(Utf8StringLiteral("pathToProjectPart.pro")), ClangBackEnd::ProjectPartDoNotExistException);
}
TEST(ProjectPart, AddProjectParts)
{
ClangBackEnd::ProjectPartContainer projectContainer(Utf8StringLiteral("pathToProjectPart.pro"), {Utf8StringLiteral("-O")});
ClangBackEnd::ProjectParts projects;
projects.createOrUpdate({projectContainer});
ASSERT_THAT(projects.project(projectContainer.projectPartId), ClangBackEnd::ProjectPart(projectContainer));
ASSERT_THAT(projects.project(projectContainer.projectPartId).arguments(), ElementsAre(Utf8StringLiteral("-O")));
}
TEST(ProjectPart, UpdateProjectParts)
{
ClangBackEnd::ProjectPartContainer projectContainer(Utf8StringLiteral("pathToProjectPart.pro"), {Utf8StringLiteral("-O")});
ClangBackEnd::ProjectPartContainer projectContainerWithNewArguments(Utf8StringLiteral("pathToProjectPart.pro"), {Utf8StringLiteral("-fast")});
ClangBackEnd::ProjectParts projects;
projects.createOrUpdate({projectContainer});
projects.createOrUpdate({projectContainerWithNewArguments});
ASSERT_THAT(projects.project(projectContainer.projectPartId), ClangBackEnd::ProjectPart(projectContainer));
ASSERT_THAT(projects.project(projectContainer.projectPartId).arguments(), ElementsAre(Utf8StringLiteral("-fast")));
}
TEST(ProjectPart, ThrowExceptionForAccesingRemovedProjectParts)
{
ClangBackEnd::ProjectPartContainer projectContainer(Utf8StringLiteral("pathToProjectPart.pro"), {Utf8StringLiteral("-O")});
ClangBackEnd::ProjectParts projects;
projects.createOrUpdate({projectContainer});
projects.remove({projectContainer.projectPartId});
ASSERT_THROW(projects.project(projectContainer.projectPartId), ClangBackEnd::ProjectPartDoNotExistException);
}
TEST(ProjectPart, ProjectPartProjectPartIdIsEmptyfterRemoving)
{
ClangBackEnd::ProjectPartContainer projectContainer(Utf8StringLiteral("pathToProjectPart.pro"), {Utf8StringLiteral("-O")});
ClangBackEnd::ProjectParts projects;
projects.createOrUpdate({projectContainer});
ClangBackEnd::ProjectPart project(projects.project(projectContainer.projectPartId));
projects.remove({projectContainer.projectPartId});
ASSERT_TRUE(project.id().isEmpty());
}
TEST(ProjectPart, ThrowsForNotExistingProjectPartButRemovesAllExistingProject)
{
ClangBackEnd::ProjectPartContainer projectContainer(Utf8StringLiteral("pathToProjectPart.pro"));
ClangBackEnd::ProjectParts projects;
projects.createOrUpdate({projectContainer});
ClangBackEnd::ProjectPart project = *projects.findProjectPart(Utf8StringLiteral("pathToProjectPart.pro"));
EXPECT_THROW(projects.remove({Utf8StringLiteral("doesnotexist.pro"), projectContainer.projectPartId}), ClangBackEnd::ProjectPartDoNotExistException);
ASSERT_THAT(projects.projects(), Not(Contains(project)));
}
TEST(ProjectPart, ProjectPartIsClearedAfterRemove)
{
ClangBackEnd::ProjectPartContainer projectContainer(Utf8StringLiteral("pathToProjectPart.pro"));
ClangBackEnd::ProjectParts projects;
projects.createOrUpdate({projectContainer});
ClangBackEnd::ProjectPart project = *projects.findProjectPart(projectContainer.projectPartId);
const auto lastChangeTimePoint = project.lastChangeTimePoint();
std::this_thread::sleep_for(ClangBackEnd::Duration(1));
projects.remove({projectContainer.projectPartId});
ASSERT_THAT(project.id(), Utf8String());
ASSERT_THAT(project.arguments().count(), 0);
ASSERT_THAT(project.lastChangeTimePoint(), Gt(lastChangeTimePoint));
}
TEST(ProjectPart, HasProjectPart)
{
ClangBackEnd::ProjectPartContainer projectContainer(Utf8StringLiteral("pathToProjectPart.pro"));
ClangBackEnd::ProjectParts projects;
projects.createOrUpdate({projectContainer});
ASSERT_TRUE(projects.hasProjectPart(projectContainer.projectPartId));
}
TEST(ProjectPart, DoNotHasProjectPart)
{
ClangBackEnd::ProjectPartContainer projectContainer(Utf8StringLiteral("pathToProjectPart.pro"));
ClangBackEnd::ProjectParts projects;
projects.createOrUpdate({projectContainer});
ASSERT_FALSE(projects.hasProjectPart(Utf8StringLiteral("doesnotexist.pro")));
}
}

View File

@@ -62,7 +62,6 @@ protected:
protected:
Utf8String filePath{Utf8StringLiteral("foo.cpp")};
ClangBackEnd::FileContainer fileContainer{filePath,
Utf8StringLiteral("projectPartId"),
Utf8StringLiteral("unsaved content"),
true,
1};
@@ -207,7 +206,7 @@ TEST_F(ReadAndWriteMessageBlock, CompareDocumentsClosedMessage)
TEST_F(ReadAndWriteMessageBlock, CompareRequestCompletionsMessage)
{
CompareMessage(ClangBackEnd::RequestCompletionsMessage(Utf8StringLiteral("foo.cpp"), 24, 33, Utf8StringLiteral("do what I want")));
CompareMessage(ClangBackEnd::RequestCompletionsMessage(Utf8StringLiteral("foo.cpp"), 24, 33));
}
TEST_F(ReadAndWriteMessageBlock, CompareCompletionsMessage)

View File

@@ -1,41 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2017 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3 as published by the Free Software
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
**
****************************************************************************/
#pragma once
#include <projects.h>
namespace UnitTest {
struct RunProjectCreateOrUpdate
{
RunProjectCreateOrUpdate(ClangBackEnd::ProjectParts &projects,
const QVector<ClangBackEnd::ProjectPartContainer> &projectContainers)
{
projects.createOrUpdate(projectContainers);
}
};
} // namespace UnitTest

View File

@@ -31,8 +31,6 @@
#include <clangdocuments.h>
#include <clangstring.h>
#include <clangtranslationunit.h>
#include <projectpart.h>
#include <projects.h>
#include <skippedsourceranges.h>
#include <sourcelocation.h>
#include <sourcerange.h>
@@ -47,7 +45,6 @@ using ClangBackEnd::Document;
using ClangBackEnd::Documents;
using ClangBackEnd::TranslationUnit;
using ClangBackEnd::UnsavedFiles;
using ClangBackEnd::ProjectPart;
using ClangBackEnd::ClangString;
using ClangBackEnd::SourceRange;
using ClangBackEnd::SkippedSourceRanges;
@@ -89,16 +86,12 @@ struct Data {
document.parse();
}
ClangBackEnd::ProjectParts projects;
ClangBackEnd::UnsavedFiles unsavedFiles;
ClangBackEnd::Documents documents{projects, unsavedFiles};
ClangBackEnd::Documents documents{unsavedFiles};
Utf8String filePath = Utf8StringLiteral(TESTDATA_DIR"/skippedsourceranges.cpp");
Document document{filePath,
ProjectPart(Utf8StringLiteral("projectPartId"),
TestEnvironment::addPlatformArguments({Utf8StringLiteral("-std=c++11"),
Utf8StringLiteral("-DBLAH")})),
{},
documents};
Utf8StringVector compilationArguments{TestEnvironment::addPlatformArguments(
{Utf8StringLiteral("-std=c++11"), Utf8StringLiteral("-DBLAH")})};
Document document{filePath, compilationArguments, documents};
TranslationUnit translationUnit{filePath,
filePath,
document.translationUnit().cxIndex(),

View File

@@ -28,8 +28,6 @@
#include <diagnostic.h>
#include <diagnosticset.h>
#include <projectpart.h>
#include <projects.h>
#include <clangdocument.h>
#include <clangdocuments.h>
#include <clangtranslationunit.h>
@@ -40,7 +38,6 @@
using ClangBackEnd::Diagnostic;
using ClangBackEnd::DiagnosticSet;
using ClangBackEnd::ProjectPart;
using ClangBackEnd::SourceLocation;
using ClangBackEnd::Document;
using ClangBackEnd::UnsavedFiles;
@@ -51,12 +48,9 @@ using testing::Not;
namespace {
struct Data {
ProjectPart projectPart{Utf8StringLiteral("projectPartId")};
ClangBackEnd::ProjectParts projects;
ClangBackEnd::UnsavedFiles unsavedFiles;
ClangBackEnd::Documents documents{projects, unsavedFiles};
ClangBackEnd::Documents documents{unsavedFiles};
Document document{Utf8StringLiteral(TESTDATA_DIR"/diagnostic_source_location.cpp"),
projectPart,
Utf8StringVector(),
documents};
UnitTest::RunDocumentParse _1{document};

View File

@@ -30,10 +30,8 @@
#include <clangtranslationunit.h>
#include <diagnostic.h>
#include <diagnosticset.h>
#include <projectpart.h>
#include <clangdocument.h>
#include <clangdocuments.h>
#include <projects.h>
#include <unsavedfiles.h>
#include <sourcerange.h>
@@ -45,7 +43,6 @@ using ClangBackEnd::DiagnosticSet;
using ClangBackEnd::Document;
using ClangBackEnd::Documents;
using ClangBackEnd::TranslationUnit;
using ClangBackEnd::ProjectPart;
using ClangBackEnd::UnsavedFiles;
using ClangBackEnd::Diagnostic;
using ClangBackEnd::SourceRange;
@@ -74,15 +71,11 @@ MATCHER_P4(IsSourceLocation, filePath, line, column, offset,
}
struct Data {
ProjectPart projectPart{Utf8StringLiteral("projectPartId"),
TestEnvironment::addPlatformArguments({Utf8StringLiteral("-pedantic")})};
ClangBackEnd::ProjectParts projects;
ClangBackEnd::UnsavedFiles unsavedFiles;
ClangBackEnd::Documents documents{projects, unsavedFiles};
ClangBackEnd::Documents documents{unsavedFiles};
Utf8String filePath{Utf8StringLiteral(TESTDATA_DIR"/diagnostic_source_range.cpp")};
Document document{filePath,
projectPart,
Utf8StringVector(),
{TestEnvironment::addPlatformArguments({Utf8StringLiteral("-pedantic")})},
documents};
UnitTest::RunDocumentParse _1{document};
TranslationUnit translationUnit{filePath,

View File

@@ -33,8 +33,6 @@
#include <clangsupport_global.h>
#include <clangstring.h>
#include <fulltokeninfo.h>
#include <projectpart.h>
#include <projects.h>
#include <sourcelocation.h>
#include <sourcerange.h>
#include <tokeninfo.h>
@@ -52,7 +50,6 @@ using ClangBackEnd::Document;
using ClangBackEnd::Documents;
using ClangBackEnd::TranslationUnit;
using ClangBackEnd::UnsavedFiles;
using ClangBackEnd::ProjectPart;
using ClangBackEnd::ClangString;
using ClangBackEnd::SourceRange;
@@ -127,15 +124,13 @@ struct Data {
document.parse();
}
ClangBackEnd::ProjectParts projects;
ClangBackEnd::UnsavedFiles unsavedFiles;
ClangBackEnd::Documents documents{projects, unsavedFiles};
ClangBackEnd::Documents documents{unsavedFiles};
Utf8String filePath{Utf8StringLiteral(TESTDATA_DIR"/highlightingmarks.cpp")};
Document document{filePath,
ProjectPart(Utf8StringLiteral("projectPartId"),
TestEnvironment::addPlatformArguments({Utf8StringLiteral("-std=c++14"),
Utf8StringLiteral("-I" TESTDATA_DIR)})),
{},
TestEnvironment::addPlatformArguments(
{Utf8StringLiteral("-std=c++14"),
Utf8StringLiteral("-I" TESTDATA_DIR)}),
documents};
TranslationUnit translationUnit{filePath,
filePath,

Some files were not shown because too many files have changed in this diff Show More