2015-10-01 12:45:06 +02:00
|
|
|
/****************************************************************************
|
2015-06-01 18:51:55 +02:00
|
|
|
**
|
2016-01-15 14:57:14 +01:00
|
|
|
** Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
|
** Contact: https://www.qt.io/licensing/
|
2015-06-01 18:51:55 +02:00
|
|
|
**
|
|
|
|
|
** 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
|
2016-01-15 14:57:14 +01:00
|
|
|
** 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.
|
2015-06-01 18:51:55 +02:00
|
|
|
**
|
2016-01-15 14:57:14 +01:00
|
|
|
** 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.
|
2015-06-01 18:51:55 +02:00
|
|
|
**
|
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
2016-09-07 10:42:12 +02:00
|
|
|
#include "clangdocument.h"
|
2015-06-01 18:51:55 +02:00
|
|
|
|
2016-09-07 10:42:12 +02:00
|
|
|
#include "clangdocuments.h"
|
2015-08-31 12:40:14 +02:00
|
|
|
#include "clangstring.h"
|
2016-05-30 10:25:52 +02:00
|
|
|
#include "clangunsavedfilesshallowarguments.h"
|
2015-06-01 18:51:55 +02:00
|
|
|
#include "codecompleter.h"
|
2015-06-16 12:38:04 +02:00
|
|
|
#include "projectpart.h"
|
2016-09-09 14:25:59 +02:00
|
|
|
#include "clangexceptions.h"
|
2016-09-07 14:50:58 +02:00
|
|
|
#include "clangtranslationunit.h"
|
2016-07-15 12:30:25 +02:00
|
|
|
#include "clangtranslationunitupdater.h"
|
2015-06-01 18:51:55 +02:00
|
|
|
#include "unsavedfiles.h"
|
2016-05-30 10:25:52 +02:00
|
|
|
#include "unsavedfile.h"
|
2015-06-16 12:38:04 +02:00
|
|
|
|
|
|
|
|
#include <utf8string.h>
|
|
|
|
|
|
2015-08-31 12:40:14 +02:00
|
|
|
#include <QDebug>
|
2015-06-16 12:38:04 +02:00
|
|
|
#include <QFileInfo>
|
2015-07-28 16:44:39 +02:00
|
|
|
#include <QLoggingCategory>
|
|
|
|
|
|
2015-08-31 12:40:14 +02:00
|
|
|
#include <ostream>
|
|
|
|
|
|
2015-06-16 11:56:00 +02:00
|
|
|
namespace ClangBackEnd {
|
2015-06-01 18:51:55 +02:00
|
|
|
|
2016-09-07 10:42:12 +02:00
|
|
|
class DocumentData
|
2015-06-01 18:51:55 +02:00
|
|
|
{
|
|
|
|
|
public:
|
2016-09-07 10:42:12 +02:00
|
|
|
DocumentData(const Utf8String &filePath,
|
|
|
|
|
const ProjectPart &projectPart,
|
|
|
|
|
const Utf8StringVector &fileArguments,
|
|
|
|
|
Documents &documents);
|
|
|
|
|
~DocumentData();
|
2015-06-01 18:51:55 +02:00
|
|
|
|
|
|
|
|
public:
|
2016-09-07 10:42:12 +02:00
|
|
|
Documents &documents;
|
2016-05-31 16:07:09 +02:00
|
|
|
|
|
|
|
|
const Utf8String filePath;
|
|
|
|
|
const Utf8StringVector fileArguments;
|
|
|
|
|
|
2015-06-01 18:51:55 +02:00
|
|
|
ProjectPart projectPart;
|
2016-05-31 16:07:09 +02:00
|
|
|
time_point lastProjectPartChangeTimePoint;
|
|
|
|
|
|
2015-06-01 18:51:55 +02:00
|
|
|
CXTranslationUnit translationUnit = nullptr;
|
|
|
|
|
CXIndex index = nullptr;
|
2016-05-31 16:07:09 +02:00
|
|
|
|
|
|
|
|
QSet<Utf8String> dependedFilePaths;
|
|
|
|
|
|
2015-08-31 12:40:14 +02:00
|
|
|
uint documentRevision = 0;
|
2016-05-31 16:07:09 +02:00
|
|
|
time_point needsToBeReparsedChangeTimePoint;
|
|
|
|
|
bool hasParseOrReparseFailed = false;
|
2015-11-23 13:31:46 +01:00
|
|
|
bool needsToBeReparsed = false;
|
2015-11-25 15:21:24 +01:00
|
|
|
bool isUsedByCurrentEditor = false;
|
|
|
|
|
bool isVisibleInEditor = false;
|
2015-06-01 18:51:55 +02:00
|
|
|
};
|
|
|
|
|
|
2016-09-07 10:42:12 +02:00
|
|
|
DocumentData::DocumentData(const Utf8String &filePath,
|
|
|
|
|
const ProjectPart &projectPart,
|
|
|
|
|
const Utf8StringVector &fileArguments,
|
|
|
|
|
Documents &documents)
|
|
|
|
|
: documents(documents),
|
2016-05-31 16:07:09 +02:00
|
|
|
filePath(filePath),
|
2015-11-05 13:57:57 +01:00
|
|
|
fileArguments(fileArguments),
|
2016-05-31 16:07:09 +02:00
|
|
|
projectPart(projectPart),
|
|
|
|
|
lastProjectPartChangeTimePoint(std::chrono::steady_clock::now()),
|
|
|
|
|
needsToBeReparsedChangeTimePoint(lastProjectPartChangeTimePoint)
|
2015-06-01 18:51:55 +02:00
|
|
|
{
|
2015-08-31 12:40:14 +02:00
|
|
|
dependedFilePaths.insert(filePath);
|
2015-06-01 18:51:55 +02:00
|
|
|
}
|
|
|
|
|
|
2016-09-07 10:42:12 +02:00
|
|
|
DocumentData::~DocumentData()
|
2015-06-01 18:51:55 +02:00
|
|
|
{
|
|
|
|
|
clang_disposeTranslationUnit(translationUnit);
|
|
|
|
|
clang_disposeIndex(index);
|
|
|
|
|
}
|
|
|
|
|
|
2016-09-07 10:42:12 +02:00
|
|
|
Document::Document(const Utf8String &filePath,
|
|
|
|
|
const ProjectPart &projectPart,
|
|
|
|
|
const Utf8StringVector &fileArguments,
|
|
|
|
|
Documents &documents,
|
|
|
|
|
FileExistsCheck fileExistsCheck)
|
|
|
|
|
: d(std::make_shared<DocumentData>(filePath,
|
|
|
|
|
projectPart,
|
|
|
|
|
fileArguments,
|
|
|
|
|
documents))
|
2015-06-01 18:51:55 +02:00
|
|
|
{
|
|
|
|
|
if (fileExistsCheck == CheckIfFileExists)
|
|
|
|
|
checkIfFileExists();
|
|
|
|
|
}
|
|
|
|
|
|
2016-09-07 10:42:12 +02:00
|
|
|
Document::~Document() = default;
|
|
|
|
|
Document::Document(const Document &) = default;
|
|
|
|
|
Document &Document::operator=(const Document &) = default;
|
2015-11-25 15:21:24 +01:00
|
|
|
|
2016-09-07 10:42:12 +02:00
|
|
|
Document::Document(Document &&other)
|
2016-05-31 16:07:09 +02:00
|
|
|
: d(std::move(other.d))
|
2015-11-25 15:21:24 +01:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2016-09-07 10:42:12 +02:00
|
|
|
Document &Document::operator=(Document &&other)
|
2015-11-25 15:21:24 +01:00
|
|
|
{
|
2016-05-31 16:07:09 +02:00
|
|
|
d = std::move(other.d);
|
2015-11-25 15:21:24 +01:00
|
|
|
|
2016-05-31 16:07:09 +02:00
|
|
|
return *this;
|
2015-11-25 15:21:24 +01:00
|
|
|
}
|
|
|
|
|
|
2016-09-07 10:42:12 +02:00
|
|
|
void Document::reset()
|
2015-06-01 18:51:55 +02:00
|
|
|
{
|
|
|
|
|
d.reset();
|
|
|
|
|
}
|
|
|
|
|
|
2016-09-07 10:42:12 +02:00
|
|
|
bool Document::isNull() const
|
2015-06-01 18:51:55 +02:00
|
|
|
{
|
2016-05-31 16:07:09 +02:00
|
|
|
return !d;
|
2015-06-01 18:51:55 +02:00
|
|
|
}
|
|
|
|
|
|
2016-09-07 10:42:12 +02:00
|
|
|
bool Document::isIntact() const
|
2016-01-28 18:31:05 +01:00
|
|
|
{
|
2016-05-31 16:07:09 +02:00
|
|
|
return !isNull()
|
|
|
|
|
&& fileExists()
|
|
|
|
|
&& !d->hasParseOrReparseFailed;
|
2016-01-28 18:31:05 +01:00
|
|
|
}
|
|
|
|
|
|
2016-09-07 10:42:12 +02:00
|
|
|
Utf8String Document::filePath() const
|
2015-06-01 18:51:55 +02:00
|
|
|
{
|
|
|
|
|
checkIfNull();
|
|
|
|
|
|
|
|
|
|
return d->filePath;
|
|
|
|
|
}
|
|
|
|
|
|
2016-09-07 10:42:12 +02:00
|
|
|
Utf8StringVector Document::fileArguments() const
|
2016-05-30 10:25:52 +02:00
|
|
|
{
|
|
|
|
|
checkIfNull();
|
|
|
|
|
|
|
|
|
|
return d->fileArguments;
|
|
|
|
|
}
|
|
|
|
|
|
2016-09-07 10:42:12 +02:00
|
|
|
FileContainer Document::fileContainer() const
|
2015-08-31 16:28:26 +02:00
|
|
|
{
|
|
|
|
|
checkIfNull();
|
|
|
|
|
|
2015-08-31 12:40:14 +02:00
|
|
|
return FileContainer(d->filePath,
|
|
|
|
|
d->projectPart.projectPartId(),
|
|
|
|
|
Utf8String(),
|
|
|
|
|
false,
|
|
|
|
|
d->documentRevision);
|
|
|
|
|
}
|
|
|
|
|
|
2016-09-07 10:42:12 +02:00
|
|
|
Utf8String Document::projectPartId() const
|
2015-08-31 12:40:14 +02:00
|
|
|
{
|
|
|
|
|
checkIfNull();
|
|
|
|
|
|
2016-05-31 16:07:09 +02:00
|
|
|
return d->projectPart.projectPartId();
|
2015-08-31 12:40:14 +02:00
|
|
|
}
|
|
|
|
|
|
2016-09-07 10:42:12 +02:00
|
|
|
const ProjectPart &Document::projectPart() const
|
2015-08-31 12:40:14 +02:00
|
|
|
{
|
2016-05-31 16:07:09 +02:00
|
|
|
checkIfNull();
|
2015-08-31 12:40:14 +02:00
|
|
|
|
2016-05-31 16:07:09 +02:00
|
|
|
return d->projectPart;
|
2015-08-31 12:40:14 +02:00
|
|
|
}
|
|
|
|
|
|
2016-09-07 10:42:12 +02:00
|
|
|
const time_point Document::lastProjectPartChangeTimePoint() const
|
2015-08-31 12:40:14 +02:00
|
|
|
{
|
2016-05-31 16:07:09 +02:00
|
|
|
checkIfNull();
|
2015-08-31 16:28:26 +02:00
|
|
|
|
2016-05-31 16:07:09 +02:00
|
|
|
return d->lastProjectPartChangeTimePoint;
|
2015-06-01 18:51:55 +02:00
|
|
|
}
|
|
|
|
|
|
2016-09-07 10:42:12 +02:00
|
|
|
bool Document::isProjectPartOutdated() const
|
2015-08-26 16:33:32 +02:00
|
|
|
{
|
2016-05-31 16:07:09 +02:00
|
|
|
checkIfNull();
|
2015-08-26 16:33:32 +02:00
|
|
|
|
2016-05-31 16:07:09 +02:00
|
|
|
return d->projectPart.lastChangeTimePoint() >= d->lastProjectPartChangeTimePoint;
|
2015-11-18 17:07:44 +01:00
|
|
|
}
|
|
|
|
|
|
2016-09-07 10:42:12 +02:00
|
|
|
uint Document::documentRevision() const
|
2015-08-31 16:28:26 +02:00
|
|
|
{
|
2016-05-31 16:07:09 +02:00
|
|
|
checkIfNull();
|
2015-08-26 16:33:32 +02:00
|
|
|
|
2016-05-31 16:07:09 +02:00
|
|
|
return d->documentRevision;
|
2015-08-31 16:28:26 +02:00
|
|
|
}
|
|
|
|
|
|
2016-09-07 10:42:12 +02:00
|
|
|
void Document::setDocumentRevision(uint revision)
|
2015-09-18 17:01:32 +02:00
|
|
|
{
|
2016-05-31 16:07:09 +02:00
|
|
|
checkIfNull();
|
2015-09-18 17:01:32 +02:00
|
|
|
|
2016-05-31 16:07:09 +02:00
|
|
|
d->documentRevision = revision;
|
2015-09-18 17:01:32 +02:00
|
|
|
}
|
|
|
|
|
|
2016-09-07 10:42:12 +02:00
|
|
|
bool Document::isUsedByCurrentEditor() const
|
2015-08-31 12:40:14 +02:00
|
|
|
{
|
2016-05-31 16:07:09 +02:00
|
|
|
checkIfNull();
|
2015-08-31 12:40:14 +02:00
|
|
|
|
2016-05-31 16:07:09 +02:00
|
|
|
return d->isUsedByCurrentEditor;
|
2015-08-31 12:40:14 +02:00
|
|
|
}
|
|
|
|
|
|
2016-09-07 10:42:12 +02:00
|
|
|
void Document::setIsUsedByCurrentEditor(bool isUsedByCurrentEditor)
|
2015-12-07 13:37:02 +01:00
|
|
|
{
|
2016-05-31 16:07:09 +02:00
|
|
|
checkIfNull();
|
2015-12-07 13:37:02 +01:00
|
|
|
|
2016-05-31 16:07:09 +02:00
|
|
|
d->isUsedByCurrentEditor = isUsedByCurrentEditor;
|
2015-08-31 12:40:14 +02:00
|
|
|
}
|
|
|
|
|
|
2016-09-07 10:42:12 +02:00
|
|
|
bool Document::isVisibleInEditor() const
|
2015-11-18 17:07:44 +01:00
|
|
|
{
|
2016-05-31 16:07:09 +02:00
|
|
|
checkIfNull();
|
2015-11-18 17:07:44 +01:00
|
|
|
|
2016-05-31 16:07:09 +02:00
|
|
|
return d->isVisibleInEditor;
|
2015-11-17 13:33:31 +01:00
|
|
|
}
|
|
|
|
|
|
2016-09-07 10:42:12 +02:00
|
|
|
void Document::setIsVisibleInEditor(bool isVisibleInEditor)
|
2015-06-01 18:51:55 +02:00
|
|
|
{
|
2016-05-31 16:07:09 +02:00
|
|
|
checkIfNull();
|
2015-06-01 18:51:55 +02:00
|
|
|
|
2016-05-31 16:07:09 +02:00
|
|
|
d->isVisibleInEditor = isVisibleInEditor;
|
2015-06-01 18:51:55 +02:00
|
|
|
}
|
|
|
|
|
|
2016-09-07 10:42:12 +02:00
|
|
|
time_point Document::isNeededReparseChangeTimePoint() const
|
2015-08-31 12:40:14 +02:00
|
|
|
{
|
2016-05-31 16:07:09 +02:00
|
|
|
checkIfNull();
|
2015-10-12 17:36:18 +02:00
|
|
|
|
2016-05-31 16:07:09 +02:00
|
|
|
return d->needsToBeReparsedChangeTimePoint;
|
2015-12-07 13:37:02 +01:00
|
|
|
}
|
|
|
|
|
|
2016-09-07 10:42:12 +02:00
|
|
|
bool Document::isNeedingReparse() const
|
2015-10-12 17:36:18 +02:00
|
|
|
{
|
2016-05-31 16:07:09 +02:00
|
|
|
checkIfNull();
|
2015-10-12 17:36:18 +02:00
|
|
|
|
2016-05-31 16:07:09 +02:00
|
|
|
return d->needsToBeReparsed;
|
2015-08-31 12:40:14 +02:00
|
|
|
}
|
|
|
|
|
|
2016-09-07 10:42:12 +02:00
|
|
|
void Document::setDirtyIfProjectPartIsOutdated()
|
2015-06-01 18:51:55 +02:00
|
|
|
{
|
2016-05-31 16:07:09 +02:00
|
|
|
if (isProjectPartOutdated())
|
|
|
|
|
setDirty();
|
2016-04-22 15:31:49 +02:00
|
|
|
}
|
|
|
|
|
|
2016-09-07 10:42:12 +02:00
|
|
|
void Document::setDirtyIfDependencyIsMet(const Utf8String &filePath)
|
2016-04-22 15:31:49 +02:00
|
|
|
{
|
2016-05-31 16:07:09 +02:00
|
|
|
if (d->dependedFilePaths.contains(filePath) && isMainFileAndExistsOrIsOtherFile(filePath))
|
|
|
|
|
setDirty();
|
2015-06-01 18:51:55 +02:00
|
|
|
}
|
|
|
|
|
|
2016-09-07 10:42:12 +02:00
|
|
|
TranslationUnitUpdateInput Document::createUpdateInput() const
|
2015-08-31 12:40:14 +02:00
|
|
|
{
|
2016-07-15 12:30:25 +02:00
|
|
|
TranslationUnitUpdateInput updateInput;
|
2016-05-31 16:07:09 +02:00
|
|
|
updateInput.parseNeeded = isProjectPartOutdated();
|
2016-07-15 12:30:25 +02:00
|
|
|
updateInput.reparseNeeded = isNeedingReparse();
|
2016-05-31 16:07:09 +02:00
|
|
|
updateInput.needsToBeReparsedChangeTimePoint = d->needsToBeReparsedChangeTimePoint;
|
2016-07-15 12:30:25 +02:00
|
|
|
updateInput.filePath = filePath();
|
|
|
|
|
updateInput.fileArguments = fileArguments();
|
2016-09-07 10:42:12 +02:00
|
|
|
updateInput.unsavedFiles = d->documents.unsavedFiles();
|
2016-07-15 12:30:25 +02:00
|
|
|
updateInput.projectId = projectPart().projectPartId();
|
|
|
|
|
updateInput.projectArguments = projectPart().arguments();
|
2015-08-31 12:40:14 +02:00
|
|
|
|
2016-06-05 19:59:23 +02:00
|
|
|
return updateInput;
|
|
|
|
|
}
|
|
|
|
|
|
2016-09-07 10:42:12 +02:00
|
|
|
TranslationUnitUpdater Document::createUpdater() const
|
2016-06-05 19:59:23 +02:00
|
|
|
{
|
|
|
|
|
const TranslationUnitUpdateInput updateInput = createUpdateInput();
|
2016-05-31 16:07:09 +02:00
|
|
|
TranslationUnitUpdater updater(d->index, d->translationUnit, updateInput);
|
2015-08-31 12:40:14 +02:00
|
|
|
|
2016-07-15 12:30:25 +02:00
|
|
|
return updater;
|
2015-08-31 12:40:14 +02:00
|
|
|
}
|
|
|
|
|
|
2016-09-07 10:42:12 +02:00
|
|
|
void Document::setHasParseOrReparseFailed(bool hasFailed)
|
2016-05-31 16:07:09 +02:00
|
|
|
{
|
|
|
|
|
d->hasParseOrReparseFailed = hasFailed;
|
|
|
|
|
}
|
|
|
|
|
|
2016-09-07 10:42:12 +02:00
|
|
|
void Document::incorporateUpdaterResult(const TranslationUnitUpdateResult &result) const
|
2015-08-31 12:40:14 +02:00
|
|
|
{
|
2016-05-31 16:07:09 +02:00
|
|
|
d->hasParseOrReparseFailed = result.hasParseOrReparseFailed;
|
|
|
|
|
if (d->hasParseOrReparseFailed) {
|
|
|
|
|
d->needsToBeReparsed = false;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2016-07-15 12:30:25 +02:00
|
|
|
if (result.parseTimePointIsSet)
|
|
|
|
|
d->lastProjectPartChangeTimePoint = result.parseTimePoint;
|
2015-09-01 10:23:45 +02:00
|
|
|
|
2016-05-31 16:07:09 +02:00
|
|
|
if (result.parseTimePointIsSet || result.reparsed)
|
|
|
|
|
d->dependedFilePaths = result.dependedOnFilePaths;
|
|
|
|
|
|
2016-09-07 10:42:12 +02:00
|
|
|
d->documents.addWatchedFiles(d->dependedFilePaths);
|
2015-07-15 13:55:51 +02:00
|
|
|
|
2016-05-31 16:07:09 +02:00
|
|
|
if (result.reparsed
|
|
|
|
|
&& result.needsToBeReparsedChangeTimePoint == d->needsToBeReparsedChangeTimePoint) {
|
2016-07-15 12:30:25 +02:00
|
|
|
d->needsToBeReparsed = false;
|
2016-05-31 16:07:09 +02:00
|
|
|
}
|
2016-04-22 15:31:49 +02:00
|
|
|
}
|
|
|
|
|
|
2016-09-07 14:50:58 +02:00
|
|
|
TranslationUnit Document::translationUnit() const
|
2016-04-22 15:31:49 +02:00
|
|
|
{
|
2016-05-31 16:07:09 +02:00
|
|
|
checkIfNull();
|
|
|
|
|
|
2016-09-07 14:50:58 +02:00
|
|
|
return TranslationUnit(d->filePath, d->index, d->translationUnit);
|
2016-04-22 15:31:49 +02:00
|
|
|
}
|
|
|
|
|
|
2016-09-07 10:42:12 +02:00
|
|
|
void Document::parse() const
|
2015-11-06 11:16:53 +01:00
|
|
|
{
|
2016-05-31 16:07:09 +02:00
|
|
|
checkIfNull();
|
|
|
|
|
|
|
|
|
|
const TranslationUnitUpdateInput updateInput = createUpdateInput();
|
2016-09-07 14:50:58 +02:00
|
|
|
TranslationUnitUpdateResult result = translationUnit().parse(updateInput);
|
2016-05-31 16:07:09 +02:00
|
|
|
|
|
|
|
|
incorporateUpdaterResult(result);
|
2015-11-06 11:16:53 +01:00
|
|
|
}
|
|
|
|
|
|
2016-09-07 10:42:12 +02:00
|
|
|
void Document::reparse() const
|
2015-07-15 13:55:51 +02:00
|
|
|
{
|
2016-05-31 16:07:09 +02:00
|
|
|
checkIfNull();
|
|
|
|
|
|
|
|
|
|
const TranslationUnitUpdateInput updateInput = createUpdateInput();
|
2016-09-07 14:50:58 +02:00
|
|
|
TranslationUnitUpdateResult result = translationUnit().reparse(updateInput);
|
2016-05-31 16:07:09 +02:00
|
|
|
|
|
|
|
|
incorporateUpdaterResult(result);
|
2015-07-15 13:55:51 +02:00
|
|
|
}
|
|
|
|
|
|
2016-09-07 10:42:12 +02:00
|
|
|
const QSet<Utf8String> Document::dependedFilePaths() const
|
2015-06-01 18:51:55 +02:00
|
|
|
{
|
2016-05-31 16:07:09 +02:00
|
|
|
checkIfNull();
|
|
|
|
|
checkIfFileExists();
|
|
|
|
|
|
|
|
|
|
return d->dependedFilePaths;
|
2015-06-01 18:51:55 +02:00
|
|
|
}
|
|
|
|
|
|
2016-09-07 10:42:12 +02:00
|
|
|
void Document::setDirty()
|
2016-07-15 12:30:25 +02:00
|
|
|
{
|
2016-05-31 16:07:09 +02:00
|
|
|
d->needsToBeReparsedChangeTimePoint = std::chrono::steady_clock::now();
|
|
|
|
|
d->needsToBeReparsed = true;
|
2016-07-15 12:30:25 +02:00
|
|
|
}
|
|
|
|
|
|
2016-09-07 10:42:12 +02:00
|
|
|
void Document::checkIfNull() const
|
2016-05-31 16:07:09 +02:00
|
|
|
{
|
|
|
|
|
if (isNull())
|
2016-09-09 14:42:35 +02:00
|
|
|
throw DocumentIsNullException();
|
2016-05-31 16:07:09 +02:00
|
|
|
}
|
2015-06-01 18:51:55 +02:00
|
|
|
|
2016-09-07 10:42:12 +02:00
|
|
|
void Document::checkIfFileExists() const
|
2016-05-31 16:07:09 +02:00
|
|
|
{
|
|
|
|
|
if (!fileExists())
|
2016-09-09 14:42:35 +02:00
|
|
|
throw DocumentFileDoesNotExistException(d->filePath);
|
2016-05-31 16:07:09 +02:00
|
|
|
}
|
2015-06-01 18:51:55 +02:00
|
|
|
|
2016-09-07 10:42:12 +02:00
|
|
|
bool Document::fileExists() const
|
2015-06-01 18:51:55 +02:00
|
|
|
{
|
2016-05-31 16:07:09 +02:00
|
|
|
return QFileInfo::exists(d->filePath.toString());
|
2015-06-01 18:51:55 +02:00
|
|
|
}
|
|
|
|
|
|
2016-09-07 10:42:12 +02:00
|
|
|
bool Document::isMainFileAndExistsOrIsOtherFile(const Utf8String &filePath) const
|
2015-06-01 18:51:55 +02:00
|
|
|
{
|
2016-05-31 16:07:09 +02:00
|
|
|
if (filePath == d->filePath)
|
|
|
|
|
return QFileInfo::exists(d->filePath);
|
2015-06-01 18:51:55 +02:00
|
|
|
|
2016-05-31 16:07:09 +02:00
|
|
|
return true;
|
2015-06-01 18:51:55 +02:00
|
|
|
}
|
|
|
|
|
|
2016-09-07 10:42:12 +02:00
|
|
|
bool operator==(const Document &first, const Document &second)
|
2015-06-01 18:51:55 +02:00
|
|
|
{
|
|
|
|
|
return first.filePath() == second.filePath() && first.projectPartId() == second.projectPartId();
|
|
|
|
|
}
|
|
|
|
|
|
2016-09-07 10:42:12 +02:00
|
|
|
void PrintTo(const Document &document, ::std::ostream *os)
|
2015-08-31 12:40:14 +02:00
|
|
|
{
|
2016-09-07 10:42:12 +02:00
|
|
|
*os << "Document("
|
|
|
|
|
<< document.filePath().constData() << ", "
|
|
|
|
|
<< document.projectPartId().constData() << ", "
|
|
|
|
|
<< document.documentRevision() << ")";
|
2015-08-31 12:40:14 +02:00
|
|
|
}
|
|
|
|
|
|
2015-06-16 11:56:00 +02:00
|
|
|
} // namespace ClangBackEnd
|