2013-12-10 14:37:32 +01:00
|
|
|
/****************************************************************************
|
|
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
|
** Contact: https://www.qt.io/licensing/
|
2013-12-10 14:37:32 +01: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:40 +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.
|
2013-12-10 14:37:32 +01:00
|
|
|
**
|
2016-01-15 14:57:40 +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.
|
2013-12-10 14:37:32 +01:00
|
|
|
**
|
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
2016-03-18 07:55:01 +01:00
|
|
|
#pragma once
|
2013-12-10 14:37:32 +01:00
|
|
|
|
2018-02-09 13:51:39 +01:00
|
|
|
#include <cplusplus/Icons.h>
|
|
|
|
|
|
2016-01-12 12:51:33 +01:00
|
|
|
#include <cpptools/projectpart.h>
|
2019-01-31 10:16:28 +01:00
|
|
|
#include <cpptools/compileroptionsbuilder.h>
|
2013-12-10 14:37:32 +01:00
|
|
|
|
2018-10-17 09:42:48 +02:00
|
|
|
#include <QTextCursor>
|
|
|
|
|
|
2018-02-01 13:27:50 +01:00
|
|
|
QT_BEGIN_NAMESPACE
|
|
|
|
|
class QTextBlock;
|
|
|
|
|
QT_END_NAMESPACE
|
|
|
|
|
|
2016-11-22 15:17:42 +01:00
|
|
|
namespace CppTools {
|
|
|
|
|
class CppEditorDocumentHandle;
|
2018-07-10 15:53:51 +02:00
|
|
|
class ProjectInfo;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
namespace Utils {
|
|
|
|
|
class FileName;
|
2016-11-22 15:17:42 +01:00
|
|
|
}
|
|
|
|
|
|
2018-02-09 13:51:39 +01:00
|
|
|
namespace ClangBackEnd { class TokenInfoContainer; }
|
|
|
|
|
|
2013-12-10 14:37:32 +01:00
|
|
|
namespace ClangCodeModel {
|
|
|
|
|
namespace Utils {
|
|
|
|
|
|
2016-11-22 15:17:42 +01:00
|
|
|
CppTools::CppEditorDocumentHandle *cppDocument(const QString &filePath);
|
|
|
|
|
void setLastSentDocumentRevision(const QString &filePath, uint revision);
|
|
|
|
|
|
2018-09-25 09:41:32 +02:00
|
|
|
QStringList createClangOptions(const CppTools::ProjectPart &projectPart,
|
2019-01-31 10:16:28 +01:00
|
|
|
CppTools::UseBuildSystemWarnings useBuildSystemWarnings,
|
2014-10-16 15:27:19 +02:00
|
|
|
CppTools::ProjectFile::Kind fileKind);
|
2013-12-10 14:37:32 +01:00
|
|
|
|
2015-05-08 15:48:17 +02:00
|
|
|
CppTools::ProjectPart::Ptr projectPartForFile(const QString &filePath);
|
2015-10-13 15:56:41 +02:00
|
|
|
CppTools::ProjectPart::Ptr projectPartForFileBasedOnProcessor(const QString &filePath);
|
2015-09-24 14:25:53 +02:00
|
|
|
bool isProjectPartLoaded(const CppTools::ProjectPart::Ptr projectPart);
|
2015-07-14 17:30:17 +02:00
|
|
|
QString projectPartIdForFile(const QString &filePath);
|
2018-09-25 16:19:41 +02:00
|
|
|
int clangColumn(const QTextBlock &line, int cppEditorColumn);
|
|
|
|
|
int cppEditorColumn(const QTextBlock &line, int clangColumn);
|
2015-05-08 15:48:17 +02:00
|
|
|
|
2019-01-29 16:03:38 +01:00
|
|
|
QString currentCppEditorDocumentFilePath();
|
|
|
|
|
|
2018-05-09 15:12:01 +02:00
|
|
|
QString diagnosticCategoryPrefixRemoved(const QString &text);
|
|
|
|
|
|
2018-07-25 10:00:38 +02:00
|
|
|
::Utils::CodeModelIcon::Type iconTypeForToken(const ClangBackEnd::TokenInfoContainer &token);
|
2018-02-09 13:51:39 +01:00
|
|
|
|
2018-07-10 15:53:51 +02:00
|
|
|
void generateCompilationDB(::Utils::FileName projectDir, CppTools::ProjectInfo projectInfo);
|
|
|
|
|
|
2019-01-28 12:40:03 +01:00
|
|
|
class DiagnosticTextInfo
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
DiagnosticTextInfo(const QString &text);
|
|
|
|
|
|
|
|
|
|
QString textWithoutOption() const;
|
|
|
|
|
QString option() const;
|
|
|
|
|
QString category() const;
|
|
|
|
|
|
|
|
|
|
static bool isClazyOption(const QString &option);
|
|
|
|
|
static QString clazyCheckName(const QString &option);
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
const QString m_text;
|
|
|
|
|
const int m_squareBracketStartIndex;
|
|
|
|
|
};
|
|
|
|
|
|
2018-10-17 09:42:48 +02:00
|
|
|
namespace Text {
|
|
|
|
|
|
|
|
|
|
template <class CharacterProvider>
|
|
|
|
|
void moveToPreviousChar(CharacterProvider &provider, QTextCursor &cursor)
|
|
|
|
|
{
|
|
|
|
|
cursor.movePosition(QTextCursor::PreviousCharacter);
|
|
|
|
|
while (provider.characterAt(cursor.position()).isSpace())
|
|
|
|
|
cursor.movePosition(QTextCursor::PreviousCharacter);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
template <class CharacterProvider>
|
|
|
|
|
void moveToPreviousWord(CharacterProvider &provider, QTextCursor &cursor)
|
|
|
|
|
{
|
|
|
|
|
cursor.movePosition(QTextCursor::PreviousWord);
|
|
|
|
|
while (provider.characterAt(cursor.position()) == ':')
|
|
|
|
|
cursor.movePosition(QTextCursor::PreviousWord, QTextCursor::MoveAnchor, 2);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
template <class CharacterProvider>
|
|
|
|
|
bool matchPreviousWord(CharacterProvider &provider, QTextCursor cursor, QString pattern)
|
|
|
|
|
{
|
|
|
|
|
cursor.movePosition(QTextCursor::PreviousWord);
|
|
|
|
|
while (provider.characterAt(cursor.position()) == ':')
|
|
|
|
|
cursor.movePosition(QTextCursor::PreviousWord, QTextCursor::MoveAnchor, 2);
|
|
|
|
|
|
|
|
|
|
int previousWordStart = cursor.position();
|
|
|
|
|
cursor.movePosition(QTextCursor::NextWord);
|
|
|
|
|
moveToPreviousChar(provider, cursor);
|
|
|
|
|
QString toMatch = provider.textAt(previousWordStart, cursor.position() - previousWordStart + 1);
|
|
|
|
|
|
|
|
|
|
pattern = pattern.simplified();
|
|
|
|
|
while (!pattern.isEmpty() && pattern.endsWith(toMatch)) {
|
|
|
|
|
pattern.chop(toMatch.length());
|
|
|
|
|
if (pattern.endsWith(' '))
|
|
|
|
|
pattern.chop(1);
|
|
|
|
|
if (!pattern.isEmpty()) {
|
|
|
|
|
cursor.movePosition(QTextCursor::StartOfWord);
|
|
|
|
|
cursor.movePosition(QTextCursor::PreviousWord);
|
|
|
|
|
previousWordStart = cursor.position();
|
|
|
|
|
cursor.movePosition(QTextCursor::NextWord);
|
|
|
|
|
moveToPreviousChar(provider, cursor);
|
|
|
|
|
toMatch = provider.textAt(previousWordStart, cursor.position() - previousWordStart + 1);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return pattern.isEmpty();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // namespace Text
|
2013-12-10 14:37:32 +01:00
|
|
|
} // namespace Utils
|
|
|
|
|
} // namespace Clang
|