2015-06-01 18:51:55 +02:00
|
|
|
/****************************************************************************
|
|
|
|
|
**
|
|
|
|
|
** Copyright (C) 2015 The Qt Company Ltd.
|
|
|
|
|
** Contact: http://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 Digia. For licensing terms and
|
|
|
|
|
** conditions see http://www.qt.io/licensing. For further information
|
|
|
|
|
** use the contact form at http://www.qt.io/contact-us.
|
|
|
|
|
**
|
|
|
|
|
** GNU Lesser General Public License Usage
|
|
|
|
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
|
|
|
|
** General Public License version 2.1 or version 3 as published by the Free
|
|
|
|
|
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
|
|
|
|
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
|
|
|
|
** following information to ensure the GNU Lesser General Public License
|
|
|
|
|
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
|
|
|
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
|
|
|
|
**
|
|
|
|
|
** In addition, as a special exception, Digia gives you certain additional
|
|
|
|
|
** rights. These rights are described in the Digia Qt LGPL Exception
|
|
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
|
**
|
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
|
|
#include "filecontainer.h"
|
|
|
|
|
|
2015-07-14 14:54:01 +02:00
|
|
|
#include "clangbackendipcdebugutils.h"
|
|
|
|
|
|
2015-06-01 18:51:55 +02:00
|
|
|
#include <QDataStream>
|
2015-06-16 12:38:04 +02:00
|
|
|
#include <QDebug>
|
2015-06-01 18:51:55 +02:00
|
|
|
|
|
|
|
|
#include <ostream>
|
|
|
|
|
|
2015-06-16 11:56:00 +02:00
|
|
|
namespace ClangBackEnd {
|
2015-06-01 18:51:55 +02:00
|
|
|
|
2015-08-31 12:40:14 +02:00
|
|
|
FileContainer::FileContainer(const Utf8String &filePath,
|
2015-06-01 18:51:55 +02:00
|
|
|
const Utf8String &projectPartId,
|
|
|
|
|
const Utf8String &unsavedFileContent,
|
2015-08-31 12:40:14 +02:00
|
|
|
bool hasUnsavedFileContent,
|
|
|
|
|
quint32 documentRevision)
|
|
|
|
|
: filePath_(filePath),
|
2015-06-01 18:51:55 +02:00
|
|
|
projectPartId_(projectPartId),
|
|
|
|
|
unsavedFileContent_(unsavedFileContent),
|
2015-08-31 12:40:14 +02:00
|
|
|
documentRevision_(documentRevision),
|
2015-06-01 18:51:55 +02:00
|
|
|
hasUnsavedFileContent_(hasUnsavedFileContent)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2015-08-31 12:40:14 +02:00
|
|
|
FileContainer::FileContainer(const Utf8String &filePath,
|
|
|
|
|
const Utf8String &projectPartId,
|
2015-11-05 13:57:57 +01:00
|
|
|
const Utf8StringVector &fileArguments,
|
2015-08-31 12:40:14 +02:00
|
|
|
quint32 documentRevision)
|
|
|
|
|
: filePath_(filePath),
|
|
|
|
|
projectPartId_(projectPartId),
|
2015-11-05 13:57:57 +01:00
|
|
|
fileArguments_(fileArguments),
|
2015-08-31 12:40:14 +02:00
|
|
|
documentRevision_(documentRevision),
|
|
|
|
|
hasUnsavedFileContent_(false)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2015-06-01 18:51:55 +02:00
|
|
|
const Utf8String &FileContainer::filePath() const
|
|
|
|
|
{
|
|
|
|
|
return filePath_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const Utf8String &FileContainer::projectPartId() const
|
|
|
|
|
{
|
|
|
|
|
return projectPartId_;
|
|
|
|
|
}
|
|
|
|
|
|
2015-11-05 13:57:57 +01:00
|
|
|
const Utf8StringVector &FileContainer::fileArguments() const
|
|
|
|
|
{
|
|
|
|
|
return fileArguments_;
|
|
|
|
|
}
|
|
|
|
|
|
2015-06-01 18:51:55 +02:00
|
|
|
const Utf8String &FileContainer::unsavedFileContent() const
|
|
|
|
|
{
|
|
|
|
|
return unsavedFileContent_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool FileContainer::hasUnsavedFileContent() const
|
|
|
|
|
{
|
|
|
|
|
return hasUnsavedFileContent_;
|
|
|
|
|
}
|
|
|
|
|
|
2015-08-31 12:40:14 +02:00
|
|
|
quint32 FileContainer::documentRevision() const
|
|
|
|
|
{
|
|
|
|
|
return documentRevision_;
|
|
|
|
|
}
|
|
|
|
|
|
2015-06-01 18:51:55 +02:00
|
|
|
QDataStream &operator<<(QDataStream &out, const FileContainer &container)
|
|
|
|
|
{
|
|
|
|
|
out << container.filePath_;
|
|
|
|
|
out << container.projectPartId_;
|
2015-11-05 13:57:57 +01:00
|
|
|
out << container.fileArguments_;
|
2015-06-01 18:51:55 +02:00
|
|
|
out << container.unsavedFileContent_;
|
2015-08-31 12:40:14 +02:00
|
|
|
out << container.documentRevision_;
|
2015-06-01 18:51:55 +02:00
|
|
|
out << container.hasUnsavedFileContent_;
|
|
|
|
|
|
|
|
|
|
return out;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QDataStream &operator>>(QDataStream &in, FileContainer &container)
|
|
|
|
|
{
|
|
|
|
|
in >> container.filePath_;
|
|
|
|
|
in >> container.projectPartId_;
|
2015-11-05 13:57:57 +01:00
|
|
|
in >> container.fileArguments_;
|
2015-06-01 18:51:55 +02:00
|
|
|
in >> container.unsavedFileContent_;
|
2015-08-31 12:40:14 +02:00
|
|
|
in >> container.documentRevision_;
|
2015-06-01 18:51:55 +02:00
|
|
|
in >> container.hasUnsavedFileContent_;
|
|
|
|
|
|
|
|
|
|
return in;
|
|
|
|
|
}
|
|
|
|
|
|
2015-06-10 13:52:45 +02:00
|
|
|
bool operator==(const FileContainer &first, const FileContainer &second)
|
2015-06-01 18:51:55 +02:00
|
|
|
{
|
|
|
|
|
return first.filePath_ == second.filePath_ && first.projectPartId_ == second.projectPartId_;
|
|
|
|
|
}
|
|
|
|
|
|
2015-06-10 13:52:45 +02:00
|
|
|
bool operator<(const FileContainer &first, const FileContainer &second)
|
2015-06-01 18:51:55 +02:00
|
|
|
{
|
|
|
|
|
if (first.filePath_ == second.filePath_)
|
|
|
|
|
return first.projectPartId_ < second.projectPartId_;
|
|
|
|
|
|
|
|
|
|
return first.filePath_ < second.filePath_;
|
|
|
|
|
}
|
|
|
|
|
|
2015-06-10 13:52:45 +02:00
|
|
|
QDebug operator<<(QDebug debug, const FileContainer &container)
|
2015-06-01 18:51:55 +02:00
|
|
|
{
|
|
|
|
|
debug.nospace() << "FileContainer("
|
2015-08-31 12:40:14 +02:00
|
|
|
<< container.filePath() << ", "
|
|
|
|
|
<< container.projectPartId() << ", "
|
2015-11-05 13:57:57 +01:00
|
|
|
<< container.fileArguments() << ", "
|
2015-08-31 12:40:14 +02:00
|
|
|
<< container.documentRevision();
|
2015-06-01 18:51:55 +02:00
|
|
|
|
2015-07-14 14:54:01 +02:00
|
|
|
if (container.hasUnsavedFileContent()) {
|
|
|
|
|
const Utf8String fileWithContent = debugWriteFileForInspection(
|
|
|
|
|
container.unsavedFileContent(),
|
|
|
|
|
debugId(container));
|
2015-06-01 18:51:55 +02:00
|
|
|
debug.nospace() << ", "
|
2015-07-14 14:54:01 +02:00
|
|
|
<< "<" << fileWithContent << ">";
|
|
|
|
|
}
|
2015-06-01 18:51:55 +02:00
|
|
|
|
|
|
|
|
debug.nospace() << ")";
|
|
|
|
|
|
|
|
|
|
return debug;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void PrintTo(const FileContainer &container, ::std::ostream* os)
|
|
|
|
|
{
|
|
|
|
|
*os << "FileContainer("
|
2015-08-31 12:40:14 +02:00
|
|
|
<< container.filePath().constData() << ", "
|
|
|
|
|
<< container.projectPartId().constData() << ", "
|
2015-11-05 13:57:57 +01:00
|
|
|
<< container.fileArguments().constData() << ", "
|
2015-08-31 12:40:14 +02:00
|
|
|
<< container.documentRevision();
|
2015-06-01 18:51:55 +02:00
|
|
|
|
|
|
|
|
if (container.hasUnsavedFileContent())
|
|
|
|
|
*os << ", "
|
|
|
|
|
<< container.unsavedFileContent().constData();
|
|
|
|
|
|
|
|
|
|
*os << ")";
|
|
|
|
|
}
|
|
|
|
|
|
2015-06-16 11:56:00 +02:00
|
|
|
} // namespace ClangBackEnd
|
2015-06-01 18:51:55 +02:00
|
|
|
|