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 DocumentsOpenedMessage;
class EchoMessage; class EchoMessage;
class FollowSymbolMessage; class FollowSymbolMessage;
class ProjectPartsRemovedMessage;
class ProjectPartsUpdatedMessage;
class ReferencesMessage; class ReferencesMessage;
class RequestAnnotationsMessage; class RequestAnnotationsMessage;
class RequestCompletionsMessage; class RequestCompletionsMessage;

View File

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

View File

@@ -47,9 +47,6 @@ public:
virtual void documentsClosed(const DocumentsClosedMessage &message) = 0; virtual void documentsClosed(const DocumentsClosedMessage &message) = 0;
virtual void documentVisibilityChanged(const DocumentVisibilityChangedMessage &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 unsavedFilesUpdated(const UnsavedFilesUpdatedMessage &message) = 0;
virtual void unsavedFilesRemoved(const UnsavedFilesRemovedMessage &message) = 0; virtual void unsavedFilesRemoved(const UnsavedFilesRemovedMessage &message) = 0;

View File

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

View File

@@ -57,16 +57,6 @@ void ClangCodeModelServerProxy::documentsClosed(const DocumentsClosedMessage &me
m_writeMessageBlock.write(message); 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) void ClangCodeModelServerProxy::unsavedFilesUpdated(const UnsavedFilesUpdatedMessage &message)
{ {
m_writeMessageBlock.write(message); m_writeMessageBlock.write(message);

View File

@@ -55,9 +55,6 @@ public:
void documentsClosed(const DocumentsClosedMessage &message) override; void documentsClosed(const DocumentsClosedMessage &message) override;
void documentVisibilityChanged(const DocumentVisibilityChangedMessage &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 unsavedFilesUpdated(const UnsavedFilesUpdatedMessage &message) override;
void unsavedFilesRemoved(const UnsavedFilesRemovedMessage &message) override; void unsavedFilesRemoved(const UnsavedFilesRemovedMessage &message) override;

View File

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

View File

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

View File

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

View File

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

View File

@@ -50,12 +50,6 @@ QDebug operator<<(QDebug debug, const MessageEnvelop &messageEnvelop)
case MessageType::DocumentVisibilityChangedMessage: case MessageType::DocumentVisibilityChangedMessage:
qDebug() << messageEnvelop.message<DocumentVisibilityChangedMessage>(); qDebug() << messageEnvelop.message<DocumentVisibilityChangedMessage>();
break; break;
case MessageType::ProjectPartsUpdatedMessage:
qDebug() << messageEnvelop.message<ProjectPartsUpdatedMessage>();
break;
case MessageType::ProjectPartsRemovedMessage:
qDebug() << messageEnvelop.message<ProjectPartsRemovedMessage>();
break;
case MessageType::UnsavedFilesUpdatedMessage: case MessageType::UnsavedFilesUpdatedMessage:
qDebug() << messageEnvelop.message<UnsavedFilesUpdatedMessage>(); qDebug() << messageEnvelop.message<UnsavedFilesUpdatedMessage>();
break; 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, RequestCompletionsMessage(const Utf8String &filePath,
quint32 line, quint32 line,
quint32 column, quint32 column,
const Utf8String &projectPartId,
qint32 funcNameStartLine = -1, qint32 funcNameStartLine = -1,
qint32 funcNameStartColumn = -1) qint32 funcNameStartColumn = -1)
: filePath(filePath) : filePath(filePath)
, projectPartId(projectPartId)
, ticketNumber(++ticketCounter) , ticketNumber(++ticketCounter)
, line(line) , line(line)
, column(column) , column(column)
@@ -56,7 +54,6 @@ public:
friend QDataStream &operator<<(QDataStream &out, const RequestCompletionsMessage &message) friend QDataStream &operator<<(QDataStream &out, const RequestCompletionsMessage &message)
{ {
out << message.filePath; out << message.filePath;
out << message.projectPartId;
out << message.ticketNumber; out << message.ticketNumber;
out << message.line; out << message.line;
out << message.column; out << message.column;
@@ -69,7 +66,6 @@ public:
friend QDataStream &operator>>(QDataStream &in, RequestCompletionsMessage &message) friend QDataStream &operator>>(QDataStream &in, RequestCompletionsMessage &message)
{ {
in >> message.filePath; in >> message.filePath;
in >> message.projectPartId;
in >> message.ticketNumber; in >> message.ticketNumber;
in >> message.line; in >> message.line;
in >> message.column; in >> message.column;
@@ -84,7 +80,6 @@ public:
{ {
return first.ticketNumber == second.ticketNumber return first.ticketNumber == second.ticketNumber
&& first.filePath == second.filePath && first.filePath == second.filePath
&& first.projectPartId == second.projectPartId
&& first.line == second.line && first.line == second.line
&& first.column == second.column && first.column == second.column
&& first.funcNameStartLine == second.funcNameStartLine && first.funcNameStartLine == second.funcNameStartLine

View File

@@ -80,9 +80,6 @@ public:
void documentsClosed(const DocumentsClosedMessage &) override {} void documentsClosed(const DocumentsClosedMessage &) override {}
void documentVisibilityChanged(const DocumentVisibilityChangedMessage &) override {} void documentVisibilityChanged(const DocumentVisibilityChangedMessage &) override {}
void projectPartsUpdated(const ProjectPartsUpdatedMessage &) override {}
void projectPartsRemoved(const ProjectPartsRemovedMessage &) override {}
void unsavedFilesUpdated(const UnsavedFilesUpdatedMessage &) override {} void unsavedFilesUpdated(const UnsavedFilesUpdatedMessage &) override {}
void unsavedFilesRemoved(const UnsavedFilesRemovedMessage &) override {} void unsavedFilesRemoved(const UnsavedFilesRemovedMessage &) override {}
@@ -137,42 +134,6 @@ void BackendCommunicator::initializeBackend()
m_backendStartTimeOut.start(backEndStartTimeOutInMs); 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 { namespace {
Utf8String currentCppEditorDocumentFilePath() Utf8String currentCppEditorDocumentFilePath()
{ {
@@ -253,15 +214,6 @@ void BackendCommunicator::documentVisibilityChanged(const Utf8String &currentEdi
m_sender->documentVisibilityChanged(message); 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() void BackendCommunicator::restoreCppEditorDocuments()
{ {
resetCppEditorDocumentProcessors(); 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) void BackendCommunicator::documentsChangedFromCppEditorDocument(const QString &filePath)
{ {
const CppTools::CppEditorDocumentHandle *document = ClangCodeModel::Utils::cppDocument(filePath); const CppTools::CppEditorDocumentHandle *document = ClangCodeModel::Utils::cppDocument(filePath);
@@ -316,7 +262,6 @@ void BackendCommunicator::documentsChanged(const QString &filePath,
const bool hasUnsavedContent = true; const bool hasUnsavedContent = true;
documentsChanged({{filePath, documentsChanged({{filePath,
Utf8String(),
Utf8String::fromByteArray(contents), Utf8String::fromByteArray(contents),
hasUnsavedContent, hasUnsavedContent,
documentRevision}}); documentRevision}});
@@ -330,7 +275,6 @@ void BackendCommunicator::unsavedFilesUpdated(const QString &filePath,
// TODO: Send new only if changed // TODO: Send new only if changed
unsavedFilesUpdated({{filePath, unsavedFilesUpdated({{filePath,
Utf8String(),
Utf8String::fromByteArray(contents), Utf8String::fromByteArray(contents),
hasUnsavedContent, hasUnsavedContent,
documentRevision}}); documentRevision}});
@@ -412,10 +356,8 @@ void BackendCommunicator::documentsChangedWithRevisionCheck(Core::IDocument *doc
{ {
const auto textDocument = qobject_cast<TextDocument*>(document); const auto textDocument = qobject_cast<TextDocument*>(document);
const auto filePath = textDocument->filePath().toString(); const auto filePath = textDocument->filePath().toString();
const QString projectPartId = CppTools::CppToolsBridge::projectPartIdForFile(filePath);
documentsChangedWithRevisionCheck(FileContainer(filePath, documentsChangedWithRevisionCheck(FileContainer(filePath,
projectPartId,
Utf8StringVector(), Utf8StringVector(),
textDocument->document()->revision())); textDocument->document()->revision()));
} }
@@ -510,8 +452,6 @@ void BackendCommunicator::logError(const QString &text)
void BackendCommunicator::initializeBackendWithCurrentData() void BackendCommunicator::initializeBackendWithCurrentData()
{ {
projectPartsUpdatedForFallback();
projectPartsUpdatedForCurrentProjects();
unsavedFilesUpdatedForUiHeaders(); unsavedFilesUpdatedForUiHeaders();
restoreCppEditorDocuments(); restoreCppEditorDocuments();
documentVisibilityChanged(); documentVisibilityChanged();
@@ -537,19 +477,6 @@ void BackendCommunicator::documentsClosed(const FileContainers &fileContainers)
m_sender->documentsClosed(message); 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) void BackendCommunicator::unsavedFilesUpdated(const FileContainers &fileContainers)
{ {
const UnsavedFilesUpdatedMessage message(fileContainers); const UnsavedFilesUpdatedMessage message(fileContainers);
@@ -566,14 +493,12 @@ void BackendCommunicator::requestCompletions(ClangCompletionAssistProcessor *ass
const QString &filePath, const QString &filePath,
quint32 line, quint32 line,
quint32 column, quint32 column,
const QString &projectFilePath,
qint32 funcNameStartLine, qint32 funcNameStartLine,
qint32 funcNameStartColumn) qint32 funcNameStartColumn)
{ {
const RequestCompletionsMessage message(filePath, const RequestCompletionsMessage message(filePath,
line, line,
column, column,
projectFilePath,
funcNameStartLine, funcNameStartLine,
funcNameStartColumn); funcNameStartColumn);
m_sender->requestCompletions(message); m_sender->requestCompletions(message);

View File

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

View File

@@ -199,16 +199,9 @@ void BackendReceiver::annotations(const AnnotationsMessage &message)
<< message.skippedPreprocessorRanges.size() << "skipped preprocessor ranges"; << message.skippedPreprocessorRanges.size() << "skipped preprocessor ranges";
auto processor = ClangEditorDocumentProcessor::get(message.fileContainer.filePath); auto processor = ClangEditorDocumentProcessor::get(message.fileContainer.filePath);
if (!processor) if (!processor)
return; 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; const quint32 documentRevision = message.fileContainer.documentRevision;
if (message.onlyTokenInfos) { if (message.onlyTokenInfos) {
processor->updateTokenInfos(message.tokenInfos, documentRevision); processor->updateTokenInfos(message.tokenInfos, documentRevision);

View File

@@ -71,20 +71,6 @@ void BackendSender::documentsClosed(const DocumentsClosedMessage &message)
m_connection->serverProxy().documentsClosed(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) void BackendSender::unsavedFilesUpdated(const UnsavedFilesUpdatedMessage &message)
{ {
QTC_CHECK(m_connection->isConnected()); QTC_CHECK(m_connection->isConnected());

View File

@@ -44,9 +44,6 @@ public:
void documentsClosed(const ClangBackEnd::DocumentsClosedMessage &message) override; void documentsClosed(const ClangBackEnd::DocumentsClosedMessage &message) override;
void documentVisibilityChanged(const ClangBackEnd::DocumentVisibilityChangedMessage &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 unsavedFilesUpdated(const ClangBackEnd::UnsavedFilesUpdatedMessage &message) override;
void unsavedFilesRemoved(const ClangBackEnd::UnsavedFilesRemovedMessage &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(); BackendCommunicator &communicator = m_interface->communicator();
communicator.documentsChanged({{m_interface->fileName(), communicator.documentsChanged({{m_interface->fileName(),
Utf8String(),
Utf8String::fromByteArray(info.unsavedContent), Utf8String::fromByteArray(info.unsavedContent),
info.isDocumentModified, info.isDocumentModified,
uint(m_interface->textDocument()->revision())}}); uint(m_interface->textDocument()->revision())}});
@@ -658,12 +657,10 @@ bool ClangCompletionAssistProcessor::sendCompletionRequest(int position,
const Position cursorPosition = extractLineColumn(position); const Position cursorPosition = extractLineColumn(position);
const Position functionNameStart = extractLineColumn(functionNameStartPosition); const Position functionNameStart = extractLineColumn(functionNameStartPosition);
const QString projectPartId = CppTools::CppToolsBridge::projectPartIdForFile(filePath);
communicator.requestCompletions(this, communicator.requestCompletions(this,
filePath, filePath,
uint(cursorPosition.line), uint(cursorPosition.line),
uint(cursorPosition.column), uint(cursorPosition.column),
projectPartId,
functionNameStart.line, functionNameStart.line,
functionNameStart.column); functionNameStart.column);
setLastCompletionPosition(filePath, position); setLastCompletionPosition(filePath, position);

View File

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

View File

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

View File

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

View File

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

View File

@@ -63,26 +63,6 @@ using namespace CppTools;
namespace ClangCodeModel { namespace ClangCodeModel {
namespace Utils { 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 class LibClangOptionsBuilder final : public CompilerOptionsBuilder
{ {
public: public:
@@ -122,16 +102,10 @@ private:
} }
}; };
/** QStringList createClangOptions(const ProjectPart &projectPart, ProjectFile::Kind fileKind)
* @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)
{ {
if (!pPart) return LibClangOptionsBuilder(projectPart)
return QStringList(); .build(fileKind, CompilerOptionsBuilder::PchUsage::None);
return LibClangOptionsBuilder(*pPart).build(fileKind, CompilerOptionsBuilder::PchUsage::None);
} }
ProjectPart::Ptr projectPartForFile(const QString &filePath) ProjectPart::Ptr projectPartForFile(const QString &filePath)

View File

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

View File

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

View File

@@ -55,7 +55,7 @@ static bool useSupportiveTranslationUnit()
namespace ClangBackEnd { namespace ClangBackEnd {
ClangCodeModelServer::ClangCodeModelServer() ClangCodeModelServer::ClangCodeModelServer()
: documents(projects, unsavedFiles) : documents(unsavedFiles)
{ {
updateAnnotationsTimer.setSingleShot(true); updateAnnotationsTimer.setSingleShot(true);
QObject::connect(&updateAnnotationsTimer, QObject::connect(&updateAnnotationsTimer,
@@ -74,7 +74,7 @@ ClangCodeModelServer::ClangCodeModelServer()
QObject::connect(documents.clangFileSystemWatcher(), QObject::connect(documents.clangFileSystemWatcher(),
&ClangFileSystemWatcher::fileChanged, &ClangFileSystemWatcher::fileChanged,
[this](const Utf8String &filePath) { [this](const Utf8String &filePath) {
if (!documents.hasDocumentWithFilePath(filePath)) if (!documents.hasDocument(filePath))
updateAnnotationsTimer.start(0); 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) void ClangCodeModelServer::unsavedFilesUpdated(const UnsavedFilesUpdatedMessage &message)
{ {
qCDebug(serverLog) << "########## unsavedFilesUpdated"; qCDebug(serverLog) << "########## unsavedFilesUpdated";
@@ -232,7 +195,7 @@ void ClangCodeModelServer::requestCompletions(const ClangBackEnd::RequestComplet
TIME_SCOPE_DURATION("ClangCodeModelServer::requestCompletions"); TIME_SCOPE_DURATION("ClangCodeModelServer::requestCompletions");
try { try {
Document document = documents.document(message.filePath, message.projectPartId); Document document = documents.document(message.filePath);
DocumentProcessor processor = documentProcessors().processor(document); DocumentProcessor processor = documentProcessors().processor(document);
JobRequest jobRequest = processor.createJobRequest(JobRequest::Type::RequestCompletions); JobRequest jobRequest = processor.createJobRequest(JobRequest::Type::RequestCompletions);
@@ -255,8 +218,7 @@ void ClangCodeModelServer::requestAnnotations(const RequestAnnotationsMessage &m
TIME_SCOPE_DURATION("ClangCodeModelServer::requestAnnotations"); TIME_SCOPE_DURATION("ClangCodeModelServer::requestAnnotations");
try { try {
auto document = documents.document(message.fileContainer.filePath, auto document = documents.document(message.fileContainer.filePath);
message.fileContainer.projectPartId);
DocumentProcessor processor = documentProcessors().processor(document); DocumentProcessor processor = documentProcessors().processor(document);
processor.addJob(JobRequest::Type::RequestAnnotations); processor.addJob(JobRequest::Type::RequestAnnotations);
@@ -285,8 +247,7 @@ void ClangCodeModelServer::requestReferences(const RequestReferencesMessage &mes
TIME_SCOPE_DURATION("ClangCodeModelServer::requestReferences"); TIME_SCOPE_DURATION("ClangCodeModelServer::requestReferences");
try { try {
const Document document = documents.document(message.fileContainer.filePath, const Document document = documents.document(message.fileContainer.filePath);
message.fileContainer.projectPartId);
DocumentProcessor processor = documentProcessors().processor(document); DocumentProcessor processor = documentProcessors().processor(document);
JobRequest jobRequest = processor.createJobRequest(JobRequest::Type::RequestReferences); JobRequest jobRequest = processor.createJobRequest(JobRequest::Type::RequestReferences);
@@ -305,8 +266,7 @@ void ClangCodeModelServer::requestFollowSymbol(const RequestFollowSymbolMessage
TIME_SCOPE_DURATION("ClangCodeModelServer::requestFollowSymbol"); TIME_SCOPE_DURATION("ClangCodeModelServer::requestFollowSymbol");
try { try {
const Utf8String &projectPartId = message.fileContainer.projectPartId; Document document = documents.document(message.fileContainer.filePath);
Document document = documents.document(message.fileContainer.filePath, projectPartId);
DocumentProcessor processor = documentProcessors().processor(document); DocumentProcessor processor = documentProcessors().processor(document);
JobRequest jobRequest = processor.createJobRequest(JobRequest::Type::RequestFollowSymbol); JobRequest jobRequest = processor.createJobRequest(JobRequest::Type::RequestFollowSymbol);
@@ -323,8 +283,7 @@ void ClangCodeModelServer::requestToolTip(const RequestToolTipMessage &message)
TIME_SCOPE_DURATION("ClangCodeModelServer::requestToolTip"); TIME_SCOPE_DURATION("ClangCodeModelServer::requestToolTip");
try { try {
const Document document = documents.document(message.fileContainer.filePath, const Document document = documents.document(message.fileContainer.filePath);
message.fileContainer.projectPartId);
DocumentProcessor processor = documentProcessors().processor(document); DocumentProcessor processor = documentProcessors().processor(document);
JobRequest jobRequest = processor.createJobRequest(JobRequest::Type::RequestToolTip); JobRequest jobRequest = processor.createJobRequest(JobRequest::Type::RequestToolTip);
@@ -504,7 +463,7 @@ DocumentProcessors &ClangCodeModelServer::documentProcessors()
// DocumentProcessors needs a reference to the client, but the client // DocumentProcessors needs a reference to the client, but the client
// is not known at construction time of ClangCodeModelServer, so // is not known at construction time of ClangCodeModelServer, so
// construct DocumentProcessors in a lazy manner. // construct DocumentProcessors in a lazy manner.
documentProcessors_.reset(new DocumentProcessors(documents, unsavedFiles, projects, *client())); documentProcessors_.reset(new DocumentProcessors(documents, unsavedFiles, *client()));
} }
return *documentProcessors_.data(); return *documentProcessors_.data();

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -28,16 +28,14 @@
#include "clangdocument.h" #include "clangdocument.h"
#include "clangdocuments.h" #include "clangdocuments.h"
#include "clangtranslationunits.h" #include "clangtranslationunits.h"
#include "projects.h"
#include "unsavedfiles.h" #include "unsavedfiles.h"
#include <utils/algorithm.h> #include <utils/algorithm.h>
namespace ClangBackEnd { namespace ClangBackEnd {
JobQueue::JobQueue(Documents &documents, ProjectParts &projectParts, const Utf8String &logTag) JobQueue::JobQueue(Documents &documents, const Utf8String &logTag)
: m_documents(documents) : m_documents(documents)
, m_projectParts(projectParts)
, m_logTag(logTag) , m_logTag(logTag)
{ {
} }
@@ -104,12 +102,12 @@ bool JobQueue::isJobRequestAddable(const JobRequest &jobRequest, QString &notAdd
return false; return false;
} }
if (!m_documents.hasDocument(jobRequest.filePath, jobRequest.projectPartId)) { if (!m_documents.hasDocument(jobRequest.filePath)) {
notAddableReason = "document already closed"; notAddableReason = "document already closed";
return false; return false;
} }
const Document document = m_documents.document(jobRequest.filePath, jobRequest.projectPartId); const Document document = m_documents.document(jobRequest.filePath);
if (!document.isIntact()) { if (!document.isIntact()) {
notAddableReason = "document not intact"; notAddableReason = "document not intact";
return false; return false;
@@ -131,22 +129,14 @@ bool JobQueue::isJobRequestExpired(const JobRequest &jobRequest, QString &expira
} }
} }
bool projectCheckedAndItExists = false;
if (conditions.testFlag(Condition::DocumentClosed)) { if (conditions.testFlag(Condition::DocumentClosed)) {
if (!m_documents.hasDocument(jobRequest.filePath, jobRequest.projectPartId)) { if (!m_documents.hasDocument(jobRequest.filePath)) {
expirationReason = "document already closed"; expirationReason = "document already closed";
return true; return true;
} }
if (!m_projectParts.hasProjectPart(jobRequest.projectPartId)) {
expirationReason = "project already closed";
return true;
}
projectCheckedAndItExists = true;
const Document document const Document document
= m_documents.document(jobRequest.filePath, jobRequest.projectPartId); = m_documents.document(jobRequest.filePath);
if (!document.isIntact()) { if (!document.isIntact()) {
expirationReason = "document not intact"; expirationReason = "document not intact";
return true; 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; return false;
} }
@@ -193,8 +170,8 @@ void JobQueue::prioritizeRequests()
{ {
const auto lessThan = [this] (const JobRequest &r1, const JobRequest &r2) { 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. // 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 &t1 = m_documents.document(r1.filePath);
const Document &t2 = m_documents.document(r2.filePath, r2.projectPartId); const Document &t2 = m_documents.document(r2.filePath);
return priority(t1) > priority(t2); return priority(t1) > priority(t2);
}; };
@@ -267,8 +244,7 @@ JobRequests JobQueue::takeJobRequestsToRunNow()
const JobRequest &request = i.next(); const JobRequest &request = i.next();
try { try {
const Document &document = m_documents.document(request.filePath, const Document &document = m_documents.document(request.filePath);
request.projectPartId);
if (!areRunConditionsMet(request, document)) if (!areRunConditionsMet(request, document))
continue; continue;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -35,8 +35,7 @@ class CommandLineArguments
{ {
public: public:
CommandLineArguments(const char *filePath, CommandLineArguments(const char *filePath,
const Utf8StringVector &projectPartArguments, const Utf8StringVector &compilationArguments,
const Utf8StringVector &fileArguments,
bool addVerboseOption); bool addVerboseOption);
const char * const *data() const; 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); echoMessage(message);
} }
void EchoClangCodeModelServer::projectPartsUpdated(const ProjectPartsUpdatedMessage &message)
{
echoMessage(message);
}
void EchoClangCodeModelServer::projectPartsRemoved(const ProjectPartsRemovedMessage &message)
{
echoMessage(message);
}
void EchoClangCodeModelServer::unsavedFilesUpdated(const UnsavedFilesUpdatedMessage &message) void EchoClangCodeModelServer::unsavedFilesUpdated(const UnsavedFilesUpdatedMessage &message)
{ {
echoMessage(message); echoMessage(message);

View File

@@ -42,9 +42,6 @@ public:
void documentsClosed(const DocumentsClosedMessage &message) override; void documentsClosed(const DocumentsClosedMessage &message) override;
void documentVisibilityChanged(const DocumentVisibilityChangedMessage &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 unsavedFilesUpdated(const UnsavedFilesUpdatedMessage &message) override;
void unsavedFilesRemoved(const UnsavedFilesRemovedMessage &message) override; void unsavedFilesRemoved(const UnsavedFilesRemovedMessage &message) override;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -65,7 +65,6 @@ protected:
protected: protected:
Utf8String filePath{Utf8StringLiteral(TESTDATA_DIR"/complete_extractor_function.cpp")}; Utf8String filePath{Utf8StringLiteral(TESTDATA_DIR"/complete_extractor_function.cpp")};
ClangBackEnd::FileContainer fileContainer{filePath, ClangBackEnd::FileContainer fileContainer{filePath,
Utf8StringLiteral("projectPartId"),
Utf8StringLiteral("unsaved content"), Utf8StringLiteral("unsaved content"),
true, true,
1}; 1};
@@ -152,7 +151,7 @@ TEST_F(ClientServerInProcess, SendUnregisterUnsavedFilesForEditorMessage)
TEST_F(ClientServerInProcess, SendCompleteCodeMessage) 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)) EXPECT_CALL(mockClangCodeModelServer, requestCompletions(message))
.Times(1); .Times(1);
@@ -185,29 +184,6 @@ TEST_F(ClientServerInProcess, SendCompletionsMessage)
scheduleClientMessages(); 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) TEST_F(ClientServerInProcess, DocumentVisibilityChangedMessage)
{ {
ClangBackEnd::DocumentVisibilityChangedMessage ClangBackEnd::DocumentVisibilityChangedMessage

View File

@@ -121,7 +121,7 @@ TEST_F(ClientServerOutsideProcess, SendDocumentsClosedMessage)
TEST_F(ClientServerOutsideProcess, SendCompleteCodeMessage) 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); EchoMessage echoMessage(codeCompleteMessage);
EXPECT_CALL(mockClangCodeModelClient, echo(echoMessage)); EXPECT_CALL(mockClangCodeModelClient, echo(echoMessage));
@@ -130,29 +130,6 @@ TEST_F(ClientServerOutsideProcess, SendCompleteCodeMessage)
ASSERT_TRUE(client.waitForEcho()); 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() void ClientServerOutsideProcess::SetUp()
{ {
QSignalSpy clientSpy(&client, &ConnectionClient::connectedToLocalSocket); QSignalSpy clientSpy(&client, &ConnectionClient::connectedToLocalSocket);

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -99,7 +99,6 @@ class FilePathId;
class FilePath; class FilePath;
class WatcherEntry; class WatcherEntry;
class SourceLocationsContainer; class SourceLocationsContainer;
class ProjectPartsUpdatedMessage;
class CancelMessage; class CancelMessage;
class AliveMessage; class AliveMessage;
class CompletionsMessage; class CompletionsMessage;
@@ -112,7 +111,6 @@ class FollowSymbolMessage;
class RequestCompletionsMessage; class RequestCompletionsMessage;
class EndMessage; class EndMessage;
class DocumentsOpenedMessage; class DocumentsOpenedMessage;
class ProjectPartsRemovedMessage;
class DocumentsClosedMessage; class DocumentsClosedMessage;
class CodeCompletion; class CodeCompletion;
class CodeCompletionChunk; class CodeCompletionChunk;
@@ -126,7 +124,6 @@ class FullTokenInfo;
class HighlightingMarkContainer; class HighlightingMarkContainer;
class NativeFilePath; class NativeFilePath;
class PrecompiledHeadersUpdatedMessage; class PrecompiledHeadersUpdatedMessage;
class ProjectPartContainer;
class ProjectPartPch; class ProjectPartPch;
class UnsavedFilesUpdatedMessage; class UnsavedFilesUpdatedMessage;
class RemoveProjectPartsMessage; 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 IdPaths &idPaths);
std::ostream &operator<<(std::ostream &out, const WatcherEntry &entry); 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 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 CancelMessage &message);
std::ostream &operator<<(std::ostream &out, const AliveMessage &message); std::ostream &operator<<(std::ostream &out, const AliveMessage &message);
std::ostream &operator<<(std::ostream &out, const CompletionsMessage &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 RequestCompletionsMessage &message);
std::ostream &operator<<(std::ostream &out, const EndMessage &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 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 DocumentsClosedMessage &message);
std::ostream &operator<<(std::ostream &out, const CodeCompletion &message); std::ostream &operator<<(std::ostream &out, const CodeCompletion &message);
std::ostream &operator<<(std::ostream &out, const CodeCompletionChunk &chunk); 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 HighlightingMarkContainer &container);
std::ostream &operator<<(std::ostream &out, const NativeFilePath &filePath); 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 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 ProjectPartPch &projectPartPch);
std::ostream &operator<<(std::ostream &out, const UnsavedFilesUpdatedMessage &message); std::ostream &operator<<(std::ostream &out, const UnsavedFilesUpdatedMessage &message);
std::ostream &operator<<(std::ostream &out, const RemoveProjectPartsMessage &message); std::ostream &operator<<(std::ostream &out, const RemoveProjectPartsMessage &message);

View File

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

View File

@@ -43,11 +43,6 @@ public:
MOCK_METHOD1(documentVisibilityChanged, MOCK_METHOD1(documentVisibilityChanged,
void(const ClangBackEnd::DocumentVisibilityChangedMessage &message)); void(const ClangBackEnd::DocumentVisibilityChangedMessage &message));
MOCK_METHOD1(projectPartsUpdated,
void(const ClangBackEnd::ProjectPartsUpdatedMessage &message));
MOCK_METHOD1(projectPartsRemoved,
void(const ClangBackEnd::ProjectPartsRemovedMessage &message));
MOCK_METHOD1(unsavedFilesUpdated, MOCK_METHOD1(unsavedFilesUpdated,
void(const ClangBackEnd::UnsavedFilesUpdatedMessage &message)); void(const ClangBackEnd::UnsavedFilesUpdatedMessage &message));
MOCK_METHOD1(unsavedFilesRemoved, 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: protected:
Utf8String filePath{Utf8StringLiteral("foo.cpp")}; Utf8String filePath{Utf8StringLiteral("foo.cpp")};
ClangBackEnd::FileContainer fileContainer{filePath, ClangBackEnd::FileContainer fileContainer{filePath,
Utf8StringLiteral("projectPartId"),
Utf8StringLiteral("unsaved content"), Utf8StringLiteral("unsaved content"),
true, true,
1}; 1};
@@ -207,7 +206,7 @@ TEST_F(ReadAndWriteMessageBlock, CompareDocumentsClosedMessage)
TEST_F(ReadAndWriteMessageBlock, CompareRequestCompletionsMessage) 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) 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 <clangdocuments.h>
#include <clangstring.h> #include <clangstring.h>
#include <clangtranslationunit.h> #include <clangtranslationunit.h>
#include <projectpart.h>
#include <projects.h>
#include <skippedsourceranges.h> #include <skippedsourceranges.h>
#include <sourcelocation.h> #include <sourcelocation.h>
#include <sourcerange.h> #include <sourcerange.h>
@@ -47,7 +45,6 @@ using ClangBackEnd::Document;
using ClangBackEnd::Documents; using ClangBackEnd::Documents;
using ClangBackEnd::TranslationUnit; using ClangBackEnd::TranslationUnit;
using ClangBackEnd::UnsavedFiles; using ClangBackEnd::UnsavedFiles;
using ClangBackEnd::ProjectPart;
using ClangBackEnd::ClangString; using ClangBackEnd::ClangString;
using ClangBackEnd::SourceRange; using ClangBackEnd::SourceRange;
using ClangBackEnd::SkippedSourceRanges; using ClangBackEnd::SkippedSourceRanges;
@@ -89,16 +86,12 @@ struct Data {
document.parse(); document.parse();
} }
ClangBackEnd::ProjectParts projects;
ClangBackEnd::UnsavedFiles unsavedFiles; ClangBackEnd::UnsavedFiles unsavedFiles;
ClangBackEnd::Documents documents{projects, unsavedFiles}; ClangBackEnd::Documents documents{unsavedFiles};
Utf8String filePath = Utf8StringLiteral(TESTDATA_DIR"/skippedsourceranges.cpp"); Utf8String filePath = Utf8StringLiteral(TESTDATA_DIR"/skippedsourceranges.cpp");
Document document{filePath, Utf8StringVector compilationArguments{TestEnvironment::addPlatformArguments(
ProjectPart(Utf8StringLiteral("projectPartId"), {Utf8StringLiteral("-std=c++11"), Utf8StringLiteral("-DBLAH")})};
TestEnvironment::addPlatformArguments({Utf8StringLiteral("-std=c++11"), Document document{filePath, compilationArguments, documents};
Utf8StringLiteral("-DBLAH")})),
{},
documents};
TranslationUnit translationUnit{filePath, TranslationUnit translationUnit{filePath,
filePath, filePath,
document.translationUnit().cxIndex(), document.translationUnit().cxIndex(),

View File

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

View File

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

View File

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

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