2015-10-01 12:45:06 +02:00
|
|
|
/****************************************************************************
|
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 The Qt Company. For licensing terms and
|
|
|
|
|
** conditions see http://www.qt.io/terms-conditions. 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, The Qt Company gives you certain additional
|
|
|
|
|
** rights. These rights are described in The Qt Company LGPL Exception
|
|
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
|
**
|
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
2015-06-16 11:56:00 +02:00
|
|
|
#ifndef CLANGBACKEND_TRANSLATIONUNIT_H
|
|
|
|
|
#define CLANGBACKEND_TRANSLATIONUNIT_H
|
2015-06-01 18:51:55 +02:00
|
|
|
|
2015-08-31 12:40:14 +02:00
|
|
|
#include <utf8stringvector.h>
|
|
|
|
|
|
2015-06-01 18:51:55 +02:00
|
|
|
#include <clang-c/Index.h>
|
|
|
|
|
|
2015-06-16 12:38:04 +02:00
|
|
|
#include <QtGlobal>
|
|
|
|
|
|
2015-06-01 18:51:55 +02:00
|
|
|
#include <chrono>
|
|
|
|
|
#include <memory>
|
2015-08-31 12:40:14 +02:00
|
|
|
#include <QSet>
|
2015-06-01 18:51:55 +02:00
|
|
|
|
|
|
|
|
class Utf8String;
|
|
|
|
|
|
2015-06-16 11:56:00 +02:00
|
|
|
namespace ClangBackEnd {
|
2015-06-01 18:51:55 +02:00
|
|
|
|
|
|
|
|
class TranslationUnitData;
|
|
|
|
|
class CodeCompleter;
|
|
|
|
|
class UnsavedFiles;
|
|
|
|
|
class ProjectPart;
|
2015-08-31 16:28:26 +02:00
|
|
|
class DiagnosticSet;
|
|
|
|
|
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-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
|
|
|
|
|
|
|
|
bool isNull() const;
|
|
|
|
|
|
|
|
|
|
void reset();
|
2015-08-31 16:28:26 +02:00
|
|
|
void reparse() const;
|
2015-06-01 18:51:55 +02:00
|
|
|
|
|
|
|
|
CXIndex index() const;
|
|
|
|
|
CXTranslationUnit cxTranslationUnit() const;
|
|
|
|
|
CXUnsavedFile * cxUnsavedFiles() const;
|
|
|
|
|
uint unsavedFilesCount() const;
|
|
|
|
|
|
|
|
|
|
const Utf8String &filePath() const;
|
|
|
|
|
const Utf8String &projectPartId() const;
|
2015-08-31 16:28:26 +02:00
|
|
|
FileContainer fileContainer() const;
|
2015-08-31 12:40:14 +02:00
|
|
|
const ProjectPart &projectPart() const;
|
|
|
|
|
|
|
|
|
|
void setDocumentRevision(uint revision);
|
|
|
|
|
uint documentRevision() const;
|
|
|
|
|
|
|
|
|
|
const time_point &lastProjectPartChangeTimePoint() const;
|
2015-06-01 18:51:55 +02:00
|
|
|
|
2015-08-31 12:40:14 +02:00
|
|
|
bool isNeedingReparse() const;
|
2015-08-26 16:33:32 +02:00
|
|
|
bool hasNewDiagnostics() const;
|
2015-06-01 18:51:55 +02:00
|
|
|
|
2015-08-31 16:28:26 +02:00
|
|
|
DiagnosticSet diagnostics() const;
|
|
|
|
|
|
2015-08-31 12:40:14 +02:00
|
|
|
const QSet<Utf8String> &dependedFilePaths() const;
|
|
|
|
|
|
2015-08-26 16:33:32 +02:00
|
|
|
void setDirtyIfDependencyIsMet(const Utf8String &filePath);
|
2015-08-31 12:40:14 +02:00
|
|
|
|
2015-06-01 18:51:55 +02:00
|
|
|
private:
|
|
|
|
|
void checkIfNull() const;
|
|
|
|
|
void checkIfFileExists() const;
|
2015-08-31 12:40:14 +02:00
|
|
|
void updateLastProjectPartChangeTimePoint() const;
|
|
|
|
|
void removeTranslationUnitIfProjectPartWasChanged() const;
|
|
|
|
|
bool projectPartIsOutdated() const;
|
2015-10-12 17:36:18 +02:00
|
|
|
bool isMainFileAndExistsOrIsOtherFile(const Utf8String &filePath) const;
|
2015-06-01 18:51:55 +02:00
|
|
|
void createTranslationUnitIfNeeded() const;
|
|
|
|
|
void checkTranslationUnitErrorCode(CXErrorCode errorCode) const;
|
2015-07-15 13:55:51 +02:00
|
|
|
void reparseTranslationUnit() const;
|
2015-08-31 12:40:14 +02:00
|
|
|
void reparseTranslationUnitIfFilesAreChanged() const;
|
|
|
|
|
void updateIncludeFilePaths() const;
|
2015-09-01 12:00:21 +02:00
|
|
|
static uint defaultOptions();
|
2015-08-31 12:40:14 +02:00
|
|
|
static void includeCallback(CXFile included_file,
|
2015-09-01 09:14:34 +02:00
|
|
|
CXSourceLocation * /*inclusion_stack*/,
|
2015-08-31 12:40:14 +02:00
|
|
|
unsigned /*include_len*/,
|
|
|
|
|
CXClientData clientData);
|
|
|
|
|
UnsavedFiles &unsavedFiles() 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
|
2015-06-01 18:51:55 +02:00
|
|
|
|
2015-06-16 11:56:00 +02:00
|
|
|
#endif // CLANGBACKEND_TRANSLATIONUNIT_H
|