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-03-18 07:55:01 +01:00
|
|
|
#pragma once
|
2015-06-01 18:51:55 +02:00
|
|
|
|
2016-07-15 12:30:25 +02:00
|
|
|
#include "clangtranslationunitupdater.h"
|
|
|
|
|
|
2016-06-05 19:59:23 +02:00
|
|
|
#include "clangtranslationunitcore.h"
|
|
|
|
|
|
2015-08-31 12:40:14 +02:00
|
|
|
#include <utf8stringvector.h>
|
|
|
|
|
|
2015-06-01 18:51:55 +02:00
|
|
|
#include <clang-c/Index.h>
|
|
|
|
|
|
2016-05-31 16:07:09 +02:00
|
|
|
#include <QSet>
|
2015-06-16 12:38:04 +02:00
|
|
|
#include <QtGlobal>
|
|
|
|
|
|
2015-06-01 18:51:55 +02:00
|
|
|
#include <chrono>
|
|
|
|
|
#include <memory>
|
|
|
|
|
|
|
|
|
|
class Utf8String;
|
|
|
|
|
|
2015-06-16 11:56:00 +02:00
|
|
|
namespace ClangBackEnd {
|
2015-06-01 18:51:55 +02:00
|
|
|
|
2016-06-05 19:59:23 +02:00
|
|
|
class TranslationUnitCore;
|
2015-06-01 18:51:55 +02:00
|
|
|
class TranslationUnitData;
|
2016-07-15 12:30:25 +02:00
|
|
|
class TranslationUnitUpdateResult;
|
2015-06-01 18:51:55 +02:00
|
|
|
class ProjectPart;
|
2015-08-31 16:28:26 +02:00
|
|
|
class FileContainer;
|
2015-08-31 12:40:14 +02:00
|
|
|
class TranslationUnits;
|
2015-06-01 18:51:55 +02:00
|
|
|
|
|
|
|
|
using time_point = std::chrono::steady_clock::time_point;
|
|
|
|
|
|
|
|
|
|
class TranslationUnit
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
enum FileExistsCheck {
|
|
|
|
|
CheckIfFileExists,
|
|
|
|
|
DoNotCheckIfFileExists
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
TranslationUnit() = default;
|
|
|
|
|
TranslationUnit(const Utf8String &filePath,
|
|
|
|
|
const ProjectPart &projectPart,
|
2015-11-05 13:57:57 +01:00
|
|
|
const Utf8StringVector &fileArguments,
|
2015-08-31 12:40:14 +02:00
|
|
|
TranslationUnits &translationUnits,
|
2015-06-01 18:51:55 +02:00
|
|
|
FileExistsCheck fileExistsCheck = CheckIfFileExists);
|
|
|
|
|
~TranslationUnit();
|
|
|
|
|
|
|
|
|
|
TranslationUnit(const TranslationUnit &cxTranslationUnit);
|
2015-06-10 13:52:45 +02:00
|
|
|
TranslationUnit &operator=(const TranslationUnit &cxTranslationUnit);
|
2015-06-01 18:51:55 +02:00
|
|
|
|
|
|
|
|
TranslationUnit(TranslationUnit &&cxTranslationUnit);
|
2015-06-10 13:52:45 +02:00
|
|
|
TranslationUnit &operator=(TranslationUnit &&cxTranslationUnit);
|
2015-06-01 18:51:55 +02:00
|
|
|
|
|
|
|
|
void reset();
|
|
|
|
|
|
2016-05-31 16:07:09 +02:00
|
|
|
bool isNull() const;
|
2016-04-22 15:31:49 +02:00
|
|
|
bool isIntact() const;
|
|
|
|
|
|
2016-05-30 10:25:52 +02:00
|
|
|
Utf8String filePath() const;
|
|
|
|
|
Utf8StringVector fileArguments() const;
|
2015-08-31 16:28:26 +02:00
|
|
|
FileContainer fileContainer() const;
|
2016-05-31 16:07:09 +02:00
|
|
|
|
|
|
|
|
Utf8String projectPartId() const;
|
2015-08-31 12:40:14 +02:00
|
|
|
const ProjectPart &projectPart() const;
|
2016-05-31 16:07:09 +02:00
|
|
|
const time_point lastProjectPartChangeTimePoint() const;
|
|
|
|
|
bool isProjectPartOutdated() const;
|
2015-08-31 12:40:14 +02:00
|
|
|
|
|
|
|
|
uint documentRevision() const;
|
2016-05-31 16:07:09 +02:00
|
|
|
void setDocumentRevision(uint revision);
|
2015-08-31 12:40:14 +02:00
|
|
|
|
2016-05-31 16:07:09 +02:00
|
|
|
bool isUsedByCurrentEditor() const;
|
|
|
|
|
void setIsUsedByCurrentEditor(bool isUsedByCurrentEditor);
|
2015-08-31 16:28:26 +02:00
|
|
|
|
2016-05-31 16:07:09 +02:00
|
|
|
bool isVisibleInEditor() const;
|
|
|
|
|
void setIsVisibleInEditor(bool isVisibleInEditor);
|
2015-08-31 12:40:14 +02:00
|
|
|
|
2016-05-31 16:07:09 +02:00
|
|
|
bool isNeedingReparse() const;
|
2015-12-07 13:37:02 +01:00
|
|
|
void setDirtyIfProjectPartIsOutdated();
|
2015-08-26 16:33:32 +02:00
|
|
|
void setDirtyIfDependencyIsMet(const Utf8String &filePath);
|
2015-08-31 12:40:14 +02:00
|
|
|
|
2016-05-31 16:07:09 +02:00
|
|
|
TranslationUnitUpdateInput createUpdateInput() const;
|
|
|
|
|
void incorporateUpdaterResult(const TranslationUnitUpdateResult &result) const;
|
2015-11-17 13:33:31 +01:00
|
|
|
|
2016-06-05 19:59:23 +02:00
|
|
|
TranslationUnitCore translationUnitCore() const;
|
2015-11-17 13:33:31 +01:00
|
|
|
|
2016-05-31 16:07:09 +02:00
|
|
|
public: // for tests
|
|
|
|
|
void parse() const;
|
|
|
|
|
void reparse() const;
|
|
|
|
|
const QSet<Utf8String> dependedFilePaths() const;
|
|
|
|
|
TranslationUnitUpdater createUpdater() const;
|
|
|
|
|
void setHasParseOrReparseFailed(bool hasFailed);
|
|
|
|
|
time_point isNeededReparseChangeTimePoint() const;
|
2016-03-07 16:20:50 +01:00
|
|
|
|
2015-06-01 18:51:55 +02:00
|
|
|
private:
|
2015-12-07 13:37:02 +01:00
|
|
|
void setDirty();
|
2016-05-31 16:07:09 +02:00
|
|
|
|
2015-06-01 18:51:55 +02:00
|
|
|
void checkIfNull() const;
|
|
|
|
|
void checkIfFileExists() const;
|
2016-07-15 12:30:25 +02:00
|
|
|
|
2016-05-31 16:07:09 +02:00
|
|
|
bool fileExists() const;
|
|
|
|
|
bool isMainFileAndExistsOrIsOtherFile(const Utf8String &filePath) const;
|
2015-06-01 18:51:55 +02:00
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
mutable std::shared_ptr<TranslationUnitData> d;
|
|
|
|
|
};
|
|
|
|
|
|
2015-06-10 13:52:45 +02:00
|
|
|
bool operator==(const TranslationUnit &first, const TranslationUnit &second);
|
2015-08-31 12:40:14 +02:00
|
|
|
void PrintTo(const TranslationUnit &translationUnit, ::std::ostream *os);
|
2015-06-16 11:56:00 +02:00
|
|
|
} // namespace ClangBackEnd
|